[PATCH] readelf: Fix output of rnglists section

Bernd Edlinger bernd.edlinger@hotmail.de
Tue Nov 10 15:26:44 GMT 2020


Noticed this when examining the debug info in the following
gdb test case binutils-gdb/gdb/testsuite/gdb.cp/step-and-next-inline.cc:

$ gcc -g -gdwarf-5 -O2 step-and-next-inline.cc
$ readelf --debug-dump=Ranges a.out
Contents of the .debug_rnglists section:

    Offset   Begin    End
    0000000c 0000000000401160 00000000004011ca
    00000016 0000000000401060 0000000000401065
    00000020 <End of list>
    00000021 0000000000401165 (base address)
    0000002a 0000000000401165 0000000000401165 (start == end)
    0000002d 0000000000401169 0000000000401173
    00000030 00000000008021c5 00000000008021ca <== wrong
    0000003a <End of list>
    0000003b 0000000000401160 00000000004011ca
    00000045 0000000000401060 0000000000401065
    0000004f 0000000000401070 0000000000401085
    00000059 <End of list>

It turns out that the .s file contans this:

.LLRL2:
        .byte   0x5
        .quad   .LBB8
        .byte   0x4
        .uleb128 .LBB8-.LBB8
        .uleb128 .LBE8-.LBB8
        .byte   0x4
        .uleb128 .LBB12-.LBB8
        .uleb128 .LBE12-.LBB8
        .byte   0x7
        .quad   .LBB17
        .uleb128 .LBE17-.LBB17
        .byte   0

So 0x7 = DW_RLE_start_length is wrong decoded and got the
base address added unexpectedly.
while 0x4 = DW_RLE_offset_pair is the only entry that needs
to add the base address.

BTW: gdb does it right, see:
commit d0ce17d8537 ("gdb: fix issues with handling DWARF v5 rnglists & .dwo files.").

2020-11-10  Bernd Edlinger  <bernd.edlinger@hotmail.de>

	* dwarf.c (display_debug_rnglists_list): Only DW_RLE_offset_pair
	needs the base address added.


Regression test successful on x86_64-pc-linux-gnu.
Is it OK for trunk?


Thanks
Bernd.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-readelf-Fix-output-of-rnglists-section.patch
Type: text/x-patch
Size: 2643 bytes
Desc: not available
URL: <https://sourceware.org/pipermail/binutils/attachments/20201110/80c9ecd5/attachment.bin>


More information about the Binutils mailing list