Skip to content

Commit

Permalink
[ELF,test] Improve tombstone value tests
Browse files Browse the repository at this point in the history
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 llvm#74686
  • Loading branch information
MaskRay committed Dec 7, 2023
1 parent dd0e38e commit 0e6685a
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
11 changes: 11 additions & 0 deletions lld/test/ELF/debug-dead-reloc-32.s
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,17 @@
# CHECK-NEXT: Contents of section .debug_addr:
# CHECK-NEXT: 0000 00000000

## -z dead-reloc-in-nonalloc= can override the tombstone value.
# RUN: ld.lld -z dead-reloc-in-nonalloc=.debug_loc=42 -z dead-reloc-in-nonalloc=.debug_addr=0xfffffffffffffffe %t.o -o %t1
# RUN: llvm-objdump -s %t1 | FileCheck %s --check-prefix=OVERRIDE

# OVERRIDE: Contents of section .debug_loc:
# OVERRIDE-NEXT: 0000 2a000000 *...
# OVERRIDE-NEXT: Contents of section .debug_ranges:
# OVERRIDE-NEXT: 0000 01000000 ....
# OVERRIDE-NEXT: Contents of section .debug_addr:
# OVERRIDE-NEXT: 0000 feffffff ....

.section .text.1,"axe"
.byte 0

Expand Down
11 changes: 8 additions & 3 deletions lld/test/ELF/debug-dead-reloc.s
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# REQUIRES: x86
# REQUIRES: aarch64, x86
## Test we resolve symbolic relocations in .debug_* sections to a tombstone
## value if the referenced symbol is discarded (--gc-sections, non-prevailing
## section group, SHF_EXCLUDE, /DISCARD/, etc).
Expand All @@ -9,13 +9,18 @@
# RUN: llvm-objdump -s %t | FileCheck %s
# RUN: llvm-readobj -r %t | FileCheck %s --check-prefix=REL

# RUN: echo '.globl _start; _start: bl group' | llvm-mc -filetype=obj -triple=aarch64 - -o %t.a64.o
# RUN: llvm-mc -filetype=obj -triple=aarch64 %s -o %t1.a64.o
# RUN: ld.lld --emit-relocs --gc-sections %t.a64.o %t1.a64.o %t1.a64.o -o %t.a64
# RUN: llvm-objdump -s %t.a64 | FileCheck %s

# CHECK: Contents of section .debug_loc:
# CHECK-NEXT: 0000 01000000 00000000 01000000 00000000
# CHECK: Contents of section .debug_ranges:
# CHECK-NEXT: 0000 01000000 00000000 01000000 00000000
# CHECK: Contents of section .debug_addr:
# CHECK-NEXT: 0000 {{.*}}000 00000000 {{.*}}000 00000000
# CHECK-NEXT: 0010 00000000 00000000 {{.*}}000 00000000
# CHECK-NEXT: 0000 {{.*}}00 00000000 {{.*}}00 00000000
# CHECK-NEXT: 0010 00000000 00000000 {{.*}}00 00000000
# CHECK: Contents of section .debug_foo:
# CHECK-NEXT: 0000 00000000 00000000 08000000 00000000
# CHECK-NEXT: 0010 00000000 00000000 08000000 00000000
Expand Down

0 comments on commit 0e6685a

Please sign in to comment.