[Bug binutils/32927] New: readelf --dwarf-check --debug-dump=Ranges produces nonsense warnings for DWARF 4 and DWARF5

2025-04-29 Thread hmeyer.eu at gmail dot com
https://sourceware.org/bugzilla/show_bug.cgi?id=32927

Bug ID: 32927
   Summary: readelf --dwarf-check --debug-dump=Ranges produces
nonsense warnings for DWARF 4 and DWARF5
   Product: binutils
   Version: 2.45 (HEAD)
Status: UNCONFIRMED
  Severity: normal
  Priority: P2
 Component: binutils
  Assignee: unassigned at sourceware dot org
  Reporter: hmeyer.eu at gmail dot com
  Target Milestone: ---

example output from --dwarf-check --debug-dump=Ranges:

DWARF4/debug_ranges:

Offset   BeginEnd
 36d4 36d4 (start == end)
 36d8 36dc
 
readelf: Warning: There is a hole [0 - 0x30] in .debug_ranges section.
0030 36d4 36d8
0030 36dc 36e5
0030 
readelf: Warning: There is a hole [0x30 - 0x60] in .debug_ranges section.
0060 3704 3704 (start == end)
0060 3708 370c
0060 
readelf: Warning: There is a hole [0x60 - 0x90] in .debug_ranges section.
0090 3704 3708
0090 370c 3715
0090 

DWARF5/debug_rnglists:
Offset   BeginEnd
000c 36d4 (base address)
0015 36d4 36d4  (start == end)
0018 36d8 36dc 
001b 
readelf: Warning: There is a hole [0xc - 0x1c] in .debug_rnglists section.
001c 36d4 (base address)
0025 36d4 36d8 
0028 36dc 36e5 
002b 
readelf: Warning: There is a hole [0x1c - 0x2c] in .debug_rnglists section.
002c 3704 (base address)
0035 3704 3704  (start == end)
0038 3708 370c 
003b 

The hole check always triggers, even if the other output shows that there are
no holes.

If the hole check triggers, it prevents the overlap check from triggering, even
if there are overlaps. However, it is normal for compilers (GCC 13 and later)
to produce overlapping rangelists in debug_rnglists as noted in the discussion
of bug 30792.

readelf --dwarf-check --debug-dump=Ranges seems to be broken for all versions
since 2.35, which is the oldest I tested (debian oldstable).

I have not attached a binary, it seems to be wrong for all inputs.

-- 
You are receiving this mail because:
You are on the CC list for the bug.


[Bug binutils/32927] readelf --dwarf-check --debug-dump=Ranges produces nonsense warnings for DWARF 4 and DWARF5

2025-04-29 Thread hmeyer.eu at gmail dot com
https://sourceware.org/bugzilla/show_bug.cgi?id=32927

--- Comment #2 from Henning Meyer  ---
The following C++ program represents the simplest example I could find that is
complicated enough to warrant the creation of discontinuous ranges in debug
information:


#include 
struct Base {};
void func() {
static std::unique_ptr varStatic = std::make_unique();
}
int main(int, char**) {
func();
return 0;
}

I compile with g++-14 -g3 -gdwarf-5 -O2 -c:

readelf --dwarf-check --debug-dump=Ranges

Contents of the .debug_rnglists section:

readelf: Warning: Range lists in .debug_rnglists section start at 0xc

 Table at Offset: 0:
  Length:  0x5d
  DWARF version:   5
  Address size:8
  Segment size:0
  Offset entries:  0
Offset   BeginEnd
000c 0024 (base address)
0015 0024 002e 
0018 003c 0043 
001b 
readelf: Warning: There is a hole [0xc - 0x1c] in .debug_rnglists section.
001c 002e (base address)
0025 002e 002e  (start == end)
0028 003c 0043 
002b 
readelf: Warning: There is a hole [0x1c - 0x2c] in .debug_rnglists section.
002c 002e (base address)
0035 002e 003c 
0038 0043 004f 
003b 0050 0053 
003e 0055 005e 
0041 
readelf: Warning: There is a hole [0x2c - 0x42] in .debug_rnglists section.
0042  0076 
004c  0017 
0056  000e 
0060 

(That is the complete output). I can attach the binary, it is 180K in size.

-- 
You are receiving this mail because:
You are on the CC list for the bug.


[Bug binutils/32927] readelf --dwarf-check --debug-dump=Ranges produces nonsense warnings for DWARF 4 and DWARF5

2025-04-30 Thread hmeyer.eu at gmail dot com
https://sourceware.org/bugzilla/show_bug.cgi?id=32927

--- Comment #4 from Henning Meyer  ---
I've applied the patch, it removes the bogus warnings on my test set.

-- 
You are receiving this mail because:
You are on the CC list for the bug.