ELF: Don't check relocations in non-loaded, non-alloced sections
[deliverable/binutils-gdb.git] / ld / testsuite / ld-x86-64 / tls.exp
CommitLineData
e2cbcd91 1# Expect script for x86-64 TLS tests.
b3adc24a 2# Copyright (C) 2016-2020 Free Software Foundation, Inc.
e2cbcd91
L
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.
25if ![isnative] {
26 return
27}
28
29# Only on Linux for now.
30if ![istarget "x86_64-*-linux*"] {
31 return
32}
33
34# Check to see if the C compiler works
44ed8092 35if { ![check_compiler_available] } {
e2cbcd91
L
36 return
37}
38
39run_cc_link_tests [list \
40 [list \
dcc03cb3 41 "Build tls-def1.o tls-main1.o" \
e2cbcd91 42 "" \
6c0d3bde 43 "-fPIE -Wa,-mx86-used-note=yes" \
e2cbcd91
L
44 {tls-def1.c tls-main1.c} \
45 ] \
46 [list \
47 "Build tls-gd1.o tls-ld1.o" \
48 "" \
6c0d3bde 49 "-fPIC -Wa,-mrelax-relocations=yes,-mx86-used-note=yes" \
e2cbcd91
L
50 {tls-gd1.S tls-ld1.S} \
51 ] \
52 [list \
53 "Build libtls-1a.so" \
54 "-shared tmpdir/tls-def1.o" \
6c0d3bde 55 "-Wa,-mx86-used-note=yes" \
e2cbcd91
L
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" \
6c0d3bde 63 "-Wa,-mx86-used-note=yes" \
e2cbcd91
L
64 {dummy.s} \
65 {} \
66 "libtls-1b.so" \
67 ] \
d6f48aed
L
68 [list \
69 "Build libtls-1bn.so" \
70 "-Wl,-z,now -shared tmpdir/tls-gd1.o tmpdir/tls-ld1.o" \
6c0d3bde 71 "-Wa,-mx86-used-note=yes" \
d6f48aed
L
72 {dummy.s} \
73 {} \
74 "libtls-1bn.so" \
75 ] \
e2cbcd91
L
76]
77
982c6f26 78run_ld_link_exec_tests [list \
e2cbcd91
L
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" \
6c0d3bde 83 "-Wa,-mx86-used-note=yes" \
e2cbcd91
L
84 { dummy.s } \
85 "tls-1a" \
86 "pass.out" \
87 ] \
d6f48aed
L
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" \
6c0d3bde 92 "-Wa,-mx86-used-note=yes" \
d6f48aed
L
93 { dummy.s } \
94 "tls-1an" \
95 "pass.out" \
96 ] \
e2cbcd91
L
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" \
6c0d3bde 101 "-Wa,-mx86-used-note=yes" \
e2cbcd91
L
102 { dummy.s } \
103 "tls-1b" \
104 "pass.out" \
105 ] \
d6f48aed
L
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" \
6c0d3bde 110 "-Wa,-mx86-used-note=yes" \
d6f48aed
L
111 { dummy.s } \
112 "tls-1bn" \
113 "pass.out" \
114 ] \
e2cbcd91
L
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" \
6c0d3bde 119 "-Wa,-mx86-used-note=yes" \
e2cbcd91
L
120 { dummy.s } \
121 "tls-1c" \
122 "pass.out" \
123 ] \
124 [list \
125 "TLS GD/LD -> IE transition without PLT" \
d9816402
AM
126 "-Wl,--no-as-needed,-R,tmpdir tmpdir/tls-main1.o \
127 tmpdir/tls-gd1.o tmpdir/tls-ld1.o tmpdir/libtls-1a.so" \
6c0d3bde 128 "-Wa,-mx86-used-note=yes" \
e2cbcd91
L
129 { dummy.s } \
130 "tls-1d" \
131 "pass.out" \
132 ] \
d6f48aed
L
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" \
6c0d3bde 137 "-Wa,-mx86-used-note=yes" \
d6f48aed
L
138 { dummy.s } \
139 "tls-1dn" \
140 "pass.out" \
141 ] \
e2cbcd91
L
142 [list \
143 "TLS without PLT (1)" \
d9816402
AM
144 "-Wl,--no-as-needed,-R,tmpdir tmpdir/tls-main1.o \
145 tmpdir/libtls-1a.so tmpdir/libtls-1b.so" \
6c0d3bde 146 "-Wa,-mx86-used-note=yes" \
e2cbcd91
L
147 { dummy.s } \
148 "tls-1e" \
149 "pass.out" \
150 ] \
151 [list \
152 "TLS without PLT (2)" \
d9816402
AM
153 "-Wl,--no-as-needed,-R,tmpdir tmpdir/tls-main1.o \
154 tmpdir/tls-def1.o tmpdir/libtls-1b.so" \
6c0d3bde 155 "-Wa,-mx86-used-note=yes" \
e2cbcd91
L
156 { dummy.s } \
157 "tls-1f" \
158 "pass.out" \
159 ] \
d6f48aed
L
160 [list \
161 "TLS without PLT (3)" \
3d850592 162 "-Wl,--no-as-needed -Wl,-z,now tmpdir/tls-main1.o \
d6f48aed 163 tmpdir/libtls-1a.so tmpdir/libtls-1bn.so -Wl,-R,tmpdir" \
6c0d3bde 164 "-Wa,-mx86-used-note=yes" \
d6f48aed
L
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" \
6c0d3bde 173 "-Wa,-mx86-used-note=yes" \
d6f48aed
L
174 { dummy.s } \
175 "tls-1fn" \
176 "pass.out" \
177 ] \
e2cbcd91 178]
1670f9c1 179
6a462ad4
L
180# Skip if -mtls-dialect=gnu2 doesn't work.
181if { ![run_host_cmd_yesno $CC "-c -O2 -fPIC $GNU2_CFLAGS $srcdir/$subdir/tlsdesc1b.c -o tmpdir/tlsdesc1b.o"] } {
1670f9c1
L
182 return
183}
184
185run_cc_link_tests [list \
186 [list \
187 "Build libtlsdesc1.so" \
188 "-shared" \
6c0d3bde 189 "-fPIC $GNU2_CFLAGS -Wa,-mx86-used-note=yes" \
1670f9c1
L
190 { tlsdesc1b.c } \
191 {} \
192 "libtlsdesc1.so" \
193 ] \
194 [list \
195 "Build libtlsdesc1n.so" \
196 "-Wl,-z,now -shared" \
6c0d3bde 197 "-fPIC $GNU2_CFLAGS -Wa,-mx86-used-note=yes" \
1670f9c1
L
198 { tlsdesc1b.c } \
199 {} \
200 "libtlsdesc1n.so" \
201 ] \
202]
203
0aae7e72
L
204# Run-time tests which require working GNU2 TLS support.
205if { ![check_gnu2_tls_available] } {
206 return
207}
208
25d28c91
L
209if { [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" \
6c0d3bde 214 "-Wa,-mx86-used-note=yes" \
25d28c91
L
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" \
6c0d3bde 223 "-Wa,-mx86-used-note=yes" \
25d28c91
L
224 { tlsdesc1a.c } \
225 "tlsdesc1c" \
226 "pass.out" \
227 "-fPIE $GNU2_CFLAGS" \
228 ] \
229 ]
230}
231
1670f9c1 232run_ld_link_exec_tests [list \
1670f9c1
L
233 [list \
234 "Run tlsdesc1 (-z now)" \
235 "-Wl,-z,now -Wl,--no-as-needed tmpdir/libtlsdesc1n.so" \
6c0d3bde 236 "-Wa,-mx86-used-note=yes" \
1670f9c1
L
237 { tlsdesc1a.c } \
238 "tlsdesc1b" \
239 "pass.out" \
240 "$GNU2_CFLAGS" \
241 ] \
1670f9c1
L
242 [list \
243 "Run tlsdesc1 with PIE (-z now)" \
244 "-pie -Wl,-z,now -Wl,--no-as-needed tmpdir/libtlsdesc1n.so" \
6c0d3bde 245 "-Wa,-mx86-used-note=yes" \
1670f9c1
L
246 { tlsdesc1a.c } \
247 "tlsdesc1d" \
248 "pass.out" \
249 "-fPIE $GNU2_CFLAGS" \
250 ] \
251]
This page took 0.213498 seconds and 4 git commands to generate.