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: Readelf vs objdump


Hi Stan, Hi Daniel, Hi Hans-Peter,

>>While Daniel answered the question IMHO perfectly, I can't help 
>>but wonder where this should be documented; it comes up now and
>>then.  (I assume it isn't documented, or Stan would know.)
>>Stan, where would/did you look for the answer to this question
>>(documentation-wise)?
>>
> Top of readelf.c seems like one obvious place. The user manual ought
> to say something too, otherwise how does the user know which to prefer
> for what purpose?

OK - How about this patch then ?  Any comments/suggestions ?

Cheers
        Nick

2003-11-25  Daniel Jacobowitz <drow@mvista.com>
            Nick Clifton  <nickc@redhat.com>

	* readelf.c: Add a comment describing the difference between
	readelf and objdump.
        * doc/binutils.texi (readelf): Likewise.

Index: binutils/readelf.c
===================================================================
RCS file: /cvs/src/src/binutils/readelf.c,v
retrieving revision 1.225
diff -c -3 -p -r1.225 readelf.c
*** binutils/readelf.c	7 Nov 2003 12:19:34 -0000	1.225
--- binutils/readelf.c	25 Nov 2003 17:03:46 -0000
***************
*** 21,27 ****
--- 21,45 ----
     Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
     02111-1307, USA.  */
  
+ /* The difference between readelf and objdump:
  
+   Both programs are capabale of displaying the contents of ELF format files,
+   so why does the binutils project have two file dumpers ?
+   
+   The reason is that 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.
+ 
+   This is why the readelf program does not link against the BFD library - it
+   exists as an independent program to help verify the correct working of BFD.
+ 
+   There is also the case that readelf can provide more information about an
+   ELF file than is provided by objdump.  In particular it can display DWARF
+   debugging information which (at the moment) objdump cannot.  */
+ 
  #include <assert.h>
  #include <sys/types.h>
  #include <sys/stat.h>

Index: binutils/doc/binutils.texi
===================================================================
RCS file: /cvs/src/src/binutils/doc/binutils.texi,v
retrieving revision 1.49
diff -c -3 -p -r1.49 binutils.texi
*** binutils/doc/binutils.texi	23 Nov 2003 01:10:45 -0000	1.49
--- binutils/doc/binutils.texi	25 Nov 2003 17:03:50 -0000
*************** files.  The options control what particu
*** 3122,3127 ****
--- 3122,3132 ----
  @var{elffile}@dots{} are the object files to be examined.  32-bit and
  64-bit ELF files are supported, as are archives containing ELF files.
  
+ This program performs a similar function to @command{objdump} but it
+ goes into more detail and it exists independently of the @sc{bfd}
+ library, so if there is a bug in @sc{bfd} then readelf will not be
+ affected.
+ 
  @c man end
  
  @c man begin OPTIONS readelf
        


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