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