This is the mail archive of the binutils@sourceware.org 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: Difference between objdump and readlelf output


On Thu, Jan 04, 2007 at 11:21:37PM +1030, Alan Modra wrote:
> On Thu, Jan 04, 2007 at 03:41:01AM -0800, Tiron Adrian wrote:
> > [root@localhost understanding_elf]# readelf -x21 hello
> 
> readelf -x is broken for little-endian.   I don't think readelf should
> be trying to print the value of each 32-bit word.  After all, the
> section data may well not be 32-bit words, especially on 64-bit
> targets.  Instead we should just dump the bytes, with an extra space
> every 4 bytes to help in counting bytes.
> 
> Does anyone think we should be doing something different?
> 
> 	* readelf.c (dump_section): Don't print 32-bit values, which
> 	were done incorrectly for little-endian.  Instead print bytes.

I've actually found the existing behavior useful.  It's not reversing
32-bit values - the entire line is reversed, so you have to read it
right to left, but it's easy to make out 64-bit words.

If you're going to reverse the order, can there be some sort of header
indicating what it's printing?  Because otherwise we'll have two
versions of readelf producing similar looking output in the opposite
order.

drow@caradoc:~% readelf -x 20 /bin/ls

Hex dump of section '.dynamic':
  0x00514028 00000000 00000001 00000000 00000001 ................
  0x00514038 00000000 0000003d 00000000 00000001 ........=.......

  0x00514078 00000000 0040d938 00000000 0000000d ........8.@.....

drow@caradoc:~% objdump -s -j .dynamic /bin/ls

/bin/ls:     file format elf64-x86-64

Contents of section .dynamic:
 514028 01000000 00000000 01000000 00000000  ................
 514038 01000000 00000000 3d000000 00000000  ........=.......

 514078 0d000000 00000000 38d94000 00000000  ........8.@.....

Neither of those is the intuitive order, but readelf's version is more
useful if you want to pick out a multi-byte value.


-- 
Daniel Jacobowitz
CodeSourcery


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