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