Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / lld / test / ELF / bsymbolic.s
blob5e434a14953e31718434bbbe6147f6a54047b096
1 # REQUIRES: x86
2 # RUN: rm -rf %t && split-file %s %t
3 # RUN: llvm-mc -filetype=obj -triple=x86_64 %t/a.s -o %t/a.o
4 # RUN: llvm-mc -filetype=obj -triple=x86_64 %t/b.s -o %t/b.o
5 # RUN: ld.lld -shared %t/a.o %t/b.o -o %t0.so
6 # RUN: llvm-readobj -r %t0.so | FileCheck %s --check-prefix=REL_DEF
7 # RUN: llvm-objdump -d %t0.so | FileCheck %s --check-prefix=ASM_DEF
9 ## -Bsymbolic-non-weak-functions makes all STB_GLOBAL STT_FUNC definitions non-preemptible.
10 # RUN: ld.lld -shared -Bsymbolic-non-weak-functions %t/a.o %t/b.o -o %t1.so
11 # RUN: llvm-readobj -r %t1.so | FileCheck %s --check-prefix=REL_GFUN
12 # RUN: llvm-objdump -d %t1.so | FileCheck %s --check-prefix=ASM_GFUN
14 ## -Bsymbolic-functions makes all STT_FUNC definitions non-preemptible.
15 # RUN: ld.lld -shared -Bsymbolic-functions %t/a.o %t/b.o -o %t2.so
16 # RUN: llvm-readobj -r %t2.so | FileCheck %s --check-prefix=REL_FUN
17 # RUN: llvm-objdump -d %t2.so | FileCheck %s --check-prefix=ASM_FUN
19 ## -Bsymbolic makes all definitions non-preemptible.
20 # RUN: ld.lld -shared -Bsymbolic %t/a.o %t/b.o -o %t3.so
21 # RUN: llvm-readobj -r %t3.so | FileCheck %s --check-prefix=REL_ALL
22 # RUN: llvm-objdump -d %t3.so | FileCheck %s --check-prefix=ASM_ALL
24 ## -Bsymbolic-non-weak makes all STB_GLOBAL definitions non-preemptible.
25 # RUN: ld.lld -shared -Bsymbolic-non-weak %t/a.o %t/b.o -o %t4.so
26 # RUN: llvm-readobj -r %t4.so | FileCheck %s --check-prefix=REL_GALL
27 # RUN: llvm-objdump -d %t4.so | FileCheck %s --check-prefix=ASM_GALL
29 # RUN: ld.lld -shared -Bsymbolic-functions -Bsymbolic %t/a.o %t/b.o -o %t.so
30 # RUN: cmp %t.so %t3.so
31 # RUN: ld.lld -shared -Bsymbolic -Bsymbolic-functions %t/a.o %t/b.o -o %t.so
32 # RUN: cmp %t.so %t2.so
33 # RUN: ld.lld -shared -Bno-symbolic -Bsymbolic %t/a.o %t/b.o -o %t.so
34 # RUN: cmp %t.so %t3.so
36 ## -Bno-symbolic can cancel previously specified -Bsymbolic and -Bsymbolic-functions.
37 # RUN: ld.lld -shared -Bsymbolic -Bno-symbolic %t/a.o %t/b.o -o %t.so
38 # RUN: cmp %t.so %t0.so
39 # RUN: ld.lld -shared -Bsymbolic-functions -Bno-symbolic %t/a.o %t/b.o -o %t.so
40 # RUN: cmp %t.so %t0.so
42 # REL_DEF: .rela.dyn {
43 # REL_DEF-NEXT: R_X86_64_RELATIVE -
44 # REL_DEF-NEXT: R_X86_64_RELATIVE -
45 # REL_DEF-NEXT: R_X86_64_64 data_weak_default
46 # REL_DEF-NEXT: R_X86_64_64 data_default
47 # REL_DEF-NEXT: }
48 # REL_DEF-NEXT: .rela.plt {
49 # REL_DEF-NEXT: R_X86_64_JUMP_SLOT default
50 # REL_DEF-NEXT: R_X86_64_JUMP_SLOT notype_default
51 # REL_DEF-NEXT: R_X86_64_JUMP_SLOT weak_default
52 # REL_DEF-NEXT: R_X86_64_JUMP_SLOT ext_default
53 # REL_DEF-NEXT: R_X86_64_JUMP_SLOT undef
54 # REL_DEF-NEXT: }
56 # ASM_DEF: <_start>:
57 # ASM_DEF-NEXT: callq {{.*}} <default@plt>
58 # ASM_DEF-NEXT: callq {{.*}} <protected>
59 # ASM_DEF-NEXT: callq {{.*}} <hidden>
60 # ASM_DEF-NEXT: callq {{.*}} <weak_default@plt>
61 # ASM_DEF-NEXT: callq {{.*}} <ext_default@plt>
62 # ASM_DEF-NEXT: callq {{.*}} <notype_default@plt>
63 # ASM_DEF-NEXT: callq {{.*}} <undef@plt>
65 # REL_GFUN: .rela.dyn {
66 # REL_GFUN-NEXT: R_X86_64_RELATIVE -
67 # REL_GFUN-NEXT: R_X86_64_RELATIVE -
68 # REL_GFUN-NEXT: R_X86_64_64 data_weak_default
69 # REL_GFUN-NEXT: R_X86_64_64 data_default
70 # REL_GFUN-NEXT: }
71 # REL_GFUN-NEXT: .rela.plt {
72 # REL_GFUN-NEXT: R_X86_64_JUMP_SLOT notype_default
73 # REL_GFUN-NEXT: R_X86_64_JUMP_SLOT weak_default
74 # REL_GFUN-NEXT: R_X86_64_JUMP_SLOT undef
75 # REL_GFUN-NEXT: }
77 # ASM_GFUN: <_start>:
78 # ASM_GFUN-NEXT: callq {{.*}} <default>
79 # ASM_GFUN-NEXT: callq {{.*}} <protected>
80 # ASM_GFUN-NEXT: callq {{.*}} <hidden>
81 # ASM_GFUN-NEXT: callq {{.*}} <weak_default@plt>
82 # ASM_GFUN-NEXT: callq {{.*}} <ext_default>
83 # ASM_GFUN-NEXT: callq {{.*}} <notype_default@plt>
84 # ASM_GFUN-NEXT: callq {{.*}} <undef@plt>
86 # REL_FUN: .rela.dyn {
87 # REL_FUN-NEXT: R_X86_64_RELATIVE -
88 # REL_FUN-NEXT: R_X86_64_RELATIVE -
89 # REL_FUN-NEXT: R_X86_64_64 data_weak_default
90 # REL_FUN-NEXT: R_X86_64_64 data_default
91 # REL_FUN-NEXT: }
92 # REL_FUN-NEXT: .rela.plt {
93 # REL_FUN-NEXT: R_X86_64_JUMP_SLOT notype_default
94 # REL_FUN-NEXT: R_X86_64_JUMP_SLOT undef
95 # REL_FUN-NEXT: }
97 # ASM_FUN: <_start>:
98 # ASM_FUN-NEXT: callq {{.*}} <default>
99 # ASM_FUN-NEXT: callq {{.*}} <protected>
100 # ASM_FUN-NEXT: callq {{.*}} <hidden>
101 # ASM_FUN-NEXT: callq {{.*}} <weak_default>
102 # ASM_FUN-NEXT: callq {{.*}} <ext_default>
103 # ASM_FUN-NEXT: callq {{.*}} <notype_default@plt>
104 # ASM_FUN-NEXT: callq {{.*}} <undef@plt>
106 # REL_ALL: .rela.dyn {
107 # REL_ALL-NEXT: R_X86_64_RELATIVE -
108 # REL_ALL-NEXT: R_X86_64_RELATIVE -
109 # REL_ALL-NEXT: R_X86_64_RELATIVE -
110 # REL_ALL-NEXT: R_X86_64_RELATIVE -
111 # REL_ALL-NEXT: }
112 # REL_ALL-NEXT: .rela.plt {
113 # REL_ALL-NEXT: R_X86_64_JUMP_SLOT undef
114 # REL_ALL-NEXT: }
116 # ASM_ALL: <_start>:
117 # ASM_ALL-NEXT: callq {{.*}} <default>
118 # ASM_ALL-NEXT: callq {{.*}} <protected>
119 # ASM_ALL-NEXT: callq {{.*}} <hidden>
120 # ASM_ALL-NEXT: callq {{.*}} <weak_default>
121 # ASM_ALL-NEXT: callq {{.*}} <ext_default>
122 # ASM_ALL-NEXT: callq {{.*}} <notype_default>
123 # ASM_ALL-NEXT: callq {{.*}} <undef@plt>
125 # REL_GALL: .rela.dyn {
126 # REL_GALL-NEXT: R_X86_64_RELATIVE -
127 # REL_GALL-NEXT: R_X86_64_RELATIVE -
128 # REL_GALL-NEXT: R_X86_64_RELATIVE -
129 # REL_GALL-NEXT: R_X86_64_64 data_weak_default
130 # REL_GALL-NEXT: }
131 # REL_GALL-NEXT: .rela.plt {
132 # REL_GALL-NEXT: R_X86_64_JUMP_SLOT weak_default
133 # REL_GALL-NEXT: R_X86_64_JUMP_SLOT undef
134 # REL_GALL-NEXT: }
136 # ASM_GALL: <_start>:
137 # ASM_GALL-NEXT: callq {{.*}} <default>
138 # ASM_GALL-NEXT: callq {{.*}} <protected>
139 # ASM_GALL-NEXT: callq {{.*}} <hidden>
140 # ASM_GALL-NEXT: callq {{.*}} <weak_default@plt>
141 # ASM_GALL-NEXT: callq {{.*}} <ext_default>
142 # ASM_GALL-NEXT: callq {{.*}} <notype_default>
143 # ASM_GALL-NEXT: callq {{.*}} <undef@plt>
145 #--- a.s
146 .globl default, protected, hidden, notype_default
147 .weak weak_default
148 .protected protected
149 .hidden hidden
150 .type default, @function
151 .type protected, @function
152 .type hidden, @function
153 .type weak_default, @function
154 default: nop
155 protected: nop
156 hidden: nop
157 weak_default: nop
158 notype_default: nop
160 .globl _start
161 _start:
162 callq default@PLT
163 callq protected@PLT
164 callq hidden@PLT
166 callq weak_default@PLT
168 callq ext_default@PLT
170 callq notype_default@PLT
172 callq undef@PLT
174 .data
175 .quad data_default
176 .quad data_weak_default
177 .quad data_protected
178 .quad data_hidden
180 .globl data_default, data_weak_default, data_protected, data_hidden
181 .weak data_weak_default
182 .protected data_protected
183 .hidden data_hidden
184 .type data_default, @object
185 .type data_weak_default, @object
186 .type data_protected, @object
187 .type data_hidden, @object
188 data_default: .byte 0
189 data_weak_default: .byte 0
190 data_protected: .byte 0
191 data_hidden: .byte 0
193 #--- b.s
194 .globl ext_default
195 .type ext_default,@function
196 ext_default: