ld: Append -mx86-used-note=no to ASFLAGS
[deliverable/binutils-gdb.git] / ld / testsuite / ld-i386 / i386.exp
1 # Expect script for ld-i386 tests
2 # Copyright (C) 2002-2018 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 global ASFLAGS
23 set saved_ASFLAGS "$ASFLAGS"
24 if { [is_elf_format] \
25 && ([istarget "i?86-*-*"] || [istarget "x86_64-*-*"]) } {
26 set ASFLAGS "$ASFLAGS -mx86-used-note=no"
27 }
28
29 # Test i386 linking; all types of relocs. This tests the assembler and
30 # tools like objdump as well as the linker.
31
32 if {[istarget "i?86-*-vxworks"]} {
33 set i386tests {
34 {"VxWorks shared library test 1"
35 "-shared -Tvxworks1.ld --hash-style=sysv" ""
36 "" {vxworks1-lib.s}
37 {{readelf --relocs vxworks1-lib.rd} {objdump -dr vxworks1-lib.dd}
38 {readelf --symbols vxworks1-lib.nd} {readelf -d vxworks1-lib.td}}
39 "libvxworks1.so"}
40 {"VxWorks executable test 1 (dynamic)" \
41 "tmpdir/libvxworks1.so -Tvxworks1.ld --hash-style=sysv -q --force-dynamic" ""
42 "" {vxworks1.s}
43 {{readelf --relocs vxworks1.rd} {objdump -dr vxworks1.dd}}
44 "vxworks1"}
45 {"VxWorks executable test 2 (dynamic)" \
46 "-Tvxworks1.ld --hash-style=sysv -q --force-dynamic" ""
47 "" {vxworks2.s}
48 {{readelf --segments vxworks2.sd}}
49 "vxworks2"}
50 {"VxWorks executable test 2 (static)"
51 "-Tvxworks1.ld --hash-style=sysv" ""
52 "" {vxworks2.s}
53 {{readelf --segments vxworks2-static.sd}}
54 "vxworks2"}
55 }
56 run_ld_link_tests $i386tests
57 run_dump_test "vxworks1-static"
58 }
59
60 if [istarget "*-*-go32*"] {
61 run_ld_link_tests {{"go32 stub" "" "" "" {zero.s} {} "go32stub"}}
62
63 set src "tmpdir/go32stub"
64 set dest "tmpdir/go32stub-copy"
65
66 set test "go32 stub patch the source"
67 set fi [open $src r+]
68 fconfigure $fi -translation binary
69 if {[read $fi 2] != "MZ"} {
70 fail $test
71 } else {
72 pass $test
73 seek $fi 0x40
74 puts -nonewline $fi "objcopy-test-go32stub"
75 }
76 close $fi
77
78 set test "go32 stub objcopy"
79 set status [remote_exec build $OBJCOPY "$OBJCOPYFLAGS $src $dest"]
80 set exec_output [lindex $status 1]
81 set exec_output [prune_warnings $exec_output]
82 if [string match "" $exec_output] then {
83 pass $test
84 } else {
85 send_log "$exec_output\n"
86 verbose "$exec_output" 1
87 fail $test
88 }
89
90 # cmp would compare the whole files and some data after the initial exe
91 # stub could differ.
92 set test "go32 stub comparison after objcopy"
93 set fi [open $src]
94 fconfigure $fi -translation binary
95 set src_stub [read $fi 2048]
96 close $fi
97 set fi [open $dest]
98 fconfigure $fi -translation binary
99 set dest_stub [read $fi 2048]
100 close $fi
101 if {$src_stub == $dest_stub} {
102 pass $test
103 } else {
104 fail $test
105 }
106 }
107
108 if { !([istarget "i?86-*-elf*"]
109 || [istarget "i?86-*-linux*"]
110 || [istarget "i?86-*-gnu*"]
111 || [istarget "i?86-*-nacl*"]
112 || [istarget "x86_64-*-nacl*"]
113 || [istarget "x86_64-*-linux*"]
114 || [istarget "amd64-*-linux*"]) } {
115 return
116 }
117
118 # List contains test-items with 3 items followed by 2 lists:
119 # 0:name 1:ld early options 2:ld late options 3:assembler options
120 # 4:filenames of assembler files 5: action and options. 6: name of output file
121
122 # Actions:
123 # objdump: Apply objdump options on result. Compare with regex (last arg).
124 # nm: Apply nm options on result. Compare with regex (last arg).
125 # readelf: Apply readelf options on result. Compare with regex (last arg).
126
127 set i386tests {
128 {"Helper shared library (basic PLT test)"
129 "-shared -melf_i386" "" "--32" {pltlib.s} {} "libpltlib.so"}
130 {"basic PLT generation (non-PIC)"
131 "-melf_i386 tmpdir/libpltlib.so" "" "--32" {plt.s}
132 {{objdump -drj.plt plt.pd}} "plt"}
133 {"basic PLT generation (PIC)"
134 "-shared -melf_i386 tmpdir/libpltlib.so" "" "--32" {plt-pic.s}
135 {{objdump -drj.plt plt-pic.pd}} "libplt-pic.so"}
136 {"TLS -fpic -shared transitions"
137 "-shared -melf_i386 --no-ld-generated-unwind-info \
138 -z noseparate-code --hash-style=sysv" ""
139 "--32" {tlspic1.s tlspic2.s}
140 {{readelf -Ssrl tlspic.rd} {objdump -drj.text tlspic.dd}
141 {objdump -sj.got tlspic.sd} {objdump -sj.tdata tlspic.td}}
142 "libtlspic.so"}
143 {"TLS -fpic -shared transitions without PLT"
144 "-shared -melf_i386 --no-ld-generated-unwind-info \
145 -z noseparate-code --hash-style=sysv" ""
146 "-mrelax-relocations=yes --32"
147 {tlspic3.s tlspic2.s}
148 {{readelf -Ssrl tlspic2.rd} {objdump -drj.text tlspic2.dd}
149 {objdump -sj.got tlspic2.sd} {objdump -sj.tdata tlspic2.td}}
150 "libtlspic2.so"}
151 {"TLS descriptor -fpic -shared transitions"
152 "-shared -melf_i386 --no-ld-generated-unwind-info \
153 -z noseparate-code --hash-style=sysv" ""
154 "--32" {tlsdesc.s tlspic2.s}
155 {{readelf -Ssrl tlsdesc.rd} {objdump -drj.text tlsdesc.dd}
156 {objdump "-s -j.got -j.got.plt" tlsdesc.sd} {objdump -sj.tdata tlsdesc.td}}
157 "libtlsdesc.so"}
158 {"Helper shared library" "-shared -melf_i386" ""
159 "--32" {tlslib.s} {} "libtlslib.so"}
160 {"TLS -fpic and -fno-pic exec transitions"
161 "-melf_i386 tmpdir/libtlslib.so --no-ld-generated-unwind-info \
162 -z noseparate-code --hash-style=sysv" ""
163 "--32" {tlsbinpic.s tlsbin.s}
164 {{readelf -Ssrl tlsbin.rd} {objdump -drj.text tlsbin.dd}
165 {objdump -sj.got tlsbin.sd} {objdump -sj.tdata tlsbin.td}}
166 "tlsbin"}
167 {"TLS -fpic and -fno-pic exec transitions without PLT"
168 "-melf_i386 tmpdir/libtlslib.so --no-ld-generated-unwind-info \
169 -z noseparate-code --hash-style=sysv" ""
170 "-mrelax-relocations=yes --32"
171 {tlsbinpic2.s tlsbin.s}
172 {{readelf -Ssrl tlsbin2.rd} {objdump -drj.text tlsbin2.dd}
173 {objdump -sj.got tlsbin2.sd} {objdump -sj.tdata tlsbin2.td}}
174 "tlsbin2"}
175 {"TLS descriptor -fpic and -fno-pic exec transitions"
176 "-melf_i386 tmpdir/libtlslib.so --no-ld-generated-unwind-info \
177 -z noseparate-code --hash-style=sysv" ""
178 "--32" {tlsbindesc.s tlsbin.s}
179 {{readelf -Ssrl tlsbindesc.rd} {objdump -drj.text tlsbindesc.dd}
180 {objdump -sj.got tlsbindesc.sd} {objdump -sj.tdata tlsbindesc.td}}
181 "tlsbindesc"}
182 {"TLS -fno-pic -shared"
183 "-shared -melf_i386 --no-ld-generated-unwind-info \
184 -z noseparate-code --hash-style=sysv" ""
185 "--32" {tlsnopic1.s tlsnopic2.s}
186 {{readelf -Ssrl tlsnopic.rd} {objdump -drj.text tlsnopic.dd}
187 {objdump -sj.got tlsnopic.sd}} "libtlsnopic.so"}
188 {"TLS with global dynamic and descriptors"
189 "-shared -melf_i386 --no-ld-generated-unwind-info \
190 -z noseparate-code --hash-style=sysv" ""
191 "--32" {tlsgdesc.s}
192 {{readelf -Ssrl tlsgdesc.rd} {objdump -drj.text tlsgdesc.dd}}
193 "libtlsgdesc.so"}
194 {"TLS in debug sections" "-melf_i386" ""
195 "--32" {tlsg.s}
196 {{objdump -sj.debug_foobar tlsg.sd}} "tlsg"}
197 {"TLS @indntpoff with %eax" "-melf_i386" "" "--32" {tlsindntpoff.s}
198 {{objdump -drj.text tlsindntpoff.dd}} "tlsindntpoff"}
199 {"Reloc section order" "-shared -melf_i386 -z nocombreloc" "" "--32"
200 {reloc.s} {{objdump -hw reloc.d}} "reloc.so"}
201 {"Basic --emit-relocs support" "-shared -melf_i386 --emit-relocs" "" "--32"
202 {emit-relocs.s} {{readelf --relocs emit-relocs.rd}} "emit-relocs.so"}
203 {"-z combreloc relocation sections" "-shared -melf_i386 -z combreloc" ""
204 "--32" {combreloc.s} {{readelf -r combreloc.d}} "combreloc.so"}
205 {"TLS GD->LE transition" "-melf_i386" ""
206 "--32" {tlsgd1.s}
207 {{objdump -dwr tlsgd1.dd}} "tlsgd1"}
208 {"TLS GD->LE transition without PLT" "-melf_i386" ""
209 "-mrelax-relocations=yes --32"
210 {tlsgd3.s}
211 {{objdump -dwr tlsgd3.dd}} "tlsgd3"}
212 {"TLS LD->LE transition" "-melf_i386" ""
213 "--32" {tlsld1.s}
214 {{objdump -dwr tlsld1.dd}} "tlsld1"}
215 {"TLS LD->LE transition without PLT" "-melf_i386" ""
216 "-mrelax-relocations=yes --32"
217 {tlsld2.s}
218 {{objdump -dwr tlsld2.dd}} "tlsld2"}
219 {"TLS IE->LE transition" "-melf_i386" ""
220 "--32" {tlsie1.s}
221 {{objdump -dwr tlsie1.dd}} "tlsie1"}
222 {"PR ld/17313 (1)" "-melf_i386" ""
223 "--32 -mx86-used-note=yes" {zero.s} {} ""}
224 {"PR ld/17313 (2)" "-melf_i386 -shared --just-symbols=tmpdir/zero.o" ""
225 "--32 -mx86-used-note=yes" {lea1.s} {} "libpr17313.so"}
226 {"PR ld/17306 (1)" "-melf_i386" ""
227 "--32 -mx86-used-note=yes" {pr17306b.s} {} ""}
228 {"PR ld/17306 (2)" "-melf_i386 -shared -Bsymbolic --just-symbols=tmpdir/pr17306b.o" ""
229 "--32 -mx86-used-note=yes" {pr17306a.s} {} "libpr17306.so"}
230 {"PR ld/17709 (1)" "-melf_i386 -shared" ""
231 "--32 -mx86-used-note=yes" {pr17709a.s} {} "libpr17709.so"}
232 {"PR ld/17709 (2)" "-melf_i386 tmpdir/libpr17709.so" ""
233 "--32 -mx86-used-note=yes"
234 {pr17709b.s} {{readelf -r pr17709.rd}} "pr17709"}
235 {"Build pr19827a.o" "" ""
236 "--32 -mx86-used-note=yes" { pr19827a.S }}
237 {"Build pr19827b.so" "-melf_i386 -shared" ""
238 "--32 -mx86-used-note=yes"
239 { pr19827b.S } {} "pr19827b.so"}
240 {"Build pr19827" "-melf_i386 -pie tmpdir/pr19827a.o tmpdir/pr19827b.so" ""
241 "--32 -mx86-used-note=yes"
242 { dummy.s } {{readelf {-rW} pr19827.rd}} "pr19827"}
243 {"Build pr19827.so" "-melf_i386 -shared -Bsymbolic" ""
244 "--32 -mx86-used-note=yes"
245 { pr19827a.S } {{readelf {-rW} pr19827.rd}} "pr19827.so"}
246 }
247
248 # So as to avoid rewriting every last test case here in a nacl variant,
249 # we use black magic to massage the generic cases into nacl-variant cases.
250 if [istarget "*-*-nacl*"] {
251 # Change all the -melf_i386 to -melf_i386_nacl so linking can succeed.
252 regsub -all elf_i386 $i386tests elf_i386_nacl i386tests
253
254 # Same, applied to all the run_dump_test cases.
255 set options_regsub(ld) {elf_i386 elf_i386_nacl}
256
257 # The section/segment layout differs too much for the vanilla
258 # readelf output files to match. So massage the cases so that
259 # they refer to a foo-nacl.rd file instead of a foo.rd file.
260 regsub -all {([a-z0-9]+)\.rd} $i386tests {\1-nacl.rd} i386tests
261
262 # Likewise for PLTs.
263 regsub -all -- {([a-z0-9]+)\.pd} $i386tests {\1-nacl.pd} i386tests
264 }
265
266 proc iamcu_tests {} {
267 if {[istarget "*-*-nacl*"]} then {
268 return
269 }
270
271 global as
272 global srcdir
273 global subdir
274
275 if ![ld_assemble $as "--32 -march=iamcu $srcdir/$subdir/start.s" tmpdir/startiamcu.o] {
276 unresolved "Build Intel MCU start.o"
277 return
278 }
279
280 if ![ld_assemble $as "--32 $srcdir/$subdir/start.s" tmpdir/start32.o] {
281 unresolved "Build ia32 start.o"
282 return
283 }
284
285 if ![ld_assemble $as "--32 -march=iamcu $srcdir/$subdir/foo.s" tmpdir/fooiamcu.o] {
286 unresolved "Build Intel MCU foo.o"
287 return
288 }
289
290 if ![ld_assemble $as "--32 $srcdir/$subdir/foo.s" tmpdir/foo32.o] {
291 unresolved "Build ia32 foo.o"
292 return
293 }
294
295 run_dump_test "abs-iamcu"
296 run_dump_test "iamcu-1"
297 run_dump_test "iamcu-2"
298 run_dump_test "iamcu-3"
299 run_dump_test "iamcu-4"
300 }
301
302 iamcu_tests
303
304 run_ld_link_tests $i386tests
305
306 run_dump_test "abs"
307 run_dump_test "pcrel8"
308 run_dump_test "pcrel16"
309 run_dump_test "pcrel16abs"
310 run_dump_test "alloc"
311 run_dump_test "warn1"
312 run_dump_test "tlsgd2"
313 run_dump_test "tlsgd4"
314 run_dump_test "tlsie2"
315 run_dump_test "tlsie3"
316 run_dump_test "tlsie4"
317 run_dump_test "tlsie5"
318 run_dump_test "hidden1"
319 run_dump_test "hidden2"
320 run_dump_test "hidden3"
321 run_dump_test "protected1"
322 run_dump_test "protected2"
323 run_dump_test "protected3"
324 run_dump_test "protected4"
325 run_dump_test "protected5"
326 run_dump_test "protected6a"
327 run_dump_test "protected6b"
328 run_dump_test "protected7"
329 run_dump_test "tlspie1"
330 run_dump_test "tlspie2"
331 run_dump_test "tlspie3a"
332 run_dump_test "tlspie3b"
333 run_dump_test "tlspie3c"
334 run_dump_test "nogot1"
335 run_dump_test "nogot2"
336 run_dump_test "discarded1"
337 run_dump_test "pr12718"
338 run_dump_test "pr12921"
339 run_dump_test "pr12570a"
340 run_dump_test "pr12570b"
341 run_dump_test "lea1a"
342 run_dump_test "lea1b"
343 run_dump_test "lea1c"
344 run_dump_test "lea1d"
345 run_dump_test "lea1e"
346 run_dump_test "lea1f"
347 run_dump_test "mov1a"
348 run_dump_test "mov1b"
349 run_dump_test "mov2a"
350 run_dump_test "mov2b"
351 run_dump_test "mov3"
352 run_dump_test "branch1"
353 run_dump_test "call1"
354 run_dump_test "call2"
355 run_dump_test "call3a"
356 run_dump_test "call3b"
357 run_dump_test "call3c"
358 run_dump_test "call3d"
359 run_dump_test "call3e"
360 run_dump_test "call3f"
361 run_dump_test "call3g"
362 run_dump_test "call3h"
363 run_dump_test "jmp1"
364 run_dump_test "jmp2"
365 run_dump_test "load1"
366 run_dump_test "load1-nacl"
367 run_dump_test "load2"
368 run_dump_test "load3"
369 run_dump_test "load4a"
370 run_dump_test "load4b"
371 run_dump_test "load5a"
372 run_dump_test "load5b"
373 run_dump_test "load6"
374 run_dump_test "load7"
375 run_dump_test "pr19175"
376 run_dump_test "pr19615"
377 run_dump_test "pr19636-1a"
378 run_dump_test "pr19636-1b"
379 run_dump_test "pr19636-1c"
380 run_dump_test "pr19636-1d"
381 run_dump_test "pr19636-1d-nacl"
382 run_dump_test "pr19636-1e"
383 run_dump_test "pr19636-1f"
384 run_dump_test "pr19636-1g"
385 run_dump_test "pr19636-1h"
386 run_dump_test "pr19636-1i"
387 run_dump_test "pr19636-1j"
388 run_dump_test "pr19636-1k"
389 run_dump_test "pr19636-1l"
390 run_dump_test "pr19636-2a"
391 run_dump_test "pr19636-2b"
392 run_dump_test "pr19636-2c"
393 run_dump_test "pr19636-2c-nacl"
394 run_dump_test "pr19636-2d"
395 run_dump_test "pr19636-2d-nacl"
396 run_dump_test "pr19636-2e"
397 run_dump_test "pr19636-2e-nacl"
398 run_dump_test "pr19636-3a"
399 run_dump_test "pr19636-3b"
400 run_dump_test "pr19636-3c"
401 run_dump_test "pr19636-3d"
402 run_dump_test "pr19636-3e"
403 run_dump_test "pr19636-3f"
404 run_dump_test "pr19636-3g"
405 run_dump_test "pr19636-3h"
406 run_dump_test "pr19636-3i"
407 run_dump_test "pr19636-4a"
408 run_dump_test "pr19636-4b"
409 run_dump_test "pr19636-4c"
410 run_dump_test "pr19636-4d"
411 run_dump_test "pr19645"
412 run_dump_test "pr19609-1a"
413 run_dump_test "pr19609-1b"
414 run_dump_test "pr19609-1c"
415 run_dump_test "pr19609-1d"
416 run_dump_test "pr19609-1e"
417 run_dump_test "pr19609-1f"
418 run_dump_test "pr19609-1g"
419 run_dump_test "pr19609-1h"
420 run_dump_test "pr19609-1i"
421 run_dump_test "pr19609-2a"
422 run_dump_test "pr19609-2b"
423 run_dump_test "pr19609-2c"
424 run_dump_test "undefweaka"
425 run_dump_test "undefweakb"
426 run_dump_test "pr19539"
427 run_dump_test "pr20117"
428 run_dump_test "pr20244-1a"
429 run_dump_test "pr20244-1b"
430 run_dump_test "pr20244-1c"
431 run_dump_test "pr20244-2a"
432 run_dump_test "pr20244-2b"
433 run_dump_test "pr20244-2c"
434 run_dump_test "pr20244-2d"
435 run_dump_test "pr20244-4a"
436 run_dump_test "pr20244-4b"
437 run_dump_test "pr20244-4c"
438 run_dump_test "pr20253-3"
439 run_dump_test "pr20253-4a"
440 run_dump_test "pr20253-4b"
441 run_dump_test "pr20253-4c"
442 run_dump_test "pr20253-5"
443 run_dump_test "pr20515"
444 run_dump_test "property-x86-3"
445 run_dump_test "property-x86-4a"
446 run_dump_test "property-x86-4b"
447 run_dump_test "property-x86-5"
448 run_dump_test "property-x86-ibt1a"
449 run_dump_test "property-x86-ibt1b"
450 run_dump_test "property-x86-ibt2"
451 run_dump_test "property-x86-ibt3a"
452 run_dump_test "property-x86-ibt3b"
453 run_dump_test "property-x86-ibt4"
454 run_dump_test "property-x86-ibt5"
455 run_dump_test "property-x86-shstk1a"
456 run_dump_test "property-x86-shstk1b"
457 run_dump_test "property-x86-shstk2"
458 run_dump_test "property-x86-shstk3a"
459 run_dump_test "property-x86-shstk3b"
460 run_dump_test "property-x86-shstk4"
461 run_dump_test "property-x86-shstk5"
462 run_dump_test "pie1"
463 run_dump_test "pie1-nacl"
464 run_dump_test "pr21884"
465 run_dump_test "pr21884-nacl"
466 run_dump_test "pr22115-1a"
467 run_dump_test "pr22115-1b"
468 run_dump_test "pr22115-1c"
469 run_dump_test "pr22115-1d"
470 run_dump_test "pr22135"
471 run_dump_test "pr22782"
472 run_dump_test "pr22929"
473 run_dump_test "pr23189"
474 run_dump_test "pr23194"
475 run_dump_test "pr23372a"
476 run_dump_test "pr23372b"
477 run_dump_test "pr23372c"
478 run_dump_test "pr23372d"
479 run_dump_test "pr23486a"
480 run_dump_test "pr23486b"
481 run_dump_test "pr23486c"
482 run_dump_test "pr23486d"
483
484 if { !([istarget "i?86-*-linux*"]
485 || [istarget "i?86-*-gnu*"]
486 || [istarget "i?86-*-nacl*"]
487 || [istarget "x86_64-*-nacl*"]
488 || [istarget "x86_64-*-linux*"]) } {
489 set ASFLAGS "$saved_ASFLAGS"
490 return
491 }
492
493 run_dump_test "compressed1"
494 run_dump_test "pr12627"
495 run_dump_test "pr13302"
496 run_dump_test "pr14215"
497 run_dump_test "pr17057"
498 run_dump_test "pr17935-1"
499 run_dump_test "pr17935-2"
500 run_dump_test "pr18801"
501 run_dump_test "pr18815"
502 run_dump_test "pr19939a"
503 run_dump_test "pr19939b"
504 run_dump_test "tlsdesc2"
505
506 proc undefined_weak {cflags ldflags} {
507 set testname "Undefined weak symbol"
508 if { ![ string match "" $cflags$ldflags] } {
509 set testname "$testname ($cflags $ldflags)"
510 }
511
512 if { [string match "*-fPIE*" $cflags]
513 && ![string match "*-z nodynamic-undefined-weak*" $ldflags] } {
514 set weak_symbol "Weak defined"
515 } else {
516 set weak_symbol "Weak undefined"
517 }
518
519 run_cc_link_tests [list \
520 [list \
521 "Build libpr19704a.so" \
522 "-shared -Wl,-soname,libpr19704.so" \
523 "-Wa,-mrelax-relocations=yes" \
524 { dummy.s } \
525 {} \
526 "libpr19704a.so" \
527 ] \
528 [list \
529 "Build libpr19704b.so" \
530 "-shared -Wl,-soname,libpr19704.so" \
531 "-fPIC -Wa,-mrelax-relocations=yes" \
532 { pr19704b.c } \
533 {} \
534 "libpr19704b.so" \
535 ] \
536 ]
537
538 exec cp tmpdir/libpr19704a.so tmpdir/libpr19704.so
539
540 run_ld_link_exec_tests [list \
541 [list \
542 "Run pr19704" \
543 "$ldflags tmpdir/libpr19704.so -Wl,-R,tmpdir" \
544 "-Wa,-mrelax-relocations=yes" \
545 { pr19704a.c } \
546 "pr19704" \
547 "pr19704.out" \
548 "$cflags" \
549 ] \
550 ]
551
552 exec cp tmpdir/libpr19704b.so tmpdir/libpr19704.so
553
554 set exec_output [run_host_cmd tmpdir/pr19704 ""]
555 if {![string match $weak_symbol $exec_output]} {
556 fail $testname
557 } else {
558 pass $testname
559 }
560 }
561
562 # Add $PLT_CFLAGS if PLT is expected.
563 global PLT_CFLAGS
564
565 # Must be Linux native with the C compiler
566 if { [isnative]
567 && [istarget "i?86-*-linux*"]
568 && [which $CC] != 0 } {
569 run_cc_link_tests [list \
570 [list \
571 "Build plt-lib.so" \
572 "-shared" \
573 "-fPIC -Wa,-mrelax-relocations=yes" \
574 { plt-lib.c } \
575 {} \
576 "libplt-lib.so" \
577 ] \
578 [list \
579 "Build libplt-main1.a" \
580 "" \
581 "-fPIC -Wa,-mrelax-relocations=yes,-mrelax-relocations=yes" \
582 { plt-main1.c } \
583 {{readelf {-Wr} plt-main1.rd}} \
584 "libplt-main1.a" \
585 ] \
586 [list \
587 "Build libplt-main2.a" \
588 "" \
589 "-fPIC -Wa,-mrelax-relocations=yes,-mrelax-relocations=yes" \
590 { plt-main2.c } \
591 {{readelf {-Wr} plt-main2.rd}} \
592 "libplt-main2.a" \
593 ] \
594 [list \
595 "Build libplt-main3.a" \
596 "" \
597 "-fPIC -Wa,-mrelax-relocations=yes,-mrelax-relocations=yes $PLT_CFLAGS" \
598 { plt-main3.c } \
599 {{readelf {-Wr} plt-main3.rd}} \
600 "libplt-main3.a" \
601 ] \
602 [list \
603 "Build libplt-main4.a" \
604 "" \
605 "-fPIC -Wa,-mrelax-relocations=yes,-mrelax-relocations=yes $PLT_CFLAGS" \
606 { plt-main4.c } \
607 {{readelf {-Wr} plt-main4.rd}} \
608 "libplt-main4.a" \
609 ] \
610 [list \
611 "Build plt-main" \
612 "tmpdir/plt-main1.o tmpdir/plt-main2.o tmpdir/plt-main3.o \
613 tmpdir/plt-main4.o tmpdir/libplt-lib.so" \
614 "-Wa,-mrelax-relocations=yes" \
615 { plt-main5.c } \
616 {{readelf {-Wr} plt-main.rd}} \
617 "plt-main" \
618 ] \
619 [list \
620 "Build plt-main with PIE" \
621 "tmpdir/plt-main1.o tmpdir/plt-main2.o tmpdir/plt-main3.o \
622 tmpdir/plt-main4.o tmpdir/libplt-lib.so -pie" \
623 "-fPIC -Wa,-mrelax-relocations=yes" \
624 { plt-main5.c } \
625 {{readelf {-Wr} plt-main.rd}} \
626 "plt-main" \
627 ] \
628 [list \
629 "Build copyreloc-lib.so" \
630 "-shared" \
631 "-fPIC -Wa,-mrelax-relocations=yes" \
632 { copyreloc-lib.c } \
633 {} \
634 "copyreloc-lib.so" \
635 ] \
636 [list \
637 "Build libcopyreloc-main.a" \
638 "" \
639 "-Wa,-mrelax-relocations=yes" \
640 { copyreloc-main.S } \
641 {} \
642 "libcopyreloc-main.a" \
643 ] \
644 [list \
645 "Build copyreloc-main with PIE and GOTOFF (1)" \
646 "tmpdir/copyreloc-main.o tmpdir/copyreloc-lib.so -pie" \
647 "-Wa,-mrelax-relocations=yes" \
648 { dummy.s } \
649 {{readelf {-Wr} copyreloc-main1.rd}} \
650 "copyreloc-main" \
651 ] \
652 [list \
653 "Build copyreloc-main with PIE and GOTOFF (2)" \
654 "tmpdir/copyreloc-main.o tmpdir/copyreloc-lib.so -pie" \
655 "-Wa,-mrelax-relocations=yes" \
656 { dummy.s } \
657 {{readelf {-Wr} copyreloc-main2.rd}} \
658 "copyreloc-main" \
659 ] \
660 [list \
661 "Build pr17689.so" \
662 "-shared" \
663 "-fPIC -Wa,-mrelax-relocations=yes" \
664 { pr17689a.c } \
665 {} \
666 "pr17689.so" \
667 ] \
668 [list \
669 "Build pr17689.so with -z now" \
670 "-shared -Wl,-z,now" \
671 "-fPIC -Wa,-mrelax-relocations=yes" \
672 { pr17689a.c } \
673 {{readelf {-Wr} pr17689now.rd}} \
674 "pr17689now.so" \
675 ] \
676 [list \
677 "Build pr17689ver.so" \
678 "-shared -Wl,--version-script,pr17689a.t" \
679 "-fPIC -Wa,-mrelax-relocations=yes" \
680 { pr17689a.c } \
681 {} \
682 "pr17689ver.so" \
683 ] \
684 [list \
685 "Build pr17689.a" \
686 "" \
687 "-Wa,-mrelax-relocations=yes" \
688 { pr17689b.S } \
689 {} \
690 "pr17689.a" \
691 ] \
692 [list \
693 "Build pr17689 with PIE and GOTOFF" \
694 "tmpdir/pr17689b.o tmpdir/pr17689.so -pie" \
695 "-Wa,-mrelax-relocations=yes" \
696 { dummy.c } \
697 {{readelf {-Wr} pr17689.rd}} \
698 "pr17689" \
699 ] \
700 [list \
701 "Build pr17689 with PIE, -z now and GOTOFF" \
702 "tmpdir/pr17689b.o tmpdir/pr17689.so -pie -Wl,-z,now" \
703 "-Wa,-mrelax-relocations=yes" \
704 { dummy.c } \
705 {{readelf {-Wr} pr17689now.rd}} \
706 "pr17689now" \
707 ] \
708 [list \
709 "Build pr17689ver with PIE and GOTOFF" \
710 "tmpdir/pr17689b.o tmpdir/pr17689ver.so -pie" \
711 "-Wa,-mrelax-relocations=yes" \
712 { dummy.c } \
713 {{readelf {-Wr} pr17689ver.rd}} \
714 "pr17689ver" \
715 ] \
716 [list \
717 "Build pr17827 with PIE and GOTOFF" \
718 "tmpdir/pr17689b.o tmpdir/pr17689.so -pie" \
719 "-Wa,-mrelax-relocations=yes" \
720 { dummy.c } \
721 {{readelf {-Wr} pr17827.rd}} \
722 "pr17827" \
723 ] \
724 [list \
725 "Build pr18900.so" \
726 "-shared" \
727 "-fPIC -Wa,-mrelax-relocations=yes" \
728 { pr18900a.c } \
729 "" \
730 "pr18900.so" \
731 ] \
732 [list \
733 "Build pr18900.o" \
734 "-r -nostdlib" \
735 "-Wa,-mrelax-relocations=yes" \
736 { pr18900b.c pr18900c.c } \
737 "" \
738 "pr18900.o" \
739 ] \
740 [list \
741 "Build pr18900a" \
742 "tmpdir/pr18900.o tmpdir/pr18900.so" \
743 "-Wa,-mrelax-relocations=yes" \
744 { dummy.s } \
745 {{readelf {-Wrd} pr18900a.rd}} \
746 "pr18900a" \
747 ] \
748 [list \
749 "Build pr18900b" \
750 "-Wl,--as-needed tmpdir/pr18900.o tmpdir/pr18900.so" \
751 "-Wa,-mrelax-relocations=yes" \
752 { dummy.s } \
753 {{readelf {-Wrd} pr18900b.rd}} \
754 "pr18900b" \
755 ] \
756 [list \
757 "Build pr19031.so" \
758 "-shared" \
759 "-fPIC -Wa,-mrelax-relocations=yes" \
760 { pr19031a.c } \
761 "" \
762 "pr19031.so" \
763 ] \
764 [list \
765 "Build got1d.so" \
766 "-shared" \
767 "-Wa,-mrelax-relocations=yes" \
768 { got1d.S } \
769 "" \
770 "got1d.so" \
771 ] \
772 [list \
773 "Build gotpc1.o" \
774 "-r -nostdlib" \
775 "-Wa,-mrelax-relocations=yes" \
776 { got1a.S got1b.c got1c.c } \
777 "" \
778 "gotpc1.o" \
779 ] \
780 [list \
781 "Build gotpc1" \
782 "$NOPIE_LDFLAGS -Wl,--as-needed tmpdir/gotpc1.o tmpdir/got1d.so" \
783 "-Wa,-mx86-used-note=no" \
784 { dummy.s } \
785 {{objdump {-dw} got1.dd}} \
786 "got1" \
787 ] \
788 [list \
789 "Build pr19319.so" \
790 "-shared" \
791 "-Wa,-mx86-used-note=no" \
792 { pr19319a.S } \
793 "" \
794 "pr19319.so" \
795 ] \
796 [list \
797 "Build pr19319" \
798 "-pie -nostdlib -nostartfiles tmpdir/pr19319.so" \
799 "-Wa,-mrelax-relocations=yes" \
800 { pr19319b.S } \
801 {{objdump {-dw} pr19319.dd}} \
802 "pr19319" \
803 ] \
804 [list \
805 "Build property 1" \
806 "" \
807 "-Wa,-mx86-used-note=no" \
808 {pass.c property-no-copy.S} \
809 {{readelf {-n} property-1.r}} \
810 "property-1" \
811 ] \
812 [list \
813 "Build property 1 (.o)" \
814 "-r -nostdlib" \
815 "-Wa,-mx86-used-note=yes" \
816 {pass.c property-no-copy.S} \
817 {{readelf {-n} property-1a.r}} \
818 "property-1.o" \
819 ] \
820 [list \
821 "Build property 1 (.so)" \
822 "-shared" \
823 "-fPIC -Wa,-mx86-used-note=no" \
824 {pass.c property-no-copy.S} \
825 {{readelf {-n} property-1.r}} \
826 "property-1.so" \
827 ] \
828 [list \
829 "Build property 2" \
830 "" \
831 "-Wa,-mx86-used-note=no" \
832 {pass.c property-stack.S} \
833 {{readelf {-n} property-2.r}} \
834 "property-2" \
835 ] \
836 [list \
837 "Build property 2 (.o)" \
838 "-r -nostdlib" \
839 "-Wa,-mx86-used-note=yes" \
840 {pass.c property-stack.S} \
841 {{readelf {-n} property-2a.r}} \
842 "property-2.o" \
843 ] \
844 [list \
845 "Build property 2 (.so)" \
846 "-shared" \
847 "-fPIC -Wa,-mx86-used-note=no" \
848 {pass.c property-stack.S} \
849 {{readelf {-n} property-2.r}} \
850 "property-2.so" \
851 ] \
852 [list \
853 "Build property 3" \
854 "" \
855 "-Wa,-mx86-used-note=no" \
856 {pass.c property-stack.S property-x86-1.S} \
857 {{readelf {-n} property-3.r}} \
858 "property-3" \
859 ] \
860 [list \
861 "Build property 3 (.o)" \
862 "-r -nostdlib" \
863 "-Wa,-mx86-used-note=yes" \
864 {pass.c property-x86-1.S property-stack.S} \
865 {{readelf {-n} property-3a.r}} \
866 "property-3.o" \
867 ] \
868 [list \
869 "Build property 3 (.so)" \
870 "-shared" \
871 "-fPIC -Wa,-mx86-used-note=no" \
872 {property-x86-1.S pass.c property-stack.S} \
873 {{readelf {-n} property-3.r}} \
874 "property-3.so" \
875 ] \
876 [list \
877 "Build property 4" \
878 "" \
879 "-Wa,-mx86-used-note=no" \
880 {pass.c property-stack.S property-x86-1.S property-x86-2.S} \
881 {{readelf {-n} property-4.r}} \
882 "property-4" \
883 ] \
884 [list \
885 "Build property 4 (.o)" \
886 "-r -nostdlib" \
887 "-Wa,-mx86-used-note=yes" \
888 {pass.c property-x86-2.S property-x86-1.S property-stack.S} \
889 {{readelf {-n} property-4a.r}} \
890 "property-4.o" \
891 ] \
892 [list \
893 "Build property 4 (.so)" \
894 "-shared" \
895 "-fPIC -Wa,-mx86-used-note=no" \
896 {property-x86-2.S property-x86-1.S pass.c property-stack.S} \
897 {{readelf {-n} property-4.r}} \
898 "property-4.so" \
899 ] \
900 [list \
901 "Build property 4 (-Wl,-z,stack-size=0)" \
902 "-Wl,-z,stack-size=0" \
903 "-Wa,-mx86-used-note=no" \
904 {pass.c property-stack.S property-x86-1.S property-x86-2.S} \
905 {{readelf {-n} property-4.r}} \
906 "property-4" \
907 ] \
908 [list \
909 "Build property 5" \
910 "-Wl,-z,stack-size=0x900000" \
911 "-Wa,-mx86-used-note=no" \
912 {pass.c property-stack.S property-x86-1.S property-x86-2.S} \
913 {{readelf {-n} property-5.r}} \
914 "property-5" \
915 ] \
916 [list \
917 "Build property 5 (.o)" \
918 "-r -nostdlib -Wl,-z,stack-size=0x900000" \
919 "-Wa,-mx86-used-note=yes" \
920 {pass.c property-x86-2.S property-x86-1.S property-stack.S} \
921 {{readelf {-n} property-5a.r}} \
922 "property-5.o" \
923 ] \
924 [list \
925 "Build property 5 (.so)" \
926 "-shared -Wl,-z,stack-size=0x900000" \
927 "-fPIC -Wa,-mx86-used-note=no" \
928 {property-x86-2.S property-x86-1.S pass.c property-stack.S} \
929 {{readelf {-n} property-5.r}} \
930 "property-5.so" \
931 ] \
932 [list \
933 "Build property-6.so" \
934 "-shared" \
935 "-fPIC -Wa,-mx86-used-note=no" \
936 {property-6a.c property-6c.S} \
937 {{readelf {-n} property-6.r}} \
938 "property-6.so" \
939 ] \
940 [list \
941 "Build property-6.o" \
942 "-r -nostdlib" \
943 "-Wa,-mx86-used-note=yes" \
944 {property-6b.c property-stack.S} \
945 {{readelf {-n} property-2a.r}} \
946 "property-6.o" \
947 ] \
948 [list \
949 "Build property-6" \
950 "-Wl,--as-needed tmpdir/property-6.o tmpdir/property-6.so" \
951 "-Wa,-mx86-used-note=no" \
952 { dummy.s } \
953 {{readelf {-n} property-2.r}} \
954 "property-6" \
955 ] \
956 [list \
957 "Build property 7a (.o)" \
958 "-r -nostdlib" \
959 "-Wa,-mx86-used-note=yes" \
960 {property-unsorted-1.S} \
961 {{readelf {-n} property-7a.r}} \
962 "property-7a.o" \
963 ] \
964 [list \
965 "Build property 7b (.o)" \
966 "-r -nostdlib" \
967 "-Wa,-mx86-used-note=yes" \
968 {property-unsorted-2.S} \
969 {{readelf {-n} property-7a.r}} \
970 "property-7b.o" \
971 ] \
972 ]
973
974 run_ld_link_exec_tests [list \
975 [list \
976 "Run plt-main" \
977 "tmpdir/plt-main1.o tmpdir/plt-main2.o tmpdir/plt-main3.o \
978 tmpdir/plt-main4.o tmpdir/libplt-lib.so" \
979 "-Wa,-mx86-used-note=yes" \
980 { plt-main5.c } \
981 "plt-main" \
982 "plt-main.out" \
983 ] \
984 [list \
985 "Run plt-main with PIE" \
986 "tmpdir/plt-main1.o tmpdir/plt-main2.o tmpdir/plt-main3.o \
987 tmpdir/plt-main4.o tmpdir/libplt-lib.so -pie" \
988 "-Wa,-mx86-used-note=yes" \
989 { plt-main5.c } \
990 "plt-main-pie" \
991 "plt-main.out" \
992 "-fPIC" \
993 ] \
994 [list \
995 "Run copyreloc-main with PIE and GOTOFF" \
996 "-Wl,--as-needed tmpdir/copyreloc-main.o tmpdir/copyreloc-lib.so -pie" \
997 "-Wa,-mx86-used-note=yes" \
998 { dummy.s } \
999 "copyreloc-main" \
1000 "copyreloc-main.out" \
1001 ] \
1002 [list \
1003 "Run pr17689 with PIE and GOTOFF" \
1004 "tmpdir/pr17689b.o tmpdir/pr17689.so -pie" \
1005 "-Wa,-mx86-used-note=yes" \
1006 { dummy.c } \
1007 "pr17689" \
1008 "pr17689.out" \
1009 ] \
1010 [list \
1011 "Run pr17689 with PIE, -z now and GOTOFF" \
1012 "tmpdir/pr17689b.o tmpdir/pr17689.so -pie -z now" \
1013 "-Wa,-mx86-used-note=yes" \
1014 { dummy.c } \
1015 "pr17689now" \
1016 "pr17689.out" \
1017 ] \
1018 [list \
1019 "Run pr17689ver with PIE and GOTOFF" \
1020 "tmpdir/pr17689b.o tmpdir/pr17689ver.so -pie" \
1021 "-Wa,-mx86-used-note=yes" \
1022 { dummy.c } \
1023 "pr17689ver" \
1024 "pr17689.out" \
1025 ] \
1026 [list \
1027 "Run pr18900" \
1028 "tmpdir/pr18900.o tmpdir/pr18900.so" \
1029 "-Wa,-mx86-used-note=yes" \
1030 { dummy.s } \
1031 "pr18900" \
1032 "pr18900.out" \
1033 ] \
1034 [list \
1035 "Run pr19031" \
1036 "$NOPIE_LDFLAGS tmpdir/pr19031.so" \
1037 "-Wa,-mx86-used-note=yes" \
1038 { pr19031b.S pr19031c.c } \
1039 "pr19031" \
1040 "pr19031.out" \
1041 "$NOPIE_CFLAGS" \
1042 ] \
1043 [list \
1044 "Run got1" \
1045 "$NOPIE_LDFLAGS tmpdir/got1d.so" \
1046 "-Wa,-mx86-used-note=yes" \
1047 { got1a.S got1b.c got1c.c } \
1048 "got1" \
1049 "got1.out" \
1050 ] \
1051 [list \
1052 "Run property 1" \
1053 "" \
1054 "-Wa,-mx86-used-note=yes" \
1055 {pass.c property-no-copy.S} \
1056 "property-1" "pass.out" \
1057 ] \
1058 [list \
1059 "Run property 1 (PIE)" \
1060 "-pie" \
1061 "-Wa,-mx86-used-note=yes" \
1062 {pass.c property-no-copy.S} \
1063 "property-1-pie" "pass.out" "-fPIE" \
1064 ] \
1065 [list \
1066 "Run property 1 (static)" \
1067 "-static" \
1068 "-Wa,-mx86-used-note=yes" \
1069 {pass.c property-no-copy.S} \
1070 "property-1-static" "pass.out" \
1071 ] \
1072 [list \
1073 "Run property 2" \
1074 "" \
1075 "-Wa,-mx86-used-note=yes" \
1076 {pass.c property-stack.S} \
1077 "property-2" "pass.out" \
1078 ] \
1079 [list \
1080 "Run property 2 (PIE)" \
1081 "-pie" \
1082 "-Wa,-mx86-used-note=yes" \
1083 {pass.c property-stack.S} \
1084 "property-2-pie" "pass.out" "-fPIE" \
1085 ] \
1086 [list \
1087 "Run property 2 (static)" \
1088 "-static" \
1089 "-Wa,-mx86-used-note=yes" \
1090 {pass.c property-stack.S} \
1091 "property-3-static" "pass.out" \
1092 ] \
1093 [list \
1094 "Run property 3" \
1095 "" \
1096 "-Wa,-mx86-used-note=yes" \
1097 {pass.c property-stack.S property-x86-1.S} \
1098 "property-3" "pass.out" \
1099 ] \
1100 [list \
1101 "Run property 3 (PIE)" \
1102 "-pie" \
1103 "-Wa,-mx86-used-note=yes" \
1104 {pass.c property-x86-1.S property-stack.S} \
1105 "property-3-pie" "pass.out" "-fPIE" \
1106 ] \
1107 [list \
1108 "Run property 3 (static)" \
1109 "-static" \
1110 "-Wa,-mx86-used-note=yes" \
1111 {property-x86-1.S pass.c property-stack.S} \
1112 "property-3-static" "pass.out" \
1113 ] \
1114 [list \
1115 "Run property 4" \
1116 "" \
1117 "-Wa,-mx86-used-note=yes" \
1118 {pass.c property-stack.S property-x86-1.S property-x86-2.S} \
1119 "property-4" "pass.out" \
1120 ] \
1121 [list \
1122 "Run property 4 (PIE)" \
1123 "-pie" \
1124 "-Wa,-mx86-used-note=yes" \
1125 {pass.c property-x86-2.S property-x86-1.S property-stack.S} \
1126 "property-4-pie" "pass.out" "-fPIE" \
1127 ] \
1128 [list \
1129 "Run property 4 (static)" \
1130 "-static" \
1131 "-Wa,-mx86-used-note=yes" \
1132 {property-x86-2.S property-x86-1.S pass.c property-stack.S} \
1133 "property-4-static" "pass.out" \
1134 ] \
1135 [list \
1136 "Run property 5" \
1137 "-Wl,-z,stack-size=0x900000" \
1138 "-Wa,-mx86-used-note=yes" \
1139 {pass.c property-stack.S property-x86-1.S property-x86-2.S} \
1140 "property-5" "pass.out" \
1141 ] \
1142 [list \
1143 "Run property 5 (PIE)" \
1144 "-pie -Wl,-z,stack-size=0x900000" \
1145 "-Wa,-mx86-used-note=yes" \
1146 {pass.c property-x86-2.S property-x86-1.S property-stack.S} \
1147 "property-5-pie" "pass.out" "-fPIE" \
1148 ] \
1149 [list \
1150 "Run property 5 (static)" \
1151 "-static -Wl,-z,stack-size=0x900000" \
1152 "-Wa,-mx86-used-note=yes" \
1153 {property-x86-2.S property-x86-1.S pass.c property-stack.S} \
1154 "property-5-static" "pass.out" \
1155 ] \
1156 ]
1157
1158 undefined_weak "$NOPIE_CFLAGS" "$NOPIE_LDFLAGS"
1159 undefined_weak "-fPIE" "$NOPIE_LDFLAGS"
1160 undefined_weak "-fPIE" "-pie"
1161 undefined_weak "-fPIE" "-z nodynamic-undefined-weak $NOPIE_LDFLAGS"
1162 undefined_weak "-fPIE" "-pie -z nodynamic-undefined-weak"
1163 }
1164
1165 global NOPIE_CFLAGS NOPIE_LDFLAGS
1166
1167 # Must be native with the C compiler and working IFUNC support,
1168 if { [isnative]
1169 && [check_ifunc_available]
1170 && [istarget "i?86-*-*"]
1171 && [which $CC] != 0 } {
1172 run_cc_link_tests [list \
1173 [list \
1174 "Build ifunc-1a.o ifunc-1b.o ifunc-1c.o ifunc-1d.o" \
1175 "" \
1176 "-fPIC -O2 -g -Wa,-mx86-used-note=yes" \
1177 { ifunc-1a.c ifunc-1b.S ifunc-1c.S ifunc-1d.S } \
1178 ] \
1179 [list \
1180 "Build pr21168a.o" \
1181 "" \
1182 "-Wa,-mx86-used-note=yes" \
1183 { pr21168a.c } \
1184 ] \
1185 [list \
1186 "Build pr21168.so" \
1187 "-shared" \
1188 "-Wa,-mx86-used-note=yes" \
1189 { pr21168b.S } \
1190 "" \
1191 "pr21168.so" \
1192 ] \
1193 ]
1194
1195 run_ld_link_exec_tests [list \
1196 [list \
1197 "Run ifunc-1a" \
1198 "tmpdir/ifunc-1a.o tmpdir/ifunc-1b.o \
1199 tmpdir/ifunc-1c.o tmpdir/ifunc-1d.o" \
1200 "-Wa,-mx86-used-note=yes" \
1201 { dummy.c } \
1202 "ifunc-1a" \
1203 "pass.out" \
1204 ] \
1205 [list \
1206 "Run ifunc-1b" \
1207 "--static tmpdir/ifunc-1a.o tmpdir/ifunc-1b.o \
1208 tmpdir/ifunc-1c.o tmpdir/ifunc-1d.o" \
1209 "-Wa,-mx86-used-note=yes" \
1210 { dummy.c } \
1211 "ifunc-1b" \
1212 "pass.out" \
1213 ] \
1214 [list \
1215 "Run pr21168" \
1216 "tmpdir/pr21168a.o tmpdir/pr21168.so" \
1217 "-Wa,-mx86-used-note=yes" \
1218 { dummy.c } \
1219 "pr21168" \
1220 "pass.out" \
1221 ] \
1222 ]
1223
1224 if { [istarget "i?86-*-linux*"] } {
1225 run_cc_link_tests [list \
1226 [list \
1227 "Build pr21168.so with -z ibtplt" \
1228 "-shared -Wl,-z,ibtplt" \
1229 "-Wa,-mx86-used-note=yes" \
1230 { pr21168b.S } \
1231 "" \
1232 "pr21168-ibt.so" \
1233 ] \
1234 [list \
1235 "Build ifunc-1a with -z ibtplt" \
1236 "-Wl,-z,ibtplt $NOPIE_LDFLAGS tmpdir/ifunc-1a.o \
1237 tmpdir/ifunc-1b.o tmpdir/ifunc-1c.o tmpdir/ifunc-1d.o" \
1238 "-Wa,-mx86-used-note=yes" \
1239 { dummy.c } \
1240 {{objdump {-dw} plt-main-ibt.dd}} \
1241 "ifunc-1a-ibt" \
1242 ] \
1243 [list \
1244 "Build ifunc-1a with PIE -z ibtplt" \
1245 "-Wl,-z,ibtplt -pie tmpdir/ifunc-1a.o \
1246 tmpdir/ifunc-1b.o tmpdir/ifunc-1c.o tmpdir/ifunc-1d.o" \
1247 "-Wa,-mx86-used-note=yes" \
1248 { dummy.c } \
1249 {{objdump {-dw} plt-pie-ibt.dd}} \
1250 "ifunc-1a-pie-ibt" \
1251 ] \
1252 ]
1253
1254 run_ld_link_exec_tests [list \
1255 [list \
1256 "Run ifunc-1a with -z ibtplt" \
1257 "-Wl,-z,ibtplt $NOPIE_LDFLAGS tmpdir/ifunc-1a.o \
1258 tmpdir/ifunc-1b.o tmpdir/ifunc-1c.o tmpdir/ifunc-1d.o" \
1259 "-Wa,-mx86-used-note=yes" \
1260 { dummy.c } \
1261 "ifunc-1a-ibt" \
1262 "pass.out" \
1263 ] \
1264 [list \
1265 "Run ifunc-1a with PIE -z ibtplt" \
1266 "-Wl,-z,ibtplt -pie tmpdir/ifunc-1a.o \
1267 tmpdir/ifunc-1b.o tmpdir/ifunc-1c.o tmpdir/ifunc-1d.o" \
1268 "-Wa,-mx86-used-note=yes" \
1269 { dummy.c } \
1270 "ifunc-1a-pie-ibt" \
1271 "pass.out" \
1272 ] \
1273 [list \
1274 "Run pr21168 with -z ibtplt" \
1275 "tmpdir/pr21168a.o tmpdir/pr21168-ibt.so" \
1276 "-Wa,-mx86-used-note=yes" \
1277 { dummy.c } \
1278 "pr21168-ibt" \
1279 "pass.out" \
1280 ] \
1281 ]
1282 }
1283 }
1284
1285 # Must be native with the C compiler.
1286 if { [isnative]
1287 && [istarget "i?86-*-*"]
1288 && [which $CC] != 0 } {
1289 run_cc_link_tests [list \
1290 [list \
1291 "Build pr22001-1.so" \
1292 "-shared" \
1293 "-Wa,-mx86-used-note=yes" \
1294 { pr22001-1a.c } \
1295 {} \
1296 "pr22001-1.so" \
1297 ] \
1298 [list \
1299 "Build pr21997-1.so" \
1300 "-shared" \
1301 "-Wa,-mx86-used-note=yes" \
1302 { property-stack.S property-no-copy.S pr21997-1a.S } \
1303 {} \
1304 "pr21997-1.so" \
1305 ] \
1306 [list \
1307 "Build pr22842.so" \
1308 "-shared" \
1309 "-fPIC -Wa,-mx86-used-note=yes" \
1310 { pr22842a.c } \
1311 {} \
1312 "pr22842.so" \
1313 ] \
1314 ]
1315
1316 run_ld_link_exec_tests [list \
1317 [list \
1318 "Run weakundef1 without PIE" \
1319 "$NOPIE_LDFLAGS" \
1320 "-Wa,-mx86-used-note=yes" \
1321 { weakundef1.c } \
1322 "weakundef1pie" \
1323 "pass.out" \
1324 "$NOPIE_CFLAGS" \
1325 ] \
1326 [list \
1327 "Run pr22001-1" \
1328 "$NOPIE_LDFLAGS -Wl,-z,nocopyreloc,--no-as-needed tmpdir/pr22001-1.so" \
1329 "-Wa,-mx86-used-note=yes" \
1330 { pr22001-1b.c } \
1331 "pr22001-1" \
1332 "pass.out" \
1333 "$NOPIE_CFLAGS" \
1334 ] \
1335 [list \
1336 "Run pr22001-1 (PIE 1)" \
1337 "$NOPIE_LDFLAGS -Wl,-z,nocopyreloc,--no-as-needed tmpdir/pr22001-1.so" \
1338 "-Wa,-mx86-used-note=yes" \
1339 { pr22001-1c.S } \
1340 "pr22001-1-pie-1" \
1341 "pass.out" \
1342 ] \
1343 [list \
1344 "Run pr22001-1 (PIE 2)" \
1345 "-pie -Wl,-z,nocopyreloc,--no-as-needed tmpdir/pr22001-1.so" \
1346 "-Wa,-mx86-used-note=yes" \
1347 { pr22001-1c.S } \
1348 "pr22001-1-pie-2" \
1349 "pass.out" \
1350 ] \
1351 [list \
1352 "Run pr22001-1 (PIC 1)" \
1353 "$NOPIE_LDFLAGS -Wl,-z,nocopyreloc,--no-as-needed tmpdir/pr22001-1.so" \
1354 "-Wa,-mx86-used-note=yes" \
1355 { pr22001-1b.c } \
1356 "pr22001-1-pic-1" \
1357 "pass.out" \
1358 "-fPIC" \
1359 ] \
1360 [list \
1361 "Run pr22001-1 (PIC 2)" \
1362 "-pie -Wl,-z,nocopyreloc,--no-as-needed tmpdir/pr22001-1.so" \
1363 "-Wa,-mx86-used-note=yes" \
1364 { pr22001-1b.c } \
1365 "pr22001-1-pic-2" \
1366 "pass.out" \
1367 "-fPIC" \
1368 ] \
1369 [list \
1370 "Run pr21997-1" \
1371 "$NOPIE_LDFLAGS -Wl,--no-as-needed tmpdir/pr21997-1.so" \
1372 "-Wa,-mx86-used-note=yes" \
1373 { pr21997-1b.c } \
1374 "pr21997-1" \
1375 "pass.out" \
1376 "$NOPIE_CFLAGS" \
1377 ] \
1378 [list \
1379 "Run pr21997-1 (PIC 1)" \
1380 "$NOPIE_LDFLAGS -Wl,--no-as-needed tmpdir/pr21997-1.so" \
1381 "-Wa,-mx86-used-note=yes" \
1382 { pr21997-1b.c } \
1383 "pr21997-1-pic-1" \
1384 "pass.out" \
1385 "-fPIC" \
1386 ] \
1387 [list \
1388 "Run pr21997-1 (PIC 2)" \
1389 "-pie -Wl,--no-as-needed tmpdir/pr21997-1.so" \
1390 "-Wa,-mx86-used-note=yes" \
1391 { pr21997-1b.c } \
1392 "pr21997-1-pic-2" \
1393 "pass.out" \
1394 "-fPIC" \
1395 ] \
1396 [list \
1397 "Run pr21997-1 (PIE 1)" \
1398 "$NOPIE_LDFLAGS -Wl,--no-as-needed tmpdir/pr21997-1.so" \
1399 "-Wa,-mx86-used-note=yes" \
1400 { pr21997-1c.S } \
1401 "pr21997-1-pie-1" \
1402 "pass.out" \
1403 ] \
1404 [list \
1405 "Run pr21997-1 (PIE 2)" \
1406 "-pie -Wl,--no-as-needed tmpdir/pr21997-1.so" \
1407 "-Wa,-mx86-used-note=yes" \
1408 { pr21997-1c.S } \
1409 "pr21997-1-pie-2" \
1410 "pass.out" \
1411 ] \
1412 [list \
1413 "Build pr22842" \
1414 "-pie -Wl,--no-as-needed tmpdir/pr22842.so" \
1415 "-Wa,-mx86-used-note=yes" \
1416 { pr22842b.S } \
1417 "pr22842" \
1418 "pass.out" \
1419 ] \
1420 ]
1421
1422 if { [at_least_gcc_version 5 0] } {
1423 run_ld_link_exec_tests [list \
1424 [list \
1425 "Run weakundef1 with PIE" \
1426 "-pie" \
1427 "-Wa,-mx86-used-note=yes" \
1428 { weakundef1.c } \
1429 "weakundef1pie" \
1430 "pass.out" \
1431 "-fPIE" \
1432 ] \
1433 ]
1434 }
1435 }
1436
1437 if { !([istarget "i?86-*-linux*"]
1438 || [istarget "x86_64-*-linux*"]) } {
1439 set ASFLAGS "$saved_ASFLAGS"
1440 return
1441 }
1442
1443 run_ld_link_tests [list \
1444 [list \
1445 "basic PLT generation (non-PIC, -z now)" \
1446 "-z now -melf_i386 --hash-style=sysv \
1447 -z noseparate-code tmpdir/libpltlib.so" \
1448 "" \
1449 "--32" \
1450 {plt2.s} \
1451 {{readelf -SW plt2.rd} {objdump -dwr plt2.dd}} \
1452 "plt2" \
1453 ] \
1454 [list \
1455 "basic PLT generation (PIC, -z now)" \
1456 "-z now -shared -melf_i386 tmpdir/libpltlib.so" \
1457 "" \
1458 "--32 -mx86-used-note=yes" \
1459 {plt-pic.s} \
1460 {{objdump -dwr plt-pic2.dd}} \
1461 "plt-pic2.so" \
1462 ] \
1463 [list \
1464 "Build pr21626.so" \
1465 "-shared -melf_i386" \
1466 "" \
1467 "--32 -mx86-used-note=yes" \
1468 {property-x86-3.s} \
1469 "" \
1470 "pr21626.so" \
1471 ] \
1472 [list \
1473 "Build pr21626" \
1474 "-melf_i386 tmpdir/pr21626.so" \
1475 "" \
1476 "--32 -mx86-used-note=yes" \
1477 {start.s foo.s} \
1478 "" \
1479 "pr21626" \
1480 ] \
1481 ]
1482
1483 # Linux only tests
1484 run_dump_test "pltgot-1"
1485 run_dump_test "pltgot-2"
1486 run_dump_test "pr20830"
1487 run_dump_test "ibt-plt-1"
1488 run_dump_test "ibt-plt-2a"
1489 run_dump_test "ibt-plt-2b"
1490 run_dump_test "ibt-plt-2c"
1491 run_dump_test "ibt-plt-2d"
1492 run_dump_test "ibt-plt-3a"
1493 run_dump_test "ibt-plt-3b"
1494 run_dump_test "ibt-plt-3c"
1495 run_dump_test "ibt-plt-3d"
1496
1497 set ASFLAGS "$saved_ASFLAGS"
This page took 0.065873 seconds and 5 git commands to generate.