* PR5900: corrupt e_shstrndx
@ 2009-03-24 19:15 Ryan Mansfield
2009-03-25 1:38 ` Alan Modra
0 siblings, 1 reply; 2+ messages in thread
From: Ryan Mansfield @ 2009-03-24 19:15 UTC (permalink / raw)
To: binutils
After the change to handle >65536 sections[1], readelf now reports a
file with no section headers as having a corrupt section header table
index. The gABI says if the file has no section name string table that
e_shstrndx will hold the value SHN_UNDEF. The proposed patch re-adds
part of the original test for whether the string table exists.
ELF Header:
Magic: 7f 45 4c 46 01 01 01 00 00 00 00 00 00 00 00 00
Class: ELF32
Data: 2's complement, little endian
Version: 1 (current)
OS/ABI: UNIX - System V
ABI Version: 0
Type: CORE (Core file)
Machine: Renesas / SuperH SH
Version: 0x1
Entry point address: 0x0
Start of program headers: 52 (bytes into file)
Start of section headers: 0 (bytes into file)
Flags: 0x0
Size of this header: 52 (bytes)
Size of program headers: 32 (bytes)
Number of program headers: 65
Size of section headers: 0 (bytes)
Number of section headers: 0
Section header string table index: 0 <corrupt: out of range>
Index: readelf.c
===================================================================
RCS file: /cvs/src/src/binutils/readelf.c,v
retrieving revision 1.441
diff -c -3 -p -r1.441 readelf.c
*** readelf.c 19 Mar 2009 14:42:52 -0000 1.441
--- readelf.c 24 Mar 2009 18:43:13 -0000
*************** process_file_header (void)
*** 3205,3211 ****
if (section_headers != NULL
&& elf_header.e_shstrndx == (SHN_XINDEX & 0xffff))
printf (" (%u)", section_headers[0].sh_link);
! else if (elf_header.e_shstrndx >= elf_header.e_shnum)
printf (" <corrupt: out of range>");
putc ('\n', stdout);
}
--- 3205,3212 ----
if (section_headers != NULL
&& elf_header.e_shstrndx == (SHN_XINDEX & 0xffff))
printf (" (%u)", section_headers[0].sh_link);
! else if (elf_header.e_shstrndx != SHN_UNDEF
! && elf_header.e_shstrndx >= elf_header.e_shnum)
printf (" <corrupt: out of range>");
putc ('\n', stdout);
}
[1] http://sourceware.org/ml/binutils/2008-03/msg00070.html
Regards,
Ryan Mansfield
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: PR5900: corrupt e_shstrndx
2009-03-24 19:15 PR5900: corrupt e_shstrndx Ryan Mansfield
@ 2009-03-25 1:38 ` Alan Modra
0 siblings, 0 replies; 2+ messages in thread
From: Alan Modra @ 2009-03-25 1:38 UTC (permalink / raw)
To: Ryan Mansfield; +Cc: binutils
On Tue, Mar 24, 2009 at 03:15:15PM -0400, Ryan Mansfield wrote:
> Index: readelf.c
> ===================================================================
> RCS file: /cvs/src/src/binutils/readelf.c,v
> retrieving revision 1.441
> diff -c -3 -p -r1.441 readelf.c
> *** readelf.c 19 Mar 2009 14:42:52 -0000 1.441
> --- readelf.c 24 Mar 2009 18:43:13 -0000
> *************** process_file_header (void)
> *** 3205,3211 ****
> if (section_headers != NULL
> && elf_header.e_shstrndx == (SHN_XINDEX & 0xffff))
> printf (" (%u)", section_headers[0].sh_link);
> ! else if (elf_header.e_shstrndx >= elf_header.e_shnum)
> printf (" <corrupt: out of range>");
> putc ('\n', stdout);
> }
> --- 3205,3212 ----
> if (section_headers != NULL
> && elf_header.e_shstrndx == (SHN_XINDEX & 0xffff))
> printf (" (%u)", section_headers[0].sh_link);
> ! else if (elf_header.e_shstrndx != SHN_UNDEF
> ! && elf_header.e_shstrndx >= elf_header.e_shnum)
> printf (" <corrupt: out of range>");
> putc ('\n', stdout);
> }
Applied with this changelog
2009-03-25 Ryan Mansfield <rmansfield@qnx.com>
* readelf.c (process_file_header): Don't report a corrupt string
table index if it is zero.
--
Alan Modra
Australia Development Lab, IBM
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2009-03-25 1:38 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-03-24 19:15 PR5900: corrupt e_shstrndx Ryan Mansfield
2009-03-25 1:38 ` Alan Modra
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).