2 ## Test we resolve symbolic relocations in .debug_* sections to a tombstone
3 ## value if the referenced symbol is discarded (--gc-sections, non-prevailing
4 ## section group, SHF_EXCLUDE, /DISCARD/, etc).
6 # RUN: echo '.globl _start; _start: call group' | llvm-mc -filetype=obj -triple=x86_64 - -o %t.o
7 # RUN: llvm-mc -filetype=obj -triple=x86_64 %s -o %t1.o
8 # RUN: ld.lld --emit-relocs --gc-sections %t.o %t1.o %t1.o -o %t
9 # RUN: llvm-objdump -s %t | FileCheck %s
10 # RUN: llvm-readobj -r %t | FileCheck %s --check-prefix=REL
12 # CHECK: Contents of section .debug_loc:
13 # CHECK-NEXT: 0000 01000000 00000000 01000000 00000000
14 # CHECK: Contents of section .debug_ranges:
15 # CHECK-NEXT: 0000 01000000 00000000 01000000 00000000
16 # CHECK: Contents of section .debug_addr:
17 # CHECK-NEXT: 0000 {{.*}}000 00000000 {{.*}}000 00000000
18 # CHECK-NEXT: 0010 00000000 00000000 {{.*}}000 00000000
19 # CHECK: Contents of section .debug_foo:
20 # CHECK-NEXT: 0000 00000000 00000000 08000000 00000000
21 # CHECK-NEXT: 0010 00000000 00000000 08000000 00000000
24 # REL-NEXT: .rela.text {
25 # REL-NEXT: 0x201121 R_X86_64_PLT32 group 0xFFFFFFFFFFFFFFFC
27 # REL-NEXT: .rela.debug_loc {
28 # REL-NEXT: 0x0 R_X86_64_NONE - 0x8
29 # REL-NEXT: 0x8 R_X86_64_NONE - 0x8
31 # REL-NEXT: .rela.debug_ranges {
32 # REL-NEXT: 0x0 R_X86_64_NONE - 0x10
33 # REL-NEXT: 0x8 R_X86_64_NONE - 0x10
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
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
49 ## -z dead-reloc-in-nonalloc= can override the tombstone value.
50 # RUN: ld.lld --gc-sections -z dead-reloc-in-nonalloc=.debug_loc=42 %t.o %t1.o %t1.o -o %t42
51 # RUN: llvm-objdump -s %t42 | FileCheck %s --check-prefix=OVERRIDE
53 # OVERRIDE: Contents of section .debug_loc:
54 # OVERRIDE-NEXT: 0000 2a000000 00000000 2a000000 00000000
58 .section .text.2,"axe"
60 .section .text.3,"axG",@progbits,group,comdat
65 ## Resolved to UINT64_C(1), with the addend ignored.
66 ## UINT64_C(-1) is a reserved value (base address selection entry) which can't be used.
69 .section .debug_ranges
73 ## .text.3 is a local symbol. The symbol defined in a non-prevailing group is
74 ## discarded. Resolved to UINT64_C(0).
76 ## group is a non-local symbol. The relocation from the second %t1.o gets
77 ## resolved to the prevailing copy.
83 ## We only deal with DW_FORM_addr. Don't special case short-range absolute
84 ## relocations. Treat them like regular absolute relocations referencing
85 ## discarded symbols, which are resolved to the addend.