https://sourceware.org/bugzilla/show_bug.cgi?id=18672
Bug ID: 18672
Summary: readelf does not show the last entries in .dynamic
section
Product: binutils
Version: 2.25
Status: NEW
Severity: normal
Priority: P2
Component: binutils
Assignee: unassigned at sourceware dot org
Reporter: simon at atanasyan dot com
Target Milestone: ---
Created attachment 8438
--> https://sourceware.org/bugzilla/attachment.cgi?id=8438&action=edit
Patch to fix the bug
readelf does not show the last entries in .dynamic section under the following
conditions:
- readelf is built for a target with 64-bit pointers
- readelf input is a binary built for a target with 32-bit pointer
- .dynamic section size exactly equals to number of entries * 4-byte
The problem is in the following code from the get_32bit_dynamic_section
function. Suppose the last two entries in the .dynamic section is DT_PLTGOT and
DT_NULL. They both occupy 16 bytes. On 64-bit host the size of Elf_Internal_Dyn
is 16 bytes so the readelf stops iterating too early and misses the DT_PLTGOT
entry. Attached patch fixes the bug.
Elf32_External_Dyn * edyn;
Elf32_External_Dyn * ext;
Elf_Internal_Dyn * entry;
...
for (ext = edyn, dynamic_nent = 0;
(char *) ext < (char *) edyn + dynamic_size - sizeof (* entry);
ext++)
{
--
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
bug-binutils mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/bug-binutils