[lld] 0e6685a - [ELF,test] Improve tombstone value tests
Fangrui Song via llvm-commits
llvm-commits at lists.llvm.org
Thu Dec 7 10:50:01 PST 2023
Author: Fangrui Song
Date: 2023-12-07T10:49:57-08:00
New Revision: 0e6685ab1a8313cd1dc7eb3c99ff642e6c492aa2
URL: https://github.com/llvm/llvm-project/commit/0e6685ab1a8313cd1dc7eb3c99ff642e6c492aa2
DIFF: https://github.com/llvm/llvm-project/commit/0e6685ab1a8313cd1dc7eb3c99ff642e6c492aa2.diff
LOG: [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
Added:
Modified:
lld/test/ELF/debug-dead-reloc-32.s
lld/test/ELF/debug-dead-reloc.s
Removed:
################################################################################
diff --git a/lld/test/ELF/debug-dead-reloc-32.s b/lld/test/ELF/debug-dead-reloc-32.s
index b2708a744f288..99335b44f51ce 100644
--- a/lld/test/ELF/debug-dead-reloc-32.s
+++ b/lld/test/ELF/debug-dead-reloc-32.s
@@ -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
diff --git a/lld/test/ELF/debug-dead-reloc.s b/lld/test/ELF/debug-dead-reloc.s
index fcf53205079ed..cfa41e00eab06 100644
--- a/lld/test/ELF/debug-dead-reloc.s
+++ b/lld/test/ELF/debug-dead-reloc.s
@@ -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).
@@ -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
More information about the llvm-commits
mailing list