]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame - ld/testsuite/ld-x86-64/x86-64.exp
Update config.guess and config.sub
[thirdparty/binutils-gdb.git] / ld / testsuite / ld-x86-64 / x86-64.exp
CommitLineData
bffbf940 1# Expect script for ld-x86_64 tests
219d1afa 2# Copyright (C) 2002-2018 Free Software Foundation, Inc.
bffbf940 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
bffbf940 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
bffbf940
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.
bffbf940
JJ
20#
21
22# Test x86_64 linking; all types of relocs. This tests the assembler and
23# tools like objdump as well as the linker.
24
25if { !([istarget "x86_64-*-elf*"]
5a68afcf 26 || [istarget "x86_64-*-nacl*"]
bffbf940
JJ
27 || [istarget "x86_64-*-linux*"]) } {
28 return
29}
30
5a68afcf
RM
31if [istarget "*-*-nacl*"] {
32 set emul "elf_x86_64_nacl"
33} else {
34 set emul "elf_x86_64"
35}
36
bffbf940 37# List contains test-items with 3 items followed by 2 lists:
897aea50
MR
38# 0:name 1:ld early options 2:ld late options 3:assembler options
39# 4:filenames of assembler files 5: action and options. 6: name of output file
bffbf940
JJ
40
41# Actions:
42# objdump: Apply objdump options on result. Compare with regex (last arg).
43# nm: Apply nm options on result. Compare with regex (last arg).
44# readelf: Apply readelf options on result. Compare with regex (last arg).
45
46set x86_64tests {
5a68afcf 47 {"Helper shared library (basic PLT test)"
897aea50 48 "-shared -melf_x86_64" "" "--64" {pltlib.s} {} "libpltlib.so"}
5a68afcf 49 {"basic PLT generation"
897aea50 50 "-melf_x86_64 tmpdir/libpltlib.so" "" "--64" {plt.s}
5a68afcf 51 {{objdump -drj.plt plt.pd}} "plt"}
e41b3a13 52 {"TLS -fpic -shared transitions"
7c9f387a
L
53 "-shared -melf_x86_64 --no-ld-generated-unwind-info \
54 -z noseparate-code -z max-page-size=0x200000 --hash-style=sysv" ""
bffbf940 55 "--64" {tlspic1.s tlspic2.s}
5db04b09 56 {{readelf -WSsrl tlspic.rd} {objdump -drj.text\ -Mintel64 tlspic.dd}
bffbf940
JJ
57 {objdump -sj.got tlspic.sd} {objdump -sj.tdata tlspic.td}}
58 "libtlspic.so"}
e2cbcd91 59 {"TLS -fpic -shared transitions with r15 as GOT base"
7c9f387a
L
60 "-shared -melf_x86_64 --no-ld-generated-unwind-info \
61 -z noseparate-code -z max-page-size=0x200000 --hash-style=sysv" ""
e2cbcd91
L
62 "--64 -mrelax-relocations=yes"
63 {tlspic3.s tlspic2.s}
64 {{readelf -WSsrl tlspic2.rd} {objdump -drj.text\ -Mintel64 tlspic2.dd}
65 {objdump -sj.got tlspic2.sd} {objdump -sj.tdata tlspic2.td}}
66 "libtlspic2.so"}
e41b3a13 67 {"TLS descriptor -fpic -shared transitions"
7c9f387a
L
68 "-shared -melf_x86_64 --no-ld-generated-unwind-info \
69 -z noseparate-code -z max-page-size=0x200000 --hash-style=sysv" ""
67a4f2b7
AO
70 "--64" {tlsdesc.s tlspic2.s}
71 {{readelf -WSsrld tlsdesc.rd} {objdump -drj.text tlsdesc.dd}
72 {objdump "-s -j.got -j.got.plt" tlsdesc.sd} {objdump -sj.tdata tlsdesc.td}
73 {objdump -drj.plt tlsdesc.pd}} "libtlsdesc.so"}
897aea50 74 {"Helper shared library" "-shared -melf_x86_64" ""
bffbf940
JJ
75 "--64" {tlslib.s} {} "libtlslib.so"}
76 {"TLS -fpic and -fno-pic exec transitions"
7c9f387a
L
77 "-melf_x86_64 tmpdir/libtlslib.so --no-ld-generated-unwind-info \
78 -z noseparate-code -z max-page-size=0x200000 --hash-style=sysv" ""
e41b3a13 79 "--64" {tlsbinpic.s tlsbin.s}
bffbf940
JJ
80 {{readelf -WSsrl tlsbin.rd} {objdump -drj.text tlsbin.dd}
81 {objdump -sj.got tlsbin.sd} {objdump -sj.tdata tlsbin.td}}
82 "tlsbin"}
e2cbcd91 83 {"TLS -fpic and -fno-pic exec transitions without PLT"
7c9f387a
L
84 "-melf_x86_64 tmpdir/libtlslib.so --no-ld-generated-unwind-info \
85 -z noseparate-code -z max-page-size=0x200000 --hash-style=sysv" ""
e2cbcd91
L
86 "-mrelax-relocations=yes --64" {tlsbinpic2.s tlsbin.s}
87 {{readelf -WSsrl tlsbin2.rd} {objdump -drj.text tlsbin2.dd}
88 {objdump -sj.got tlsbin2.sd} {objdump -sj.tdata tlsbin2.td}}
89 "tlsbin2"}
67a4f2b7 90 {"TLS descriptor -fpic and -fno-pic exec transitions"
7c9f387a
L
91 "-melf_x86_64 tmpdir/libtlslib.so --no-ld-generated-unwind-info \
92 -z noseparate-code -z max-page-size=0x200000 --hash-style=sysv" ""
e41b3a13 93 "--64" {tlsbindesc.s tlsbin.s}
67a4f2b7
AO
94 {{readelf -WSsrl tlsbindesc.rd} {objdump -drj.text tlsbindesc.dd}
95 {objdump -sj.got tlsbindesc.sd} {objdump -sj.tdata tlsbindesc.td}}
96 "tlsbindesc"}
97 {"TLS with global dynamic and descriptors"
7c9f387a
L
98 "-shared -melf_x86_64 --no-ld-generated-unwind-info \
99 -z noseparate-code -z max-page-size=0x200000 --hash-style=sysv" ""
e41b3a13 100 "--64" {tlsgdesc.s}
5db04b09 101 {{readelf -WSsrl tlsgdesc.rd} {objdump -drj.text\ -Mintel64 tlsgdesc.dd}}
67a4f2b7 102 "libtlsgdesc.so"}
897aea50 103 {"TLS in debug sections" "-melf_x86_64" ""
a45bb67d
JJ
104 "--64" {tlsg.s}
105 {{objdump -sj.debug_foobar tlsg.sd}} "tlsg"}
897aea50 106 {"TLS GD->LE transition" "-melf_x86_64" ""
a3fadc9a
L
107 "--64" {tlsgd1.s}
108 {{objdump -dwr tlsgd1.dd}} "tlsgd1"}
897aea50 109 {"TLS LD->LE transition" "-melf_x86_64" ""
a3fadc9a
L
110 "--64" {tlsld1.s}
111 {{objdump -dwr tlsld1.dd}} "tlsld1"}
897aea50 112 {"TLS IE->LE transition" "-melf_x86_64" ""
dd1093aa
L
113 "--64" {tlsie1.s}
114 {{objdump -dwr tlsie1.dd}} "tlsie1"}
897aea50 115 {"Helper 64bit object 1" "-r -melf_x86_64" ""
39334f3a 116 "--64" {mixed1a.s} {} "libmixe1a.o"}
897aea50 117 {"Helper 32bit object 1" "-r -melf_i386" ""
39334f3a 118 "--32" {mixed1b.s} {} "libmixe1b.o"}
897aea50 119 {"Helper 64bit object 2" "-r -melf_x86_64" ""
39334f3a 120 "--64" {mixed2a.s} {} "libmixe2a.o"}
897aea50 121 {"Helper 32bit object 2" "-r -melf_i386" ""
39334f3a 122 "--32" {mixed2b.s} {} "libmixe2b.o"}
897aea50
MR
123 {"Split by file with 'l' flag on section."
124 "-split-by-file -r -melf_x86_64" ""
3dbcc61d
NC
125 "--64" {split-by-file1.s split-by-file2.s}
126 {{readelf -SW split-by-file.rd}} "split-by-file.o"}
897aea50 127 {"TLS X32 IE->LE transition" "-melf32_x86_64" ""
4a4c5f25
L
128 "--x32" {tlsie4.s}
129 {{objdump -dwr tlsie4.dd}} "tlsie4"}
897aea50 130 {"TLS X32 GD->LE transition" "-melf32_x86_64" ""
52bc799a
L
131 "--x32" {tlsgd4.s}
132 {{objdump -dwr tlsgd4.dd}} "tlsgd4"}
897aea50 133 {"Helper TLS GD->IE transition DSO" "-shared -melf_x86_64" ""
52bc799a 134 "--64" {tlsgd5b.s} {} "libtlsgd5.so"}
897aea50 135 {"TLS GD->IE transition" "-melf_x86_64 tmpdir/libtlsgd5.so" ""
52bc799a 136 "--64" {tlsgd5a.s}
e2cbcd91
L
137 {{objdump -dwr tlsgd5.dd}} "tlsgd5a"}
138 {"TLS GD->IE transition without PLT"
139 "-melf_x86_64 tmpdir/libtlsgd5.so" ""
140 "-mrelax-relocations=yes --64" {tlsgd5c.s}
141 {{objdump -dwr tlsgd5.dd}} "tlsgd5b"}
897aea50 142 {"Helper TLS X32 GD->IE transition DSO" "-shared -melf32_x86_64" ""
52bc799a 143 "--x32" {tlsgd6b.s} {} "libtlsgd6.so"}
897aea50 144 {"TLS X32 GD->IE transition" "-melf32_x86_64 tmpdir/libtlsgd6.so" ""
52bc799a 145 "--x32" {tlsgd6a.s}
e2cbcd91
L
146 {{objdump -dwr tlsgd6.dd}} "tlsgd6a"}
147 {"TLS X32 GD->IE transition without PLT"
148 "-melf32_x86_64 tmpdir/libtlsgd6.so" ""
149 "-mrelax-relocations=yes --x32" {tlsgd6c.s}
150 {{objdump -dwr tlsgd6.dd}} "tlsgd6b"}
897aea50 151 {"TLS X32 LD->LE transition" "-melf32_x86_64" ""
52bc799a
L
152 "--x32" {tlsld2.s}
153 {{objdump -dwr tlsld2.dd}} "tlsld2"}
5c98a14e
JJ
154 {"TLS -mcmodel=large GD->LE transition" "-melf_x86_64" ""
155 "--64" {tlsgd7.s}
156 {{objdump -dwr tlsgd7.dd}} "tlsgd7"}
157 {"TLS -mcmodel=large LD->LE transition" "-melf_x86_64" ""
158 "--64" {tlsld3.s}
159 {{objdump -dwr tlsld3.dd}} "tlsld3"}
e2cbcd91
L
160 {"TLS -mcmodel=large LD->LE transition with r15 as GOT base"
161 "-melf_x86_64" ""
162 "--64" {tlsld4.s}
163 {{objdump -dwr tlsld4.dd}} "tlsld4"}
164 {"TLS LD->LE transition without PLT"
165 "-melf_x86_64" ""
166 "--64 -mrelax-relocations=yes"
167 {tlsld5.s}
168 {{objdump -dwr tlsld5.dd}} "tlsld5"}
169 {"TLS X32 LD->LE transition without PLT" "-melf32_x86_64" ""
170 "--x32 -mrelax-relocations=yes"
171 {tlsld6.s}
172 {{objdump -dwr tlsld6.dd}} "tlsld6"}
5c98a14e
JJ
173 {"TLS -mcmodel=large GD->IE transition" "-melf_x86_64 tmpdir/libtlsgd5.so" ""
174 "--64" {tlsgd8.s}
175 {{objdump -dwrj.text tlsgd8.dd}} "tlsgd8"}
e2cbcd91
L
176 {"TLS -mcmodel=large GD->LE transition with r15 as GOT base"
177 "-melf_x86_64" ""
178 "--64" {tlsgd9.s}
179 {{objdump -dwr tlsgd9.dd}} "tlsgd9"}
180 {"TLS -mcmodel=large GD->IE transition with r15 as GOT base"
181 "-melf_x86_64 tmpdir/libtlsgd5.so" ""
182 "--64" {tlsgd10.s}
183 {{objdump -dwrj.text tlsgd10.dd}} "tlsgd10"}
184 {"TLS GD->LE transition without PLT"
185 "-melf_x86_64" ""
186 "--64" {tlsgd11.s}
187 {{objdump -dwr tlsgd11.dd}} "tlsgd11"}
188 {"TLS X32 GD->LE transition without PLT"
189 "-melf32_x86_64" ""
190 "--x32" {tlsgd14.s}
191 {{objdump -dwr tlsgd14.dd}} "tlsgd14"}
897aea50
MR
192 {"build 32-bit object with 33 locals" "-melf_x86_64 -e 0" "" "--32" {32bit.s} {{ ld incompatible.l }} "dummy" }
193 {"build 64-bit object" "-melf_x86_64 -e 0 --defsym foo=1" "" "--64" {64bit.s} {} "dummy" }
194 {"link mixed objects" "-melf_x86_64 -e 0 tmpdir/32bit.o tmpdir/64bit.o" "" "" {} { { ld incompatible.l } } "mixed"}
29a9f53e
L
195 {"PR ld/17313 (1)" "-melf_x86_64" ""
196 "--64" {dummy.s} {} ""}
197 {"PR ld/17313 (2)" "-melf_x86_64 -shared --just-symbols=tmpdir/dummy.o" ""
198 "--64" {lea1.s} {} "libpr17313.so"}
c8831961
L
199 {"PR ld/17306 (1)" "-melf_x86_64" ""
200 "--64" {pr17306b.s} {} ""}
201 {"PR ld/17306 (2)" "-melf_x86_64 -shared -Bsymbolic --just-symbols=tmpdir/pr17306b.o" ""
202 "--64" {pr17306a.s} {} "libpr17306.so"}
f7483970
L
203 {"PR ld/17709 (1)" "-melf_x86_64 -shared" ""
204 "--64" {pr17709a.s} {} "libpr17709.so"}
205 {"PR ld/17709 (2)" "-melf_x86_64 tmpdir/libpr17709.so" ""
206 "--64" {pr17709b.s} {{readelf -rW pr17709.rd}} "pr17709"}
4e0c91e4
L
207 {"Build pr19827a.o" "" ""
208 "--64" { pr19827a.S }}
209 {"Build pr19827b.so" "-melf_x86_64 -shared" ""
210 "--64" { pr19827b.S } {} "pr19827b.so"}
211 {"Build pr19827" "-melf_x86_64 -pie tmpdir/pr19827a.o tmpdir/pr19827b.so" ""
212 "--64" { dummy.s } {{readelf {-rW} pr19827.rd}} "pr19827"}
213 {"Build pr19827.so" "-melf_x86_64 -shared -Bsymbolic" ""
214 "--64" { pr19827a.S } {{readelf {-rW} pr19827.rd}} "pr19827.so"}
338c190a
L
215 {"Build pr19969.so" "-melf_x86_64 -shared" ""
216 "--64" { pr19969a.S } {} "pr19969.so"}
d8457a04
L
217 {"Build pr20550a.o" "" ""
218 "--64" { pr20550a.s }}
219 {"Build pr20550b.so" "-melf_x86_64 -shared" ""
220 "--64" { pr20550b.s } {} "pr20550b.so"}
221 {"Build pr20550" "-melf_x86_64 -pie tmpdir/pr20550a.o tmpdir/pr20550b.so" ""
222 "--64" { dummy.s } {} "pr20550"}
5a68afcf
RM
223}
224
225# So as to avoid rewriting every last test case here in a nacl variant,
226# we use black magic to massage the generic cases into nacl-variant cases.
227if [istarget "*-*-nacl*"] {
228 set emul elf_x86_64_nacl
229
230 set lhs {elf(32)?_(i386|x86_64)[[:>:]]}
231 set rhs {&_nacl}
232
233 # Change all the -melf_x86_64 to -melf_x86_64_nacl so linking can succeed.
234 regsub -all -- $lhs $x86_64tests $rhs x86_64tests
235
7c9f387a
L
236 set zlhs {-z noseparate-code -z max-page-size=0x200000}
237 set zrhs {}
238
239 # Remove -z max-page-size=0x200000 -z noseparate-code since they
240 # generate different addresses for nacl targets.
241 regsub -all -- $zlhs $x86_64tests $zrhs x86_64tests
242
5a68afcf
RM
243 # Same, applied to all the run_dump_test cases.
244 set options_regsub(ld) [list $lhs $rhs]
245
246 # The section/segment layout differs too much for the vanilla
247 # readelf output files to match. So massage the cases so that
248 # they refer to a foo-nacl.rd file instead of a foo.rd file.
249 regsub -all -- {([a-z0-9]+)\.rd} $x86_64tests {\1-nacl.rd} x86_64tests
250
251 # Likewise for PLTs.
252 regsub -all -- {([a-z0-9]+)\.pd} $x86_64tests {\1-nacl.pd} x86_64tests
253} else {
254 set emul elf_x86_64
bffbf940
JJ
255}
256
257run_ld_link_tests $x86_64tests
ac2aa337 258
39334f3a
L
259global link_output
260global ld
261
b51176f1 262set test_name "Mixed x86_64 and i386 input test 1"
39334f3a 263set test mixed1
d9816402 264if { ![ld_link $ld tmpdir/$test "-m$emul tmpdir/${test}a.o tmpdir/${test}b.o"] } {
64b384e1 265 if [string match "*i386* architecture of input file `tmpdir/${test}b.o' is incompatible with i386:x86-64* output*" $link_output] {
5a68afcf 266 pass "$test_name"
39334f3a 267 } {
5a68afcf 268 fail "$test_name"
39334f3a
L
269 }
270}
271
b51176f1 272set test_name "Mixed x86_64 and i386 input test 2"
39334f3a 273set test mixed2
d9816402 274if { ![ld_link $ld tmpdir/$test "-m$emul tmpdir/${test}a.o tmpdir/${test}b.o"] } {
64b384e1 275 if [string match "*i386* architecture of input file `tmpdir/${test}b.o' is incompatible with i386:x86-64* output*" $link_output] {
5a68afcf 276 pass "$test_name"
39334f3a 277 } {
5a68afcf 278 fail "$test_name"
39334f3a
L
279 }
280}
281
ac2aa337 282run_dump_test "abs"
8a9036a4 283run_dump_test "abs-l1om"
43083a50 284run_dump_test "apic"
ac2aa337
JB
285run_dump_test "pcrel8"
286run_dump_test "pcrel16"
dd1093aa
L
287run_dump_test "tlsgd2"
288run_dump_test "tlsgd3"
e2cbcd91
L
289run_dump_test "tlsgd12"
290run_dump_test "tlsgd13"
dd1093aa
L
291run_dump_test "tlsie2"
292run_dump_test "tlsie3"
41bed6dd
L
293run_dump_test "hidden1"
294run_dump_test "hidden2"
295run_dump_test "hidden3"
e3c0e327
L
296run_dump_test "hidden4"
297run_dump_test "hidden5"
41bed6dd
L
298run_dump_test "protected1"
299run_dump_test "protected2"
8a9036a4 300run_dump_test "protected2-l1om"
41bed6dd 301run_dump_test "protected3"
8a9036a4 302run_dump_test "protected3-l1om"
bdb892b9
L
303run_dump_test "protected4"
304run_dump_test "protected5"
e3c0e327 305run_dump_test "protected6a"
889c2a67 306run_dump_test "protected6b"
3d949995
L
307run_dump_test "protected7a"
308run_dump_test "protected7b"
73784fa5 309run_dump_test "protected8"
9b769489 310run_dump_test "tlsle1"
1d85728f 311run_dump_test "tlspie1"
e2cbcd91
L
312run_dump_test "tlspie2a"
313run_dump_test "tlspie2b"
314run_dump_test "tlspie2c"
6f8bcf84 315run_dump_test "unique1"
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"
aed64b35 321run_dump_test "pr13947"
2fe0fd06
L
322run_dump_test "pr12570a"
323run_dump_test "pr12570b"
17d6eea5 324run_dump_test "pr14215"
8981c88a 325run_dump_test "pr14207"
553d1284 326run_dump_test "gotplt1"
6333bc0d 327run_dump_test "pie1"
126697d1 328run_dump_test "pie2"
c5bb8910
L
329run_dump_test "pie3"
330run_dump_test "pie3-nacl"
03f2309a 331run_dump_test "pic1"
b8871f35
L
332run_dump_test "largecomm-1a"
333run_dump_test "largecomm-1b"
334run_dump_test "largecomm-1c"
335run_dump_test "largecomm-1d"
336run_dump_test "largecomm-1e"
337run_dump_test "largecomm-1f"
3ab94f96
L
338run_dump_test "pr19539a"
339run_dump_test "pr19539b"
4c10bbaa
L
340run_dump_test "pr19807-1a"
341run_dump_test "pr19807-1b"
342run_dump_test "pr19807-2a"
343run_dump_test "pr19807-2b"
344run_dump_test "pr19807-2c"
345run_dump_test "pr19807-2d"
346run_dump_test "pr19807-2e"
338c190a 347run_dump_test "pr19969"
2168b268
L
348run_dump_test "pr20093-1"
349run_dump_test "pr20093-2"
73caa85d 350run_dump_test "property-x86-3"
92f7d783
L
351run_dump_test "property-x86-4a"
352run_dump_test "property-x86-4b"
654f3b6a
L
353run_dump_test "property-x86-3-x32"
354run_dump_test "property-x86-4a-x32"
355run_dump_test "property-x86-4b-x32"
ee2fdd6f
L
356run_dump_test "property-x86-ibt1a"
357run_dump_test "property-x86-ibt1b"
358run_dump_test "property-x86-ibt1a-x32"
359run_dump_test "property-x86-ibt1b-x32"
360run_dump_test "property-x86-ibt2"
361run_dump_test "property-x86-ibt2-x32"
362run_dump_test "property-x86-ibt3a"
363run_dump_test "property-x86-ibt3b"
364run_dump_test "property-x86-ibt3a-x32"
365run_dump_test "property-x86-ibt3b-x32"
366run_dump_test "property-x86-ibt4"
367run_dump_test "property-x86-ibt4-x32"
368run_dump_test "property-x86-ibt5"
369run_dump_test "property-x86-ibt5-x32"
48580982
L
370run_dump_test "property-x86-shstk1a"
371run_dump_test "property-x86-shstk1b"
372run_dump_test "property-x86-shstk1a-x32"
373run_dump_test "property-x86-shstk1b-x32"
374run_dump_test "property-x86-shstk2"
375run_dump_test "property-x86-shstk2-x32"
376run_dump_test "property-x86-shstk3a"
377run_dump_test "property-x86-shstk3b"
378run_dump_test "property-x86-shstk3a-x32"
379run_dump_test "property-x86-shstk3b-x32"
380run_dump_test "property-x86-shstk4"
381run_dump_test "property-x86-shstk4-x32"
382run_dump_test "property-x86-shstk5"
383run_dump_test "property-x86-shstk5-x32"
9593aade 384run_dump_test "pr21884"
34c4758c 385run_dump_test "pr21884-nacl"
0e30d991 386run_dump_test "pr22071"
0a27fed7
L
387run_dump_test "pr22115-1a"
388run_dump_test "pr22115-1a-x32"
389run_dump_test "pr22115-1b"
390run_dump_test "pr22115-1b-x32"
391run_dump_test "pr22115-1c"
392run_dump_test "pr22115-1c-x32"
393run_dump_test "pr22115-1d"
394run_dump_test "pr22115-1d-x32"
5e5e02ae 395run_dump_test "pr22135"
cd048363
L
396run_dump_test "pr22782a"
397run_dump_test "pr22782b"
941036f4 398run_dump_test "pr23189"
97373b2e 399run_dump_test "pr23194"
b638b5d5
L
400run_dump_test "pr23324a"
401run_dump_test "pr23324b"
25d17eb4 402
5a68afcf 403if { ![istarget "x86_64-*-linux*"] && ![istarget "x86_64-*-nacl*"]} {
25d17eb4
L
404 return
405}
406
5a68afcf 407if ![ld_assemble $as "--x32 $srcdir/$subdir/start.s" tmpdir/startx32.o] {
889a4d3e
L
408 unresolved "Build ILP32 start.o"
409 return
410}
411
5a68afcf 412if ![ld_assemble $as "--32 $srcdir/$subdir/start.s" tmpdir/start32.o] {
889a4d3e
L
413 unresolved "Build ia32 start.o"
414 return
415}
416
5a68afcf 417if ![ld_assemble $as "--64 $srcdir/$subdir/start.s" tmpdir/start64.o] {
889a4d3e
L
418 unresolved "Build LP64 start.o"
419 return
420}
421
5a68afcf 422if ![ld_assemble $as "--x32 $srcdir/$subdir/foo.s" tmpdir/foox32.o] {
889a4d3e
L
423 unresolved "Build ILP32 foo.o"
424 return
425}
426
5a68afcf 427if ![ld_assemble $as "--32 $srcdir/$subdir/foo.s" tmpdir/foo32.o] {
889a4d3e
L
428 unresolved "Build ia32 foo.o"
429 return
430}
431
5a68afcf 432if ![ld_assemble $as "--64 $srcdir/$subdir/foo.s" tmpdir/foo64.o] {
889a4d3e
L
433 unresolved "Build LP64 foo.o"
434 return
435}
436
25d17eb4 437run_dump_test "compressed1"
889a4d3e
L
438run_dump_test "ilp32-1"
439run_dump_test "ilp32-2"
440run_dump_test "ilp32-3"
82e96e07 441run_dump_test "ilp32-4"
5a68afcf 442run_dump_test "ilp32-4-nacl"
248775ba 443run_dump_test "ilp32-5"
d7921315
L
444run_dump_test "ilp32-6"
445run_dump_test "ilp32-7"
446run_dump_test "ilp32-8"
447run_dump_test "ilp32-9"
df4f9443 448run_dump_test "ilp32-10"
8cf0d2dd 449run_dump_test "ilp32-11"
889a4d3e
L
450run_dump_test "ia32-1"
451run_dump_test "ia32-2"
452run_dump_test "ia32-3"
453run_dump_test "lp64-1"
454run_dump_test "lp64-2"
455run_dump_test "lp64-3"
64d25c44
L
456run_dump_test "pr13082-1a"
457run_dump_test "pr13082-1b"
458run_dump_test "pr13082-2a"
459run_dump_test "pr13082-2b"
460run_dump_test "pr13082-3a"
461run_dump_test "pr13082-3b"
bae420ef
L
462run_dump_test "pr13082-3c"
463run_dump_test "pr13082-3d"
64d25c44
L
464run_dump_test "pr13082-4a"
465run_dump_test "pr13082-4b"
466run_dump_test "pr13082-5a"
467run_dump_test "pr13082-5b"
468run_dump_test "pr13082-6a"
469run_dump_test "pr13082-6b"
80d87326
L
470run_dump_test "lea1a"
471run_dump_test "lea1b"
472run_dump_test "lea1c"
473run_dump_test "lea1d"
474run_dump_test "lea1e"
475run_dump_test "lea1f"
daa67607
L
476run_dump_test "lea1g"
477run_dump_test "lea1h"
478run_dump_test "lea1i"
479run_dump_test "lea1j"
480run_dump_test "lea1k"
481run_dump_test "lea1l"
3f65f599
L
482run_dump_test "mov1a"
483run_dump_test "mov1b"
484run_dump_test "mov1c"
485run_dump_test "mov1d"
02e2aef8
L
486run_dump_test "mov2a"
487run_dump_test "mov2b"
488run_dump_test "mov2c"
489run_dump_test "mov2d"
56ceb5b5
L
490run_dump_test "load1a"
491run_dump_test "load1b"
492run_dump_test "load1c"
493run_dump_test "load1d"
caa65211
L
494run_dump_test "load1a-nacl"
495run_dump_test "load1b-nacl"
496run_dump_test "load1c-nacl"
497run_dump_test "load1d-nacl"
2856a627 498run_dump_test "load2"
caa65211
L
499run_dump_test "call1a"
500run_dump_test "call1b"
501run_dump_test "call1c"
502run_dump_test "call1d"
503run_dump_test "call1e"
504run_dump_test "call1f"
505run_dump_test "call1g"
506run_dump_test "call1h"
507run_dump_test "call1i"
1952c5cd
L
508run_dump_test "pr17935-1"
509run_dump_test "pr17935-2"
b19a8f85 510run_dump_test "pr18160"
875b5b9d 511run_dump_test "pr18176"
8efa2874 512run_dump_test "pr18801"
13a2df29 513run_dump_test "pr18815"
9865bd0d
L
514run_dump_test "pr19013"
515run_dump_test "pr19013-x32"
516run_dump_test "pr19013-nacl"
7963511f 517run_dump_test "pr19162"
7b7e7f1d 518run_dump_test "pr19175"
6ba2af25 519run_dump_test "pr18591"
e20365c5 520run_dump_test "pr19615"
aec6b87e
L
521run_dump_test "pr19636-1a"
522run_dump_test "pr19636-1b"
523run_dump_test "pr19636-1c"
524run_dump_test "pr19636-1d"
525run_dump_test "pr19636-1e"
526run_dump_test "pr19636-1f"
527run_dump_test "pr19636-1g"
853ee16f
L
528run_dump_test "pr19636-1h"
529run_dump_test "pr19636-1i"
530run_dump_test "pr19636-1j"
aec6b87e
L
531run_dump_test "pr19636-2a"
532run_dump_test "pr19636-2b"
533run_dump_test "pr19636-2c"
534run_dump_test "pr19636-2d"
535run_dump_test "pr19636-2d-nacl"
536run_dump_test "pr19636-2e"
537run_dump_test "pr19636-2f"
538run_dump_test "pr19636-2g"
539run_dump_test "pr19636-2h"
540run_dump_test "pr19636-2i"
853ee16f
L
541run_dump_test "pr19636-2j"
542run_dump_test "pr19636-2k"
543run_dump_test "pr19636-2l"
544run_dump_test "pr19636-2m"
aec6b87e
L
545run_dump_test "pr19636-3a"
546run_dump_test "pr19636-3b"
547run_dump_test "pr19636-3c"
b8871f35 548run_dump_test "pr19645"
bae420ef
L
549run_dump_test "pr19609-1a"
550run_dump_test "pr19609-1b"
551run_dump_test "pr19609-1c"
552run_dump_test "pr19609-1d"
553run_dump_test "pr19609-1e"
554run_dump_test "pr19609-1f"
555run_dump_test "pr19609-1g"
556run_dump_test "pr19609-1h"
557run_dump_test "pr19609-1i"
558run_dump_test "pr19609-1j"
559run_dump_test "pr19609-1k"
560run_dump_test "pr19609-1l"
561run_dump_test "pr19609-1m"
562run_dump_test "pr19609-2a"
563run_dump_test "pr19609-2b"
564run_dump_test "pr19609-2c"
565run_dump_test "pr19609-2d"
566run_dump_test "pr19609-3a"
567run_dump_test "pr19609-3b"
568run_dump_test "pr19609-4a"
569run_dump_test "pr19609-4b"
570run_dump_test "pr19609-4c"
571run_dump_test "pr19609-4d"
572run_dump_test "pr19609-4e"
573run_dump_test "pr19609-5a"
574run_dump_test "pr19609-5b"
575run_dump_test "pr19609-5c"
576run_dump_test "pr19609-5d"
577run_dump_test "pr19609-5e"
578run_dump_test "pr19609-6a"
579run_dump_test "pr19609-6b"
580run_dump_test "pr19609-6c"
581run_dump_test "pr19609-6d"
582run_dump_test "pr19609-7a"
583run_dump_test "pr19609-7b"
584run_dump_test "pr19609-7c"
585run_dump_test "pr19609-7d"
2df3368d
L
586run_dump_test "pr19939a"
587run_dump_test "pr19939b"
87d455c0 588run_dump_test "pr19719"
233cc9c1
L
589run_dump_test "pr20253-1a"
590run_dump_test "pr20253-1b"
591run_dump_test "pr20253-1c"
592run_dump_test "pr20253-1d"
593run_dump_test "pr20253-1e"
594run_dump_test "pr20253-1f"
595run_dump_test "pr20253-1g"
596run_dump_test "pr20253-1h"
597run_dump_test "pr20253-1i"
598run_dump_test "pr20253-1j"
599run_dump_test "pr20253-1k"
600run_dump_test "pr20253-1l"
601run_dump_test "pr20253-3"
602run_dump_test "pr20253-4a"
603run_dump_test "pr20253-4b"
604run_dump_test "pr20253-4c"
605run_dump_test "pr20253-4d"
606run_dump_test "pr20253-4e"
607run_dump_test "pr20253-4f"
608run_dump_test "pr20253-5a"
609run_dump_test "pr20253-5b"
97d343d4 610run_dump_test "tlsdesc2"
d7de6408 611run_dump_test "pr22048"
347a8774 612run_dump_test "pr22929"
aec6b87e
L
613
614proc undefined_weak {cflags ldflags} {
615 set testname "Undefined weak symbol"
616 if { ![ string match "" $cflags$ldflags] } {
617 set testname "$testname ($cflags $ldflags)"
618 }
619
074f6066
L
620 if { [string match "*-fPIE*" $cflags]
621 && ![string match "*nodynamic-undefined-weak*" $ldflags] } {
aec6b87e
L
622 set weak_symbol "Weak defined"
623 } else {
624 set weak_symbol "Weak undefined"
625 }
626
627 run_cc_link_tests [list \
628 [list \
629 "Build libpr19704a.so" \
630 "-shared -Wl,-soname,libpr19704.so" \
631 "" \
632 { dummy.s } \
633 {} \
634 "libpr19704a.so" \
635 ] \
636 [list \
637 "Build libpr19704b.so" \
638 "-shared -Wl,-soname,libpr19704.so" \
639 "-fPIC" \
640 { pr19704b.c } \
641 {} \
642 "libpr19704b.so" \
643 ] \
644 ]
645
646 exec cp tmpdir/libpr19704a.so tmpdir/libpr19704.so
647
982c6f26 648 run_ld_link_exec_tests [list \
aec6b87e
L
649 [list \
650 "Run pr19704" \
d9816402 651 "-Wl,--no-as-needed,-R,tmpdir $ldflags tmpdir/libpr19704.so" \
aec6b87e
L
652 "" \
653 { pr19704a.c } \
654 "pr19704" \
655 "pr19704.out" \
656 "$cflags" \
657 ] \
658 ]
659
660 exec cp tmpdir/libpr19704b.so tmpdir/libpr19704.so
661
662 set exec_output [run_host_cmd tmpdir/pr19704 ""]
663 if {![string match $weak_symbol $exec_output]} {
664 fail $testname
665 } else {
666 pass $testname
667 }
668}
adc7571d 669
ea9fb8b3
L
670# Add $PLT_CFLAGS if PLT is expected.
671global PLT_CFLAGS
a7eaf017
L
672# Add $NOPIE_CFLAGS and $NOPIE_LDFLAGS if non-PIE is required.
673global NOPIE_CFLAGS NOPIE_LDFLAGS
ea9fb8b3 674
56d4d7f2
L
675# Must be native with the C compiler
676if { [isnative] && [which $CC] != 0 } {
adc7571d
L
677 run_cc_link_tests {
678 {"Helper X32 DSO from x86-64 object" "" "-m64 -fPIC -g"
679 {simple.c} {} "libsimple.a"}
680 }
681
682 set convertx32 "$objcopy -O elf32-x86-64 tmpdir/simple.o tmpdir/simple-x32.o"
683 send_log "$convertx32\n"
684 set got [remote_exec host "$convertx32"]
685 if { [lindex $got 0] != 0 || ![string match "" [lindex $got 1]] } then {
686 send_log "$got\n"
687 fail "Convert x86-64 object to x32"
688 return
689 }
690
691 run_ld_link_tests {
692 {"X32 DSO from x86-64 object"
897aea50 693 "-shared -melf32_x86_64 tmpdir/simple-x32.o" "" "--x32"
adc7571d
L
694 {dummy.s} {{readelf {-s --wide} x86-64-x32.rd}} "x86-64-x32"}
695 }
76e7af5f
L
696
697 run_cc_link_tests [list \
698 [list \
699 "Build plt-lib.so" \
700 "-shared" \
701 "-fPIC" \
702 { plt-lib.c } \
703 {} \
704 "libplt-lib.so" \
705 ] \
706 [list \
707 "Build libplt-main1.a" \
708 "" \
0cb4071e 709 "-fPIC -Wa,-mrelax-relocations=yes" \
76e7af5f
L
710 { plt-main1.c } \
711 {{readelf {-Wr} plt-main1.rd}} \
712 "libplt-main1.a" \
713 ] \
714 [list \
715 "Build libplt-main2.a" \
716 "" \
0cb4071e 717 "-fPIC -Wa,-mrelax-relocations=yes" \
76e7af5f
L
718 { plt-main2.c } \
719 {{readelf {-Wr} plt-main2.rd}} \
720 "libplt-main2.a" \
721 ] \
722 [list \
723 "Build libplt-main3.a" \
724 "" \
0cb4071e 725 "-fPIC -Wa,-mrelax-relocations=yes $PLT_CFLAGS" \
76e7af5f
L
726 { plt-main3.c } \
727 {{readelf {-Wr} plt-main3.rd}} \
728 "libplt-main3.a" \
729 ] \
730 [list \
731 "Build libplt-main4.a" \
732 "" \
0cb4071e 733 "-fPIC -Wa,-mrelax-relocations=yes $PLT_CFLAGS" \
76e7af5f
L
734 { plt-main4.c } \
735 {{readelf {-Wr} plt-main4.rd}} \
736 "libplt-main4.a" \
737 ] \
dd7e64d4
L
738 [list \
739 "Build plt-main" \
740 "tmpdir/plt-main1.o tmpdir/plt-main2.o tmpdir/plt-main3.o \
741 tmpdir/plt-main4.o tmpdir/libplt-lib.so" \
742 "" \
743 { plt-main5.c } \
744 {{readelf {-Wr} plt-main.rd}} \
745 "plt-main" \
746 ] \
747 [list \
748 "Build plt-main with PIE" \
749 "tmpdir/plt-main1.o tmpdir/plt-main2.o tmpdir/plt-main3.o \
750 tmpdir/plt-main4.o tmpdir/libplt-lib.so -pie" \
751 "-fPIC" \
752 { plt-main5.c } \
753 {{readelf {-Wr} plt-main.rd}} \
754 "plt-main" \
755 ] \
9a926d55
L
756 [list \
757 "Build copyreloc-lib.so" \
758 "-shared" \
759 "-fPIC" \
760 { copyreloc-lib.c } \
761 {} \
762 "copyreloc-lib.so" \
763 ] \
764 [list \
46175b4e
L
765 "Build libcopyreloc-main.a" \
766 "" \
9a926d55 767 "" \
01bbed2a 768 { copyreloc-main.S } \
46175b4e
L
769 {} \
770 "libcopyreloc-main.a" \
771 ] \
772 [list \
773 "Build copyreloc-main with PIE without -fPIE (1)" \
774 "tmpdir/copyreloc-main.o tmpdir/copyreloc-lib.so -pie" \
775 "" \
776 { dummy.s } \
9a926d55
L
777 {{readelf {-Wr} copyreloc-main1.rd}} \
778 "copyreloc-main" \
779 ] \
780 [list \
781 "Build copyreloc-main with PIE without -fPIE (2)" \
46175b4e 782 "tmpdir/copyreloc-main.o tmpdir/copyreloc-lib.so -pie" \
9a926d55 783 "" \
46175b4e 784 { dummy.s } \
9a926d55
L
785 {{readelf {-Wr} copyreloc-main2.rd}} \
786 "copyreloc-main" \
787 ] \
bc696fd5
L
788 [list \
789 "Build pr17689.so" \
790 "-shared" \
791 "-fPIC" \
792 { pr17689a.c } \
793 {} \
794 "pr17689.so" \
795 ] \
25070364
L
796 [list \
797 "Build pr17689now.so with -z now" \
798 "-shared -Wl,-z,now" \
799 "-fPIC" \
800 { pr17689a.c } \
801 {{readelf {-Wr} pr17689now.rd}} \
802 "pr17689now.so" \
803 ] \
bc696fd5 804 [list \
37ce0cc4
L
805 "Build pr17689b.o" \
806 "" \
bc696fd5
L
807 "" \
808 { pr17689b.S } \
37ce0cc4
L
809 {} \
810 ] \
811 [list \
812 "Build pr17689 with PIE without -fPIE" \
813 "tmpdir/pr17689b.o tmpdir/pr17689.so -pie" \
814 "" \
815 { dummy.s } \
bc696fd5
L
816 {{readelf {-Wr} pr17689.rd}} \
817 "pr17689" \
818 ] \
25070364
L
819 [list \
820 "Build pr17689 with PIE -z now without -fPIE" \
37ce0cc4 821 "tmpdir/pr17689b.o tmpdir/pr17689.so -pie -Wl,-z,now" \
25070364 822 "" \
37ce0cc4 823 { dummy.s } \
25070364
L
824 {{readelf {-Wr} pr17689now.rd}} \
825 "pr17689now" \
826 ] \
9d1d54d5
L
827 [list \
828 "Build pr17827 with PIE without -fPIE" \
37ce0cc4 829 "-Wl,--as-needed tmpdir/pr17689b.o tmpdir/pr17689.so -pie" \
9d1d54d5 830 "" \
37ce0cc4 831 { dummy.s } \
9d1d54d5
L
832 {{readelf {-Wr} pr17827.rd}} \
833 "pr17827" \
834 ] \
04ebc307
L
835 [list \
836 "Build pr18900.so" \
837 "-shared" \
838 "-fPIC" \
839 { pr18900a.c } \
840 "" \
841 "pr18900.so" \
842 ] \
843 [list \
23a4bd22
L
844 "Build pr18900.o" \
845 "-r -nostdlib" \
04ebc307
L
846 "" \
847 { pr18900b.c pr18900c.c } \
23a4bd22
L
848 "" \
849 "pr18900.o" \
850 ] \
851 [list \
852 "Build pr18900a" \
853 "tmpdir/pr18900.o tmpdir/pr18900.so" \
854 "" \
855 { dummy.s } \
04ebc307
L
856 {{readelf {-Wrd} pr18900a.rd}} \
857 "pr18900a" \
858 ] \
859 [list \
860 "Build pr18900b" \
23a4bd22 861 "-Wl,--as-needed tmpdir/pr18900.o tmpdir/pr18900.so" \
04ebc307 862 "" \
23a4bd22 863 { dummy.s } \
04ebc307
L
864 {{readelf {-Wrd} pr18900b.rd}} \
865 "pr18900b" \
866 ] \
5db4f0d3
L
867 [list \
868 "Build pr19031.so" \
869 "-shared" \
870 "-fPIC" \
871 { pr19031a.c } \
872 "" \
873 "pr19031.so" \
874 ] \
56ceb5b5
L
875 [list \
876 "Build gotpcrel1d.so" \
877 "-shared" \
878 "" \
879 { gotpcrel1d.S } \
880 "" \
881 "gotpcrel1d.so" \
882 ] \
37ce0cc4 883 [list \
b1058ce9 884 "Build gotpcrel1a.o gotpcrel1b.o gotpcrel1c.o" \
37ce0cc4 885 "" \
b1058ce9 886 "-Wa,-mrelax-relocations=yes" \
37ce0cc4 887 { gotpcrel1a.S gotpcrel1b.c gotpcrel1c.c } \
37ce0cc4 888 ] \
56ceb5b5
L
889 [list \
890 "Build gotpcrel1" \
68193357
L
891 "$NOPIE_LDFLAGS -Wl,--as-needed tmpdir/gotpcrel1a.o \
892 tmpdir/gotpcrel1b.o tmpdir/gotpcrel1c.o \
893 tmpdir/gotpcrel1d.so" \
37ce0cc4 894 { dummy.s } \
b1058ce9 895 "" \
56ceb5b5
L
896 {{objdump {-dw} gotpcrel1.dd}} \
897 "gotpcrel1" \
898 ] \
ead3d542
L
899 [list \
900 "Build pr19319.so" \
901 "-shared" \
902 "" \
903 { pr19319a.S } \
904 "" \
905 "pr19319.so" \
906 ] \
907 [list \
908 "Build pr19319" \
909 "-pie -nostdlib -nostartfiles tmpdir/pr19319.so" \
910 "" \
911 { pr19319b.S } \
912 {{objdump {-dw} pr19319.dd}} \
913 "pr19319" \
914 ] \
46bed679
L
915 [list \
916 "Build property 1" \
917 "" \
918 "" \
919 {pass.c property-no-copy.S} \
920 {{readelf {-n} property-1.r}} \
921 "property-1" \
922 ] \
923 [list \
924 "Build property 1 (.o)" \
925 "-r -nostdlib" \
926 "" \
927 {pass.c property-no-copy.S} \
928 {{readelf {-n} property-1.r}} \
929 "property-1.o" \
930 ] \
931 [list \
932 "Build property 1 (.so)" \
933 "-shared" \
934 "-fPIC" \
935 {pass.c property-no-copy.S} \
936 {{readelf {-n} property-1.r}} \
937 "property-1.so" \
938 ] \
939 [list \
940 "Build property 2" \
941 "" \
942 "" \
943 {pass.c property-stack.S} \
944 {{readelf {-n} property-2.r}} \
945 "property-2" \
946 ] \
947 [list \
948 "Build property 2 (.o)" \
949 "-r -nostdlib" \
950 "" \
951 {pass.c property-stack.S} \
952 {{readelf {-n} property-2.r}} \
953 "property-2.o" \
954 ] \
955 [list \
956 "Build property 2 (.so)" \
957 "-shared" \
958 "-fPIC" \
959 {pass.c property-stack.S} \
960 {{readelf {-n} property-2.r}} \
961 "property-2.so" \
962 ] \
963 [list \
964 "Build property 3" \
965 "" \
966 "" \
967 {pass.c property-stack.S property-x86-1.S} \
968 {{readelf {-n} property-3.r}} \
969 "property-3" \
970 ] \
971 [list \
972 "Build property 3 (.o)" \
973 "-r -nostdlib" \
974 "" \
975 {pass.c property-x86-1.S property-stack.S} \
976 {{readelf {-n} property-3.r}} \
977 "property-3.o" \
978 ] \
979 [list \
980 "Build property 3 (.so)" \
981 "-shared" \
982 "-fPIC" \
983 {property-x86-1.S pass.c property-stack.S} \
984 {{readelf {-n} property-3.r}} \
985 "property-3.so" \
986 ] \
987 [list \
988 "Build property 4" \
989 "" \
990 "" \
991 {pass.c property-stack.S property-x86-1.S property-x86-2.S} \
992 {{readelf {-n} property-4.r}} \
993 "property-4" \
994 ] \
995 [list \
996 "Build property 4 (.o)" \
997 "-r -nostdlib" \
998 "" \
999 {pass.c property-x86-2.S property-x86-1.S property-stack.S} \
1000 {{readelf {-n} property-4.r}} \
1001 "property-4.o" \
1002 ] \
1003 [list \
1004 "Build property 4 (.so)" \
1005 "-shared" \
1006 "-fPIC" \
1007 {property-x86-2.S property-x86-1.S pass.c property-stack.S} \
1008 {{readelf {-n} property-4.r}} \
1009 "property-4.so" \
1010 ] \
1011 [list \
1012 "Build property 4 (-Wl,-z,stack-size=0)" \
1013 "-Wl,-z,stack-size=0" \
1014 "" \
1015 {pass.c property-stack.S property-x86-1.S property-x86-2.S} \
1016 {{readelf {-n} property-4.r}} \
1017 "property-4" \
1018 ] \
1019 [list \
1020 "Build property 5" \
1021 "-Wl,-z,stack-size=0x900000" \
1022 "" \
1023 {pass.c property-stack.S property-x86-1.S property-x86-2.S} \
1024 {{readelf {-n} property-5.r}} \
1025 "property-5" \
1026 ] \
1027 [list \
1028 "Build property 5 (.o)" \
1029 "-r -nostdlib -Wl,-z,stack-size=0x900000" \
1030 "" \
1031 {pass.c property-x86-2.S property-x86-1.S property-stack.S} \
1032 {{readelf {-n} property-5.r}} \
1033 "property-5.o" \
1034 ] \
1035 [list \
1036 "Build property 5 (.so)" \
1037 "-shared -Wl,-z,stack-size=0x900000" \
1038 "-fPIC" \
1039 {property-x86-2.S property-x86-1.S pass.c property-stack.S} \
1040 {{readelf {-n} property-5.r}} \
1041 "property-5.so" \
1042 ] \
1043 [list \
1044 "Build property-6.so" \
1045 "-shared" \
1046 "-fPIC" \
1047 {property-6a.c property-6c.S} \
1048 {{readelf {-n} property-6.r}} \
1049 "property-6.so" \
1050 ] \
1051 [list \
1052 "Build property-6.o" \
1053 "-r -nostdlib" \
1054 "" \
1055 {property-6b.c property-stack.S} \
1056 {{readelf {-n} property-2.r}} \
1057 "property-6.o" \
1058 ] \
1059 [list \
1060 "Build property-6" \
1061 "-Wl,--as-needed tmpdir/property-6.o tmpdir/property-6.so" \
1062 { dummy.s } \
1063 "" \
1064 {{readelf {-n} property-2.r}} \
1065 "property-6" \
1066 ] \
1067 [list \
1068 "Build property 7a (.o)" \
1069 "-r -nostdlib" \
1070 "" \
1071 {property-unsorted-1.S} \
1072 {{readelf {-n} property-7.r}} \
1073 "property-7a.o" \
1074 ] \
1075 [list \
1076 "Build property 7b (.o)" \
1077 "-r -nostdlib" \
1078 "" \
1079 {property-unsorted-2.S} \
1080 {{readelf {-n} property-7.r}} \
1081 "property-7b.o" \
1082 ] \
7073b5b9
L
1083 [list \
1084 "Build pr22001-1.so" \
1085 "-shared" \
1086 "-fPIC" \
1087 { pr22001-1a.c } \
1088 {} \
1089 "pr22001-1.so" \
1090 ] \
1091 [list \
1092 "Build pr22001-1a" \
1093 "$NOPIE_LDFLAGS -Wl,-z,nocopyreloc,--no-as-needed tmpdir/pr22001-1.so" \
1094 "$NOPIE_CFLAGS" \
1095 { pr22001-1b.c } \
1096 {{error_output "pr22001-1a.err"}} \
1097 "pr22001-1a" \
1098 ] \
a5b4ee94
L
1099 [list \
1100 "Build pr21997-1.so" \
1101 "-shared" \
1102 "" \
1103 { property-stack.S property-no-copy.S pr21997-1a.S } \
1104 {} \
1105 "pr21997-1.so" \
1106 ] \
1107 [list \
1108 "Build pr21997-1a" \
1109 "$NOPIE_LDFLAGS -Wl,--no-as-needed tmpdir/pr21997-1.so" \
1110 "$NOPIE_CFLAGS" \
1111 { pr21997-1b.c } \
1112 {{error_output "pr21997-1a.err"}} \
1113 "pr21997-1a" \
1114 ] \
ad71ce8d
L
1115 [list \
1116 "Build pr22064a.o" \
1117 "" \
1118 "" \
1119 { pr22064a.S } \
1120 ] \
1121 [list \
1122 "Build pr22064.so" \
1123 "-shared" \
1124 "-fPIC" \
1125 { pr22064b.c } \
1126 {} \
1127 "pr22064.so" \
1128 ] \
cf9e7f1f
L
1129 [list \
1130 "Build pr22393-3a.so" \
1131 "-shared -Wl,-z,separate-code,-z,max-page-size=0x1000" \
1132 "-fPIC" \
1133 {pr22393-3a.c} \
1134 {{readelf -lW pr22393-3a.rd} \
1135 {readelf -lW pr22393-3b.rd}} \
1136 "pr22393-3a.so" \
1137 ] \
1138 [list \
1139 "Build pr22393-3a-now.so" \
1140 "-shared -Wl,-z,separate-code,-z,now,-z,max-page-size=0x1000" \
1141 "-fPIC" \
1142 {pr22393-3a.c} \
1143 {{readelf -lW pr22393-3a.rd} \
1144 {readelf -lW pr22393-3b.rd}} \
1145 "pr22393-3a-now.so" \
1146 ] \
1147 [list \
1148 "Build pr22393-3" \
85f2093d 1149 "$NOPIE_LDFLAGS -Wl,-z,separate-code,-z,max-page-size=0x1000,--no-as-needed tmpdir/pr22393-3a.so" \
cf9e7f1f
L
1150 "$NOPIE_CFLAGS" \
1151 {pr22393-3b.c} \
1152 {{readelf -lW pr22393-3a.rd} \
1153 {readelf -lW pr22393-3b.rd}} \
1154 "pr22393-3" \
1155 ] \
1156 [list \
1157 "Build pr22393-3 (PIE)" \
85f2093d 1158 "-pie -Wl,-z,separate-code,-z,max-page-size=0x1000,--no-as-needed tmpdir/pr22393-3a-now.so" \
cf9e7f1f
L
1159 "-fPIE" \
1160 {pr22393-3b.c} \
1161 {{readelf -lW pr22393-3a.rd} \
1162 {readelf -lW pr22393-3b.rd}} \
1163 "pr22393-3-pie" \
1164 ] \
1165 [list \
1166 "Build pr22393-3 (static)" \
1167 "-static -Wl,-z,separate-code,-z,max-page-size=0x1000" \
1168 "" \
1169 {pr22393-3a.c pr22393-3b.c} \
1170 {{readelf -lW pr22393-3a.rd} \
1171 {readelf -lW pr22393-3b.rd}} \
1172 "pr22393-3-static" \
1173 ] \
bd7ab16b
L
1174 [list \
1175 "Build pr22791-1.so" \
1176 "-shared" \
1177 "-fPIC" \
1178 { pr22791-1a.c } \
1179 {} \
1180 "pr22791-1.so" \
1181 ] \
1182 [list \
1183 "Build pr22791-1" \
1184 "-pie -Wl,--no-as-needed tmpdir/pr22791-1.so" \
1185 "$NOPIE_CFLAGS" \
1186 { pr22791-1b.s } \
1187 {{error_output "pr22791-1.err"}} \
1188 "pr22791-1" \
1189 ] \
1190 [list \
1191 "Build pr22791-2a.o" \
1192 "" \
1193 "$NOPIE_CFLAGS" \
1194 { pr22791-2a.s } \
1195 ] \
1196 [list \
1197 "Build pr22791-2.so" \
1198 "-shared tmpdir/pr22791-2a.o" \
1199 "-fPIC" \
1200 { pr22791-2b.c } \
1201 {{readelf -drW pr22791-2.rd}} \
1202 "pr22791-2.so" \
1203 ] \
1204 [list \
1205 "Build pr22791-2" \
1206 "-pie -Wl,--no-as-needed tmpdir/pr22791-2.so" \
1207 "$NOPIE_CFLAGS" \
1208 { pr22791-2c.s } \
1209 {{readelf -drW pr22791-2.rd}} \
1210 "pr22791-2" \
1211 ] \
451875b4
L
1212 [list \
1213 "Build pr22842.so" \
1214 "-shared" \
1215 "-fPIC" \
1216 { pr22842a.c } \
1217 {} \
1218 "pr22842.so" \
1219 ] \
1220 [list \
1221 "Build pr22842" \
1222 "-pie -Wl,--no-as-needed tmpdir/pr22842.so" \
1223 "" \
1224 { pr22842b.S } \
1225 {{readelf -rW pr22842a.rd} \
1226 {readelf -rW pr22842b.rd}} \
1227 "pr22842" \
1228 ] \
76e7af5f
L
1229 ]
1230
28e6a46b
L
1231 if {[istarget "x86_64-*-linux*-gnux32"]} {
1232 run_ld_link_exec_tests [list \
1233 [list \
1234 "Run pr22001-1b" \
1235 "$NOPIE_LDFLAGS -Wl,-z,nocopyreloc,--no-as-needed tmpdir/pr22001-1.so" \
1236 "" \
1237 { pr22001-1c.c } \
1238 "pr22001-1b" \
1239 "pass.out" \
1240 "$NOPIE_CFLAGS" \
1241 ] \
a5b4ee94
L
1242 [list \
1243 "Run pr21997-1b" \
1244 "$NOPIE_LDFLAGS -Wl,--no-as-needed tmpdir/pr21997-1.so" \
1245 "" \
1246 { pr21997-1c.c } \
1247 "pr21997-1b" \
1248 "pass.out" \
1249 "$NOPIE_CFLAGS" \
1250 ] \
28e6a46b
L
1251 ]
1252 } else {
1253 run_cc_link_tests [list \
1254 [list \
1255 "Build pr22001-1b" \
1256 "$NOPIE_LDFLAGS -Wl,-z,nocopyreloc,--no-as-needed tmpdir/pr22001-1.so" \
1257 "$NOPIE_CFLAGS" \
1258 { pr22001-1c.c } \
1259 {{error_output "pr22001-1b.err"}} \
1260 "pr22001-1b" \
1261 ] \
a5b4ee94
L
1262 [list \
1263 "Build pr21997-1b" \
1264 "$NOPIE_LDFLAGS -Wl,--no-as-needed tmpdir/pr21997-1.so" \
1265 "$NOPIE_CFLAGS" \
1266 { pr21997-1c.c } \
1267 {{error_output "pr21997-1b.err"}} \
1268 "pr21997-1b" \
1269 ] \
28e6a46b
L
1270 ]
1271 }
1272
982c6f26 1273 run_ld_link_exec_tests [list \
76e7af5f
L
1274 [list \
1275 "Run plt-main" \
d9816402
AM
1276 "-Wl,--no-as-needed tmpdir/plt-main1.o tmpdir/plt-main2.o \
1277 tmpdir/plt-main3.o tmpdir/plt-main4.o tmpdir/libplt-lib.so" \
76e7af5f
L
1278 "" \
1279 { plt-main5.c } \
1280 "plt-main" \
1281 "plt-main.out" \
1282 ] \
ce641d0b
L
1283 [list \
1284 "Run plt-main with PIE" \
d9816402
AM
1285 "-Wl,--no-as-needed -pie tmpdir/plt-main1.o tmpdir/plt-main2.o \
1286 tmpdir/plt-main3.o tmpdir/plt-main4.o tmpdir/libplt-lib.so" \
ce641d0b
L
1287 "" \
1288 { plt-main5.c } \
1289 "plt-main-pie" \
1290 "plt-main.out" \
1291 "-fPIC" \
1292 ] \
9a926d55
L
1293 [list \
1294 "Run copyreloc-main with PIE without -fPIE" \
d9816402 1295 "-Wl,--as-needed -pie tmpdir/copyreloc-main.o tmpdir/copyreloc-lib.so" \
9a926d55 1296 "" \
46175b4e 1297 { dummy.s } \
9a926d55
L
1298 "copyreloc-main" \
1299 "copyreloc-main.out" \
1300 ] \
bc696fd5
L
1301 [list \
1302 "Run pr17689 with PIE without -fPIE" \
d9816402 1303 "-Wl,--no-as-needed -pie tmpdir/pr17689b.o tmpdir/pr17689.so" \
bc696fd5 1304 "" \
37ce0cc4 1305 { dummy.s } \
bc696fd5
L
1306 "pr17689" \
1307 "pr17689.out" \
1308 ] \
25070364
L
1309 [list \
1310 "Run pr17689 with PIE -z now without -fPIE" \
d9816402 1311 "-Wl,--as-needed,-z,now -pie tmpdir/pr17689b.o tmpdir/pr17689.so" \
25070364 1312 "" \
37ce0cc4 1313 { dummy.s } \
25070364
L
1314 "pr17689now" \
1315 "pr17689.out" \
1316 ] \
04ebc307
L
1317 [list \
1318 "Run pr18900" \
d9816402 1319 "-Wl,--no-as-needed tmpdir/pr18900.o tmpdir/pr18900.so" \
04ebc307 1320 "" \
23a4bd22 1321 { dummy.s } \
04ebc307
L
1322 "pr18900" \
1323 "pr18900.out" \
1324 ] \
5db4f0d3
L
1325 [list \
1326 "Run pr19031" \
68193357 1327 "$NOPIE_LDFLAGS -Wl,--no-as-needed tmpdir/pr19031.so" \
5db4f0d3
L
1328 "" \
1329 { pr19031b.S pr19031c.c } \
1330 "pr19031" \
1331 "pr19031.out" \
68193357 1332 "$NOPIE_CFLAGS" \
5db4f0d3 1333 ] \
56ceb5b5
L
1334 [list \
1335 "Run gotpcrel1" \
d9816402 1336 "-Wl,--no-as-needed tmpdir/gotpcrel1d.so" \
56ceb5b5
L
1337 "" \
1338 { gotpcrel1a.S gotpcrel1b.c gotpcrel1c.c } \
1339 "gotpcrel1" \
1340 "gotpcrel1.out" \
1341 ] \
46bed679
L
1342 [list \
1343 "Run property 1" \
1344 "" \
1345 "" \
1346 {pass.c property-no-copy.S} \
1347 "property-1" "pass.out" \
1348 ] \
1349 [list \
1350 "Run property 1 (PIE)" \
1351 "-pie" \
1352 "" \
1353 {pass.c property-no-copy.S} \
1354 "property-1-pie" "pass.out" "-fPIE" \
1355 ] \
1356 [list \
1357 "Run property 1 (static)" \
1358 "-static" \
1359 "" \
1360 {pass.c property-no-copy.S} \
1361 "property-1-static" "pass.out" \
1362 ] \
1363 [list \
1364 "Run property 2" \
1365 "" \
1366 "" \
1367 {pass.c property-stack.S} \
1368 "property-2" "pass.out" \
1369 ] \
1370 [list \
1371 "Run property 2 (PIE)" \
1372 "-pie" \
1373 "" \
1374 {pass.c property-stack.S} \
1375 "property-2-pie" "pass.out" "-fPIE" \
1376 ] \
1377 [list \
1378 "Run property 2 (static)" \
1379 "-static" \
1380 "" \
1381 {pass.c property-stack.S} \
1382 "property-3-static" "pass.out" \
1383 ] \
1384 [list \
1385 "Run property 3" \
1386 "" \
1387 "" \
1388 {pass.c property-stack.S property-x86-1.S} \
1389 "property-3" "pass.out" \
1390 ] \
1391 [list \
1392 "Run property 3 (PIE)" \
1393 "-pie" \
1394 "" \
1395 {pass.c property-x86-1.S property-stack.S} \
1396 "property-3-pie" "pass.out" "-fPIE" \
1397 ] \
1398 [list \
1399 "Run property 3 (static)" \
1400 "-static" \
1401 "" \
1402 {property-x86-1.S pass.c property-stack.S} \
1403 "property-3-static" "pass.out" \
1404 ] \
1405 [list \
1406 "Run property 4" \
1407 "" \
1408 "" \
1409 {pass.c property-stack.S property-x86-1.S property-x86-2.S} \
1410 "property-4" "pass.out" \
1411 ] \
1412 [list \
1413 "Run property 4 (PIE)" \
1414 "-pie" \
1415 "" \
1416 {pass.c property-x86-2.S property-x86-1.S property-stack.S} \
1417 "property-4-pie" "pass.out" "-fPIE" \
1418 ] \
1419 [list \
1420 "Run property 4 (static)" \
1421 "-static" \
1422 "" \
1423 {property-x86-2.S property-x86-1.S pass.c property-stack.S} \
1424 "property-4-static" "pass.out" \
1425 ] \
1426 [list \
1427 "Run property 5" \
1428 "-Wl,-z,stack-size=0x900000" \
1429 "" \
1430 {pass.c property-stack.S property-x86-1.S property-x86-2.S} \
1431 "property-5" "pass.out" \
1432 ] \
1433 [list \
1434 "Run property 5 (PIE)" \
1435 "-pie -Wl,-z,stack-size=0x900000" \
1436 "" \
1437 {pass.c property-x86-2.S property-x86-1.S property-stack.S} \
1438 "property-5-pie" "pass.out" "-fPIE" \
1439 ] \
1440 [list \
1441 "Run property 5 (static)" \
1442 "-static -Wl,-z,stack-size=0x900000" \
1443 "" \
1444 {property-x86-2.S property-x86-1.S pass.c property-stack.S} \
1445 "property-5-static" "pass.out" \
1446 ] \
7073b5b9
L
1447 [list \
1448 "Run pr22001-1a (PIC 1)" \
1449 "$NOPIE_LDFLAGS -Wl,-z,nocopyreloc,--no-as-needed tmpdir/pr22001-1.so" \
1450 "" \
1451 { pr22001-1b.c } \
1452 "pr22001-1a-pic-1" \
1453 "pass.out" \
1454 "-fPIC" \
1455 ] \
1456 [list \
1457 "Run pr22001-1a (PIC 2)" \
1458 "-pie -Wl,-z,nocopyreloc,--no-as-needed tmpdir/pr22001-1.so" \
1459 "" \
1460 { pr22001-1b.c } \
1461 "pr22001-1a-pic-2" \
1462 "pass.out" \
1463 "-fPIC" \
1464 ] \
1465 [list \
1466 "Run pr22001-1b (PIC 1)" \
1467 "$NOPIE_LDFLAGS -Wl,-z,nocopyreloc,--no-as-needed tmpdir/pr22001-1.so" \
1468 "" \
1469 { pr22001-1c.c } \
1470 "pr22001-1b-pic-1" \
1471 "pass.out" \
1472 "-fPIC" \
1473 ] \
1474 [list \
1475 "Run pr22001-1b (PIC 2)" \
1476 "-pie -Wl,-z,nocopyreloc,--no-as-needed tmpdir/pr22001-1.so" \
1477 "" \
1478 { pr22001-1c.c } \
1479 "pr22001-1b-pic-2" \
1480 "pass.out" \
1481 "-fPIC" \
1482 ] \
a5b4ee94
L
1483 [list \
1484 "Run pr21997-1a (PIC 1)" \
1485 "$NOPIE_LDFLAGS -Wl,--no-as-needed tmpdir/pr21997-1.so" \
1486 "" \
1487 { pr21997-1b.c } \
1488 "pr21997-1a-pic-1" \
1489 "pass.out" \
1490 "-fPIC" \
1491 ] \
1492 [list \
1493 "Run pr21997-1a (PIC 2)" \
1494 "-pie -Wl,--no-as-needed tmpdir/pr21997-1.so" \
1495 "" \
1496 { pr21997-1b.c } \
1497 "pr21997-1a-pic-2" \
1498 "pass.out" \
1499 "-fPIC" \
1500 ] \
1501 [list \
1502 "Run pr21997-1b (PIC 1)" \
1503 "$NOPIE_LDFLAGS -Wl,--no-as-needed tmpdir/pr21997-1.so" \
1504 "" \
1505 { pr21997-1c.c } \
1506 "pr21997-1b-pic-1" \
1507 "pass.out" \
1508 "-fPIC" \
1509 ] \
1510 [list \
1511 "Run pr21997-1b (PIC 2)" \
1512 "-pie -Wl,--no-as-needed tmpdir/pr21997-1.so" \
1513 "" \
1514 { pr21997-1c.c } \
1515 "pr21997-1b-pic-2" \
1516 "pass.out" \
1517 "-fPIC" \
1518 ] \
ad71ce8d
L
1519 [list \
1520 "Run pr22064" \
1521 "-pie -Wl,--no-as-needed tmpdir/pr22064a.o tmpdir/pr22064.so" \
1522 "" \
1523 { dummy.s } \
1524 "pr22064-pie" \
1525 "pass.out" \
1526 "-fPIE" \
1527 ] \
cf9e7f1f
L
1528 [list \
1529 "Run pr22393-3" \
1530 "$NOPIE_LDFLAGS -Wl,-z,separate-code,-z,max-page-size=0x1000,--no-as-needed tmpdir/pr22393-3a.so" \
1531 "" \
1532 {pr22393-3b.c} \
1533 "pr22393-3" \
1534 "pass.out" \
1535 "$NOPIE_CFLAGS" \
1536 ] \
1537 [list \
1538 "Run pr22393-3 (PIE)" \
1539 "-pie -Wl,-z,separate-code,-z,max-page-size=0x1000,--no-as-needed tmpdir/pr22393-3a-now.so" \
1540 "" \
1541 {pr22393-3b.c} \
1542 "pr22393-3-pie" \
1543 "pass.out" \
1544 "-fPIE" \
1545 ] \
1546 [list \
1547 "Run pr22393-3 (static)" \
1548 "-static -Wl,-z,separate-code,-z,max-page-size=0x1000" \
1549 "" \
1550 {pr22393-3a.c pr22393-3b.c} \
1551 "pr22393-3-static" \
1552 "pass.out" \
1553 ] \
bd7ab16b
L
1554 [list \
1555 "Run pr22791-2" \
1556 "-pie -Wl,--no-as-needed tmpdir/pr22791-2.so" \
1557 "" \
1558 { pr22791-2c.s } \
1559 "pr22791-2" \
1560 "pass.out" \
1561 "$NOPIE_CFLAGS" \
1562 ] \
451875b4
L
1563 [list \
1564 "Build pr22842" \
1565 "-pie -Wl,--no-as-needed tmpdir/pr22842.so" \
1566 "" \
1567 { pr22842b.S } \
1568 "pr22842" \
1569 "pass.out" \
1570 ] \
76e7af5f 1571 ]
dd7e64d4 1572
3c4f3228
L
1573 # Run-time tests which require working ifunc attribute support.
1574 if { [check_ifunc_attribute_available] } {
1575 run_cc_link_tests [list \
1576 [list \
1577 "Build libpr19784a.so" \
1578 "-shared -Wl,-Bsymbolic-functions" \
1579 "-fPIC -O2 -g" \
1580 { pr19784b.c pr19784c.c } \
1581 {} \
1582 "libpr19784a.so" \
1583 ] \
1584 [list \
1585 "Build libpr19784b.so" \
1586 "-shared -Wl,-Bsymbolic-functions" \
1587 "-fPIC -O2 -g" \
1588 { pr19784c.c pr19784b.c } \
1589 {} \
1590 "libpr19784b.so" \
1591 ] \
1592 [list \
1593 "Build pr19784a.o" \
1594 "" \
1595 "" \
1596 { pr19784a.c } \
1597 ] \
1598 ]
1599
1600 run_ld_link_exec_tests [list \
1601 [list \
1602 "Run pr19784a" \
d9816402 1603 "-Wl,--no-as-needed tmpdir/pr19784a.o tmpdir/libpr19784a.so" \
3c4f3228
L
1604 "" \
1605 { dummy.s } \
1606 "pr19784a" \
1607 "pass.out" \
1608 ] \
1609 [list \
1610 "Run pr19784b" \
d9816402 1611 "-Wl,--as-needed tmpdir/pr19784a.o tmpdir/libpr19784b.so" \
3c4f3228
L
1612 "" \
1613 { dummy.s } \
1614 "pr19784b" \
1615 "pass.out" \
1616 ] \
1617 ]
1618 }
1619
dd7e64d4
L
1620 if { [istarget "x86_64-*-linux*"] \
1621 && ![istarget "x86_64-*-linux*-gnux32"]} {
1622
1623 run_cc_link_tests [list \
1624 [list \
1625 "Build plt-main with -z bndplt" \
1626 "tmpdir/plt-main1.o tmpdir/plt-main2.o tmpdir/plt-main3.o \
7c9f387a
L
1627 tmpdir/plt-main4.o tmpdir/libplt-lib.so -z bndplt \
1628 -z noseparate-code -z max-page-size=0x200000" \
dd7e64d4
L
1629 "" \
1630 { plt-main5.c } \
1631 {{objdump {-drw} plt-main-bnd.dd}} \
1632 "plt-main-bnd" \
1633 ] \
1634 [list \
1635 "Build plt-main with PIE and -z bndplt" \
1636 "tmpdir/plt-main1.o tmpdir/plt-main2.o tmpdir/plt-main3.o \
7c9f387a
L
1637 tmpdir/plt-main4.o tmpdir/libplt-lib.so -z bndplt -pie \
1638 -z noseparate-code -z max-page-size=0x200000" \
dd7e64d4
L
1639 "-fPIC" \
1640 { plt-main5.c } \
1641 {{objdump {-drw} plt-main-bnd.dd}} \
1642 "plt-main-pie-bnd" \
1643 ] \
38b12349
L
1644 [list \
1645 "Build plt-main with -z bndplt -z now" \
1646 "tmpdir/plt-main1.o tmpdir/plt-main2.o tmpdir/plt-main3.o \
7c9f387a
L
1647 tmpdir/plt-main4.o tmpdir/libplt-lib.so -z bndplt -z now \
1648 -z noseparate-code -z max-page-size=0x200000" \
38b12349
L
1649 "" \
1650 { plt-main5.c } \
1651 {{readelf {-SW} plt-main-bnd-now.rd} {objdump {-drw} plt-main-bnd.dd}} \
1652 "plt-main-bnd-now" \
1653 ] \
1654 [list \
1655 "Build plt-main with PIE and -z bndplt -z now" \
1656 "tmpdir/plt-main1.o tmpdir/plt-main2.o tmpdir/plt-main3.o \
7c9f387a
L
1657 tmpdir/plt-main4.o tmpdir/libplt-lib.so -z bndplt -z now -pie \
1658 -z noseparate-code -z max-page-size=0x200000" \
38b12349
L
1659 "-fPIC" \
1660 { plt-main5.c } \
1661 {{readelf {-SW} plt-main-bnd-now.rd} {objdump {-drw} plt-main-bnd.dd}} \
1662 "plt-main-pie-bnd-now" \
1663 ] \
dd7e64d4
L
1664 ]
1665
982c6f26 1666 run_ld_link_exec_tests [list \
dd7e64d4
L
1667 [list \
1668 "Run plt-main with -z bndplt" \
d9816402
AM
1669 "-Wl,--no-as-needed,-z,bndplt tmpdir/plt-main1.o \
1670 tmpdir/plt-main2.o tmpdir/plt-main3.o \
1671 tmpdir/plt-main4.o tmpdir/libplt-lib.so" \
dd7e64d4
L
1672 "" \
1673 { plt-main5.c } \
1674 "plt-main-bnd" \
1675 "plt-main.out" \
1676 ] \
1677 [list \
1678 "Run plt-main with PIE and -z bndplt" \
d9816402
AM
1679 "-Wl,--no-as-needed,-z,bndplt -pie tmpdir/plt-main1.o \
1680 tmpdir/plt-main2.o tmpdir/plt-main3.o \
1681 tmpdir/plt-main4.o tmpdir/libplt-lib.so" \
dd7e64d4
L
1682 "" \
1683 { plt-main5.c } \
1684 "plt-main-pie-bnd" \
1685 "plt-main.out" \
1686 "-fPIC" \
1687 ] \
38b12349
L
1688 [list \
1689 "Run plt-main with -z bndplt -z now" \
1690 "-Wl,--no-as-needed,-z,bndplt,-z,now tmpdir/plt-main1.o \
1691 tmpdir/plt-main2.o tmpdir/plt-main3.o \
1692 tmpdir/plt-main4.o tmpdir/libplt-lib.so" \
1693 "" \
1694 { plt-main5.c } \
1695 "plt-main-bnd-now" \
1696 "plt-main.out" \
1697 ] \
1698 [list \
1699 "Run plt-main with PIE and -z bndplt -z now" \
1700 "-Wl,--no-as-needed,-z,bndplt,-z,now -pie tmpdir/plt-main1.o \
1701 tmpdir/plt-main2.o tmpdir/plt-main3.o \
1702 tmpdir/plt-main4.o tmpdir/libplt-lib.so" \
1703 "" \
1704 { plt-main5.c } \
1705 "plt-main-pie-bnd-now" \
1706 "plt-main.out" \
1707 "-fPIC" \
1708 ] \
9d734efa
L
1709 [list \
1710 "Run pr20800" \
d9816402 1711 "-Wl,-z,now -pie" \
9d734efa
L
1712 "" \
1713 { pr20800a.S pr20800b.S } \
1714 "pr20800" \
1715 "pass.out" \
1716 ] \
dd7e64d4 1717 ]
85406233
L
1718 if { [check_ifunc_attribute_available] } {
1719 run_ld_link_exec_tests [list \
1720 [list \
1721 "Run pr21481a" \
1722 "$NOPIE_LDFLAGS -Wl,-z,bndplt" \
1723 "" \
1724 { pr21481a.c pr21481b.S } \
1725 "pr21481a" \
1726 "pass.out" \
1727 "$NOPIE_CFLAGS" \
1728 ] \
1729 [list \
1730 "Run pr21481b" \
1731 "$NOPIE_LDFLAGS -Wl,-z,bndplt,-z,now" \
1732 "" \
1733 { pr21481a.c pr21481b.S } \
1734 "pr21481b" \
1735 "pass.out" \
1736 "$NOPIE_CFLAGS" \
1737 ] \
1738 ]
1739 }
dd7e64d4 1740 }
aec6b87e 1741
ee2fdd6f
L
1742 if { [istarget "x86_64-*-linux*"] } {
1743 if { [istarget "x86_64-*-linux*-gnux32"] } {
1744 set pltdump {{objdump {-drw} plt-main-ibt-x32.dd}}
1745 set pltsecdump {{readelf {-SW} plt-main-ibt-now.rd} {objdump {-drw} plt-main-ibt-x32.dd}}
1746 } else {
1747 set pltdump {{objdump {-drw} plt-main-ibt.dd}}
1748 set pltsecdump {{readelf {-SW} plt-main-ibt-now.rd} {objdump {-drw} plt-main-ibt.dd}}
1749 }
1750 run_cc_link_tests [list \
1751 [list \
1752 "Build plt-main with -z ibtplt" \
1753 "tmpdir/plt-main1.o tmpdir/plt-main2.o tmpdir/plt-main3.o \
7c9f387a
L
1754 tmpdir/plt-main4.o tmpdir/libplt-lib.so -z ibtplt \
1755 -z noseparate-code -z max-page-size=0x200000" \
ee2fdd6f
L
1756 "" \
1757 { plt-main5.c } \
1758 $pltdump \
1759 "plt-main-ibt" \
1760 ] \
1761 [list \
1762 "Build plt-main with PIE and -z ibtplt" \
1763 "tmpdir/plt-main1.o tmpdir/plt-main2.o tmpdir/plt-main3.o \
7c9f387a
L
1764 tmpdir/plt-main4.o tmpdir/libplt-lib.so -z ibtplt -pie \
1765 -z noseparate-code -z max-page-size=0x200000" \
ee2fdd6f
L
1766 "-fPIC" \
1767 { plt-main5.c } \
1768 $pltdump \
1769 "plt-main-pie-ibt" \
1770 ] \
1771 [list \
1772 "Build plt-main with -z ibtplt -z now" \
1773 "tmpdir/plt-main1.o tmpdir/plt-main2.o tmpdir/plt-main3.o \
7c9f387a
L
1774 tmpdir/plt-main4.o tmpdir/libplt-lib.so -z ibtplt -z now \
1775 -z noseparate-code -z max-page-size=0x200000" \
ee2fdd6f
L
1776 "" \
1777 { plt-main5.c } \
1778 $pltsecdump \
1779 "plt-main-ibt-now" \
1780 ] \
1781 [list \
1782 "Build plt-main with PIE and -z ibtplt -z now" \
1783 "tmpdir/plt-main1.o tmpdir/plt-main2.o tmpdir/plt-main3.o \
7c9f387a
L
1784 tmpdir/plt-main4.o tmpdir/libplt-lib.so -z ibtplt -z now -pie \
1785 -z noseparate-code -z max-page-size=0x200000" \
ee2fdd6f
L
1786 "-fPIC" \
1787 { plt-main5.c } \
1788 $pltsecdump \
1789 "plt-main-pie-ibt-now" \
1790 ] \
1791 [list \
1792 "Build libibtplt-lib.so with -z ibtplt" \
7c9f387a
L
1793 "-shared -z ibtplt \
1794 -z noseparate-code -z max-page-size=0x200000" \
ee2fdd6f
L
1795 "-fPIC" \
1796 { plt-main1.c plt-main2.c plt-main3.c plt-main4.c} \
1797 $pltdump \
1798 "libibtplt-lib.so" \
1799 ] \
1800 [list \
1801 "Build libibtplt--now-lib.so with -z ibtplt -z now" \
7c9f387a
L
1802 "-shared -z ibtplt -z now \
1803 -z noseparate-code -z max-page-size=0x200000" \
ee2fdd6f
L
1804 "-fPIC" \
1805 { plt-main1.c plt-main2.c plt-main3.c plt-main4.c} \
1806 $pltdump \
1807 "libibtplt-now-lib.so" \
1808 ] \
1809 ]
1810
1811 run_ld_link_exec_tests [list \
1812 [list \
1813 "Run plt-main with -z ibtplt" \
1814 "-Wl,--no-as-needed,-z,ibtplt tmpdir/plt-main1.o \
1815 tmpdir/plt-main2.o tmpdir/plt-main3.o \
1816 tmpdir/plt-main4.o tmpdir/libplt-lib.so" \
1817 "" \
1818 { plt-main5.c } \
1819 "plt-main-ibt" \
1820 "plt-main.out" \
1821 ] \
1822 [list \
1823 "Run plt-main with PIE and -z ibtplt" \
1824 "-Wl,--no-as-needed,-z,ibtplt -pie tmpdir/plt-main1.o \
1825 tmpdir/plt-main2.o tmpdir/plt-main3.o \
1826 tmpdir/plt-main4.o tmpdir/libplt-lib.so" \
1827 "" \
1828 { plt-main5.c } \
1829 "plt-main-pie-ibt" \
1830 "plt-main.out" \
1831 "-fPIC" \
1832 ] \
1833 [list \
1834 "Run plt-main with -z ibtplt -z now" \
1835 "-Wl,--no-as-needed,-z,ibtplt,-z,now tmpdir/plt-main1.o \
1836 tmpdir/plt-main2.o tmpdir/plt-main3.o \
1837 tmpdir/plt-main4.o tmpdir/libplt-lib.so" \
1838 "" \
1839 { plt-main5.c } \
1840 "plt-main-ibt-now" \
1841 "plt-main.out" \
1842 ] \
1843 [list \
1844 "Run plt-main with PIE and -z ibtplt -z now" \
1845 "-Wl,--no-as-needed,-z,ibtplt,-z,now -pie tmpdir/plt-main1.o \
1846 tmpdir/plt-main2.o tmpdir/plt-main3.o \
1847 tmpdir/plt-main4.o tmpdir/libplt-lib.so" \
1848 "" \
1849 { plt-main5.c } \
1850 "plt-main-pie-ibt-now" \
1851 "plt-main.out" \
1852 "-fPIC" \
1853 ] \
1854 [list \
1855 "Run plt-main with libibtplt-lib.so -z ibtplt" \
1856 "-Wl,--no-as-needed,-z,ibtplt tmpdir/libibtplt-lib.so \
1857 tmpdir/libplt-lib.so" \
1858 "" \
1859 { plt-main5.c } \
1860 "plt-main-ibt-lib" \
1861 "plt-main.out" \
1862 ] \
1863 [list \
1864 "Run plt-main with libibtplt-lib.so -z ibtplt -z now" \
1865 "-Wl,--no-as-needed,-z,ibtplt,-z,now \
1866 tmpdir/libibtplt-now-lib.so tmpdir/libplt-lib.so" \
1867 "" \
1868 { plt-main5.c } \
1869 "plt-main-ibt-now-lib" \
1870 "plt-main.out" \
1871 ] \
1872 ]
1873
1874 if { [check_ifunc_attribute_available] } {
1875 run_ld_link_exec_tests [list \
1876 [list \
1877 "Run pr21481a" \
1878 "$NOPIE_LDFLAGS -Wl,-z,ibtplt" \
1879 "" \
1880 { pr21481a.c pr21481b.S } \
1881 "pr21481a" \
1882 "pass.out" \
1883 "$NOPIE_CFLAGS" \
1884 ] \
1885 [list \
1886 "Run pr21481b" \
1887 "$NOPIE_LDFLAGS -Wl,-z,ibtplt,-z,now" \
1888 "" \
1889 { pr21481a.c pr21481b.S } \
1890 "pr21481b" \
1891 "pass.out" \
1892 "$NOPIE_CFLAGS" \
1893 ] \
1894 ]
1895 }
1896 }
1897
a7eaf017 1898 undefined_weak "$NOPIE_CFLAGS" "$NOPIE_LDFLAGS"
aec6b87e
L
1899 undefined_weak "-fPIE" ""
1900 undefined_weak "-fPIE" "-pie"
d9816402
AM
1901 undefined_weak "-fPIE" "-Wl,-z,nodynamic-undefined-weak"
1902 undefined_weak "-fPIE" "-pie -Wl,-z,nodynamic-undefined-weak"
adc7571d 1903}
ab7fede8
L
1904
1905if { ![istarget "x86_64-*-linux*"]} {
1906 return
1907}
1908
38b12349
L
1909run_ld_link_tests [list \
1910 [list \
1911 "basic PLT generation (-z now)" \
7c9f387a
L
1912 "-z now -melf_x86_64 --hash-style=sysv tmpdir/libpltlib.so \
1913 -z noseparate-code -z max-page-size=0x200000" \
38b12349
L
1914 "" \
1915 "--64" \
1916 {plt2.s} \
1917 {{readelf -SW plt2.rd} {objdump -dwr plt2.dd}} \
1918 "plt2" \
1919 ] \
abfa390d
L
1920 [list \
1921 "Build pr21626.so" \
1922 "-shared -melf_x86_64" \
1923 "" \
1924 "--64 -defsym __64_bit__=1" \
1925 {property-x86-3.s} \
1926 "" \
1927 "pr21626.so" \
1928 ] \
1929 [list \
1930 "Build pr21626" \
1931 "-melf_x86_64 tmpdir/pr21626.so" \
1932 "" \
1933 "--64" \
1934 {start.s foo.s} \
1935 "" \
1936 "pr21626" \
1937 ] \
38b12349
L
1938]
1939
ab7fede8 1940# Linux only tests
978c0540
L
1941global LD_CLASS
1942if { "$LD_CLASS" == "64bit" } then {
1943 # This test needs 64-bit linker.
1944 run_dump_test "pr17618"
1945}
a3747075 1946run_dump_test "pltgot-1"
7c1e8d3e 1947run_dump_test "pltgot-2"
59a1e29d
L
1948run_dump_test "pr20830a"
1949run_dump_test "pr20830b"
9e659176
L
1950run_dump_test "pr21038a"
1951run_dump_test "pr21038b"
8361ed4d 1952run_dump_test "pr21038c"
38b12349
L
1953run_dump_test "pr20830a-now"
1954run_dump_test "pr20830b-now"
1955run_dump_test "pr21038a-now"
1956run_dump_test "pr21038b-now"
1957run_dump_test "pr21038c-now"
ee2fdd6f
L
1958run_dump_test "ibt-plt-1"
1959run_dump_test "ibt-plt-1-x32"
1960run_dump_test "ibt-plt-2a"
1961run_dump_test "ibt-plt-2b"
1962run_dump_test "ibt-plt-2c"
1963run_dump_test "ibt-plt-2d"
1964run_dump_test "ibt-plt-2a-x32"
1965run_dump_test "ibt-plt-2b-x32"
1966run_dump_test "ibt-plt-2c-x32"
1967run_dump_test "ibt-plt-2d-x32"
1968run_dump_test "ibt-plt-3a"
1969run_dump_test "ibt-plt-3b"
1970run_dump_test "ibt-plt-3c"
1971run_dump_test "ibt-plt-3d"
1972run_dump_test "ibt-plt-3a-x32"
1973run_dump_test "ibt-plt-3b-x32"
1974run_dump_test "ibt-plt-3c-x32"
1975run_dump_test "ibt-plt-3d-x32"