After D81784, we resolve a relocation in .debug_* referencing an ICF folded
section symbol to a tombstone value.
Doing this for .debug_line has a problem (https://reviews.llvm.org/D81784#2116925 ):
.debug_line may describe folded lines as having addresses UINT64_MAX or
some wraparound small addresses.
int foo(int x) { return x; // line 2 } int bar(int x) { return x; // line 6 }
Address Line Column File ISA Discriminator Flags ------------------ ------ ------ ------ --- ------------- ------------- 0x00000000002016c0 1 0 1 0 0 is_stmt 0x00000000002016c7 2 9 1 0 0 is_stmt prologue_end 0x00000000002016ca 2 2 1 0 0 0x00000000002016cc 2 2 1 0 0 end_sequence // UINT64_MAX and wraparound small addresses 0xffffffffffffffff 5 0 1 0 0 is_stmt 0x0000000000000006 6 9 1 0 0 is_stmt prologue_end 0x0000000000000009 6 2 1 0 0 0x000000000000000b 6 2 1 0 0 end_sequence 0x00000000002016d0 9 0 1 0 0 is_stmt 0x00000000002016df 10 6 1 0 0 is_stmt prologue_end 0x00000000002016e6 11 11 1 0 0 is_stmt ...
These entries can confuse debuggers:
gdb before 2020-07-01 (binutils-gdb a8caed5d7faa639a1e6769eba551d15d8ddd9510 )
(can't continue due to a breakpoint in an invalid region of memory):
Warning: Cannot insert breakpoint 1. Cannot access memory at address 0x6
lldb (breakpoint has no effect):
(lldb) b 6 Breakpoint 1: no locations (pending). WARNING: Unable to resolve breakpoint to any actual locations.
This patch special cases .debug_line to not use the tombstone value,
restoring the previous behavior: .debug_line will have entries with the
same addresses (ICF) but different line numbers. A breakpoint on line 2
or 6 will trigger on both functions.
I recommend:
"However, resolving a relocation in .debug_line to -1 would stop debugger users from setting breakpoints on the folded-in function, so exclude .debug_line."