This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: Difference between objdump and readlelf output
- From: Alan Modra <amodra at bigpond dot net dot au>
- To: Tiron Adrian <tiron_adrian at yahoo dot com>
- Cc: binutils at sourceware dot org
- Date: Thu, 4 Jan 2007 23:21:37 +1030
- Subject: Re: Difference between objdump and readlelf output
- References: <20070104114101.81894.qmail@web58315.mail.re3.yahoo.com>
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.
Index: binutils/readelf.c
===================================================================
RCS file: /cvs/src/src/binutils/readelf.c,v
retrieving revision 1.354
diff -u -p -r1.354 readelf.c
--- binutils/readelf.c 25 Dec 2006 22:39:21 -0000 1.354
+++ binutils/readelf.c 4 Jan 2007 12:48:44 -0000
@@ -7671,34 +7671,15 @@ dump_section (Elf_Internal_Shdr *section
printf (" 0x%8.8lx ", (unsigned long) addr);
- switch (elf_header.e_ident[EI_DATA])
+ for (j = 0; j < 16; j++)
{
- default:
- case ELFDATA2LSB:
- for (j = 15; j >= 0; j --)
- {
- if (j < lbytes)
- printf ("%2.2x", data[j]);
- else
- printf (" ");
-
- if (!(j & 0x3))
- printf (" ");
- }
- break;
-
- case ELFDATA2MSB:
- for (j = 0; j < 16; j++)
- {
- if (j < lbytes)
- printf ("%2.2x", data[j]);
- else
- printf (" ");
+ if (j < lbytes)
+ printf ("%2.2x", data[j]);
+ else
+ printf (" ");
- if ((j & 3) == 3)
- printf (" ");
- }
- break;
+ if ((j & 3) == 3)
+ printf (" ");
}
for (j = 0; j < lbytes; j++)