readelf: Displaying "raw' .debug_aranges

Mark Wielaard mjw at redhat.com
Thu Mar 21 16:09:09 UTC 2013


Hi,

I was chasing a anomaly with .debug_aranges and found the eu-readelf
--debug-dump=aranges output not very helpful. It uses libdw
dwarf_getaranges which hides lots of details and sorts the addresses.
Not helpful if you are trying to see why something might be wrong.
binutils readelf also wasn't a big help because it errored out before
displaying anything. So I implemented a "raw" .debug_aranges for
eu-readelf. The output is as follows:

Table at offset 560:

 Length:            60
 DWARF version:      2
 CU offset:      2bb78
 Address size:       8
 Segment size:       0

   0x000000000043c3c0 <expr_unwind>..0x000000000043e0b1 <evalexp+0xe1>
   0x000000000041bba4 <_is_arithop>..0x000000000041bbee <_is_arithop+0x4a>

This did allow me to find what the issue was. But I am not sure yet what
the root cause is. The following comment in the new code summarizes what
is happening:

+    next_table:
+      if (readp != nexthdr)
+       {
+         size_t padding = nexthdr - readp;
+         printf (gettext ("   %Zu padding bytes\n"), padding);
+         // To skip, or not to skip, that is the question...
+         // dwarf_getaranges doesn't skip, it assumes that after
+         // seeing the terminator sequence there must be another
+         // table and ignores the length field.  Strangely enough
+         // that seems to be the right thing sometimes...
+         readp = nexthdr;
+       }

The above seems to be "correct" according to the DWARF spec. You have to
skip till the next table based on table header length field. But on the
buggy (?) .debug_aranges I am looking at not skipping the padding is the
right thing. This is also what dwarf_getaranges does. So maybe that is
correct? But it also isn't what binutils readelf and dwz seem to do...

I'll try to figure out what is going on. Meanwhile comments on the code
welcome.

Thanks,

Mark
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-readelf-Display-raw-.debug_aranges.-Don-t-use-libdw-.patch
Type: text/x-patch
Size: 7162 bytes
Desc: not available
URL: <https://lists.fedorahosted.org/pipermail/elfutils-devel/attachments/20130321/32597a93/attachment.bin>


More information about the elfutils-devel mailing list