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