bug-binutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

readelf reporting of e_shstrndx is slightly wrong


From: Mike Murphy
Subject: readelf reporting of e_shstrndx is slightly wrong
Date: Fri, 17 Aug 2018 20:53:51 +0000

According to the ELF standard:

e_shstrndx

This member holds the section header table index of the entry associated with the section name string table. If the file has no section name string table, this member holds the value SHN_UNDEF. See ``Sections'' and ``String Table'' below for more information.

If the section name string table section index is greater than or equal to SHN_LORESERVE (0xff00), this member has the value SHN_XINDEX (0xffff) and the actual index of the section name string table section is contained in the sh_link field of the section header at index 0. (Otherwise, the sh_link member of the initial entry contains 0.)

The current readelf -h seems to assume that if there are more than 0xff00 sections, then the shstrndx will also be past that.  But there is nothing to prevent the section name string table from being section 1, in which case e_shstrndx should just be 1.  But the readelf implementation has:

               else if (elf_header.e_shstrndx != SHN_UNDEF && elf_header.e_shstrndx >= elf_header.e_shnum)

                   printf(_(“<corrupt: out of range>”));

 

 

 

 

 

 


reply via email to

[Prev in Thread] Current Thread [Next in Thread]