Improve decoding of corrupt/unrecognised gnu build attribute notes.
* readelf.c (process_section_headers): Warn about overlarge sections. (print_gnu_build_attribute_name): Print the number of unrecognised note types. Fix formatting in the presence of errors. (testsuite/binutils-all/note-2-32.s): Fix encoding of numeric notes. (testsuite/binutils-all/note-2-64.s): Likewise.
This commit is contained in:
parent
b41c5a85a7
commit
3e6b644558
@ -1,3 +1,12 @@
|
|||||||
|
2017-04-26 Nick Clifton <nickc@redhat.com>
|
||||||
|
|
||||||
|
* readelf.c (process_section_headers): Warn about overlarge
|
||||||
|
sections.
|
||||||
|
(print_gnu_build_attribute_name): Print the number of unrecognised
|
||||||
|
note types. Fix formatting in the presence of errors.
|
||||||
|
(testsuite/binutils-all/note-2-32.s): Fix encoding of numeric notes.
|
||||||
|
(testsuite/binutils-all/note-2-64.s): Likewise.
|
||||||
|
|
||||||
2017-04-26 Maciej W. Rozycki <macro@imgtec.com>
|
2017-04-26 Maciej W. Rozycki <macro@imgtec.com>
|
||||||
|
|
||||||
* readelf.c (process_mips_specific): Add static GOT support.
|
* readelf.c (process_mips_specific): Add static GOT support.
|
||||||
|
@ -6215,6 +6215,13 @@ process_section_headers (FILE * file)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Check the sh_size field. */
|
||||||
|
if (section->sh_size > current_file_size
|
||||||
|
&& section->sh_type != SHT_NOBITS
|
||||||
|
&& section->sh_type != SHT_NULL
|
||||||
|
&& section->sh_type < SHT_LOOS)
|
||||||
|
warn (_("Size of section %u is larger than the entire file!\n"), i);
|
||||||
|
|
||||||
printf (" [%2u] ", i);
|
printf (" [%2u] ", i);
|
||||||
if (do_section_details)
|
if (do_section_details)
|
||||||
printf ("%s\n ", printable_section_name (section));
|
printf ("%s\n ", printable_section_name (section));
|
||||||
@ -16982,7 +16989,6 @@ print_gnu_build_attribute_name (Elf_Internal_Note * pnote)
|
|||||||
expected_types = bool_expected;
|
expected_types = bool_expected;
|
||||||
++ name;
|
++ name;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
if (ISPRINT (* name))
|
if (ISPRINT (* name))
|
||||||
{
|
{
|
||||||
@ -16996,9 +17002,11 @@ print_gnu_build_attribute_name (Elf_Internal_Note * pnote)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
error (_("unexpected character in name field\n"));
|
static char tmpbuf [128];
|
||||||
print_symbol (- left, _("<unknown attribute>"));
|
error (_("unrecognised byte in name field: %d\n"), * name);
|
||||||
return 0;
|
sprintf (tmpbuf, _("<unknown:_%d>"), * name);
|
||||||
|
text = tmpbuf;
|
||||||
|
name ++;
|
||||||
}
|
}
|
||||||
expected_types = "*$!+";
|
expected_types = "*$!+";
|
||||||
break;
|
break;
|
||||||
@ -17028,7 +17036,10 @@ print_gnu_build_attribute_name (Elf_Internal_Note * pnote)
|
|||||||
{
|
{
|
||||||
case GNU_BUILD_ATTRIBUTE_TYPE_NUMERIC:
|
case GNU_BUILD_ATTRIBUTE_TYPE_NUMERIC:
|
||||||
{
|
{
|
||||||
unsigned int bytes = pnote->namesz - (name - pnote->namedata);
|
/* The -1 is because the name field is always 0 terminated, and we
|
||||||
|
want to be able to ensure that the shift in the while loop below
|
||||||
|
will not overflow. */
|
||||||
|
unsigned int bytes = (pnote->namesz - (name - pnote->namedata)) - 1;
|
||||||
unsigned long long val = 0;
|
unsigned long long val = 0;
|
||||||
unsigned int shift = 0;
|
unsigned int shift = 0;
|
||||||
char * decoded = NULL;
|
char * decoded = NULL;
|
||||||
@ -17036,10 +17047,12 @@ print_gnu_build_attribute_name (Elf_Internal_Note * pnote)
|
|||||||
/* PR 21378 */
|
/* PR 21378 */
|
||||||
if (bytes > sizeof (val))
|
if (bytes > sizeof (val))
|
||||||
{
|
{
|
||||||
error (_("corrupt name field: namesz of %lu is too large for a numeric value\n"),
|
error (_("corrupt numeric name field: too many bytes in the value: %x\n"),
|
||||||
pnote->namesz);
|
bytes);
|
||||||
return FALSE;
|
bytes = sizeof (val);
|
||||||
}
|
}
|
||||||
|
/* We do not bother to warn if bytes == 0 as this can
|
||||||
|
happen with some early versions of the gcc plugin. */
|
||||||
|
|
||||||
while (bytes --)
|
while (bytes --)
|
||||||
{
|
{
|
||||||
@ -17079,7 +17092,15 @@ print_gnu_build_attribute_name (Elf_Internal_Note * pnote)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (decoded != NULL)
|
if (decoded != NULL)
|
||||||
print_symbol (-left, decoded);
|
{
|
||||||
|
print_symbol (-left, decoded);
|
||||||
|
left = 0;
|
||||||
|
}
|
||||||
|
else if (val == 0)
|
||||||
|
{
|
||||||
|
printf ("0x0");
|
||||||
|
left -= 3;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (do_wide)
|
if (do_wide)
|
||||||
|
@ -17,23 +17,21 @@ note1.s:
|
|||||||
.dc.l 0x100
|
.dc.l 0x100
|
||||||
.asciz "$gcc 7.0.1"
|
.asciz "$gcc 7.0.1"
|
||||||
|
|
||||||
.dc.l 2
|
|
||||||
.dc.l 0
|
|
||||||
.dc.l 0x100
|
|
||||||
.dc.b 0x2b, 0x2
|
|
||||||
.dc.b 0, 0
|
|
||||||
|
|
||||||
.dc.l 3
|
.dc.l 3
|
||||||
.dc.l 0
|
.dc.l 0
|
||||||
.dc.l 0x100
|
.dc.l 0x100
|
||||||
.dc.b 0x2a, 0x7, 0
|
.dc.b 0x2b, 0x2, 0
|
||||||
.dc.b 0
|
.dc.b 0
|
||||||
|
|
||||||
.dc.l 3
|
.dc.l 4
|
||||||
.dc.l 0
|
.dc.l 0
|
||||||
.dc.l 0x100
|
.dc.l 0x100
|
||||||
.dc.b 0x2a, 0x6, 0
|
.dc.b 0x2a, 0x7, 0, 0
|
||||||
.dc.b 0
|
|
||||||
|
.dc.l 4
|
||||||
|
.dc.l 0
|
||||||
|
.dc.l 0x100
|
||||||
|
.dc.b 0x2a, 0x6, 0, 0
|
||||||
.popsection
|
.popsection
|
||||||
|
|
||||||
|
|
||||||
@ -55,23 +53,21 @@ func1:
|
|||||||
.dc.l 0x100
|
.dc.l 0x100
|
||||||
.asciz "$gcc 7.0.1"
|
.asciz "$gcc 7.0.1"
|
||||||
|
|
||||||
.dc.l 2
|
.dc.l 3
|
||||||
.dc.l 0
|
.dc.l 0
|
||||||
.dc.l 0x100
|
.dc.l 0x100
|
||||||
.dc.b 0x21, 0x2
|
.dc.b 0x21, 0x2, 0
|
||||||
.dc.b 0, 0
|
.dc.b 0
|
||||||
|
|
||||||
.dc.l 3
|
.dc.l 4
|
||||||
.dc.l 0
|
.dc.l 0
|
||||||
.dc.l 0x101
|
.dc.l 0x101
|
||||||
.dc.b 0x2a, 0x7, 1
|
.dc.b 0x2a, 0x7, 1, 0
|
||||||
.dc.b 0
|
|
||||||
|
|
||||||
.dc.l 3
|
.dc.l 4
|
||||||
.dc.l 0
|
.dc.l 0
|
||||||
.dc.l 0x100
|
.dc.l 0x100
|
||||||
.dc.b 0x2a, 0x6, 0
|
.dc.b 0x2a, 0x6, 0, 0
|
||||||
.dc.b 0
|
|
||||||
.popsection
|
.popsection
|
||||||
|
|
||||||
.global note3.s
|
.global note3.s
|
||||||
|
@ -17,23 +17,21 @@ note1.s:
|
|||||||
.dc.l 0x100
|
.dc.l 0x100
|
||||||
.asciz "$gcc 7.0.1"
|
.asciz "$gcc 7.0.1"
|
||||||
|
|
||||||
.dc.l 2
|
|
||||||
.dc.l 0
|
|
||||||
.dc.l 0x100
|
|
||||||
.dc.b 0x2b, 0x2
|
|
||||||
.dc.b 0, 0
|
|
||||||
|
|
||||||
.dc.l 3
|
.dc.l 3
|
||||||
.dc.l 0
|
.dc.l 0
|
||||||
.dc.l 0x100
|
.dc.l 0x100
|
||||||
.dc.b 0x2a, 0x7, 0
|
.dc.b 0x2b, 0x2, 0
|
||||||
.dc.b 0
|
.dc.b 0
|
||||||
|
|
||||||
.dc.l 3
|
.dc.l 4
|
||||||
.dc.l 0
|
.dc.l 0
|
||||||
.dc.l 0x100
|
.dc.l 0x100
|
||||||
.dc.b 0x2a, 0x6, 0
|
.dc.b 0x2a, 0x7, 0, 0
|
||||||
.dc.b 0
|
|
||||||
|
.dc.l 4
|
||||||
|
.dc.l 0
|
||||||
|
.dc.l 0x100
|
||||||
|
.dc.b 0x2a, 0x6, 0, 0
|
||||||
.popsection
|
.popsection
|
||||||
|
|
||||||
|
|
||||||
@ -56,23 +54,21 @@ func1:
|
|||||||
.dc.l 0x100
|
.dc.l 0x100
|
||||||
.asciz "$gcc 7.0.1"
|
.asciz "$gcc 7.0.1"
|
||||||
|
|
||||||
.dc.l 2
|
.dc.l 3
|
||||||
.dc.l 0
|
.dc.l 0
|
||||||
.dc.l 0x100
|
.dc.l 0x100
|
||||||
.dc.b 0x21, 0x2
|
.dc.b 0x21, 0x2, 0
|
||||||
.dc.b 0, 0
|
.dc.b 0
|
||||||
|
|
||||||
.dc.l 3
|
.dc.l 4
|
||||||
.dc.l 0
|
.dc.l 0
|
||||||
.dc.l 0x101
|
.dc.l 0x101
|
||||||
.dc.b 0x2a, 0x7, 1
|
.dc.b 0x2a, 0x7, 1, 0
|
||||||
.dc.b 0
|
|
||||||
|
|
||||||
.dc.l 3
|
.dc.l 4
|
||||||
.dc.l 0
|
.dc.l 0
|
||||||
.dc.l 0x100
|
.dc.l 0x100
|
||||||
.dc.b 0x2a, 0x6, 0
|
.dc.b 0x2a, 0x6, 0, 0
|
||||||
.dc.b 0
|
|
||||||
.popsection
|
.popsection
|
||||||
|
|
||||||
|
|
||||||
@ -93,5 +89,3 @@ note3.s:
|
|||||||
.asciz "$gcc 7.0.1"
|
.asciz "$gcc 7.0.1"
|
||||||
|
|
||||||
.popsection
|
.popsection
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user