[ELF] Refine isExported/isPreemptible condition
[llvm-project.git] / lld / test / ELF / debug-dead-reloc.s
blob1a8823737ed563054d43ebcb986ec33cc30bef48
1 # REQUIRES: aarch64, x86
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 # 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
17 # CHECK: Contents of section .debug_loc:
18 # CHECK-NEXT: 0000 01000000 00000000 01000000 00000000
19 # CHECK: Contents of section .debug_ranges:
20 # CHECK-NEXT: 0000 01000000 00000000 01000000 00000000
21 # CHECK: Contents of section .debug_addr:
22 # CHECK-NEXT: 0000 {{.*}}00 00000000 {{.*}}00 00000000
23 # CHECK-NEXT: 0010 00000000 00000000 {{.*}}00 00000000
24 # CHECK: Contents of section .debug_names:
25 # CHECK-NEXT: 0000 00000000 00000000 00000000 ffffffff .
26 # CHECK-NEXT: 0010 ffffffff ffffffff .
27 # CHECK: Contents of section .debug_foo:
28 # CHECK-NEXT: 0000 00000000 00000000 00000000 00000000
29 # CHECK-NEXT: 0010 00000000 00000000 00000000 00000000
31 # REL: Relocations [
32 # REL-NEXT: .rela.text {
33 # REL-NEXT: 0x201121 R_X86_64_PLT32 group 0xFFFFFFFFFFFFFFFC
34 # REL-NEXT: }
35 # REL-NEXT: .rela.debug_loc {
36 # REL-NEXT: 0x0 R_X86_64_NONE - 0x8
37 # REL-NEXT: 0x8 R_X86_64_NONE - 0x8
38 # REL-NEXT: }
39 # REL-NEXT: .rela.debug_ranges {
40 # REL-NEXT: 0x0 R_X86_64_NONE - 0x10
41 # REL-NEXT: 0x8 R_X86_64_NONE - 0x10
42 # REL-NEXT: }
43 # REL-NEXT: .rela.debug_addr {
44 # REL-NEXT: 0x0 R_X86_64_64 .text 0x1D
45 # REL-NEXT: 0x8 R_X86_64_64 group 0x20
46 # REL-NEXT: 0x10 R_X86_64_NONE - 0x18
47 # REL-NEXT: 0x18 R_X86_64_64 group 0x20
48 # REL-NEXT: }
49 # REL-NEXT: .rela.debug_names {
50 # REL-NEXT: 0x0 R_X86_64_32 .debug_info 0x0
51 # REL-NEXT: 0x4 R_X86_64_64 .debug_info 0x0
52 # REL-NEXT: 0xC R_X86_64_NONE - 0x0
53 # REL-NEXT: 0x10 R_X86_64_NONE - 0x0
54 # REL-NEXT: }
55 # REL-NEXT: .rela.debug_foo {
56 # REL-NEXT: 0x0 R_X86_64_NONE - 0x8
57 # REL-NEXT: 0x8 R_X86_64_NONE - 0x8
58 # REL-NEXT: 0x10 R_X86_64_NONE - 0x8
59 # REL-NEXT: 0x18 R_X86_64_NONE - 0x8
60 # REL-NEXT: }
61 # REL-NEXT: ]
63 ## -z dead-reloc-in-nonalloc= can override the tombstone value.
64 # RUN: ld.lld --gc-sections -z dead-reloc-in-nonalloc=.debug_loc=42 %t.o %t1.o %t1.o -o %t42
65 # RUN: llvm-objdump -s %t42 | FileCheck %s --check-prefix=OVERRIDE
67 # OVERRIDE: Contents of section .debug_loc:
68 # OVERRIDE-NEXT: 0000 2a000000 00000000 2a000000 00000000
70 .section .text.1,"ax"
71 .byte 0
72 .section .text.2,"axe"
73 .byte 0
74 .section .text.3,"axG",@progbits,group,comdat
75 .globl group
76 group:
77 .byte 0
79 ## Resolved to UINT64_C(1), with the addend ignored.
80 ## UINT64_C(-1) is a reserved value (base address selection entry) which can't be used.
81 .section .debug_loc
82 .quad .text.1+8
83 .section .debug_ranges
84 .quad .text.2+16
86 .section .debug_addr
87 ## .text.3 is a local symbol. The symbol defined in a non-prevailing group is
88 ## discarded. Resolved to UINT64_C(0).
89 .quad .text.3+24
90 ## group is a non-local symbol. The relocation from the second %t1.o gets
91 ## resolved to the prevailing copy.
92 .quad group+32
94 .section .debug_info,"G",@progbits,5657452045627120676,comdat
95 .Ltu_begin0:
97 .section .debug_names
98 ## .debug_names may reference a local type unit defined in a COMDAT .debug_info
99 ## section (-g -gpubnames -fdebug-types-section). If the referenced section is
100 ## non-prevailing, resolve to UINT32_MAX.
101 .long .Ltu_begin0
102 ## ... or UINT64_MAX for DWARF64.
103 .quad .Ltu_begin0
105 .section .debug_foo
106 .quad .text.1+8
108 ## We only deal with DW_FORM_addr. Don't special case short-range absolute
109 ## relocations. Treat them like regular absolute relocations referencing
110 ## discarded symbols, which are resolved to the addend.
111 .long .text.1+8
112 .long 0