This is the mail archive of the binutils@sources.redhat.com mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

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


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.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]