]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blob - ld/testsuite/ld-i386/no-plt.exp
Update year range in copyright notice of binutils files
[thirdparty/binutils-gdb.git] / ld / testsuite / ld-i386 / no-plt.exp
1 # Expect script for i386 no-PLT 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 if ![is_elf_format] {
30 return
31 }
32
33 if ![istarget "i?86-*-*"] {
34 return
35 }
36
37 # Check to see if the C compiler works
38 if { ![check_compiler_available] } {
39 return
40 }
41
42 run_cc_link_tests [list \
43 [list \
44 "Build no-plt-func1.o no-plt-main1.o" \
45 "" \
46 "-fPIE -Wa,-mx86-used-note=yes" \
47 {no-plt-func1.c no-plt-main1.c} \
48 ] \
49 [list \
50 "Build no-plt-check1a.o no-plt-extern1a.o \
51 no-plt-check1b.o no-plt-extern1b.o" \
52 "" \
53 "-Wa,-mrelax-relocations=yes,-mx86-used-note=yes" \
54 {no-plt-check1a.S no-plt-extern1a.S \
55 no-plt-check1b.S no-plt-extern1b.S } \
56 ] \
57 [list \
58 "Build libno-plt-1a.so" \
59 "-shared tmpdir/no-plt-func1.o" \
60 "-Wa,-mx86-used-note=yes" \
61 {dummy.s} \
62 {} \
63 "libno-plt-1a.so" \
64 ] \
65 [list \
66 "Build libno-plt-1b.so" \
67 "-shared tmpdir/no-plt-extern1a.o" \
68 "-Wa,-mx86-used-note=yes" \
69 {dummy.s} \
70 {{readelf -Wr libno-plt-1b.rd} \
71 {objdump -dwrj.text libno-plt-1b.dd}} \
72 "libno-plt-1b.so" \
73 ] \
74 [list \
75 "No PLT (dynamic 1a)" \
76 "$NOPIE_LDFLAGS tmpdir/no-plt-check1a.o tmpdir/no-plt-main1.o \
77 tmpdir/no-plt-func1.o tmpdir/no-plt-extern1a.o" \
78 "-Wa,-mx86-used-note=yes" \
79 {dummy.s} \
80 {{readelf -Wr no-plt-1a.rd} {objdump -dwrj.text no-plt-1a.dd}} \
81 "no-plt-1a" \
82 ] \
83 [list \
84 "No PLT (dynamic 1b)" \
85 "tmpdir/no-plt-check1a.o tmpdir/no-plt-main1.o \
86 tmpdir/libno-plt-1a.so tmpdir/libno-plt-1b.so" \
87 "-Wa,-mx86-used-note=yes" \
88 {dummy.s} \
89 {{readelf -Wr no-plt-1b.rd} {objdump -dwrj.text no-plt-1b.dd}} \
90 "no-plt-1b" \
91 ] \
92 [list \
93 "No PLT (dynamic 1c)" \
94 "$NOPIE_LDFLAGS tmpdir/no-plt-check1a.o tmpdir/no-plt-main1.o \
95 tmpdir/no-plt-func1.o tmpdir/libno-plt-1b.so" \
96 "-Wa,-mx86-used-note=yes" \
97 {dummy.s} \
98 {{readelf -Wr no-plt-1c.rd} {objdump -dwrj.text no-plt-1c.dd}} \
99 "no-plt-1c" \
100 ] \
101 [list \
102 "No PLT (static 1d)" \
103 "-static tmpdir/no-plt-check1a.o tmpdir/no-plt-main1.o \
104 tmpdir/no-plt-func1.o tmpdir/no-plt-extern1a.o" \
105 "-Wa,-mx86-used-note=yes" \
106 {dummy.s} \
107 {{readelf -Wr no-plt-1d.rd} {objdump -dwrj.text no-plt-1d.dd}} \
108 "no-plt-1d" \
109 ] \
110 [list \
111 "No PLT (PIE 1e)" \
112 "-pie tmpdir/no-plt-check1a.o tmpdir/no-plt-main1.o \
113 tmpdir/no-plt-func1.o tmpdir/no-plt-extern1a.o" \
114 "-Wa,-mx86-used-note=yes" \
115 {dummy.s} \
116 {{readelf -Wr no-plt-1e.rd} {objdump -dwrj.text no-plt-1e.dd}} \
117 "no-plt-1e" \
118 ] \
119 [list \
120 "No PLT (PIE 1f)" \
121 "-pie tmpdir/no-plt-check1a.o tmpdir/no-plt-main1.o \
122 tmpdir/libno-plt-1a.so tmpdir/libno-plt-1b.so" \
123 "-Wa,-mx86-used-note=yes" \
124 { dummy.s } \
125 {{readelf -Wr no-plt-1f.rd} {objdump -dwrj.text no-plt-1f.dd}} \
126 "no-plt-1f" \
127 ] \
128 [list \
129 "No PLT (PIE 1g)" \
130 "-pie tmpdir/no-plt-check1a.o tmpdir/no-plt-main1.o \
131 tmpdir/no-plt-func1.o tmpdir/libno-plt-1b.so" \
132 "-Wa,-mx86-used-note=yes" \
133 { dummy.s } \
134 {{readelf -Wr no-plt-1g.rd} {objdump -dwrj.text no-plt-1g.dd}} \
135 "no-plt-1g" \
136 ] \
137 [list \
138 "No PLT (dynamic 1h)" \
139 "$NOPIE_LDFLAGS tmpdir/no-plt-check1b.o tmpdir/no-plt-main1.o \
140 tmpdir/no-plt-func1.o tmpdir/no-plt-extern1b.o" \
141 "-Wa,-mx86-used-note=yes" \
142 {dummy.s} \
143 {{readelf -Wr no-plt-1h.rd} {objdump -dwrj.text no-plt-1h.dd}} \
144 "no-plt-1h" \
145 ] \
146 [list \
147 "No PLT (dynamic 1i)" \
148 "$NOPIE_LDFLAGS tmpdir/no-plt-check1b.o tmpdir/no-plt-main1.o \
149 tmpdir/no-plt-extern1b.o tmpdir/libno-plt-1a.so" \
150 "-Wa,-mx86-used-note=yes" \
151 {dummy.s} \
152 {{readelf -Wr no-plt-1i.rd} {objdump -dwrj.text no-plt-1i.dd}} \
153 "no-plt-1i" \
154 ] \
155 [list \
156 "No PLT (static 1j)" \
157 "-static tmpdir/no-plt-check1b.o tmpdir/no-plt-main1.o \
158 tmpdir/no-plt-func1.o tmpdir/no-plt-extern1b.o" \
159 "-Wa,-mx86-used-note=yes" \
160 {dummy.s} \
161 {{readelf -Wr no-plt-1j.rd} {objdump -dwrj.text no-plt-1j.dd}} \
162 "no-plt-1j" \
163 ] \
164 ]
165
166 run_ld_link_exec_tests [list \
167 [list \
168 "No PLT (dynamic 1a)" \
169 "tmpdir/no-plt-check1a.o tmpdir/no-plt-main1.o \
170 tmpdir/no-plt-func1.o tmpdir/no-plt-extern1a.o" \
171 "-Wa,-mx86-used-note=yes" \
172 { dummy.s } \
173 "no-plt-1a" \
174 "pass.out" \
175 ] \
176 [list \
177 "No PLT (dynamic 1b)" \
178 "tmpdir/no-plt-check1a.o tmpdir/no-plt-main1.o \
179 tmpdir/libno-plt-1a.so tmpdir/libno-plt-1b.so" \
180 "-Wa,-mx86-used-note=yes" \
181 { dummy.s } \
182 "no-plt-1b" \
183 "pass.out" \
184 ] \
185 [list \
186 "No PLT (dynamic 1c)" \
187 "tmpdir/no-plt-check1a.o tmpdir/no-plt-main1.o \
188 tmpdir/no-plt-func1.o tmpdir/libno-plt-1b.so" \
189 "-Wa,-mx86-used-note=yes" \
190 { dummy.s } \
191 "no-plt-1c" \
192 "pass.out" \
193 ] \
194 [list \
195 "No PLT (static 1d)" \
196 "-static tmpdir/no-plt-check1a.o tmpdir/no-plt-main1.o \
197 tmpdir/no-plt-func1.o tmpdir/no-plt-extern1a.o" \
198 "-Wa,-mx86-used-note=yes" \
199 { dummy.s } \
200 "no-plt-1d" \
201 "pass.out" \
202 ] \
203 [list \
204 "No PLT (PIE 1e)" \
205 "-pie tmpdir/no-plt-check1a.o tmpdir/no-plt-main1.o \
206 tmpdir/no-plt-func1.o tmpdir/no-plt-extern1a.o" \
207 "-Wa,-mx86-used-note=yes" \
208 { dummy.s } \
209 "no-plt-1e" \
210 "pass.out" \
211 ] \
212 [list \
213 "No PLT (PIE 1f)" \
214 "-pie tmpdir/no-plt-check1a.o tmpdir/no-plt-main1.o \
215 tmpdir/libno-plt-1a.so tmpdir/libno-plt-1b.so" \
216 "-Wa,-mx86-used-note=yes" \
217 { dummy.s } \
218 "no-plt-1f" \
219 "pass.out" \
220 ] \
221 [list \
222 "No PLT (PIE 1g)" \
223 "-pie tmpdir/no-plt-check1a.o tmpdir/no-plt-main1.o \
224 tmpdir/no-plt-func1.o tmpdir/libno-plt-1b.so" \
225 "-Wa,-mx86-used-note=yes" \
226 { dummy.s } \
227 "no-plt-1g" \
228 "pass.out" \
229 ] \
230 [list \
231 "No PLT (dynamic 1h)" \
232 "$NOPIE_LDFLAGS tmpdir/no-plt-check1b.o tmpdir/no-plt-main1.o \
233 tmpdir/no-plt-func1.o tmpdir/no-plt-extern1b.o" \
234 "-Wa,-mx86-used-note=yes" \
235 {dummy.s} \
236 "no-plt-1h" \
237 "pass.out" \
238 ] \
239 [list \
240 "No PLT (dynamic 1i)" \
241 "$NOPIE_LDFLAGS tmpdir/no-plt-check1b.o tmpdir/no-plt-main1.o \
242 tmpdir/no-plt-extern1b.o tmpdir/libno-plt-1a.so" \
243 "-Wa,-mx86-used-note=yes" \
244 {dummy.s} \
245 "no-plt-1i" \
246 "pass.out" \
247 ] \
248 [list \
249 "No PLT (static 1j)" \
250 "-static tmpdir/no-plt-check1b.o tmpdir/no-plt-main1.o \
251 tmpdir/no-plt-func1.o tmpdir/no-plt-extern1b.o" \
252 "-Wa,-mx86-used-note=yes" \
253 {dummy.s} \
254 "no-plt-1j" \
255 "pass.out" \
256 ] \
257 ]
258
259 # Run-time tests which require working IFUNC support.
260 if { [check_ifunc_available] } {
261 run_cc_link_tests [list \
262 [list \
263 "Build pr20244-3a.o pr20244-3b.o pr20244-3c.o pr20244-3d.o" \
264 "" \
265 "-fPIC -O2 -g -Wa,-mx86-used-note=yes" \
266 { pr20244-3a.c pr20244-3b.S pr20244-3c.S pr20244-3d.S } \
267 ] \
268 [list \
269 "Build pr20253-1a.o pr20253-1b.o pr20253-1c.o pr20253-1d.o" \
270 "" \
271 "-fPIE -O2 -g -Wa,-mx86-used-note=yes" \
272 { pr20253-1a.c pr20253-1b.S pr20253-1c.S pr20253-1d.S } \
273 ] \
274 [list \
275 "Build libpr20253-1a.so" \
276 "-shared tmpdir/pr20253-1b.o \
277 tmpdir/pr20253-1c.o tmpdir/pr20253-1d.o" \
278 "-Wa,-mx86-used-note=yes" \
279 { dummy.s } \
280 {} \
281 "libpr20253-1a.so" \
282 ] \
283 [list \
284 "Build pr20253-2a.o pr20253-2b.o pr20253-2c.o pr20253-2d.o" \
285 "-Wa,-mx86-used-note=yes" \
286 "-fPIE -O2 -g" \
287 { pr20253-2a.c pr20253-2b.S pr20253-2c.S pr20253-2d.S } \
288 ] \
289 ]
290
291 run_ld_link_exec_tests [list \
292 [list \
293 "Run pr20244-3a" \
294 "$NOPIE_LDFLAGS tmpdir/pr20244-3a.o tmpdir/pr20244-3b.o \
295 tmpdir/pr20244-3c.o tmpdir/pr20244-3d.o" \
296 "-Wa,-mx86-used-note=yes" \
297 { dummy.c } \
298 "pr20244-3a" \
299 "pass.out" \
300 ] \
301 [list \
302 "Run pr20244-3b" \
303 "--static tmpdir/pr20244-3a.o tmpdir/pr20244-3b.o \
304 tmpdir/pr20244-3c.o tmpdir/pr20244-3d.o" \
305 "-Wa,-mx86-used-note=yes" \
306 { dummy.c } \
307 "pr20244-3b" \
308 "pass.out" \
309 ] \
310 [list \
311 "Run pr20253-1a" \
312 "tmpdir/pr20253-1a.o tmpdir/pr20253-1b.o \
313 tmpdir/pr20253-1c.o tmpdir/pr20253-1d.o" \
314 "-Wa,-mx86-used-note=yes" \
315 { dummy.s } \
316 "pr20253-1a" \
317 "pass.out" \
318 ] \
319 [list \
320 "Run pr20253-1b" \
321 "--static tmpdir/pr20253-1a.o tmpdir/pr20253-1b.o \
322 tmpdir/pr20253-1c.o tmpdir/pr20253-1d.o" \
323 "-Wa,-mx86-used-note=yes" \
324 { dummy.s } \
325 "pr20253-1b" \
326 "pass.out" \
327 ] \
328 [list \
329 "Run pr20253-1c" \
330 "-pie tmpdir/pr20253-1a.o tmpdir/pr20253-1b.o \
331 tmpdir/pr20253-1c.o tmpdir/pr20253-1d.o" \
332 "-Wa,-mx86-used-note=yes" \
333 { dummy.s } \
334 "pr20253-1c" \
335 "pass.out" \
336 ] \
337 [list \
338 "Run pr20253-1d" \
339 "tmpdir/pr20253-1a.o tmpdir/libpr20253-1a.so" \
340 "-Wa,-mx86-used-note=yes" \
341 { dummy.s } \
342 "pr20253-1d" \
343 "pass.out" \
344 ] \
345 [list \
346 "Run pr20253-1e" \
347 "-pie tmpdir/pr20253-1a.o tmpdir/libpr20253-1a.so" \
348 "-Wa,-mx86-used-note=yes" \
349 { dummy.s } \
350 "pr20253-1e" \
351 "pass.out" \
352 ] \
353 [list \
354 "Run pr20253-1f" \
355 "$NOPIE_LDFLAGS tmpdir/pr20253-1a.o" \
356 "-Wa,-mx86-used-note=yes" \
357 { pr20253-1b.S pr20253-1c.S pr20253-1d.S } \
358 "pr20253-1f" \
359 "pass.out" \
360 "-DCHECK_PLT" \
361 ] \
362 [list \
363 "Run pr20253-1g" \
364 "--static tmpdir/pr20253-1a.o" \
365 "-Wa,-mx86-used-note=yes" \
366 { pr20253-1b.S pr20253-1c.S pr20253-1d.S } \
367 "pr20253-1g" \
368 "pass.out" \
369 "-DCHECK_PLT" \
370 ] \
371 [list \
372 "Run pr20253-2a" \
373 "$NOPIE_LDFLAGS tmpdir/pr20253-2a.o tmpdir/pr20253-2b.o \
374 tmpdir/pr20253-2c.o tmpdir/pr20253-2d.o" \
375 "-Wa,-mx86-used-note=yes" \
376 { dummy.s } \
377 "pr20253-2a" \
378 "pass.out" \
379 ] \
380 [list \
381 "Run pr20253-2b" \
382 "--static tmpdir/pr20253-2a.o tmpdir/pr20253-2b.o \
383 tmpdir/pr20253-2c.o tmpdir/pr20253-2d.o" \
384 "-Wa,-mx86-used-note=yes" \
385 { dummy.s } \
386 "pr20253-2b" \
387 "pass.out" \
388 ] \
389 [list \
390 "Run pr20253-2c" \
391 "$NOPIE_LDFLAGS tmpdir/pr20253-2a.o" \
392 "-Wa,-mx86-used-note=yes" \
393 { pr20253-2b.S pr20253-2c.S pr20253-2d.S } \
394 "pr20253-2c" \
395 "pass.out" \
396 "-DCHECK_PLT" \
397 ] \
398 [list \
399 "Run pr20253-2d" \
400 "--static tmpdir/pr20253-2a.o" \
401 "-Wa,-mx86-used-note=yes" \
402 { pr20253-2b.S pr20253-2c.S pr20253-2d.S } \
403 "pr20253-2d" \
404 "pass.out" \
405 "-DCHECK_PLT" \
406 ] \
407 ]
408 }