]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blob - ld/testsuite/ld-x86-64/tls.exp
Update year range in copyright notice of binutils files
[thirdparty/binutils-gdb.git] / ld / testsuite / ld-x86-64 / tls.exp
1 # Expect script for x86-64 TLS tests.
2 # Copyright (C) 2016-2021 Free Software Foundation, Inc.
3 #
4 # This file is part of the GNU Binutils.
5 #
6 # This program is free software; you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation; either version 3 of the License, or
9 # (at your option) any later version.
10 #
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
15 #
16 # You should have received a copy of the GNU General Public License
17 # along with this program; if not, write to the Free Software
18 # Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
19 # MA 02110-1301, USA.
20 #
21
22 # The following tests require running the executable generated by ld,
23 # or enough of a build environment to create a fully linked executable.
24 # This is not commonly available when testing a cross-built linker.
25 if ![isnative] {
26 return
27 }
28
29 # Only on Linux for now.
30 if ![istarget "x86_64-*-linux*"] {
31 return
32 }
33
34 # Check to see if the C compiler works
35 if { ![check_compiler_available] } {
36 return
37 }
38
39 run_cc_link_tests [list \
40 [list \
41 "Build tls-def1.o tls-main1.o" \
42 "" \
43 "-fPIE -Wa,-mx86-used-note=yes" \
44 {tls-def1.c tls-main1.c} \
45 ] \
46 [list \
47 "Build tls-gd1.o tls-ld1.o" \
48 "" \
49 "-fPIC -Wa,-mrelax-relocations=yes,-mx86-used-note=yes" \
50 {tls-gd1.S tls-ld1.S} \
51 ] \
52 [list \
53 "Build libtls-1a.so" \
54 "-shared tmpdir/tls-def1.o" \
55 "-Wa,-mx86-used-note=yes" \
56 {dummy.s} \
57 {} \
58 "libtls-1a.so" \
59 ] \
60 [list \
61 "Build libtls-1b.so" \
62 "-shared tmpdir/tls-gd1.o tmpdir/tls-ld1.o" \
63 "-Wa,-mx86-used-note=yes" \
64 {dummy.s} \
65 {} \
66 "libtls-1b.so" \
67 ] \
68 [list \
69 "Build libtls-1bn.so" \
70 "-Wl,-z,now -shared tmpdir/tls-gd1.o tmpdir/tls-ld1.o" \
71 "-Wa,-mx86-used-note=yes" \
72 {dummy.s} \
73 {} \
74 "libtls-1bn.so" \
75 ] \
76 ]
77
78 run_ld_link_exec_tests [list \
79 [list \
80 "TLS GD/LD -> LE transition without PLT (dynamic)" \
81 "tmpdir/tls-def1.o tmpdir/tls-main1.o tmpdir/tls-gd1.o \
82 tmpdir/tls-ld1.o" \
83 "-Wa,-mx86-used-note=yes" \
84 { dummy.s } \
85 "tls-1a" \
86 "pass.out" \
87 ] \
88 [list \
89 "TLS GD/LD -> LE transition without PLT (dynamic, -z now)" \
90 "-Wl,-z,now tmpdir/tls-def1.o tmpdir/tls-main1.o tmpdir/tls-gd1.o \
91 tmpdir/tls-ld1.o" \
92 "-Wa,-mx86-used-note=yes" \
93 { dummy.s } \
94 "tls-1an" \
95 "pass.out" \
96 ] \
97 [list \
98 "TLS GD/LD -> LE transition without PLT (PIE)" \
99 "-pie tmpdir/tls-def1.o tmpdir/tls-main1.o tmpdir/tls-gd1.o \
100 tmpdir/tls-ld1.o" \
101 "-Wa,-mx86-used-note=yes" \
102 { dummy.s } \
103 "tls-1b" \
104 "pass.out" \
105 ] \
106 [list \
107 "TLS GD/LD -> LE transition without PLT (PIE, -z now)" \
108 "-pie -Wl,-z,now tmpdir/tls-def1.o tmpdir/tls-main1.o tmpdir/tls-gd1.o \
109 tmpdir/tls-ld1.o" \
110 "-Wa,-mx86-used-note=yes" \
111 { dummy.s } \
112 "tls-1bn" \
113 "pass.out" \
114 ] \
115 [list \
116 "TLS GD/LD -> LE transition without PLT (static)" \
117 "-static tmpdir/tls-def1.o tmpdir/tls-main1.o tmpdir/tls-gd1.o \
118 tmpdir/tls-ld1.o" \
119 "-Wa,-mx86-used-note=yes" \
120 { dummy.s } \
121 "tls-1c" \
122 "pass.out" \
123 ] \
124 [list \
125 "TLS GD/LD -> IE transition without PLT" \
126 "-Wl,--no-as-needed,-R,tmpdir tmpdir/tls-main1.o \
127 tmpdir/tls-gd1.o tmpdir/tls-ld1.o tmpdir/libtls-1a.so" \
128 "-Wa,-mx86-used-note=yes" \
129 { dummy.s } \
130 "tls-1d" \
131 "pass.out" \
132 ] \
133 [list \
134 "TLS GD/LD -> IE transition without PLT (-z now)" \
135 "-Wl,-z,now tmpdir/tls-main1.o tmpdir/tls-gd1.o tmpdir/tls-ld1.o \
136 tmpdir/libtls-1a.so -Wl,-R,tmpdir" \
137 "-Wa,-mx86-used-note=yes" \
138 { dummy.s } \
139 "tls-1dn" \
140 "pass.out" \
141 ] \
142 [list \
143 "TLS without PLT (1)" \
144 "-Wl,--no-as-needed,-R,tmpdir tmpdir/tls-main1.o \
145 tmpdir/libtls-1a.so tmpdir/libtls-1b.so" \
146 "-Wa,-mx86-used-note=yes" \
147 { dummy.s } \
148 "tls-1e" \
149 "pass.out" \
150 ] \
151 [list \
152 "TLS without PLT (2)" \
153 "-Wl,--no-as-needed,-R,tmpdir tmpdir/tls-main1.o \
154 tmpdir/tls-def1.o tmpdir/libtls-1b.so" \
155 "-Wa,-mx86-used-note=yes" \
156 { dummy.s } \
157 "tls-1f" \
158 "pass.out" \
159 ] \
160 [list \
161 "TLS without PLT (3)" \
162 "-Wl,--no-as-needed -Wl,-z,now tmpdir/tls-main1.o \
163 tmpdir/libtls-1a.so tmpdir/libtls-1bn.so -Wl,-R,tmpdir" \
164 "-Wa,-mx86-used-note=yes" \
165 { dummy.s } \
166 "tls-1en" \
167 "pass.out" \
168 ] \
169 [list \
170 "TLS without PLT (4)" \
171 "-Wl,-z,now tmpdir/tls-main1.o tmpdir/tls-def1.o \
172 tmpdir/libtls-1bn.so -Wl,-R,tmpdir" \
173 "-Wa,-mx86-used-note=yes" \
174 { dummy.s } \
175 "tls-1fn" \
176 "pass.out" \
177 ] \
178 ]
179
180 # Skip if -mtls-dialect=gnu2 doesn't work.
181 if { ![run_host_cmd_yesno $CC "-c -O2 -fPIC $GNU2_CFLAGS $srcdir/$subdir/tlsdesc1b.c -o tmpdir/tlsdesc1b.o"] } {
182 return
183 }
184
185 run_cc_link_tests [list \
186 [list \
187 "Build libtlsdesc1.so" \
188 "-shared" \
189 "-fPIC $GNU2_CFLAGS -Wa,-mx86-used-note=yes" \
190 { tlsdesc1b.c } \
191 {} \
192 "libtlsdesc1.so" \
193 ] \
194 [list \
195 "Build libtlsdesc1n.so" \
196 "-Wl,-z,now -shared" \
197 "-fPIC $GNU2_CFLAGS -Wa,-mx86-used-note=yes" \
198 { tlsdesc1b.c } \
199 {} \
200 "libtlsdesc1n.so" \
201 ] \
202 ]
203
204 # Run-time tests which require working GNU2 TLS support.
205 if { ![check_gnu2_tls_available] } {
206 return
207 }
208
209 if { [at_least_gcc_version 5 0] } {
210 run_ld_link_exec_tests [list \
211 [list \
212 "Run tlsdesc1" \
213 "-Wl,--no-as-needed tmpdir/libtlsdesc1.so" \
214 "-Wa,-mx86-used-note=yes" \
215 { tlsdesc1a.c } \
216 "tlsdesc1a" \
217 "pass.out" \
218 "$GNU2_CFLAGS" \
219 ] \
220 [list \
221 "Run tlsdesc1 with PIE" \
222 "-pie -Wl,--no-as-needed tmpdir/libtlsdesc1.so" \
223 "-Wa,-mx86-used-note=yes" \
224 { tlsdesc1a.c } \
225 "tlsdesc1c" \
226 "pass.out" \
227 "-fPIE $GNU2_CFLAGS" \
228 ] \
229 ]
230 }
231
232 run_ld_link_exec_tests [list \
233 [list \
234 "Run tlsdesc1 (-z now)" \
235 "-Wl,-z,now -Wl,--no-as-needed tmpdir/libtlsdesc1n.so" \
236 "-Wa,-mx86-used-note=yes" \
237 { tlsdesc1a.c } \
238 "tlsdesc1b" \
239 "pass.out" \
240 "$GNU2_CFLAGS" \
241 ] \
242 [list \
243 "Run tlsdesc1 with PIE (-z now)" \
244 "-pie -Wl,-z,now -Wl,--no-as-needed tmpdir/libtlsdesc1n.so" \
245 "-Wa,-mx86-used-note=yes" \
246 { tlsdesc1a.c } \
247 "tlsdesc1d" \
248 "pass.out" \
249 "-fPIE $GNU2_CFLAGS" \
250 ] \
251 ]