ld: Add tests for -z separate-code and -z noseparate-code
[deliverable/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"
bab55c05 53 "-shared -melf_x86_64 --no-ld-generated-unwind-info --hash-style=sysv" ""
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 58 {"TLS -fpic -shared transitions with r15 as GOT base"
bab55c05 59 "-shared -melf_x86_64 --no-ld-generated-unwind-info --hash-style=sysv" ""
e2cbcd91
L
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"
bab55c05 66 "-shared -melf_x86_64 --no-ld-generated-unwind-info --hash-style=sysv" ""
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"
bab55c05 74 "-melf_x86_64 tmpdir/libtlslib.so --no-ld-generated-unwind-info --hash-style=sysv" ""
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 79 {"TLS -fpic and -fno-pic exec transitions without PLT"
bab55c05 80 "-melf_x86_64 tmpdir/libtlslib.so --no-ld-generated-unwind-info --hash-style=sysv" ""
e2cbcd91
L
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"
bab55c05 86 "-melf_x86_64 tmpdir/libtlslib.so --no-ld-generated-unwind-info --hash-style=sysv" ""
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"
bab55c05 92 "-shared -melf_x86_64 --no-ld-generated-unwind-info --hash-style=sysv" ""
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"
43083a50 270run_dump_test "apic"
ac2aa337
JB
271run_dump_test "pcrel8"
272run_dump_test "pcrel16"
dd1093aa
L
273run_dump_test "tlsgd2"
274run_dump_test "tlsgd3"
e2cbcd91
L
275run_dump_test "tlsgd12"
276run_dump_test "tlsgd13"
dd1093aa
L
277run_dump_test "tlsie2"
278run_dump_test "tlsie3"
41bed6dd
L
279run_dump_test "hidden1"
280run_dump_test "hidden2"
281run_dump_test "hidden3"
e3c0e327
L
282run_dump_test "hidden4"
283run_dump_test "hidden5"
41bed6dd
L
284run_dump_test "protected1"
285run_dump_test "protected2"
8a9036a4 286run_dump_test "protected2-l1om"
41bed6dd 287run_dump_test "protected3"
8a9036a4 288run_dump_test "protected3-l1om"
bdb892b9
L
289run_dump_test "protected4"
290run_dump_test "protected5"
e3c0e327 291run_dump_test "protected6a"
889c2a67 292run_dump_test "protected6b"
3d949995
L
293run_dump_test "protected7a"
294run_dump_test "protected7b"
73784fa5 295run_dump_test "protected8"
9b769489 296run_dump_test "tlsle1"
1d85728f 297run_dump_test "tlspie1"
e2cbcd91
L
298run_dump_test "tlspie2a"
299run_dump_test "tlspie2b"
300run_dump_test "tlspie2c"
6f8bcf84 301run_dump_test "unique1"
a7b16ceb 302run_dump_test "nogot1"
0629d0af 303run_dump_test "nogot2"
56d4289c 304run_dump_test "discarded1"
2abca860 305run_dump_test "pr12718"
a81aeffc 306run_dump_test "pr12921"
aed64b35 307run_dump_test "pr13947"
2fe0fd06
L
308run_dump_test "pr12570a"
309run_dump_test "pr12570b"
17d6eea5 310run_dump_test "pr14215"
8981c88a 311run_dump_test "pr14207"
553d1284 312run_dump_test "gotplt1"
6333bc0d 313run_dump_test "pie1"
126697d1 314run_dump_test "pie2"
c5bb8910
L
315run_dump_test "pie3"
316run_dump_test "pie3-nacl"
03f2309a 317run_dump_test "pic1"
b8871f35
L
318run_dump_test "largecomm-1a"
319run_dump_test "largecomm-1b"
320run_dump_test "largecomm-1c"
321run_dump_test "largecomm-1d"
322run_dump_test "largecomm-1e"
323run_dump_test "largecomm-1f"
3ab94f96
L
324run_dump_test "pr19539a"
325run_dump_test "pr19539b"
4c10bbaa
L
326run_dump_test "pr19807-1a"
327run_dump_test "pr19807-1b"
328run_dump_test "pr19807-2a"
329run_dump_test "pr19807-2b"
330run_dump_test "pr19807-2c"
331run_dump_test "pr19807-2d"
332run_dump_test "pr19807-2e"
338c190a 333run_dump_test "pr19969"
2168b268
L
334run_dump_test "pr20093-1"
335run_dump_test "pr20093-2"
73caa85d 336run_dump_test "property-x86-3"
92f7d783
L
337run_dump_test "property-x86-4a"
338run_dump_test "property-x86-4b"
654f3b6a
L
339run_dump_test "property-x86-3-x32"
340run_dump_test "property-x86-4a-x32"
341run_dump_test "property-x86-4b-x32"
ee2fdd6f
L
342run_dump_test "property-x86-ibt1a"
343run_dump_test "property-x86-ibt1b"
344run_dump_test "property-x86-ibt1a-x32"
345run_dump_test "property-x86-ibt1b-x32"
346run_dump_test "property-x86-ibt2"
347run_dump_test "property-x86-ibt2-x32"
348run_dump_test "property-x86-ibt3a"
349run_dump_test "property-x86-ibt3b"
350run_dump_test "property-x86-ibt3a-x32"
351run_dump_test "property-x86-ibt3b-x32"
352run_dump_test "property-x86-ibt4"
353run_dump_test "property-x86-ibt4-x32"
354run_dump_test "property-x86-ibt5"
355run_dump_test "property-x86-ibt5-x32"
48580982
L
356run_dump_test "property-x86-shstk1a"
357run_dump_test "property-x86-shstk1b"
358run_dump_test "property-x86-shstk1a-x32"
359run_dump_test "property-x86-shstk1b-x32"
360run_dump_test "property-x86-shstk2"
361run_dump_test "property-x86-shstk2-x32"
362run_dump_test "property-x86-shstk3a"
363run_dump_test "property-x86-shstk3b"
364run_dump_test "property-x86-shstk3a-x32"
365run_dump_test "property-x86-shstk3b-x32"
366run_dump_test "property-x86-shstk4"
367run_dump_test "property-x86-shstk4-x32"
368run_dump_test "property-x86-shstk5"
369run_dump_test "property-x86-shstk5-x32"
9593aade 370run_dump_test "pr21884"
34c4758c 371run_dump_test "pr21884-nacl"
0e30d991 372run_dump_test "pr22071"
0a27fed7
L
373run_dump_test "pr22115-1a"
374run_dump_test "pr22115-1a-x32"
375run_dump_test "pr22115-1b"
376run_dump_test "pr22115-1b-x32"
377run_dump_test "pr22115-1c"
378run_dump_test "pr22115-1c-x32"
379run_dump_test "pr22115-1d"
380run_dump_test "pr22115-1d-x32"
5e5e02ae 381run_dump_test "pr22135"
25d17eb4 382
5a68afcf 383if { ![istarget "x86_64-*-linux*"] && ![istarget "x86_64-*-nacl*"]} {
25d17eb4
L
384 return
385}
386
5a68afcf 387if ![ld_assemble $as "--x32 $srcdir/$subdir/start.s" tmpdir/startx32.o] {
889a4d3e
L
388 unresolved "Build ILP32 start.o"
389 return
390}
391
5a68afcf 392if ![ld_assemble $as "--32 $srcdir/$subdir/start.s" tmpdir/start32.o] {
889a4d3e
L
393 unresolved "Build ia32 start.o"
394 return
395}
396
5a68afcf 397if ![ld_assemble $as "--64 $srcdir/$subdir/start.s" tmpdir/start64.o] {
889a4d3e
L
398 unresolved "Build LP64 start.o"
399 return
400}
401
5a68afcf 402if ![ld_assemble $as "--x32 $srcdir/$subdir/foo.s" tmpdir/foox32.o] {
889a4d3e
L
403 unresolved "Build ILP32 foo.o"
404 return
405}
406
5a68afcf 407if ![ld_assemble $as "--32 $srcdir/$subdir/foo.s" tmpdir/foo32.o] {
889a4d3e
L
408 unresolved "Build ia32 foo.o"
409 return
410}
411
5a68afcf 412if ![ld_assemble $as "--64 $srcdir/$subdir/foo.s" tmpdir/foo64.o] {
889a4d3e
L
413 unresolved "Build LP64 foo.o"
414 return
415}
416
25d17eb4 417run_dump_test "compressed1"
889a4d3e
L
418run_dump_test "ilp32-1"
419run_dump_test "ilp32-2"
420run_dump_test "ilp32-3"
82e96e07 421run_dump_test "ilp32-4"
5a68afcf 422run_dump_test "ilp32-4-nacl"
248775ba 423run_dump_test "ilp32-5"
d7921315
L
424run_dump_test "ilp32-6"
425run_dump_test "ilp32-7"
426run_dump_test "ilp32-8"
427run_dump_test "ilp32-9"
df4f9443 428run_dump_test "ilp32-10"
8cf0d2dd 429run_dump_test "ilp32-11"
889a4d3e
L
430run_dump_test "ia32-1"
431run_dump_test "ia32-2"
432run_dump_test "ia32-3"
433run_dump_test "lp64-1"
434run_dump_test "lp64-2"
435run_dump_test "lp64-3"
64d25c44
L
436run_dump_test "pr13082-1a"
437run_dump_test "pr13082-1b"
438run_dump_test "pr13082-2a"
439run_dump_test "pr13082-2b"
440run_dump_test "pr13082-3a"
441run_dump_test "pr13082-3b"
bae420ef
L
442run_dump_test "pr13082-3c"
443run_dump_test "pr13082-3d"
64d25c44
L
444run_dump_test "pr13082-4a"
445run_dump_test "pr13082-4b"
446run_dump_test "pr13082-5a"
447run_dump_test "pr13082-5b"
448run_dump_test "pr13082-6a"
449run_dump_test "pr13082-6b"
80d87326
L
450run_dump_test "lea1a"
451run_dump_test "lea1b"
452run_dump_test "lea1c"
453run_dump_test "lea1d"
454run_dump_test "lea1e"
455run_dump_test "lea1f"
daa67607
L
456run_dump_test "lea1g"
457run_dump_test "lea1h"
458run_dump_test "lea1i"
459run_dump_test "lea1j"
460run_dump_test "lea1k"
461run_dump_test "lea1l"
3f65f599
L
462run_dump_test "mov1a"
463run_dump_test "mov1b"
464run_dump_test "mov1c"
465run_dump_test "mov1d"
02e2aef8
L
466run_dump_test "mov2a"
467run_dump_test "mov2b"
468run_dump_test "mov2c"
469run_dump_test "mov2d"
56ceb5b5
L
470run_dump_test "load1a"
471run_dump_test "load1b"
472run_dump_test "load1c"
473run_dump_test "load1d"
caa65211
L
474run_dump_test "load1a-nacl"
475run_dump_test "load1b-nacl"
476run_dump_test "load1c-nacl"
477run_dump_test "load1d-nacl"
2856a627 478run_dump_test "load2"
caa65211
L
479run_dump_test "call1a"
480run_dump_test "call1b"
481run_dump_test "call1c"
482run_dump_test "call1d"
483run_dump_test "call1e"
484run_dump_test "call1f"
485run_dump_test "call1g"
486run_dump_test "call1h"
487run_dump_test "call1i"
1952c5cd
L
488run_dump_test "pr17935-1"
489run_dump_test "pr17935-2"
b19a8f85 490run_dump_test "pr18160"
875b5b9d 491run_dump_test "pr18176"
8efa2874 492run_dump_test "pr18801"
13a2df29 493run_dump_test "pr18815"
9865bd0d
L
494run_dump_test "pr19013"
495run_dump_test "pr19013-x32"
496run_dump_test "pr19013-nacl"
7963511f 497run_dump_test "pr19162"
7b7e7f1d 498run_dump_test "pr19175"
6ba2af25 499run_dump_test "pr18591"
e20365c5 500run_dump_test "pr19615"
aec6b87e
L
501run_dump_test "pr19636-1a"
502run_dump_test "pr19636-1b"
503run_dump_test "pr19636-1c"
504run_dump_test "pr19636-1d"
505run_dump_test "pr19636-1e"
506run_dump_test "pr19636-1f"
507run_dump_test "pr19636-1g"
853ee16f
L
508run_dump_test "pr19636-1h"
509run_dump_test "pr19636-1i"
510run_dump_test "pr19636-1j"
aec6b87e
L
511run_dump_test "pr19636-2a"
512run_dump_test "pr19636-2b"
513run_dump_test "pr19636-2c"
514run_dump_test "pr19636-2d"
515run_dump_test "pr19636-2d-nacl"
516run_dump_test "pr19636-2e"
517run_dump_test "pr19636-2f"
518run_dump_test "pr19636-2g"
519run_dump_test "pr19636-2h"
520run_dump_test "pr19636-2i"
853ee16f
L
521run_dump_test "pr19636-2j"
522run_dump_test "pr19636-2k"
523run_dump_test "pr19636-2l"
524run_dump_test "pr19636-2m"
aec6b87e
L
525run_dump_test "pr19636-3a"
526run_dump_test "pr19636-3b"
527run_dump_test "pr19636-3c"
b8871f35 528run_dump_test "pr19645"
bae420ef
L
529run_dump_test "pr19609-1a"
530run_dump_test "pr19609-1b"
531run_dump_test "pr19609-1c"
532run_dump_test "pr19609-1d"
533run_dump_test "pr19609-1e"
534run_dump_test "pr19609-1f"
535run_dump_test "pr19609-1g"
536run_dump_test "pr19609-1h"
537run_dump_test "pr19609-1i"
538run_dump_test "pr19609-1j"
539run_dump_test "pr19609-1k"
540run_dump_test "pr19609-1l"
541run_dump_test "pr19609-1m"
542run_dump_test "pr19609-2a"
543run_dump_test "pr19609-2b"
544run_dump_test "pr19609-2c"
545run_dump_test "pr19609-2d"
546run_dump_test "pr19609-3a"
547run_dump_test "pr19609-3b"
548run_dump_test "pr19609-4a"
549run_dump_test "pr19609-4b"
550run_dump_test "pr19609-4c"
551run_dump_test "pr19609-4d"
552run_dump_test "pr19609-4e"
553run_dump_test "pr19609-5a"
554run_dump_test "pr19609-5b"
555run_dump_test "pr19609-5c"
556run_dump_test "pr19609-5d"
557run_dump_test "pr19609-5e"
558run_dump_test "pr19609-6a"
559run_dump_test "pr19609-6b"
560run_dump_test "pr19609-6c"
561run_dump_test "pr19609-6d"
562run_dump_test "pr19609-7a"
563run_dump_test "pr19609-7b"
564run_dump_test "pr19609-7c"
565run_dump_test "pr19609-7d"
2df3368d
L
566run_dump_test "pr19939a"
567run_dump_test "pr19939b"
87d455c0 568run_dump_test "pr19719"
233cc9c1
L
569run_dump_test "pr20253-1a"
570run_dump_test "pr20253-1b"
571run_dump_test "pr20253-1c"
572run_dump_test "pr20253-1d"
573run_dump_test "pr20253-1e"
574run_dump_test "pr20253-1f"
575run_dump_test "pr20253-1g"
576run_dump_test "pr20253-1h"
577run_dump_test "pr20253-1i"
578run_dump_test "pr20253-1j"
579run_dump_test "pr20253-1k"
580run_dump_test "pr20253-1l"
581run_dump_test "pr20253-3"
582run_dump_test "pr20253-4a"
583run_dump_test "pr20253-4b"
584run_dump_test "pr20253-4c"
585run_dump_test "pr20253-4d"
586run_dump_test "pr20253-4e"
587run_dump_test "pr20253-4f"
588run_dump_test "pr20253-5a"
589run_dump_test "pr20253-5b"
97d343d4 590run_dump_test "tlsdesc2"
d7de6408 591run_dump_test "pr22048"
aec6b87e
L
592
593proc undefined_weak {cflags ldflags} {
594 set testname "Undefined weak symbol"
595 if { ![ string match "" $cflags$ldflags] } {
596 set testname "$testname ($cflags $ldflags)"
597 }
598
074f6066
L
599 if { [string match "*-fPIE*" $cflags]
600 && ![string match "*nodynamic-undefined-weak*" $ldflags] } {
aec6b87e
L
601 set weak_symbol "Weak defined"
602 } else {
603 set weak_symbol "Weak undefined"
604 }
605
606 run_cc_link_tests [list \
607 [list \
608 "Build libpr19704a.so" \
609 "-shared -Wl,-soname,libpr19704.so" \
610 "" \
611 { dummy.s } \
612 {} \
613 "libpr19704a.so" \
614 ] \
615 [list \
616 "Build libpr19704b.so" \
617 "-shared -Wl,-soname,libpr19704.so" \
618 "-fPIC" \
619 { pr19704b.c } \
620 {} \
621 "libpr19704b.so" \
622 ] \
623 ]
624
625 exec cp tmpdir/libpr19704a.so tmpdir/libpr19704.so
626
982c6f26 627 run_ld_link_exec_tests [list \
aec6b87e
L
628 [list \
629 "Run pr19704" \
d9816402 630 "-Wl,--no-as-needed,-R,tmpdir $ldflags tmpdir/libpr19704.so" \
aec6b87e
L
631 "" \
632 { pr19704a.c } \
633 "pr19704" \
634 "pr19704.out" \
635 "$cflags" \
636 ] \
637 ]
638
639 exec cp tmpdir/libpr19704b.so tmpdir/libpr19704.so
640
641 set exec_output [run_host_cmd tmpdir/pr19704 ""]
642 if {![string match $weak_symbol $exec_output]} {
643 fail $testname
644 } else {
645 pass $testname
646 }
647}
adc7571d 648
ea9fb8b3
L
649# Add $PLT_CFLAGS if PLT is expected.
650global PLT_CFLAGS
a7eaf017
L
651# Add $NOPIE_CFLAGS and $NOPIE_LDFLAGS if non-PIE is required.
652global NOPIE_CFLAGS NOPIE_LDFLAGS
ea9fb8b3 653
56d4d7f2
L
654# Must be native with the C compiler
655if { [isnative] && [which $CC] != 0 } {
adc7571d
L
656 run_cc_link_tests {
657 {"Helper X32 DSO from x86-64 object" "" "-m64 -fPIC -g"
658 {simple.c} {} "libsimple.a"}
659 }
660
661 set convertx32 "$objcopy -O elf32-x86-64 tmpdir/simple.o tmpdir/simple-x32.o"
662 send_log "$convertx32\n"
663 set got [remote_exec host "$convertx32"]
664 if { [lindex $got 0] != 0 || ![string match "" [lindex $got 1]] } then {
665 send_log "$got\n"
666 fail "Convert x86-64 object to x32"
667 return
668 }
669
670 run_ld_link_tests {
671 {"X32 DSO from x86-64 object"
897aea50 672 "-shared -melf32_x86_64 tmpdir/simple-x32.o" "" "--x32"
adc7571d
L
673 {dummy.s} {{readelf {-s --wide} x86-64-x32.rd}} "x86-64-x32"}
674 }
76e7af5f
L
675
676 run_cc_link_tests [list \
677 [list \
678 "Build plt-lib.so" \
679 "-shared" \
680 "-fPIC" \
681 { plt-lib.c } \
682 {} \
683 "libplt-lib.so" \
684 ] \
685 [list \
686 "Build libplt-main1.a" \
687 "" \
0cb4071e 688 "-fPIC -Wa,-mrelax-relocations=yes" \
76e7af5f
L
689 { plt-main1.c } \
690 {{readelf {-Wr} plt-main1.rd}} \
691 "libplt-main1.a" \
692 ] \
693 [list \
694 "Build libplt-main2.a" \
695 "" \
0cb4071e 696 "-fPIC -Wa,-mrelax-relocations=yes" \
76e7af5f
L
697 { plt-main2.c } \
698 {{readelf {-Wr} plt-main2.rd}} \
699 "libplt-main2.a" \
700 ] \
701 [list \
702 "Build libplt-main3.a" \
703 "" \
0cb4071e 704 "-fPIC -Wa,-mrelax-relocations=yes $PLT_CFLAGS" \
76e7af5f
L
705 { plt-main3.c } \
706 {{readelf {-Wr} plt-main3.rd}} \
707 "libplt-main3.a" \
708 ] \
709 [list \
710 "Build libplt-main4.a" \
711 "" \
0cb4071e 712 "-fPIC -Wa,-mrelax-relocations=yes $PLT_CFLAGS" \
76e7af5f
L
713 { plt-main4.c } \
714 {{readelf {-Wr} plt-main4.rd}} \
715 "libplt-main4.a" \
716 ] \
dd7e64d4
L
717 [list \
718 "Build plt-main" \
719 "tmpdir/plt-main1.o tmpdir/plt-main2.o tmpdir/plt-main3.o \
720 tmpdir/plt-main4.o tmpdir/libplt-lib.so" \
721 "" \
722 { plt-main5.c } \
723 {{readelf {-Wr} plt-main.rd}} \
724 "plt-main" \
725 ] \
726 [list \
727 "Build plt-main with PIE" \
728 "tmpdir/plt-main1.o tmpdir/plt-main2.o tmpdir/plt-main3.o \
729 tmpdir/plt-main4.o tmpdir/libplt-lib.so -pie" \
730 "-fPIC" \
731 { plt-main5.c } \
732 {{readelf {-Wr} plt-main.rd}} \
733 "plt-main" \
734 ] \
9a926d55
L
735 [list \
736 "Build copyreloc-lib.so" \
737 "-shared" \
738 "-fPIC" \
739 { copyreloc-lib.c } \
740 {} \
741 "copyreloc-lib.so" \
742 ] \
743 [list \
46175b4e
L
744 "Build libcopyreloc-main.a" \
745 "" \
9a926d55 746 "" \
01bbed2a 747 { copyreloc-main.S } \
46175b4e
L
748 {} \
749 "libcopyreloc-main.a" \
750 ] \
751 [list \
752 "Build copyreloc-main with PIE without -fPIE (1)" \
753 "tmpdir/copyreloc-main.o tmpdir/copyreloc-lib.so -pie" \
754 "" \
755 { dummy.s } \
9a926d55
L
756 {{readelf {-Wr} copyreloc-main1.rd}} \
757 "copyreloc-main" \
758 ] \
759 [list \
760 "Build copyreloc-main with PIE without -fPIE (2)" \
46175b4e 761 "tmpdir/copyreloc-main.o tmpdir/copyreloc-lib.so -pie" \
9a926d55 762 "" \
46175b4e 763 { dummy.s } \
9a926d55
L
764 {{readelf {-Wr} copyreloc-main2.rd}} \
765 "copyreloc-main" \
766 ] \
bc696fd5
L
767 [list \
768 "Build pr17689.so" \
769 "-shared" \
770 "-fPIC" \
771 { pr17689a.c } \
772 {} \
773 "pr17689.so" \
774 ] \
25070364
L
775 [list \
776 "Build pr17689now.so with -z now" \
777 "-shared -Wl,-z,now" \
778 "-fPIC" \
779 { pr17689a.c } \
780 {{readelf {-Wr} pr17689now.rd}} \
781 "pr17689now.so" \
782 ] \
bc696fd5 783 [list \
37ce0cc4
L
784 "Build pr17689b.o" \
785 "" \
bc696fd5
L
786 "" \
787 { pr17689b.S } \
37ce0cc4
L
788 {} \
789 ] \
790 [list \
791 "Build pr17689 with PIE without -fPIE" \
792 "tmpdir/pr17689b.o tmpdir/pr17689.so -pie" \
793 "" \
794 { dummy.s } \
bc696fd5
L
795 {{readelf {-Wr} pr17689.rd}} \
796 "pr17689" \
797 ] \
25070364
L
798 [list \
799 "Build pr17689 with PIE -z now without -fPIE" \
37ce0cc4 800 "tmpdir/pr17689b.o tmpdir/pr17689.so -pie -Wl,-z,now" \
25070364 801 "" \
37ce0cc4 802 { dummy.s } \
25070364
L
803 {{readelf {-Wr} pr17689now.rd}} \
804 "pr17689now" \
805 ] \
9d1d54d5
L
806 [list \
807 "Build pr17827 with PIE without -fPIE" \
37ce0cc4 808 "-Wl,--as-needed tmpdir/pr17689b.o tmpdir/pr17689.so -pie" \
9d1d54d5 809 "" \
37ce0cc4 810 { dummy.s } \
9d1d54d5
L
811 {{readelf {-Wr} pr17827.rd}} \
812 "pr17827" \
813 ] \
04ebc307
L
814 [list \
815 "Build pr18900.so" \
816 "-shared" \
817 "-fPIC" \
818 { pr18900a.c } \
819 "" \
820 "pr18900.so" \
821 ] \
822 [list \
23a4bd22
L
823 "Build pr18900.o" \
824 "-r -nostdlib" \
04ebc307
L
825 "" \
826 { pr18900b.c pr18900c.c } \
23a4bd22
L
827 "" \
828 "pr18900.o" \
829 ] \
830 [list \
831 "Build pr18900a" \
832 "tmpdir/pr18900.o tmpdir/pr18900.so" \
833 "" \
834 { dummy.s } \
04ebc307
L
835 {{readelf {-Wrd} pr18900a.rd}} \
836 "pr18900a" \
837 ] \
838 [list \
839 "Build pr18900b" \
23a4bd22 840 "-Wl,--as-needed tmpdir/pr18900.o tmpdir/pr18900.so" \
04ebc307 841 "" \
23a4bd22 842 { dummy.s } \
04ebc307
L
843 {{readelf {-Wrd} pr18900b.rd}} \
844 "pr18900b" \
845 ] \
5db4f0d3
L
846 [list \
847 "Build pr19031.so" \
848 "-shared" \
849 "-fPIC" \
850 { pr19031a.c } \
851 "" \
852 "pr19031.so" \
853 ] \
56ceb5b5
L
854 [list \
855 "Build gotpcrel1d.so" \
856 "-shared" \
857 "" \
858 { gotpcrel1d.S } \
859 "" \
860 "gotpcrel1d.so" \
861 ] \
37ce0cc4 862 [list \
b1058ce9 863 "Build gotpcrel1a.o gotpcrel1b.o gotpcrel1c.o" \
37ce0cc4 864 "" \
b1058ce9 865 "-Wa,-mrelax-relocations=yes" \
37ce0cc4 866 { gotpcrel1a.S gotpcrel1b.c gotpcrel1c.c } \
37ce0cc4 867 ] \
56ceb5b5
L
868 [list \
869 "Build gotpcrel1" \
68193357
L
870 "$NOPIE_LDFLAGS -Wl,--as-needed tmpdir/gotpcrel1a.o \
871 tmpdir/gotpcrel1b.o tmpdir/gotpcrel1c.o \
872 tmpdir/gotpcrel1d.so" \
37ce0cc4 873 { dummy.s } \
b1058ce9 874 "" \
56ceb5b5
L
875 {{objdump {-dw} gotpcrel1.dd}} \
876 "gotpcrel1" \
877 ] \
ead3d542
L
878 [list \
879 "Build pr19319.so" \
880 "-shared" \
881 "" \
882 { pr19319a.S } \
883 "" \
884 "pr19319.so" \
885 ] \
886 [list \
887 "Build pr19319" \
888 "-pie -nostdlib -nostartfiles tmpdir/pr19319.so" \
889 "" \
890 { pr19319b.S } \
891 {{objdump {-dw} pr19319.dd}} \
892 "pr19319" \
893 ] \
46bed679
L
894 [list \
895 "Build property 1" \
896 "" \
897 "" \
898 {pass.c property-no-copy.S} \
899 {{readelf {-n} property-1.r}} \
900 "property-1" \
901 ] \
902 [list \
903 "Build property 1 (.o)" \
904 "-r -nostdlib" \
905 "" \
906 {pass.c property-no-copy.S} \
907 {{readelf {-n} property-1.r}} \
908 "property-1.o" \
909 ] \
910 [list \
911 "Build property 1 (.so)" \
912 "-shared" \
913 "-fPIC" \
914 {pass.c property-no-copy.S} \
915 {{readelf {-n} property-1.r}} \
916 "property-1.so" \
917 ] \
918 [list \
919 "Build property 2" \
920 "" \
921 "" \
922 {pass.c property-stack.S} \
923 {{readelf {-n} property-2.r}} \
924 "property-2" \
925 ] \
926 [list \
927 "Build property 2 (.o)" \
928 "-r -nostdlib" \
929 "" \
930 {pass.c property-stack.S} \
931 {{readelf {-n} property-2.r}} \
932 "property-2.o" \
933 ] \
934 [list \
935 "Build property 2 (.so)" \
936 "-shared" \
937 "-fPIC" \
938 {pass.c property-stack.S} \
939 {{readelf {-n} property-2.r}} \
940 "property-2.so" \
941 ] \
942 [list \
943 "Build property 3" \
944 "" \
945 "" \
946 {pass.c property-stack.S property-x86-1.S} \
947 {{readelf {-n} property-3.r}} \
948 "property-3" \
949 ] \
950 [list \
951 "Build property 3 (.o)" \
952 "-r -nostdlib" \
953 "" \
954 {pass.c property-x86-1.S property-stack.S} \
955 {{readelf {-n} property-3.r}} \
956 "property-3.o" \
957 ] \
958 [list \
959 "Build property 3 (.so)" \
960 "-shared" \
961 "-fPIC" \
962 {property-x86-1.S pass.c property-stack.S} \
963 {{readelf {-n} property-3.r}} \
964 "property-3.so" \
965 ] \
966 [list \
967 "Build property 4" \
968 "" \
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 4 (.o)" \
976 "-r -nostdlib" \
977 "" \
978 {pass.c property-x86-2.S property-x86-1.S property-stack.S} \
979 {{readelf {-n} property-4.r}} \
980 "property-4.o" \
981 ] \
982 [list \
983 "Build property 4 (.so)" \
984 "-shared" \
985 "-fPIC" \
986 {property-x86-2.S property-x86-1.S pass.c property-stack.S} \
987 {{readelf {-n} property-4.r}} \
988 "property-4.so" \
989 ] \
990 [list \
991 "Build property 4 (-Wl,-z,stack-size=0)" \
992 "-Wl,-z,stack-size=0" \
993 "" \
994 {pass.c property-stack.S property-x86-1.S property-x86-2.S} \
995 {{readelf {-n} property-4.r}} \
996 "property-4" \
997 ] \
998 [list \
999 "Build property 5" \
1000 "-Wl,-z,stack-size=0x900000" \
1001 "" \
1002 {pass.c property-stack.S property-x86-1.S property-x86-2.S} \
1003 {{readelf {-n} property-5.r}} \
1004 "property-5" \
1005 ] \
1006 [list \
1007 "Build property 5 (.o)" \
1008 "-r -nostdlib -Wl,-z,stack-size=0x900000" \
1009 "" \
1010 {pass.c property-x86-2.S property-x86-1.S property-stack.S} \
1011 {{readelf {-n} property-5.r}} \
1012 "property-5.o" \
1013 ] \
1014 [list \
1015 "Build property 5 (.so)" \
1016 "-shared -Wl,-z,stack-size=0x900000" \
1017 "-fPIC" \
1018 {property-x86-2.S property-x86-1.S pass.c property-stack.S} \
1019 {{readelf {-n} property-5.r}} \
1020 "property-5.so" \
1021 ] \
1022 [list \
1023 "Build property-6.so" \
1024 "-shared" \
1025 "-fPIC" \
1026 {property-6a.c property-6c.S} \
1027 {{readelf {-n} property-6.r}} \
1028 "property-6.so" \
1029 ] \
1030 [list \
1031 "Build property-6.o" \
1032 "-r -nostdlib" \
1033 "" \
1034 {property-6b.c property-stack.S} \
1035 {{readelf {-n} property-2.r}} \
1036 "property-6.o" \
1037 ] \
1038 [list \
1039 "Build property-6" \
1040 "-Wl,--as-needed tmpdir/property-6.o tmpdir/property-6.so" \
1041 { dummy.s } \
1042 "" \
1043 {{readelf {-n} property-2.r}} \
1044 "property-6" \
1045 ] \
1046 [list \
1047 "Build property 7a (.o)" \
1048 "-r -nostdlib" \
1049 "" \
1050 {property-unsorted-1.S} \
1051 {{readelf {-n} property-7.r}} \
1052 "property-7a.o" \
1053 ] \
1054 [list \
1055 "Build property 7b (.o)" \
1056 "-r -nostdlib" \
1057 "" \
1058 {property-unsorted-2.S} \
1059 {{readelf {-n} property-7.r}} \
1060 "property-7b.o" \
1061 ] \
7073b5b9
L
1062 [list \
1063 "Build pr22001-1.so" \
1064 "-shared" \
1065 "-fPIC" \
1066 { pr22001-1a.c } \
1067 {} \
1068 "pr22001-1.so" \
1069 ] \
1070 [list \
1071 "Build pr22001-1a" \
1072 "$NOPIE_LDFLAGS -Wl,-z,nocopyreloc,--no-as-needed tmpdir/pr22001-1.so" \
1073 "$NOPIE_CFLAGS" \
1074 { pr22001-1b.c } \
1075 {{error_output "pr22001-1a.err"}} \
1076 "pr22001-1a" \
1077 ] \
a5b4ee94
L
1078 [list \
1079 "Build pr21997-1.so" \
1080 "-shared" \
1081 "" \
1082 { property-stack.S property-no-copy.S pr21997-1a.S } \
1083 {} \
1084 "pr21997-1.so" \
1085 ] \
1086 [list \
1087 "Build pr21997-1a" \
1088 "$NOPIE_LDFLAGS -Wl,--no-as-needed tmpdir/pr21997-1.so" \
1089 "$NOPIE_CFLAGS" \
1090 { pr21997-1b.c } \
1091 {{error_output "pr21997-1a.err"}} \
1092 "pr21997-1a" \
1093 ] \
ad71ce8d
L
1094 [list \
1095 "Build pr22064a.o" \
1096 "" \
1097 "" \
1098 { pr22064a.S } \
1099 ] \
1100 [list \
1101 "Build pr22064.so" \
1102 "-shared" \
1103 "-fPIC" \
1104 { pr22064b.c } \
1105 {} \
1106 "pr22064.so" \
1107 ] \
76e7af5f
L
1108 ]
1109
28e6a46b
L
1110 if {[istarget "x86_64-*-linux*-gnux32"]} {
1111 run_ld_link_exec_tests [list \
1112 [list \
1113 "Run pr22001-1b" \
1114 "$NOPIE_LDFLAGS -Wl,-z,nocopyreloc,--no-as-needed tmpdir/pr22001-1.so" \
1115 "" \
1116 { pr22001-1c.c } \
1117 "pr22001-1b" \
1118 "pass.out" \
1119 "$NOPIE_CFLAGS" \
1120 ] \
a5b4ee94
L
1121 [list \
1122 "Run pr21997-1b" \
1123 "$NOPIE_LDFLAGS -Wl,--no-as-needed tmpdir/pr21997-1.so" \
1124 "" \
1125 { pr21997-1c.c } \
1126 "pr21997-1b" \
1127 "pass.out" \
1128 "$NOPIE_CFLAGS" \
1129 ] \
28e6a46b
L
1130 ]
1131 } else {
1132 run_cc_link_tests [list \
1133 [list \
1134 "Build pr22001-1b" \
1135 "$NOPIE_LDFLAGS -Wl,-z,nocopyreloc,--no-as-needed tmpdir/pr22001-1.so" \
1136 "$NOPIE_CFLAGS" \
1137 { pr22001-1c.c } \
1138 {{error_output "pr22001-1b.err"}} \
1139 "pr22001-1b" \
1140 ] \
a5b4ee94
L
1141 [list \
1142 "Build pr21997-1b" \
1143 "$NOPIE_LDFLAGS -Wl,--no-as-needed tmpdir/pr21997-1.so" \
1144 "$NOPIE_CFLAGS" \
1145 { pr21997-1c.c } \
1146 {{error_output "pr21997-1b.err"}} \
1147 "pr21997-1b" \
1148 ] \
28e6a46b
L
1149 ]
1150 }
1151
982c6f26 1152 run_ld_link_exec_tests [list \
76e7af5f
L
1153 [list \
1154 "Run plt-main" \
d9816402
AM
1155 "-Wl,--no-as-needed tmpdir/plt-main1.o tmpdir/plt-main2.o \
1156 tmpdir/plt-main3.o tmpdir/plt-main4.o tmpdir/libplt-lib.so" \
76e7af5f
L
1157 "" \
1158 { plt-main5.c } \
1159 "plt-main" \
1160 "plt-main.out" \
1161 ] \
ce641d0b
L
1162 [list \
1163 "Run plt-main with PIE" \
d9816402
AM
1164 "-Wl,--no-as-needed -pie tmpdir/plt-main1.o tmpdir/plt-main2.o \
1165 tmpdir/plt-main3.o tmpdir/plt-main4.o tmpdir/libplt-lib.so" \
ce641d0b
L
1166 "" \
1167 { plt-main5.c } \
1168 "plt-main-pie" \
1169 "plt-main.out" \
1170 "-fPIC" \
1171 ] \
9a926d55
L
1172 [list \
1173 "Run copyreloc-main with PIE without -fPIE" \
d9816402 1174 "-Wl,--as-needed -pie tmpdir/copyreloc-main.o tmpdir/copyreloc-lib.so" \
9a926d55 1175 "" \
46175b4e 1176 { dummy.s } \
9a926d55
L
1177 "copyreloc-main" \
1178 "copyreloc-main.out" \
1179 ] \
bc696fd5
L
1180 [list \
1181 "Run pr17689 with PIE without -fPIE" \
d9816402 1182 "-Wl,--no-as-needed -pie tmpdir/pr17689b.o tmpdir/pr17689.so" \
bc696fd5 1183 "" \
37ce0cc4 1184 { dummy.s } \
bc696fd5
L
1185 "pr17689" \
1186 "pr17689.out" \
1187 ] \
25070364
L
1188 [list \
1189 "Run pr17689 with PIE -z now without -fPIE" \
d9816402 1190 "-Wl,--as-needed,-z,now -pie tmpdir/pr17689b.o tmpdir/pr17689.so" \
25070364 1191 "" \
37ce0cc4 1192 { dummy.s } \
25070364
L
1193 "pr17689now" \
1194 "pr17689.out" \
1195 ] \
04ebc307
L
1196 [list \
1197 "Run pr18900" \
d9816402 1198 "-Wl,--no-as-needed tmpdir/pr18900.o tmpdir/pr18900.so" \
04ebc307 1199 "" \
23a4bd22 1200 { dummy.s } \
04ebc307
L
1201 "pr18900" \
1202 "pr18900.out" \
1203 ] \
5db4f0d3
L
1204 [list \
1205 "Run pr19031" \
68193357 1206 "$NOPIE_LDFLAGS -Wl,--no-as-needed tmpdir/pr19031.so" \
5db4f0d3
L
1207 "" \
1208 { pr19031b.S pr19031c.c } \
1209 "pr19031" \
1210 "pr19031.out" \
68193357 1211 "$NOPIE_CFLAGS" \
5db4f0d3 1212 ] \
56ceb5b5
L
1213 [list \
1214 "Run gotpcrel1" \
d9816402 1215 "-Wl,--no-as-needed tmpdir/gotpcrel1d.so" \
56ceb5b5
L
1216 "" \
1217 { gotpcrel1a.S gotpcrel1b.c gotpcrel1c.c } \
1218 "gotpcrel1" \
1219 "gotpcrel1.out" \
1220 ] \
46bed679
L
1221 [list \
1222 "Run property 1" \
1223 "" \
1224 "" \
1225 {pass.c property-no-copy.S} \
1226 "property-1" "pass.out" \
1227 ] \
1228 [list \
1229 "Run property 1 (PIE)" \
1230 "-pie" \
1231 "" \
1232 {pass.c property-no-copy.S} \
1233 "property-1-pie" "pass.out" "-fPIE" \
1234 ] \
1235 [list \
1236 "Run property 1 (static)" \
1237 "-static" \
1238 "" \
1239 {pass.c property-no-copy.S} \
1240 "property-1-static" "pass.out" \
1241 ] \
1242 [list \
1243 "Run property 2" \
1244 "" \
1245 "" \
1246 {pass.c property-stack.S} \
1247 "property-2" "pass.out" \
1248 ] \
1249 [list \
1250 "Run property 2 (PIE)" \
1251 "-pie" \
1252 "" \
1253 {pass.c property-stack.S} \
1254 "property-2-pie" "pass.out" "-fPIE" \
1255 ] \
1256 [list \
1257 "Run property 2 (static)" \
1258 "-static" \
1259 "" \
1260 {pass.c property-stack.S} \
1261 "property-3-static" "pass.out" \
1262 ] \
1263 [list \
1264 "Run property 3" \
1265 "" \
1266 "" \
1267 {pass.c property-stack.S property-x86-1.S} \
1268 "property-3" "pass.out" \
1269 ] \
1270 [list \
1271 "Run property 3 (PIE)" \
1272 "-pie" \
1273 "" \
1274 {pass.c property-x86-1.S property-stack.S} \
1275 "property-3-pie" "pass.out" "-fPIE" \
1276 ] \
1277 [list \
1278 "Run property 3 (static)" \
1279 "-static" \
1280 "" \
1281 {property-x86-1.S pass.c property-stack.S} \
1282 "property-3-static" "pass.out" \
1283 ] \
1284 [list \
1285 "Run property 4" \
1286 "" \
1287 "" \
1288 {pass.c property-stack.S property-x86-1.S property-x86-2.S} \
1289 "property-4" "pass.out" \
1290 ] \
1291 [list \
1292 "Run property 4 (PIE)" \
1293 "-pie" \
1294 "" \
1295 {pass.c property-x86-2.S property-x86-1.S property-stack.S} \
1296 "property-4-pie" "pass.out" "-fPIE" \
1297 ] \
1298 [list \
1299 "Run property 4 (static)" \
1300 "-static" \
1301 "" \
1302 {property-x86-2.S property-x86-1.S pass.c property-stack.S} \
1303 "property-4-static" "pass.out" \
1304 ] \
1305 [list \
1306 "Run property 5" \
1307 "-Wl,-z,stack-size=0x900000" \
1308 "" \
1309 {pass.c property-stack.S property-x86-1.S property-x86-2.S} \
1310 "property-5" "pass.out" \
1311 ] \
1312 [list \
1313 "Run property 5 (PIE)" \
1314 "-pie -Wl,-z,stack-size=0x900000" \
1315 "" \
1316 {pass.c property-x86-2.S property-x86-1.S property-stack.S} \
1317 "property-5-pie" "pass.out" "-fPIE" \
1318 ] \
1319 [list \
1320 "Run property 5 (static)" \
1321 "-static -Wl,-z,stack-size=0x900000" \
1322 "" \
1323 {property-x86-2.S property-x86-1.S pass.c property-stack.S} \
1324 "property-5-static" "pass.out" \
1325 ] \
7073b5b9
L
1326 [list \
1327 "Run pr22001-1a (PIC 1)" \
1328 "$NOPIE_LDFLAGS -Wl,-z,nocopyreloc,--no-as-needed tmpdir/pr22001-1.so" \
1329 "" \
1330 { pr22001-1b.c } \
1331 "pr22001-1a-pic-1" \
1332 "pass.out" \
1333 "-fPIC" \
1334 ] \
1335 [list \
1336 "Run pr22001-1a (PIC 2)" \
1337 "-pie -Wl,-z,nocopyreloc,--no-as-needed tmpdir/pr22001-1.so" \
1338 "" \
1339 { pr22001-1b.c } \
1340 "pr22001-1a-pic-2" \
1341 "pass.out" \
1342 "-fPIC" \
1343 ] \
1344 [list \
1345 "Run pr22001-1b (PIC 1)" \
1346 "$NOPIE_LDFLAGS -Wl,-z,nocopyreloc,--no-as-needed tmpdir/pr22001-1.so" \
1347 "" \
1348 { pr22001-1c.c } \
1349 "pr22001-1b-pic-1" \
1350 "pass.out" \
1351 "-fPIC" \
1352 ] \
1353 [list \
1354 "Run pr22001-1b (PIC 2)" \
1355 "-pie -Wl,-z,nocopyreloc,--no-as-needed tmpdir/pr22001-1.so" \
1356 "" \
1357 { pr22001-1c.c } \
1358 "pr22001-1b-pic-2" \
1359 "pass.out" \
1360 "-fPIC" \
1361 ] \
a5b4ee94
L
1362 [list \
1363 "Run pr21997-1a (PIC 1)" \
1364 "$NOPIE_LDFLAGS -Wl,--no-as-needed tmpdir/pr21997-1.so" \
1365 "" \
1366 { pr21997-1b.c } \
1367 "pr21997-1a-pic-1" \
1368 "pass.out" \
1369 "-fPIC" \
1370 ] \
1371 [list \
1372 "Run pr21997-1a (PIC 2)" \
1373 "-pie -Wl,--no-as-needed tmpdir/pr21997-1.so" \
1374 "" \
1375 { pr21997-1b.c } \
1376 "pr21997-1a-pic-2" \
1377 "pass.out" \
1378 "-fPIC" \
1379 ] \
1380 [list \
1381 "Run pr21997-1b (PIC 1)" \
1382 "$NOPIE_LDFLAGS -Wl,--no-as-needed tmpdir/pr21997-1.so" \
1383 "" \
1384 { pr21997-1c.c } \
1385 "pr21997-1b-pic-1" \
1386 "pass.out" \
1387 "-fPIC" \
1388 ] \
1389 [list \
1390 "Run pr21997-1b (PIC 2)" \
1391 "-pie -Wl,--no-as-needed tmpdir/pr21997-1.so" \
1392 "" \
1393 { pr21997-1c.c } \
1394 "pr21997-1b-pic-2" \
1395 "pass.out" \
1396 "-fPIC" \
1397 ] \
ad71ce8d
L
1398 [list \
1399 "Run pr22064" \
1400 "-pie -Wl,--no-as-needed tmpdir/pr22064a.o tmpdir/pr22064.so" \
1401 "" \
1402 { dummy.s } \
1403 "pr22064-pie" \
1404 "pass.out" \
1405 "-fPIE" \
1406 ] \
76e7af5f 1407 ]
dd7e64d4 1408
3c4f3228
L
1409 # Run-time tests which require working ifunc attribute support.
1410 if { [check_ifunc_attribute_available] } {
1411 run_cc_link_tests [list \
1412 [list \
1413 "Build libpr19784a.so" \
1414 "-shared -Wl,-Bsymbolic-functions" \
1415 "-fPIC -O2 -g" \
1416 { pr19784b.c pr19784c.c } \
1417 {} \
1418 "libpr19784a.so" \
1419 ] \
1420 [list \
1421 "Build libpr19784b.so" \
1422 "-shared -Wl,-Bsymbolic-functions" \
1423 "-fPIC -O2 -g" \
1424 { pr19784c.c pr19784b.c } \
1425 {} \
1426 "libpr19784b.so" \
1427 ] \
1428 [list \
1429 "Build pr19784a.o" \
1430 "" \
1431 "" \
1432 { pr19784a.c } \
1433 ] \
1434 ]
1435
1436 run_ld_link_exec_tests [list \
1437 [list \
1438 "Run pr19784a" \
d9816402 1439 "-Wl,--no-as-needed tmpdir/pr19784a.o tmpdir/libpr19784a.so" \
3c4f3228
L
1440 "" \
1441 { dummy.s } \
1442 "pr19784a" \
1443 "pass.out" \
1444 ] \
1445 [list \
1446 "Run pr19784b" \
d9816402 1447 "-Wl,--as-needed tmpdir/pr19784a.o tmpdir/libpr19784b.so" \
3c4f3228
L
1448 "" \
1449 { dummy.s } \
1450 "pr19784b" \
1451 "pass.out" \
1452 ] \
1453 ]
1454 }
1455
dd7e64d4
L
1456 if { [istarget "x86_64-*-linux*"] \
1457 && ![istarget "x86_64-*-linux*-gnux32"]} {
1458
1459 run_cc_link_tests [list \
1460 [list \
1461 "Build plt-main with -z bndplt" \
1462 "tmpdir/plt-main1.o tmpdir/plt-main2.o tmpdir/plt-main3.o \
1463 tmpdir/plt-main4.o tmpdir/libplt-lib.so -z bndplt" \
1464 "" \
1465 { plt-main5.c } \
1466 {{objdump {-drw} plt-main-bnd.dd}} \
1467 "plt-main-bnd" \
1468 ] \
1469 [list \
1470 "Build plt-main with PIE and -z bndplt" \
1471 "tmpdir/plt-main1.o tmpdir/plt-main2.o tmpdir/plt-main3.o \
1472 tmpdir/plt-main4.o tmpdir/libplt-lib.so -z bndplt -pie" \
1473 "-fPIC" \
1474 { plt-main5.c } \
1475 {{objdump {-drw} plt-main-bnd.dd}} \
1476 "plt-main-pie-bnd" \
1477 ] \
38b12349
L
1478 [list \
1479 "Build plt-main with -z bndplt -z now" \
1480 "tmpdir/plt-main1.o tmpdir/plt-main2.o tmpdir/plt-main3.o \
1481 tmpdir/plt-main4.o tmpdir/libplt-lib.so -z bndplt -z now" \
1482 "" \
1483 { plt-main5.c } \
1484 {{readelf {-SW} plt-main-bnd-now.rd} {objdump {-drw} plt-main-bnd.dd}} \
1485 "plt-main-bnd-now" \
1486 ] \
1487 [list \
1488 "Build plt-main with PIE and -z bndplt -z now" \
1489 "tmpdir/plt-main1.o tmpdir/plt-main2.o tmpdir/plt-main3.o \
1490 tmpdir/plt-main4.o tmpdir/libplt-lib.so -z bndplt -z now -pie" \
1491 "-fPIC" \
1492 { plt-main5.c } \
1493 {{readelf {-SW} plt-main-bnd-now.rd} {objdump {-drw} plt-main-bnd.dd}} \
1494 "plt-main-pie-bnd-now" \
1495 ] \
dd7e64d4
L
1496 ]
1497
982c6f26 1498 run_ld_link_exec_tests [list \
dd7e64d4
L
1499 [list \
1500 "Run plt-main with -z bndplt" \
d9816402
AM
1501 "-Wl,--no-as-needed,-z,bndplt tmpdir/plt-main1.o \
1502 tmpdir/plt-main2.o tmpdir/plt-main3.o \
1503 tmpdir/plt-main4.o tmpdir/libplt-lib.so" \
dd7e64d4
L
1504 "" \
1505 { plt-main5.c } \
1506 "plt-main-bnd" \
1507 "plt-main.out" \
1508 ] \
1509 [list \
1510 "Run plt-main with PIE and -z bndplt" \
d9816402
AM
1511 "-Wl,--no-as-needed,-z,bndplt -pie tmpdir/plt-main1.o \
1512 tmpdir/plt-main2.o tmpdir/plt-main3.o \
1513 tmpdir/plt-main4.o tmpdir/libplt-lib.so" \
dd7e64d4
L
1514 "" \
1515 { plt-main5.c } \
1516 "plt-main-pie-bnd" \
1517 "plt-main.out" \
1518 "-fPIC" \
1519 ] \
38b12349
L
1520 [list \
1521 "Run plt-main with -z bndplt -z now" \
1522 "-Wl,--no-as-needed,-z,bndplt,-z,now tmpdir/plt-main1.o \
1523 tmpdir/plt-main2.o tmpdir/plt-main3.o \
1524 tmpdir/plt-main4.o tmpdir/libplt-lib.so" \
1525 "" \
1526 { plt-main5.c } \
1527 "plt-main-bnd-now" \
1528 "plt-main.out" \
1529 ] \
1530 [list \
1531 "Run plt-main with PIE and -z bndplt -z now" \
1532 "-Wl,--no-as-needed,-z,bndplt,-z,now -pie tmpdir/plt-main1.o \
1533 tmpdir/plt-main2.o tmpdir/plt-main3.o \
1534 tmpdir/plt-main4.o tmpdir/libplt-lib.so" \
1535 "" \
1536 { plt-main5.c } \
1537 "plt-main-pie-bnd-now" \
1538 "plt-main.out" \
1539 "-fPIC" \
1540 ] \
9d734efa
L
1541 [list \
1542 "Run pr20800" \
d9816402 1543 "-Wl,-z,now -pie" \
9d734efa
L
1544 "" \
1545 { pr20800a.S pr20800b.S } \
1546 "pr20800" \
1547 "pass.out" \
1548 ] \
dd7e64d4 1549 ]
85406233
L
1550 if { [check_ifunc_attribute_available] } {
1551 run_ld_link_exec_tests [list \
1552 [list \
1553 "Run pr21481a" \
1554 "$NOPIE_LDFLAGS -Wl,-z,bndplt" \
1555 "" \
1556 { pr21481a.c pr21481b.S } \
1557 "pr21481a" \
1558 "pass.out" \
1559 "$NOPIE_CFLAGS" \
1560 ] \
1561 [list \
1562 "Run pr21481b" \
1563 "$NOPIE_LDFLAGS -Wl,-z,bndplt,-z,now" \
1564 "" \
1565 { pr21481a.c pr21481b.S } \
1566 "pr21481b" \
1567 "pass.out" \
1568 "$NOPIE_CFLAGS" \
1569 ] \
1570 ]
1571 }
dd7e64d4 1572 }
aec6b87e 1573
ee2fdd6f
L
1574 if { [istarget "x86_64-*-linux*"] } {
1575 if { [istarget "x86_64-*-linux*-gnux32"] } {
1576 set pltdump {{objdump {-drw} plt-main-ibt-x32.dd}}
1577 set pltsecdump {{readelf {-SW} plt-main-ibt-now.rd} {objdump {-drw} plt-main-ibt-x32.dd}}
1578 } else {
1579 set pltdump {{objdump {-drw} plt-main-ibt.dd}}
1580 set pltsecdump {{readelf {-SW} plt-main-ibt-now.rd} {objdump {-drw} plt-main-ibt.dd}}
1581 }
1582 run_cc_link_tests [list \
1583 [list \
1584 "Build plt-main with -z ibtplt" \
1585 "tmpdir/plt-main1.o tmpdir/plt-main2.o tmpdir/plt-main3.o \
1586 tmpdir/plt-main4.o tmpdir/libplt-lib.so -z ibtplt" \
1587 "" \
1588 { plt-main5.c } \
1589 $pltdump \
1590 "plt-main-ibt" \
1591 ] \
1592 [list \
1593 "Build plt-main with PIE and -z ibtplt" \
1594 "tmpdir/plt-main1.o tmpdir/plt-main2.o tmpdir/plt-main3.o \
1595 tmpdir/plt-main4.o tmpdir/libplt-lib.so -z ibtplt -pie" \
1596 "-fPIC" \
1597 { plt-main5.c } \
1598 $pltdump \
1599 "plt-main-pie-ibt" \
1600 ] \
1601 [list \
1602 "Build plt-main with -z ibtplt -z now" \
1603 "tmpdir/plt-main1.o tmpdir/plt-main2.o tmpdir/plt-main3.o \
1604 tmpdir/plt-main4.o tmpdir/libplt-lib.so -z ibtplt -z now" \
1605 "" \
1606 { plt-main5.c } \
1607 $pltsecdump \
1608 "plt-main-ibt-now" \
1609 ] \
1610 [list \
1611 "Build plt-main with PIE and -z ibtplt -z now" \
1612 "tmpdir/plt-main1.o tmpdir/plt-main2.o tmpdir/plt-main3.o \
1613 tmpdir/plt-main4.o tmpdir/libplt-lib.so -z ibtplt -z now -pie" \
1614 "-fPIC" \
1615 { plt-main5.c } \
1616 $pltsecdump \
1617 "plt-main-pie-ibt-now" \
1618 ] \
1619 [list \
1620 "Build libibtplt-lib.so with -z ibtplt" \
1621 "-shared -z ibtplt" \
1622 "-fPIC" \
1623 { plt-main1.c plt-main2.c plt-main3.c plt-main4.c} \
1624 $pltdump \
1625 "libibtplt-lib.so" \
1626 ] \
1627 [list \
1628 "Build libibtplt--now-lib.so with -z ibtplt -z now" \
1629 "-shared -z ibtplt -z now" \
1630 "-fPIC" \
1631 { plt-main1.c plt-main2.c plt-main3.c plt-main4.c} \
1632 $pltdump \
1633 "libibtplt-now-lib.so" \
1634 ] \
1635 ]
1636
1637 run_ld_link_exec_tests [list \
1638 [list \
1639 "Run plt-main with -z ibtplt" \
1640 "-Wl,--no-as-needed,-z,ibtplt tmpdir/plt-main1.o \
1641 tmpdir/plt-main2.o tmpdir/plt-main3.o \
1642 tmpdir/plt-main4.o tmpdir/libplt-lib.so" \
1643 "" \
1644 { plt-main5.c } \
1645 "plt-main-ibt" \
1646 "plt-main.out" \
1647 ] \
1648 [list \
1649 "Run plt-main with PIE and -z ibtplt" \
1650 "-Wl,--no-as-needed,-z,ibtplt -pie tmpdir/plt-main1.o \
1651 tmpdir/plt-main2.o tmpdir/plt-main3.o \
1652 tmpdir/plt-main4.o tmpdir/libplt-lib.so" \
1653 "" \
1654 { plt-main5.c } \
1655 "plt-main-pie-ibt" \
1656 "plt-main.out" \
1657 "-fPIC" \
1658 ] \
1659 [list \
1660 "Run plt-main with -z ibtplt -z now" \
1661 "-Wl,--no-as-needed,-z,ibtplt,-z,now tmpdir/plt-main1.o \
1662 tmpdir/plt-main2.o tmpdir/plt-main3.o \
1663 tmpdir/plt-main4.o tmpdir/libplt-lib.so" \
1664 "" \
1665 { plt-main5.c } \
1666 "plt-main-ibt-now" \
1667 "plt-main.out" \
1668 ] \
1669 [list \
1670 "Run plt-main with PIE and -z ibtplt -z now" \
1671 "-Wl,--no-as-needed,-z,ibtplt,-z,now -pie tmpdir/plt-main1.o \
1672 tmpdir/plt-main2.o tmpdir/plt-main3.o \
1673 tmpdir/plt-main4.o tmpdir/libplt-lib.so" \
1674 "" \
1675 { plt-main5.c } \
1676 "plt-main-pie-ibt-now" \
1677 "plt-main.out" \
1678 "-fPIC" \
1679 ] \
1680 [list \
1681 "Run plt-main with libibtplt-lib.so -z ibtplt" \
1682 "-Wl,--no-as-needed,-z,ibtplt tmpdir/libibtplt-lib.so \
1683 tmpdir/libplt-lib.so" \
1684 "" \
1685 { plt-main5.c } \
1686 "plt-main-ibt-lib" \
1687 "plt-main.out" \
1688 ] \
1689 [list \
1690 "Run plt-main with libibtplt-lib.so -z ibtplt -z now" \
1691 "-Wl,--no-as-needed,-z,ibtplt,-z,now \
1692 tmpdir/libibtplt-now-lib.so tmpdir/libplt-lib.so" \
1693 "" \
1694 { plt-main5.c } \
1695 "plt-main-ibt-now-lib" \
1696 "plt-main.out" \
1697 ] \
1698 ]
1699
1700 if { [check_ifunc_attribute_available] } {
1701 run_ld_link_exec_tests [list \
1702 [list \
1703 "Run pr21481a" \
1704 "$NOPIE_LDFLAGS -Wl,-z,ibtplt" \
1705 "" \
1706 { pr21481a.c pr21481b.S } \
1707 "pr21481a" \
1708 "pass.out" \
1709 "$NOPIE_CFLAGS" \
1710 ] \
1711 [list \
1712 "Run pr21481b" \
1713 "$NOPIE_LDFLAGS -Wl,-z,ibtplt,-z,now" \
1714 "" \
1715 { pr21481a.c pr21481b.S } \
1716 "pr21481b" \
1717 "pass.out" \
1718 "$NOPIE_CFLAGS" \
1719 ] \
1720 ]
1721 }
1722 }
1723
a7eaf017 1724 undefined_weak "$NOPIE_CFLAGS" "$NOPIE_LDFLAGS"
aec6b87e
L
1725 undefined_weak "-fPIE" ""
1726 undefined_weak "-fPIE" "-pie"
d9816402
AM
1727 undefined_weak "-fPIE" "-Wl,-z,nodynamic-undefined-weak"
1728 undefined_weak "-fPIE" "-pie -Wl,-z,nodynamic-undefined-weak"
adc7571d 1729}
ab7fede8
L
1730
1731if { ![istarget "x86_64-*-linux*"]} {
1732 return
1733}
1734
38b12349
L
1735run_ld_link_tests [list \
1736 [list \
1737 "basic PLT generation (-z now)" \
bab55c05 1738 "-z now -melf_x86_64 --hash-style=sysv tmpdir/libpltlib.so" \
38b12349
L
1739 "" \
1740 "--64" \
1741 {plt2.s} \
1742 {{readelf -SW plt2.rd} {objdump -dwr plt2.dd}} \
1743 "plt2" \
1744 ] \
abfa390d
L
1745 [list \
1746 "Build pr21626.so" \
1747 "-shared -melf_x86_64" \
1748 "" \
1749 "--64 -defsym __64_bit__=1" \
1750 {property-x86-3.s} \
1751 "" \
1752 "pr21626.so" \
1753 ] \
1754 [list \
1755 "Build pr21626" \
1756 "-melf_x86_64 tmpdir/pr21626.so" \
1757 "" \
1758 "--64" \
1759 {start.s foo.s} \
1760 "" \
1761 "pr21626" \
1762 ] \
38b12349
L
1763]
1764
ab7fede8 1765# Linux only tests
978c0540
L
1766global LD_CLASS
1767if { "$LD_CLASS" == "64bit" } then {
1768 # This test needs 64-bit linker.
1769 run_dump_test "pr17618"
1770}
a3747075 1771run_dump_test "pltgot-1"
7c1e8d3e 1772run_dump_test "pltgot-2"
59a1e29d
L
1773run_dump_test "pr20830a"
1774run_dump_test "pr20830b"
9e659176
L
1775run_dump_test "pr21038a"
1776run_dump_test "pr21038b"
8361ed4d 1777run_dump_test "pr21038c"
38b12349
L
1778run_dump_test "pr20830a-now"
1779run_dump_test "pr20830b-now"
1780run_dump_test "pr21038a-now"
1781run_dump_test "pr21038b-now"
1782run_dump_test "pr21038c-now"
ee2fdd6f
L
1783run_dump_test "ibt-plt-1"
1784run_dump_test "ibt-plt-1-x32"
1785run_dump_test "ibt-plt-2a"
1786run_dump_test "ibt-plt-2b"
1787run_dump_test "ibt-plt-2c"
1788run_dump_test "ibt-plt-2d"
1789run_dump_test "ibt-plt-2a-x32"
1790run_dump_test "ibt-plt-2b-x32"
1791run_dump_test "ibt-plt-2c-x32"
1792run_dump_test "ibt-plt-2d-x32"
1793run_dump_test "ibt-plt-3a"
1794run_dump_test "ibt-plt-3b"
1795run_dump_test "ibt-plt-3c"
1796run_dump_test "ibt-plt-3d"
1797run_dump_test "ibt-plt-3a-x32"
1798run_dump_test "ibt-plt-3b-x32"
1799run_dump_test "ibt-plt-3c-x32"
1800run_dump_test "ibt-plt-3d-x32"
This page took 1.029629 seconds and 4 git commands to generate.