Bug 28012 - readelf --debug-dump=Ranges doesn't handle concatenated .debug_rnglists sections
Summary: readelf --debug-dump=Ranges doesn't handle concatenated .debug_rnglists sections
Status: NEW
Alias: None
Product: binutils
Classification: Unclassified
Component: binutils (show other bugs)
Version: unspecified
: P2 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
Depends on:
Reported: 2021-06-25 15:55 UTC by Simon Marchi
Modified: 2021-06-25 15:56 UTC (History)
0 users

See Also:
Last reconfirmed:

ELF file containing .debug_rnglists (6.07 MB, application/gzip)
2021-06-25 15:56 UTC, Simon Marchi

Note You need to log in before you can comment on or make changes to this bug.
Description Simon Marchi 2021-06-25 15:55:52 UTC
See attached libstdc++.so.6.0.29, taken from:


(the link may be broken when the package gets upgraded, but it doesn't really matter, the attached file should be enough)

It's compiled with gcc, contains DWARF5, and contains a .debug_rnglists section.  The .debug_rnglists section is made by concatenating the .debug_rnglists contributions from all .o files, so it's made of multiple range list tables, one after the other (each range list table is described in section 7.28 of DWARF5).

It looks like readelf tries to read the whole section as one table or something, because after having displayed the entries of the first table, it shows a bunch of:

$ ~/build/binutils-gdb/binutils/readelf --debug-dump=Ranges libstdc++.so.6.0.29 |& less
    000004d8 00000000000a3580 00000000000a359b 
    000004e2 00000000000a35a0 00000000000a35b3 
    000004ec <End of list>
readelf: Warning: Corrupt offset (0x000004f9) in range entry 72
readelf: Warning: Corrupt offset (0x000004f9) in range entry 73
readelf: Warning: Corrupt offset (0x00000509) in range entry 74

I tried to debug display_debug_ranges, in binutils/dwarf.c, but I don't really understand what's happening.  The code uses num_debug_info_entries, I'm not sure where that is coming from.  But I don't see why it would be needed to deal with debug info entries here, I think it should be possible to parse and dump .debug_rnglists by just walking the section by itself until the end.
Comment 1 Simon Marchi 2021-06-25 15:56:19 UTC
Created attachment 13512 [details]
ELF file containing .debug_rnglists