This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
PR5900: corrupt e_shstrndx
- From: Ryan Mansfield <rmansfield at qnx dot com>
- To: binutils at sourceware dot org
- Date: Tue, 24 Mar 2009 15:15:15 -0400
- Subject: PR5900: corrupt e_shstrndx
- Reply-to: rmansfield at qnx dot com
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