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