diff --git a/lld/ELF/InputSection.cpp b/lld/ELF/InputSection.cpp --- a/lld/ELF/InputSection.cpp +++ b/lld/ELF/InputSection.cpp @@ -939,13 +939,16 @@ // // For pre-DWARF-v5 .debug_loc and .debug_ranges, -1 is a reserved value // (base address selection entry), so -2 is used. + // + // release/11.x only: for safety, we use 0 instead of -1 as the tombstone + // value. auto *ds = dyn_cast(&sym); if (!sym.getOutputSection() || (ds && ds->section->repl != ds->section && !isDebugLine)) { // If -z dead-reloc-in-nonalloc= is specified, respect it. - const uint64_t value = - tombstone ? SignExtend64(*tombstone) - : (isDebugLocOrRanges ? UINT64_MAX - 1 : UINT64_MAX); + const uint64_t value = tombstone + ? SignExtend64(*tombstone) + : (isDebugLocOrRanges ? UINT64_MAX - 1 : 0); target->relocateNoSym(bufLoc, type, value); continue; } diff --git a/lld/test/ELF/dead-reloc-in-nonalloc.s b/lld/test/ELF/dead-reloc-in-nonalloc.s --- a/lld/test/ELF/dead-reloc-in-nonalloc.s +++ b/lld/test/ELF/dead-reloc-in-nonalloc.s @@ -11,7 +11,7 @@ # RUN: -z dead-reloc-in-nonalloc=.not_debug=0xbbbbbbbb %t.o -o - | cmp %t - # COMMON: Contents of section .debug_addr: -# COMMON-NEXT: 0000 [[ADDR:[0-9a-f]+]] 00000000 ffffffff ffffffff +# COMMON-NEXT: 0000 [[ADDR:[0-9a-f]+]] 00000000 00000000 00000000 # AA: Contents of section .debug_info: # AA-NEXT: 0000 [[ADDR]] 00000000 aaaaaaaa 00000000 diff --git a/lld/test/ELF/debug-dead-reloc-32.s b/lld/test/ELF/debug-dead-reloc-32.s --- a/lld/test/ELF/debug-dead-reloc-32.s +++ b/lld/test/ELF/debug-dead-reloc-32.s @@ -12,7 +12,7 @@ # CHECK-NEXT: Contents of section .debug_ranges: # CHECK-NEXT: 0000 feffffff # CHECK-NEXT: Contents of section .debug_addr: -# CHECK-NEXT: 0000 ffffffff +# CHECK-NEXT: 0000 00000000 .section .text.1,"axe" .byte 0 @@ -24,6 +24,6 @@ .section .debug_ranges .long .text.1+16 -## Resolved to UINT32_C(-1), with the addend ignored. +## Resolved to UINT32_C(0), with the addend ignored. .section .debug_addr .long .text.1+8 diff --git a/lld/test/ELF/debug-dead-reloc-icf.s b/lld/test/ELF/debug-dead-reloc-icf.s --- a/lld/test/ELF/debug-dead-reloc-icf.s +++ b/lld/test/ELF/debug-dead-reloc-icf.s @@ -9,7 +9,7 @@ # RUN: llvm-objdump -s %t | FileCheck %s # CHECK: Contents of section .debug_info: -# CHECK-NEXT: 0000 {{[0-9a-f]+}}000 00000000 ffffffff ffffffff +# CHECK-NEXT: 0000 {{[0-9a-f]+}}000 00000000 00000000 00000000 # CHECK: Contents of section .debug_line: # CHECK-NEXT: 0000 [[ADDR:[0-9a-f]+]] 00000000 # CHECK-SAME: [[ADDR]] 00000000 diff --git a/lld/test/ELF/debug-dead-reloc-tls.s b/lld/test/ELF/debug-dead-reloc-tls.s --- a/lld/test/ELF/debug-dead-reloc-tls.s +++ b/lld/test/ELF/debug-dead-reloc-tls.s @@ -7,8 +7,8 @@ # RUN: llvm-objdump -s %t | FileCheck %s # CHECK: Contents of section .debug_info: -# CHECK-NEXT: 0000 ffffffff ffffffff ffffffff ffffffff -# CHECK-NEXT: 0010 ffffffff ffffffff +# CHECK-NEXT: 0000 00000000 00000000 00000000 00000000 +# CHECK-NEXT: 0010 00000000 ffffffff .globl _start _start: diff --git a/lld/test/ELF/debug-dead-reloc.s b/lld/test/ELF/debug-dead-reloc.s --- a/lld/test/ELF/debug-dead-reloc.s +++ b/lld/test/ELF/debug-dead-reloc.s @@ -14,10 +14,10 @@ # CHECK-NEXT: 0000 feffffff ffffffff feffffff ffffffff # CHECK-NEXT: Contents of section .debug_addr: # CHECK-NEXT: 0000 {{.*}}000 00000000 {{.*}}000 00000000 -# CHECK-NEXT: 0010 ffffffff ffffffff {{.*}}000 00000000 +# CHECK-NEXT: 0010 00000000 00000000 {{.*}}000 00000000 # CHECK-NEXT: Contents of section .debug_foo: -# CHECK-NEXT: 0000 ffffffff ffffffff 08000000 00000000 -# CHECK-NEXT: 0010 ffffffff ffffffff 08000000 00000000 +# CHECK-NEXT: 0000 00000000 00000000 08000000 00000000 +# CHECK-NEXT: 0010 00000000 00000000 08000000 00000000 ## -z dead-reloc-in-nonalloc= can override the tombstone value. # RUN: ld.lld --gc-sections -z dead-reloc-in-nonalloc=.debug_loc=42 %t.o %t1.o %t1.o -o %t42 @@ -44,7 +44,7 @@ .section .debug_addr ## .text.3 is a local symbol. The symbol defined in a non-prevailing group is -## discarded. Resolved to UINT64_C(-1). +## discarded. Resolved to UINT64_C(0). .quad .text.3+24 ## group is a non-local symbol. The relocation from the second %t1.o gets ## resolved to the prevailing copy.