PR24225, nios2 buffer overflow
PR 24225 * elf32-nios2.c (nios2_elf32_relocate_section): Use asprintf and PRIx64 to generate warning messages. Print local sym names too.
This commit is contained in:
parent
d57e4f2b86
commit
a31b8bd9a0
2 changed files with 27 additions and 10 deletions
|
@ -1,3 +1,9 @@
|
||||||
|
2019-02-18 Alan Modra <amodra@gmail.com>
|
||||||
|
|
||||||
|
PR 24225
|
||||||
|
* elf32-nios2.c (nios2_elf32_relocate_section): Use asprintf and
|
||||||
|
PRIx64 to generate warning messages. Print local sym names too.
|
||||||
|
|
||||||
2019-02-09 Vineet Gupta <vgupta@synopsys.com>
|
2019-02-09 Vineet Gupta <vgupta@synopsys.com>
|
||||||
|
|
||||||
* elf32-arc (INIT_SYM_STRING): Delete.
|
* elf32-arc (INIT_SYM_STRING): Delete.
|
||||||
|
|
|
@ -3720,8 +3720,8 @@ nios2_elf32_relocate_section (bfd *output_bfd,
|
||||||
const char *name = NULL;
|
const char *name = NULL;
|
||||||
int r_type;
|
int r_type;
|
||||||
const char *format;
|
const char *format;
|
||||||
char msgbuf[256];
|
char *msgbuf = NULL;
|
||||||
const char* msg = (const char*) NULL;
|
char *msg = NULL;
|
||||||
bfd_boolean unresolved_reloc;
|
bfd_boolean unresolved_reloc;
|
||||||
bfd_vma off;
|
bfd_vma off;
|
||||||
int use_plt;
|
int use_plt;
|
||||||
|
@ -3820,8 +3820,8 @@ nios2_elf32_relocate_section (bfd *output_bfd,
|
||||||
reloc_address = 0;
|
reloc_address = 0;
|
||||||
|
|
||||||
format = _("global pointer relative relocation at address "
|
format = _("global pointer relative relocation at address "
|
||||||
"0x%08x when _gp not defined\n");
|
"%#" PRIx64 " when _gp not defined\n");
|
||||||
sprintf (msgbuf, format, reloc_address);
|
asprintf (&msgbuf, format, (uint64_t) reloc_address);
|
||||||
msg = msgbuf;
|
msg = msgbuf;
|
||||||
r = bfd_reloc_dangerous;
|
r = bfd_reloc_dangerous;
|
||||||
}
|
}
|
||||||
|
@ -3838,13 +3838,22 @@ nios2_elf32_relocate_section (bfd *output_bfd,
|
||||||
{
|
{
|
||||||
if (h)
|
if (h)
|
||||||
name = h->root.root.string;
|
name = h->root.root.string;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
name = (bfd_elf_string_from_elf_section
|
||||||
|
(input_bfd, symtab_hdr->sh_link,
|
||||||
|
sym->st_name));
|
||||||
|
if (name == NULL || *name == '\0')
|
||||||
|
name = bfd_section_name (input_bfd, sec);
|
||||||
|
}
|
||||||
/* xgettext:c-format */
|
/* xgettext:c-format */
|
||||||
format = _("unable to reach %s (at 0x%08x) from the "
|
format = _("unable to reach %s (at %#" PRIx64 ") from "
|
||||||
"global pointer (at 0x%08x) because the "
|
"the global pointer (at %#" PRIx64 ") "
|
||||||
"offset (%d) is out of the allowed range, "
|
"because the offset (%" PRId64 ") is out of "
|
||||||
"-32678 to 32767\n" );
|
"the allowed range, -32678 to 32767\n" );
|
||||||
sprintf (msgbuf, format, name, symbol_address, gp,
|
asprintf (&msgbuf, format, name,
|
||||||
(signed)relocation);
|
(uint64_t) symbol_address, (uint64_t) gp,
|
||||||
|
(int64_t) relocation);
|
||||||
msg = msgbuf;
|
msg = msgbuf;
|
||||||
r = bfd_reloc_outofrange;
|
r = bfd_reloc_outofrange;
|
||||||
}
|
}
|
||||||
|
@ -4515,6 +4524,8 @@ nios2_elf32_relocate_section (bfd *output_bfd,
|
||||||
{
|
{
|
||||||
(*info->callbacks->warning) (info, msg, name, input_bfd,
|
(*info->callbacks->warning) (info, msg, name, input_bfd,
|
||||||
input_section, rel->r_offset);
|
input_section, rel->r_offset);
|
||||||
|
if (msgbuf)
|
||||||
|
free (msgbuf);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue