[davidm@napali.hpl.hp.com: readelf question]

Roland McGrath roland@redhat.com
Tue Jun 17 21:39:00 GMT 2003


readelf is full of bogus assumptions about the ELF file layout.  There are
many places that extract a virtual address from some header, and then
subtract LOADADDR from this and expect the difference to be a valid file
offset corresponding to that virtual address.  This only holds true when
those addresses lie in the first PT_LOAD segment and that segment starts at
the beginning of the file.  That is the usual situation in executables and
DSOs, but it is certainly not a requirement of the ELF format.  readelf,
even more than other tools, needs to accept and grok all files that are
valid under the spec, not just "the way it usually looks".  Each place that
currently says "foo - loadaddr" should be changed to "offset_from_vaddr (foo)"
and that function defined to search through all PT_LOAD segments to find
the one that actually contains the virtual address, and use its p_offset.



More information about the Binutils mailing list