Skip to content

Commit ab301d8

Browse files
committed
[ELF][test] --emit-relocs: test ALLOC sections discarded by --gc-sections and referenced by non-ALLOC
bbf7b9d accidentally caused a regression that is fixed by #69425. Add test to prevent regression.
1 parent 8ff3e4f commit ab301d8

File tree

1 file changed

+31
-4
lines changed

1 file changed

+31
-4
lines changed

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

Lines changed: 31 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,20 +5,47 @@
55

66
# RUN: echo '.globl _start; _start: call group' | llvm-mc -filetype=obj -triple=x86_64 - -o %t.o
77
# RUN: llvm-mc -filetype=obj -triple=x86_64 %s -o %t1.o
8-
# RUN: ld.lld --gc-sections %t.o %t1.o %t1.o -o %t
8+
# RUN: ld.lld --emit-relocs --gc-sections %t.o %t1.o %t1.o -o %t
99
# RUN: llvm-objdump -s %t | FileCheck %s
10+
# RUN: llvm-readobj -r %t | FileCheck %s --check-prefix=REL
1011

1112
# CHECK: Contents of section .debug_loc:
1213
# CHECK-NEXT: 0000 01000000 00000000 01000000 00000000
13-
# CHECK-NEXT: Contents of section .debug_ranges:
14+
# CHECK: Contents of section .debug_ranges:
1415
# CHECK-NEXT: 0000 01000000 00000000 01000000 00000000
15-
# CHECK-NEXT: Contents of section .debug_addr:
16+
# CHECK: Contents of section .debug_addr:
1617
# CHECK-NEXT: 0000 {{.*}}000 00000000 {{.*}}000 00000000
1718
# CHECK-NEXT: 0010 00000000 00000000 {{.*}}000 00000000
18-
# CHECK-NEXT: Contents of section .debug_foo:
19+
# CHECK: Contents of section .debug_foo:
1920
# CHECK-NEXT: 0000 00000000 00000000 08000000 00000000
2021
# CHECK-NEXT: 0010 00000000 00000000 08000000 00000000
2122

23+
# REL: Relocations [
24+
# REL-NEXT: .rela.text {
25+
# REL-NEXT: 0x201121 R_X86_64_PLT32 group 0xFFFFFFFFFFFFFFFC
26+
# REL-NEXT: }
27+
# REL-NEXT: .rela.debug_loc {
28+
# REL-NEXT: 0x0 R_X86_64_NONE - 0x8
29+
# REL-NEXT: 0x8 R_X86_64_NONE - 0x8
30+
# REL-NEXT: }
31+
# REL-NEXT: .rela.debug_ranges {
32+
# REL-NEXT: 0x0 R_X86_64_NONE - 0x10
33+
# REL-NEXT: 0x8 R_X86_64_NONE - 0x10
34+
# REL-NEXT: }
35+
# REL-NEXT: .rela.debug_addr {
36+
# REL-NEXT: 0x0 R_X86_64_64 .text 0x1D
37+
# REL-NEXT: 0x8 R_X86_64_64 group 0x20
38+
# REL-NEXT: 0x10 R_X86_64_NONE - 0x18
39+
# REL-NEXT: 0x18 R_X86_64_64 group 0x20
40+
# REL-NEXT: }
41+
# REL-NEXT: .rela.debug_foo {
42+
# REL-NEXT: 0x0 R_X86_64_NONE - 0x8
43+
# REL-NEXT: 0x8 R_X86_64_NONE - 0x8
44+
# REL-NEXT: 0x10 R_X86_64_NONE - 0x8
45+
# REL-NEXT: 0x18 R_X86_64_NONE - 0x8
46+
# REL-NEXT: }
47+
# REL-NEXT: ]
48+
2249
## -z dead-reloc-in-nonalloc= can override the tombstone value.
2350
# RUN: ld.lld --gc-sections -z dead-reloc-in-nonalloc=.debug_loc=42 %t.o %t1.o %t1.o -o %t42
2451
# RUN: llvm-objdump -s %t42 | FileCheck %s --check-prefix=OVERRIDE

0 commit comments

Comments
 (0)