bug-binutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Bug binutils/4700] New: binutils' readelf dump of little endian files i


From: neighbour667 at gmx dot de
Subject: [Bug binutils/4700] New: binutils' readelf dump of little endian files is no longer reversed, which reduces readability
Date: 26 Jun 2007 17:51:01 -0000

I severely regret, that you chose to remove the reversing of little endian dumps
from readelf in 2.17.50.0.10.
It was a real boon when examining elf sections.
The advantage is that you can read pointers, and multi-byte values in general,
as they are displayed.
That was a invaluable feature. One which objdump lacks. 
Additionally the nibbles were displayed contiguous.

For example, a reordered dump of .got.plt, 
    Hex dump of section '.got.plt':
      0x08049ff4 08048246 00000000 00000000 08049f4c L...........F...
loses a lot of its readability:
    Hex dump of section '.got.plt':
      0x08049ff4 4c9f0408 00000000 00000000 46820408 L...........F...

I personally find it easier to start reading on the right hand side, than
to reorder the addresses manually.

An introduction to elf with a relatively high search ranking, refers to it.
   
http://www.linuxforums.org/misc/understanding_elf_using_readelf_and_objdump_3.html

Probably, a little note in the man-page or in the dump preamble about the
reordering 
would help to prevent confusion, which seems to be the main reason for the 
change.

I propose a patch which restores the reversing and adds a note to the manual
and to the dump preamble. You certainly find better words.

--- binutils/readelf.c.msb-only 2007-06-25 20:14:55.000000000 +0200
+++ binutils/readelf.c  2007-06-26 17:48:44.000000000 +0200
@@ -7652,13 +7648,16 @@ dump_section (Elf_Internal_Shdr *section
     {
       printf (_("\nSection '%s' has no data to dump.\n"),
              SECTION_NAME (section));
       return 0;
     }
   else
-    printf (_("\nHex dump of section '%s':\n"), SECTION_NAME (section));
+    printf (_("\nHex dump of section '%s' %s:\n"), SECTION_NAME (section),
+                   (elf_header.e_ident[EI_DATA] == ELFDATA2LSB) ? 
+                   "(reversed hex values to comply with little endian 
ordering)" 
+                   : "");
 
   addr = section->sh_addr;
 
   start = get_data (NULL, file, section->sh_offset, 1, bytes,
                    _("section data"));
   if (!start)
@@ -7673,22 +7672,41 @@ dump_section (Elf_Internal_Shdr *section
       int lbytes;
 
       lbytes = (bytes > 16 ? 16 : bytes);
 
       printf ("  0x%8.8lx ", (unsigned long) addr);
 
+      switch (elf_header.e_ident[EI_DATA])
+       {
+       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 & 3) == 3)
            printf (" ");
        }
+         break;
+       }
 
       for (j = 0; j < lbytes; j++)
        {
          k = data[j];
          if (k >= ' ' && k < 0x7f)
            printf ("%c", k);
--- binutils/doc/binutils.texi.confusion        2006-09-24 17:19:58.000000000 
+0200
+++ binutils/doc/binutils.texi  2007-06-26 17:17:48.000000000 +0200
@@ -3497,12 +3497,14 @@ symbols section.
 
 @item -x <number or name>
 @itemx --hex-dump=<number or name>
 Displays the contents of the indicated section as a hexadecimal dump.
 A number identifies a particular section by index in the section table;
 any other string identifies all sections with that name in the object file.
+For little endian files the hex values are displayed from right to left, to 
+facilitate the reading of multi-byte values.
 
 @item -w[liaprmfFsoR]
 @itemx
--debug-dump[=line,=info,=abbrev,=pubnames,=aranges,=macro,=frames,=frames-interp,=str,=loc,=Ranges]
 Displays the contents of the debug sections in the file, if any are
 present.  If one of the optional letters or words follows the switch
 then only data found in those specific sections will be dumped.

-- 
           Summary: binutils' readelf dump of little endian files is no
                    longer reversed, which reduces readability
           Product: binutils
           Version: 2.17
            Status: NEW
          Severity: normal
          Priority: P2
         Component: binutils
        AssignedTo: unassigned at sources dot redhat dot com
        ReportedBy: neighbour667 at gmx dot de
                CC: bug-binutils at gnu dot org


http://sourceware.org/bugzilla/show_bug.cgi?id=4700

------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]