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