Skip to content

Commit 0e6685a

Browse files
committed
[ELF,test] Improve tombstone value tests
Add 32-bit test for -z dead-reloc-in-nonalloc= and add tests for a non-x86 64-bit (x86-64 is unique in discerning signed/unsigned 32-bit absolute relocations (R_X86_64_32/R_X86_64_32S). AArch64/PPC64/RISC-V/etc don't have the distinction). Having a test will improve coverage for #74686
1 parent dd0e38e commit 0e6685a

File tree

2 files changed

+19
-3
lines changed

2 files changed

+19
-3
lines changed

lld/test/ELF/debug-dead-reloc-32.s

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,17 @@
1414
# CHECK-NEXT: Contents of section .debug_addr:
1515
# CHECK-NEXT: 0000 00000000
1616

17+
## -z dead-reloc-in-nonalloc= can override the tombstone value.
18+
# RUN: ld.lld -z dead-reloc-in-nonalloc=.debug_loc=42 -z dead-reloc-in-nonalloc=.debug_addr=0xfffffffffffffffe %t.o -o %t1
19+
# RUN: llvm-objdump -s %t1 | FileCheck %s --check-prefix=OVERRIDE
20+
21+
# OVERRIDE: Contents of section .debug_loc:
22+
# OVERRIDE-NEXT: 0000 2a000000 *...
23+
# OVERRIDE-NEXT: Contents of section .debug_ranges:
24+
# OVERRIDE-NEXT: 0000 01000000 ....
25+
# OVERRIDE-NEXT: Contents of section .debug_addr:
26+
# OVERRIDE-NEXT: 0000 feffffff ....
27+
1728
.section .text.1,"axe"
1829
.byte 0
1930

lld/test/ELF/debug-dead-reloc.s

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# REQUIRES: x86
1+
# REQUIRES: aarch64, x86
22
## Test we resolve symbolic relocations in .debug_* sections to a tombstone
33
## value if the referenced symbol is discarded (--gc-sections, non-prevailing
44
## section group, SHF_EXCLUDE, /DISCARD/, etc).
@@ -9,13 +9,18 @@
99
# RUN: llvm-objdump -s %t | FileCheck %s
1010
# RUN: llvm-readobj -r %t | FileCheck %s --check-prefix=REL
1111

12+
# RUN: echo '.globl _start; _start: bl group' | llvm-mc -filetype=obj -triple=aarch64 - -o %t.a64.o
13+
# RUN: llvm-mc -filetype=obj -triple=aarch64 %s -o %t1.a64.o
14+
# RUN: ld.lld --emit-relocs --gc-sections %t.a64.o %t1.a64.o %t1.a64.o -o %t.a64
15+
# RUN: llvm-objdump -s %t.a64 | FileCheck %s
16+
1217
# CHECK: Contents of section .debug_loc:
1318
# CHECK-NEXT: 0000 01000000 00000000 01000000 00000000
1419
# CHECK: Contents of section .debug_ranges:
1520
# CHECK-NEXT: 0000 01000000 00000000 01000000 00000000
1621
# CHECK: Contents of section .debug_addr:
17-
# CHECK-NEXT: 0000 {{.*}}000 00000000 {{.*}}000 00000000
18-
# CHECK-NEXT: 0010 00000000 00000000 {{.*}}000 00000000
22+
# CHECK-NEXT: 0000 {{.*}}00 00000000 {{.*}}00 00000000
23+
# CHECK-NEXT: 0010 00000000 00000000 {{.*}}00 00000000
1924
# CHECK: Contents of section .debug_foo:
2025
# CHECK-NEXT: 0000 00000000 00000000 08000000 00000000
2126
# CHECK-NEXT: 0010 00000000 00000000 08000000 00000000

0 commit comments

Comments
 (0)