Readelf vs objdump

Daniel Jacobowitz drow@mvista.com
Wed Nov 19 01:31:00 GMT 2003


On Tue, Nov 18, 2003 at 05:22:46PM -0800, Stan Shebs wrote:
> So, fresh from the stunning success of Panther, and scanning the horizon for
> new prey to consu^Wassim^Wadopt :-) , we've been looking a bit at the 
> prospects
> for moving from stabs to dwarf2 debugging. It's not too hard to tweak Darwin
> GDB and GCC to get something minimal working using Mach-O object files, 
> but in
> order to scale up and improve performance, we could really use a dwarf 
> dumper,
> such as the one in readelf.
> 
> While it seems like an obvious thing to hack up the dwarf dumping code so
> that it can be used in objdump for non-ELF, it makes me wonder why there 
> is a
> separate readelf program in the first place.  Is this just historical, or is
> there a fundamental reason why binutils has two file dumpers? (I understand
> that the details of functionality are different, but that's not a 
> fundamental
> reason to have two.)

The difference in implementation is actually pretty fundamental. 
Objdump sees an ELF file through a BFD filter of the world; if bfd
has a bug where, say, it disagrees about a machine constant in e_flags,
then the odds are good that it will remain internally consistent.  The
linker sees it the BFD way, objdump sees it the BFD way, gas sees it
the BFD way.  There was need for a tool to go find out what the file
actually says.

-- 
Daniel Jacobowitz
MontaVista Software                         Debian GNU/Linux Developer



More information about the Binutils mailing list