]> 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-2024 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 run_dump_test "pr30787"
509
510 if { ![skip_sframe_tests] } {
511 run_dump_test "sframe-simple-1"
512 run_dump_test "sframe-plt-1"
513 }
514
515 if ![istarget "x86_64-*-linux*"] {
516 return
517 }
518
519 if ![ld_assemble $as "--x32 $srcdir/$subdir/start.s" tmpdir/startx32.o] {
520 fail "Build ILP32 start.o"
521 return
522 }
523
524 if ![ld_assemble $as "--32 $srcdir/$subdir/start.s" tmpdir/start32.o] {
525 fail "Build ia32 start.o"
526 return
527 }
528
529 if ![ld_assemble $as "--64 $srcdir/$subdir/start.s" tmpdir/start64.o] {
530 fail "Build LP64 start.o"
531 return
532 }
533
534 if ![ld_assemble $as "--x32 $srcdir/$subdir/foo.s" tmpdir/foox32.o] {
535 fail "Build ILP32 foo.o"
536 return
537 }
538
539 if ![ld_assemble $as "--32 $srcdir/$subdir/foo.s" tmpdir/foo32.o] {
540 fail "Build ia32 foo.o"
541 return
542 }
543
544 if ![ld_assemble $as "--64 $srcdir/$subdir/foo.s" tmpdir/foo64.o] {
545 fail "Build LP64 foo.o"
546 return
547 }
548
549 run_dump_test "compressed1"
550 run_dump_test "ilp32-1"
551 run_dump_test "ilp32-2"
552 run_dump_test "ilp32-3"
553 run_dump_test "ilp32-4"
554 run_dump_test "ilp32-5"
555 run_dump_test "ilp32-6"
556 run_dump_test "ilp32-7"
557 run_dump_test "ilp32-8"
558 run_dump_test "ilp32-9"
559 run_dump_test "ilp32-10"
560 run_dump_test "ilp32-11"
561 run_dump_test "ilp32-12"
562 run_dump_test "ia32-1"
563 run_dump_test "ia32-2"
564 run_dump_test "ia32-3"
565 run_dump_test "lp64-1"
566 run_dump_test "lp64-2"
567 run_dump_test "lp64-3"
568 run_dump_test "pr13082-1a"
569 run_dump_test "pr13082-1b"
570 run_dump_test "pr13082-2a"
571 run_dump_test "pr13082-2b"
572 run_dump_test "pr13082-3a"
573 run_dump_test "pr13082-3b"
574 run_dump_test "pr13082-3c"
575 run_dump_test "pr13082-3d"
576 run_dump_test "pr13082-4a"
577 run_dump_test "pr13082-4b"
578 run_dump_test "pr13082-5a"
579 run_dump_test "pr13082-5b"
580 run_dump_test "pr13082-6a"
581 run_dump_test "pr13082-6b"
582 run_dump_test "lea1a"
583 run_dump_test "lea1b"
584 run_dump_test "lea1c"
585 run_dump_test "lea1d"
586 run_dump_test "lea1e"
587 run_dump_test "lea1f"
588 run_dump_test "lea1g"
589 run_dump_test "lea1h"
590 run_dump_test "lea1i"
591 run_dump_test "lea1j"
592 run_dump_test "lea1k"
593 run_dump_test "lea1l"
594 run_dump_test "mov1a"
595 run_dump_test "mov1b"
596 run_dump_test "mov1c"
597 run_dump_test "mov1d"
598 run_dump_test "mov2a"
599 run_dump_test "mov2b"
600 run_dump_test "mov2c"
601 run_dump_test "mov2d"
602 run_dump_test "ljmp1"
603 run_dump_test "ljmp2"
604 run_dump_test "load1a"
605 run_dump_test "load1b"
606 run_dump_test "load1c"
607 run_dump_test "load1d"
608 run_dump_test "apx-load1a"
609 run_dump_test "apx-load1b"
610 run_dump_test "apx-load1c"
611 run_dump_test "apx-load1d"
612 run_dump_test "load2"
613 run_dump_test "call1a"
614 run_dump_test "call1b"
615 run_dump_test "call1c"
616 run_dump_test "call1d"
617 run_dump_test "call1e"
618 run_dump_test "call1f"
619 run_dump_test "call1g"
620 run_dump_test "call1h"
621 run_dump_test "call1i"
622 run_dump_test "pr17935-1"
623 run_dump_test "pr17935-2"
624 run_dump_test "pr18160"
625 run_dump_test "pr18176"
626 run_dump_test "pr18801a"
627 run_dump_test "pr18801b"
628 run_dump_test "ifunc-textrel-1a"
629 run_dump_test "ifunc-textrel-1b"
630 run_dump_test "ifunc-textrel-2a"
631 run_dump_test "ifunc-textrel-2b"
632 run_dump_test "pr18815"
633 run_dump_test "pr19013"
634 run_dump_test "pr19013-x32"
635 run_dump_test "pr19162"
636 run_dump_test "pr19175"
637 run_dump_test "pr18591"
638 run_dump_test "pr19615"
639 run_dump_test "pr19636-1a"
640 run_dump_test "pr19636-1b"
641 run_dump_test "pr19636-1c"
642 run_dump_test "pr19636-1d"
643 run_dump_test "pr19636-1e"
644 run_dump_test "pr19636-1f"
645 run_dump_test "pr19636-1g"
646 run_dump_test "pr19636-1h"
647 run_dump_test "pr19636-1i"
648 run_dump_test "pr19636-1j"
649 run_dump_test "pr19636-2a"
650 run_dump_test "pr19636-2b"
651 run_dump_test "pr19636-2c"
652 run_dump_test "pr19636-2d"
653 run_dump_test "pr19636-2e"
654 run_dump_test "pr19636-2f"
655 run_dump_test "pr19636-2g"
656 run_dump_test "pr19636-2h"
657 run_dump_test "pr19636-2i"
658 run_dump_test "pr19636-2j"
659 run_dump_test "pr19636-2k"
660 run_dump_test "pr19636-2l"
661 run_dump_test "pr19636-2m"
662 run_dump_test "pr19636-3a"
663 run_dump_test "pr19636-3b"
664 run_dump_test "pr19636-3c"
665 run_dump_test "pr19645"
666 run_dump_test "pr19609-1a"
667 run_dump_test "pr19609-1b"
668 run_dump_test "pr19609-1c"
669 run_dump_test "pr19609-1d"
670 run_dump_test "pr19609-1e"
671 run_dump_test "pr19609-1f"
672 run_dump_test "pr19609-1g"
673 run_dump_test "pr19609-1h"
674 run_dump_test "pr19609-1i"
675 run_dump_test "pr19609-1j"
676 run_dump_test "pr19609-1k"
677 run_dump_test "pr19609-1l"
678 run_dump_test "pr19609-1m"
679 run_dump_test "pr19609-2a"
680 run_dump_test "pr19609-2b"
681 run_dump_test "pr19609-2c"
682 run_dump_test "pr19609-2d"
683 run_dump_test "pr19609-3a"
684 run_dump_test "pr19609-3b"
685 run_dump_test "pr19609-4a"
686 run_dump_test "pr19609-4b"
687 run_dump_test "pr19609-4c"
688 run_dump_test "pr19609-4d"
689 run_dump_test "pr19609-4e"
690 run_dump_test "pr19609-5a"
691 run_dump_test "pr19609-5b"
692 run_dump_test "pr19609-5c"
693 run_dump_test "pr19609-5d"
694 run_dump_test "pr19609-5e"
695 run_dump_test "pr19609-6a"
696 run_dump_test "pr19609-6b"
697 run_dump_test "pr19609-6c"
698 run_dump_test "pr19609-6d"
699 run_dump_test "pr19609-7a"
700 run_dump_test "pr19609-7b"
701 run_dump_test "pr19609-7c"
702 run_dump_test "pr19609-7d"
703 run_dump_test "pr19939a"
704 run_dump_test "pr19939b"
705 run_dump_test "pr19719"
706 run_dump_test "pr20253-1a"
707 run_dump_test "pr20253-1b"
708 run_dump_test "pr20253-1c"
709 run_dump_test "pr20253-1d"
710 run_dump_test "pr20253-1e"
711 run_dump_test "pr20253-1f"
712 run_dump_test "pr20253-1g"
713 run_dump_test "pr20253-1h"
714 run_dump_test "pr20253-1i"
715 run_dump_test "pr20253-1j"
716 run_dump_test "pr20253-1k"
717 run_dump_test "pr20253-1l"
718 run_dump_test "pr20253-3"
719 run_dump_test "pr20253-4a"
720 run_dump_test "pr20253-4b"
721 run_dump_test "pr20253-4c"
722 run_dump_test "pr20253-4d"
723 run_dump_test "pr20253-4e"
724 run_dump_test "pr20253-4f"
725 run_dump_test "pr20253-5a"
726 run_dump_test "pr20253-5b"
727 run_dump_test "tlsdesc2"
728 run_dump_test "pr22048"
729 run_dump_test "pr22929"
730 run_dump_test "pr26939"
731 run_dump_test "pr26939-x32"
732 run_dump_test "pr27016a"
733 run_dump_test "pr27016b"
734 run_dump_test "report-reloc-1"
735 run_dump_test "report-reloc-1-x32"
736 run_dump_test "pr29820"
737
738 proc undefined_weak {cflags ldflags} {
739 set testname "Undefined weak symbol"
740 if { ![ string match "" $cflags$ldflags] } {
741 set testname "$testname ($cflags $ldflags)"
742 }
743
744 if { [string match "*-fPIE*" $cflags]
745 && ![string match "*nodynamic-undefined-weak*" $ldflags] } {
746 set weak_symbol "Weak defined"
747 } else {
748 set weak_symbol "Weak undefined"
749 }
750
751 run_cc_link_tests [list \
752 [list \
753 "Build libpr19704a.so" \
754 "-shared -Wl,-soname,libpr19704.so" \
755 "" \
756 { dummy.s } \
757 {} \
758 "libpr19704a.so" \
759 ] \
760 [list \
761 "Build libpr19704b.so" \
762 "-shared -Wl,-soname,libpr19704.so" \
763 "-fPIC" \
764 { pr19704b.c } \
765 {} \
766 "libpr19704b.so" \
767 ] \
768 ]
769
770 exec cp tmpdir/libpr19704a.so tmpdir/libpr19704.so
771
772 run_ld_link_exec_tests [list \
773 [list \
774 "Run pr19704" \
775 "-Wl,--no-as-needed,-R,tmpdir $ldflags tmpdir/libpr19704.so" \
776 "" \
777 { pr19704a.c } \
778 "pr19704" \
779 "pr19704.out" \
780 "$cflags" \
781 ] \
782 ]
783
784 exec cp tmpdir/libpr19704b.so tmpdir/libpr19704.so
785
786 set exec_output [run_host_cmd tmpdir/pr19704 ""]
787 if {![string match $weak_symbol $exec_output]} {
788 fail $testname
789 } else {
790 pass $testname
791 }
792 }
793
794 # Must be native with the C compiler
795 if { [isnative] && [check_compiler_available] } {
796 run_cc_link_tests [list \
797 [list \
798 "Helper X32 DSO from x86-64 object" "" \
799 "-m64 $NOSANITIZE_CFLAGS -fPIC -g" \
800 {simple.c} {} "libsimple.a" \
801 ] \
802 ]
803
804 set convertx32 "$objcopy -O elf32-x86-64 tmpdir/simple.o tmpdir/simple-x32.o"
805 send_log "$convertx32\n"
806 set got [remote_exec host "$convertx32"]
807 if { [lindex $got 0] != 0 || ![string match "" [lindex $got 1]] } then {
808 send_log "$got\n"
809 fail "Convert x86-64 object to x32"
810 return
811 }
812
813 run_ld_link_tests [list \
814 [list \
815 "X32 DSO from x86-64 object" \
816 "-shared -melf32_x86_64 tmpdir/simple-x32.o" \
817 "$NOSANITIZE_CFLAGS" \
818 "--x32 -mx86-used-note=yes" \
819 {dummy.s} {{readelf {-s --wide} x86-64-x32.rd}} \
820 "x86-64-x32" \
821 ] \
822 ]
823
824 run_cc_link_tests [list \
825 [list \
826 "Build plt-lib.so" \
827 "-shared" \
828 "-fPIC -Wa,-mx86-used-note=yes" \
829 { plt-lib.c } \
830 {} \
831 "libplt-lib.so" \
832 ] \
833 [list \
834 "Build libplt-main1.a" \
835 "" \
836 "-fPIC -Wa,-mrelax-relocations=yes,-mx86-used-note=yes" \
837 { plt-main1.c } \
838 {{readelf {-Wr} plt-main1.rd}} \
839 "libplt-main1.a" \
840 ] \
841 [list \
842 "Build libplt-main2.a" \
843 "" \
844 "-fPIC -Wa,-mrelax-relocations=yes,-mx86-used-note=yes" \
845 { plt-main2.c } \
846 {{readelf {-Wr} plt-main2.rd}} \
847 "libplt-main2.a" \
848 ] \
849 [list \
850 "Build libplt-main3.a" \
851 "" \
852 "-fPIC -Wa,-mrelax-relocations=yes,-mx86-used-note=yes $PLT_CFLAGS" \
853 { plt-main3.c } \
854 {{readelf {-Wr} plt-main3.rd}} \
855 "libplt-main3.a" \
856 ] \
857 [list \
858 "Build libplt-main4.a" \
859 "" \
860 "-fPIC -Wa,-mrelax-relocations=yes,-mx86-used-note=yes $PLT_CFLAGS" \
861 { plt-main4.c } \
862 {{readelf {-Wr} plt-main4.rd}} \
863 "libplt-main4.a" \
864 ] \
865 [list \
866 "Build plt-main" \
867 "tmpdir/plt-main1.o tmpdir/plt-main2.o tmpdir/plt-main3.o \
868 tmpdir/plt-main4.o tmpdir/libplt-lib.so" \
869 "" \
870 { plt-main5.c } \
871 {{readelf {-Wr} plt-main.rd}} \
872 "plt-main" \
873 ] \
874 [list \
875 "Build plt-main with PIE" \
876 "tmpdir/plt-main1.o tmpdir/plt-main2.o tmpdir/plt-main3.o \
877 tmpdir/plt-main4.o tmpdir/libplt-lib.so -pie" \
878 "-fPIC -Wa,-mx86-used-note=yes" \
879 { plt-main5.c } \
880 {{readelf {-Wr} plt-main.rd}} \
881 "plt-main" \
882 ] \
883 [list \
884 "Build copyreloc-lib.so" \
885 "-shared" \
886 "-fPIC -Wa,-mx86-used-note=yes" \
887 { copyreloc-lib.c } \
888 {} \
889 "copyreloc-lib.so" \
890 ] \
891 [list \
892 "Build libcopyreloc-main.a" \
893 "" \
894 "-Wa,-mx86-used-note=yes" \
895 { copyreloc-main.S } \
896 {} \
897 "libcopyreloc-main.a" \
898 ] \
899 [list \
900 "Build copyreloc-main with PIE without -fPIE (1)" \
901 "tmpdir/copyreloc-main.o tmpdir/copyreloc-lib.so -pie" \
902 "-Wa,-mx86-used-note=yes" \
903 { dummy.s } \
904 {{readelf {-Wr} copyreloc-main1.rd}} \
905 "copyreloc-main" \
906 ] \
907 [list \
908 "Build copyreloc-main with PIE without -fPIE (2)" \
909 "tmpdir/copyreloc-main.o tmpdir/copyreloc-lib.so -pie" \
910 "-Wa,-mx86-used-note=yes" \
911 { dummy.s } \
912 {{readelf {-Wr} copyreloc-main2.rd}} \
913 "copyreloc-main" \
914 ] \
915 [list \
916 "Build pr17689.so" \
917 "-shared" \
918 "-fPIC -Wa,-mx86-used-note=yes" \
919 { pr17689a.c } \
920 {} \
921 "pr17689.so" \
922 ] \
923 [list \
924 "Build pr17689now.so with -z now" \
925 "-shared -Wl,-z,now" \
926 "-fPIC -Wa,-mx86-used-note=yes" \
927 { pr17689a.c } \
928 {{readelf {-Wr} pr17689now.rd}} \
929 "pr17689now.so" \
930 ] \
931 [list \
932 "Build pr17689b.o" \
933 "" \
934 "-Wa,-mx86-used-note=yes" \
935 { pr17689b.S } \
936 {} \
937 ] \
938 [list \
939 "Build pr17689 with PIE without -fPIE" \
940 "tmpdir/pr17689b.o tmpdir/pr17689.so -pie" \
941 "-Wa,-mx86-used-note=yes" \
942 { dummy.s } \
943 {{readelf {-Wr} pr17689.rd}} \
944 "pr17689" \
945 ] \
946 [list \
947 "Build pr17689 with PIE -z now without -fPIE" \
948 "tmpdir/pr17689b.o tmpdir/pr17689.so -pie -Wl,-z,now" \
949 "-Wa,-mx86-used-note=yes" \
950 { dummy.s } \
951 {{readelf {-Wr} pr17689now.rd}} \
952 "pr17689now" \
953 ] \
954 [list \
955 "Build pr17827 with PIE without -fPIE" \
956 "-Wl,--as-needed tmpdir/pr17689b.o tmpdir/pr17689.so -pie" \
957 "-Wa,-mx86-used-note=yes" \
958 { dummy.s } \
959 {{readelf {-Wr} pr17827.rd}} \
960 "pr17827" \
961 ] \
962 [list \
963 "Build pr18900.so" \
964 "-shared" \
965 "-fPIC -Wa,-mx86-used-note=yes" \
966 { pr18900a.c } \
967 "" \
968 "pr18900.so" \
969 ] \
970 [list \
971 "Build pr18900.o" \
972 "-r -nostdlib" \
973 "-Wa,-mx86-used-note=yes" \
974 { pr18900b.c pr18900c.c } \
975 "" \
976 "pr18900.o" \
977 ] \
978 [list \
979 "Build pr18900a" \
980 "tmpdir/pr18900.o tmpdir/pr18900.so" \
981 "-Wa,-mx86-used-note=yes" \
982 { dummy.s } \
983 {{readelf {-Wrd} pr18900a.rd}} \
984 "pr18900a" \
985 ] \
986 [list \
987 "Build pr18900b" \
988 "-Wl,--as-needed tmpdir/pr18900.o tmpdir/pr18900.so" \
989 "-Wa,-mx86-used-note=yes" \
990 { dummy.s } \
991 {{readelf {-Wrd} pr18900b.rd}} \
992 "pr18900b" \
993 ] \
994 [list \
995 "Build pr19031.so" \
996 "-shared" \
997 "-fPIC -Wa,-mx86-used-note=yes" \
998 { pr19031a.c } \
999 "" \
1000 "pr19031.so" \
1001 ] \
1002 [list \
1003 "Build gotpcrel1d.so" \
1004 "-shared" \
1005 "-Wa,-mx86-used-note=yes" \
1006 { gotpcrel1d.S } \
1007 "" \
1008 "gotpcrel1d.so" \
1009 ] \
1010 [list \
1011 "Build gotpcrel1a.o gotpcrel1b.o gotpcrel1c.o" \
1012 "" \
1013 "-Wa,-mrelax-relocations=yes,-mx86-used-note=yes" \
1014 { gotpcrel1a.S gotpcrel1b.c gotpcrel1c.c } \
1015 ] \
1016 [list \
1017 "Build gotpcrel1" \
1018 "$NOPIE_LDFLAGS -Wl,--as-needed tmpdir/gotpcrel1a.o \
1019 tmpdir/gotpcrel1b.o tmpdir/gotpcrel1c.o \
1020 tmpdir/gotpcrel1d.so" \
1021 "-Wa,-mx86-used-note=yes" \
1022 { dummy.s } \
1023 {{objdump {-dw} gotpcrel1.dd}} \
1024 "gotpcrel1" \
1025 ] \
1026 [list \
1027 "Build pr19319.so" \
1028 "-shared" \
1029 "-Wa,-mx86-used-note=yes" \
1030 { pr19319a.S } \
1031 "" \
1032 "pr19319.so" \
1033 ] \
1034 [list \
1035 "Build pr19319" \
1036 "-pie -nostdlib -nostartfiles tmpdir/pr19319.so" \
1037 "-Wa,-mx86-used-note=yes" \
1038 { pr19319b.S } \
1039 {{objdump {-dw} pr19319.dd}} \
1040 "pr19319" \
1041 ] \
1042 [list \
1043 "Build pr24276.so" \
1044 "-shared -nostdlib -nostartfiles \
1045 -Ltmpdir $srcdir/$subdir/pr24276.dso" \
1046 "-Wa,-mx86-used-note=yes" \
1047 { pr19319b.S } \
1048 {{warning_output pr24276.warn}} \
1049 "pr24276.so" \
1050 ] \
1051 [list \
1052 "Build property 1" \
1053 "" \
1054 "-Wa,-mx86-used-note=no" \
1055 {pass.c property-no-copy.S} \
1056 {{readelf {-n} property-1.r}} \
1057 "property-1" \
1058 ] \
1059 [list \
1060 "Build property 1 (.o)" \
1061 "-r -nostdlib" \
1062 "-Wa,-mx86-used-note=yes" \
1063 {pass.c property-no-copy.S} \
1064 {{readelf {-n} property-1a.r}} \
1065 "property-1.o" \
1066 ] \
1067 [list \
1068 "Build property 1 (.so)" \
1069 "-shared" \
1070 "-fPIC -Wa,-mx86-used-note=no" \
1071 {pass.c property-no-copy.S} \
1072 {{readelf {-n} property-1.r}} \
1073 "property-1.so" \
1074 ] \
1075 [list \
1076 "Build property 2" \
1077 "" \
1078 "-Wa,-mx86-used-note=no" \
1079 {pass.c property-stack.S} \
1080 {{readelf {-n} property-2.r}} \
1081 "property-2" \
1082 ] \
1083 [list \
1084 "Build property 2 (.o)" \
1085 "-r -nostdlib" \
1086 "-Wa,-mx86-used-note=yes" \
1087 {pass.c property-stack.S} \
1088 {{readelf {-n} property-2a.r}} \
1089 "property-2.o" \
1090 ] \
1091 [list \
1092 "Build property 2 (.so)" \
1093 "-shared" \
1094 "-fPIC -Wa,-mx86-used-note=yes" \
1095 {pass.c property-stack.S} \
1096 {{readelf {-n} property-2.r}} \
1097 "property-2.so" \
1098 ] \
1099 [list \
1100 "Build property-6.so" \
1101 "-shared" \
1102 "-fPIC -Wa,-mx86-used-note=yes" \
1103 {property-6a.c property-6c.S} \
1104 {{readelf {-n} property-6.r}} \
1105 "property-6.so" \
1106 ] \
1107 [list \
1108 "Build property-6.o" \
1109 "-r -nostdlib" \
1110 "-Wa,-mx86-used-note=yes" \
1111 {property-6b.c property-stack.S} \
1112 {{readelf {-n} property-2a.r}} \
1113 "property-6.o" \
1114 ] \
1115 [list \
1116 "Build property-6" \
1117 "-Wl,--as-needed tmpdir/property-6.o tmpdir/property-6.so" \
1118 "-Wa,-mx86-used-note=yes" \
1119 { dummy.s } \
1120 {{readelf {-n} property-2.r}} \
1121 "property-6" \
1122 ] \
1123 [list \
1124 "Build property 7a (.o)" \
1125 "-r -nostdlib" \
1126 "-Wa,-mx86-used-note=yes" \
1127 {property-unsorted-1.S} \
1128 {{readelf {-n} property-7a.r}} \
1129 "property-7a.o" \
1130 ] \
1131 [list \
1132 "Build property 7b (.o)" \
1133 "-r -nostdlib" \
1134 "-Wa,-mx86-used-note=yes" \
1135 {property-unsorted-2.S} \
1136 {{readelf {-n} property-7a.r}} \
1137 "property-7b.o" \
1138 ] \
1139 [list \
1140 "Build pr22001-1.so" \
1141 "-shared" \
1142 "-fPIC -Wa,-mx86-used-note=yes" \
1143 { pr22001-1a.c } \
1144 {} \
1145 "pr22001-1.so" \
1146 ] \
1147 [list \
1148 "Build pr22001-1a" \
1149 "$NOPIE_LDFLAGS -Wl,-z,nocopyreloc,--no-as-needed,-z,notext tmpdir/pr22001-1.so" \
1150 "$NOPIE_CFLAGS -Wa,-mx86-used-note=yes" \
1151 { pr22001-1b.c } \
1152 {{error_output "pr22001-1a.err"}} \
1153 "pr22001-1a" \
1154 ] \
1155 [list \
1156 "Build pr21997-1.so" \
1157 "-shared" \
1158 "-Wa,-mx86-used-note=yes" \
1159 { property-stack.S property-no-copy.S pr21997-1a.S } \
1160 {} \
1161 "pr21997-1.so" \
1162 ] \
1163 [list \
1164 "Build pr21997-1a" \
1165 "$NOPIE_LDFLAGS -Wl,--no-as-needed,-z,notext tmpdir/pr21997-1.so" \
1166 "$NOPIE_CFLAGS -Wa,-mx86-used-note=yes" \
1167 { pr21997-1b.c } \
1168 {{error_output "pr21997-1a.err"}} \
1169 "pr21997-1a" \
1170 ] \
1171 [list \
1172 "Build pr22064a.o" \
1173 "" \
1174 "-Wa,-mx86-used-note=yes" \
1175 { pr22064a.S } \
1176 ] \
1177 [list \
1178 "Build pr22064.so" \
1179 "-shared" \
1180 "-fPIC -Wa,-mx86-used-note=yes" \
1181 { pr22064b.c } \
1182 {} \
1183 "pr22064.so" \
1184 ] \
1185 [list \
1186 "Build pr22393-3a.so" \
1187 "-shared -Wl,-z,separate-code,-z,max-page-size=0x1000" \
1188 "-fPIC -Wa,-mx86-used-note=yes" \
1189 {pr22393-3a.c} \
1190 {{readelf -lW pr22393-3a.rd} \
1191 {readelf -lW pr22393-3b.rd}} \
1192 "pr22393-3a.so" \
1193 ] \
1194 [list \
1195 "Build pr22393-3a-now.so" \
1196 "-shared -Wl,-z,separate-code,-z,now,-z,max-page-size=0x1000" \
1197 "-fPIC -Wa,-mx86-used-note=yes" \
1198 {pr22393-3a.c} \
1199 {{readelf -lW pr22393-3a.rd} \
1200 {readelf -lW pr22393-3b.rd}} \
1201 "pr22393-3a-now.so" \
1202 ] \
1203 [list \
1204 "Build pr22393-3" \
1205 "$NOPIE_LDFLAGS -Wl,-z,separate-code,-z,max-page-size=0x1000,--no-as-needed tmpdir/pr22393-3a.so" \
1206 "$NOPIE_CFLAGS -Wa,-mx86-used-note=yes" \
1207 {pr22393-3b.c} \
1208 {{readelf -lW pr22393-3a.rd} \
1209 {readelf -lW pr22393-3b.rd}} \
1210 "pr22393-3" \
1211 ] \
1212 [list \
1213 "Build pr22393-3 (PIE)" \
1214 "-pie -Wl,-z,separate-code,-z,max-page-size=0x1000,--no-as-needed tmpdir/pr22393-3a-now.so" \
1215 "-fPIE -Wa,-mx86-used-note=yes" \
1216 {pr22393-3b.c} \
1217 {{readelf -lW pr22393-3a.rd} \
1218 {readelf -lW pr22393-3b.rd}} \
1219 "pr22393-3-pie" \
1220 ] \
1221 [list \
1222 "Build pr22393-3 (static)" \
1223 "-static -Wl,-z,separate-code,-z,max-page-size=0x1000" \
1224 "-Wa,-mx86-used-note=yes" \
1225 {pr22393-3a.c pr22393-3b.c} \
1226 {{readelf -lW pr22393-3a.rd} \
1227 {readelf -lW pr22393-3b.rd}} \
1228 "pr22393-3-static" \
1229 ] \
1230 [list \
1231 "Build pr22791-1.so" \
1232 "-shared" \
1233 "-fPIC -Wa,-mx86-used-note=yes" \
1234 { pr22791-1a.c } \
1235 {} \
1236 "pr22791-1.so" \
1237 ] \
1238 [list \
1239 "Build pr22791-1" \
1240 "-pie -Wl,--no-as-needed,-z,notext tmpdir/pr22791-1.so" \
1241 "$NOPIE_CFLAGS -Wa,-mx86-used-note=yes" \
1242 { pr22791-1b.s } \
1243 {{error_output "pr22791-1.err"}} \
1244 "pr22791-1" \
1245 ] \
1246 [list \
1247 "Build pr22791-2a.o" \
1248 "" \
1249 "$NOPIE_CFLAGS -Wa,-mx86-used-note=yes" \
1250 { pr22791-2a.s } \
1251 ] \
1252 [list \
1253 "Build pr22791-2.so" \
1254 "-shared tmpdir/pr22791-2a.o" \
1255 "-fPIC -Wa,-mx86-used-note=yes" \
1256 { pr22791-2b.c } \
1257 {{readelf -drW pr22791-2.rd}} \
1258 "pr22791-2.so" \
1259 ] \
1260 [list \
1261 "Build pr22791-2" \
1262 "-pie -Wl,--no-as-needed tmpdir/pr22791-2.so" \
1263 "$NOPIE_CFLAGS -Wa,-mx86-used-note=yes" \
1264 { pr22791-2c.s } \
1265 {{readelf -drW pr22791-2.rd}} \
1266 "pr22791-2" \
1267 ] \
1268 [list \
1269 "Build pr22842.so" \
1270 "-shared" \
1271 "-fPIC -Wa,-mx86-used-note=yes" \
1272 { pr22842a.c } \
1273 {} \
1274 "pr22842.so" \
1275 ] \
1276 [list \
1277 "Build pr22842" \
1278 "-pie -Wl,--no-as-needed tmpdir/pr22842.so" \
1279 "-Wa,-mx86-used-note=yes" \
1280 { pr22842b.S } \
1281 {{readelf -rW pr22842a.rd} \
1282 {readelf -rW pr22842b.rd}} \
1283 "pr22842" \
1284 ] \
1285 [list \
1286 "Build libprotected-func-1.so" \
1287 "-shared" \
1288 "-fPIC -Wa,-mx86-used-note=yes" \
1289 { protected-func-1a.s } \
1290 {} \
1291 "libprotected-func-1.so" \
1292 ] \
1293 [list \
1294 "Build libprotected-func-2a.so" \
1295 "-shared" \
1296 "-fPIC -Wa,-mx86-used-note=yes" \
1297 { protected-func-2a.S } \
1298 {{readelf -n indirect-extern-access.rd}} \
1299 "libprotected-func-2a.so" \
1300 ] \
1301 [list \
1302 "Build libprotected-func-2b.so" \
1303 "-shared -z indirect-extern-access" \
1304 "-fPIC -Wa,-mx86-used-note=yes" \
1305 { protected-func-2c.c } \
1306 {{readelf -n indirect-extern-access.rd}} \
1307 "libprotected-func-2b.so" \
1308 ] \
1309 [list \
1310 "Build protected-func-2 without PIE" \
1311 "$NOPIE_LDFLAGS -Wl,--no-as-needed tmpdir/libprotected-func-2b.so" \
1312 "$NOPIE_CFLAGS -Wa,-mx86-used-note=yes" \
1313 { protected-func-1b.c } \
1314 {{error_output "pr28875-func.err"}} \
1315 "protected-func-2" \
1316 ] \
1317 [list \
1318 "Build libprotected-func-2c.so" \
1319 "-shared" \
1320 "-fPIC -Wa,-mx86-used-note=yes" \
1321 { protected-func-2c.c } \
1322 {} \
1323 "libprotected-func-2c.so" \
1324 ] \
1325 [list \
1326 "Build protected-func-2a without PIE" \
1327 "$NOPIE_LDFLAGS -Wl,--no-as-needed tmpdir/libprotected-func-2c.so" \
1328 "$NOPIE_CFLAGS -Wa,-mx86-used-note=yes" \
1329 { protected-func-1b.c } \
1330 {{error_output "pr28875-func.err"}} \
1331 "protected-func-2a" \
1332 ] \
1333 [list \
1334 "Build libprotected-data-1a.so" \
1335 "-shared -z noindirect-extern-access" \
1336 "-fPIC -Wa,-mx86-used-note=yes" \
1337 { protected-data-1a.c } \
1338 {} \
1339 "libprotected-data-1a.so" \
1340 ] \
1341 [list \
1342 "Build libprotected-data-1b.so" \
1343 "-shared -z indirect-extern-access" \
1344 "-fPIC -Wa,-mx86-used-note=yes" \
1345 { protected-data-1a.c } \
1346 {} \
1347 "libprotected-data-1b.so" \
1348 ] \
1349 [list \
1350 "Build protected-data-1 without PIE" \
1351 "$NOPIE_LDFLAGS -Wl,--no-as-needed tmpdir/libprotected-data-1b.so" \
1352 "$NOPIE_CFLAGS -Wa,-mx86-used-note=yes" \
1353 { protected-data-1b.c } \
1354 {{error_output "pr28875-data.err"}} \
1355 "protected-data-1" \
1356 ] \
1357 [list \
1358 "Build libprotected-data-2a.so" \
1359 "-shared" \
1360 "-fPIC -Wa,-mx86-used-note=yes \
1361 -DUSE_GNU_PROPERTY_1_NEEDED_INDIRECT_EXTERN_ACCESS" \
1362 { protected-data-2a.S } \
1363 {{readelf -n indirect-extern-access.rd}} \
1364 "libprotected-data-2a.so" \
1365 ] \
1366 [list \
1367 "Build libprotected-data-2b.so" \
1368 "-shared -z indirect-extern-access" \
1369 "-fPIC -Wa,-mx86-used-note=yes" \
1370 { protected-data-2a.S } \
1371 {{readelf -n indirect-extern-access.rd}} \
1372 "libprotected-data-2b.so" \
1373 ] \
1374 ]
1375
1376 if {[istarget "x86_64-*-linux*-gnux32"]} {
1377 run_cc_link_tests [list \
1378 [list \
1379 "Build pr25416-5b.o (GDesc -maddress-mode=short)" \
1380 "" \
1381 "-Wa,-mx86-used-note=yes" \
1382 { pr25416-5b.s } \
1383 ] \
1384 [list \
1385 "Build pr25416-5b.so (GDesc -> IE -maddress-mode=short)" \
1386 "-shared" \
1387 "-fPIC -Wa,-mx86-used-note=yes" \
1388 { pr25416-5b.s pr25416-5d.s } \
1389 {} \
1390 "pr25416-5b.so" \
1391 ] \
1392 [list \
1393 "Build pr25416-5c.o (GDesc -maddress-mode=long)" \
1394 "" \
1395 "-Wa,-mx86-used-note=yes" \
1396 { pr25416-5c.s } \
1397 ] \
1398 [list \
1399 "Build pr25416-5c.so (GDesc -> IE -maddress-mode=long)" \
1400 "-shared" \
1401 "-fPIC -Wa,-mx86-used-note=yes" \
1402 { pr25416-5c.s pr25416-5d.s } \
1403 {} \
1404 "pr25416-5c.so" \
1405 ] \
1406 [list \
1407 "Build pr25416-5d.so (GDesc -maddress-mode=short)" \
1408 "-shared" \
1409 "-fPIC -Wa,-mx86-used-note=yes" \
1410 { pr25416-5b.s pr25416-5e.s } \
1411 {} \
1412 "pr25416-5d.so" \
1413 ] \
1414 [list \
1415 "Build pr25416-5d.o (IE -maddress-mode=short)" \
1416 "" \
1417 "-Wa,-mx86-used-note=yes" \
1418 { pr25416-5d.s } \
1419 ] \
1420 [list \
1421 "Build pr21997-1b" \
1422 "$NOPIE_LDFLAGS -Wl,--no-as-needed,-z,notext tmpdir/pr21997-1.so" \
1423 "$NOPIE_CFLAGS -Wa,-mx86-used-note=yes" \
1424 { pr21997-1c.c } \
1425 {{error_output "pr21997-1b.err"}} \
1426 "pr21997-1b" \
1427 ] \
1428 ]
1429
1430 run_ld_link_exec_tests [list \
1431 [list \
1432 "Run pr22001-1b" \
1433 "$NOPIE_LDFLAGS -Wl,-z,nocopyreloc,--no-as-needed,-z,notext tmpdir/pr22001-1.so" \
1434 "-Wa,-mx86-used-note=yes" \
1435 { pr22001-1c.c } \
1436 "pr22001-1b" \
1437 "pass.out" \
1438 "$NOPIE_CFLAGS" \
1439 ] \
1440 [list \
1441 "Run pr25416-5a (GDesc -> IE -maddress-mode=short)" \
1442 "$NOPIE_LDFLAGS -Wl,--no-as-needed tmpdir/pr25416-5b.so" \
1443 "-Wa,-mx86-used-note=yes" \
1444 { pr25416-5a.c } \
1445 "pr25416-5a" \
1446 "pass.out" \
1447 "$NOPIE_CFLAGS" \
1448 ] \
1449 [list \
1450 "Run pr25416-5b (GDesc -> LE -maddress-mode=short" \
1451 "$NOPIE_LDFLAGS tmpdir/pr25416-5b.o tmpdir/pr25416-5d.o" \
1452 "-Wa,-mx86-used-note=yes" \
1453 { pr25416-5a.c } \
1454 "pr25416-5b" \
1455 "pass.out" \
1456 "$NOPIE_CFLAGS" \
1457 ] \
1458 [list \
1459 "Run pr25416-5c (GDesc -> IE -maddress-mode=long)" \
1460 "$NOPIE_LDFLAGS -Wl,--no-as-needed tmpdir/pr25416-5c.so" \
1461 "-Wa,-mx86-used-note=yes" \
1462 { pr25416-5a.c } \
1463 "pr25416-5c" \
1464 "pass.out" \
1465 "$NOPIE_CFLAGS" \
1466 ] \
1467 [list \
1468 "Run pr25416-5d (GDesc -> LE -maddress-mode=long)" \
1469 "$NOPIE_LDFLAGS tmpdir/pr25416-5c.o tmpdir/pr25416-5d.o" \
1470 "-Wa,-mx86-used-note=yes" \
1471 { pr25416-5a.c } \
1472 "pr25416-5d" \
1473 "pass.out" \
1474 "$NOPIE_CFLAGS" \
1475 ] \
1476 [list \
1477 "Run pr25416-5e (GDesc -maddress-mode=short)" \
1478 "$NOPIE_LDFLAGS -Wl,--no-as-needed tmpdir/pr25416-5d.so" \
1479 "-Wa,-mx86-used-note=yes" \
1480 { pr25416-5a.c } \
1481 "pr25416-5e" \
1482 "pass.out" \
1483 "$NOPIE_CFLAGS" \
1484 ] \
1485 [list \
1486 "Run pr25416-5f (PIE GDesc -> LE -maddress-mode=short)" \
1487 "-pie -Wl,-z,notext tmpdir/pr25416-5b.o tmpdir/pr25416-5d.o" \
1488 "-Wa,-mx86-used-note=yes" \
1489 { pr25416-5a.c } \
1490 "pr25416-5f" \
1491 "pass.out" \
1492 ] \
1493 [list \
1494 "Run pr25416-5g (PIE GDesc -> LE -maddress-mode=long)" \
1495 "-pie -Wl,-z,notext tmpdir/pr25416-5c.o tmpdir/pr25416-5d.o" \
1496 "-Wa,-mx86-used-note=yes" \
1497 { pr25416-5a.c } \
1498 "pr25416-5g" \
1499 "pass.out" \
1500 ] \
1501 ]
1502 } else {
1503 run_cc_link_tests [list \
1504 [list \
1505 "Build pr22001-1b" \
1506 "$NOPIE_LDFLAGS -Wl,-z,nocopyreloc,--no-as-needed,-z,notext tmpdir/pr22001-1.so" \
1507 "$NOPIE_CFLAGS -Wa,-mx86-used-note=yes" \
1508 { pr22001-1c.c } \
1509 {{error_output "pr22001-1b.err"}} \
1510 "pr22001-1b" \
1511 ] \
1512 [list \
1513 "Build pr21997-1b" \
1514 "$NOPIE_LDFLAGS -Wl,--no-as-needed,-z,notext tmpdir/pr21997-1.so" \
1515 "$NOPIE_CFLAGS -Wa,-mx86-used-note=yes" \
1516 { pr21997-1c.c } \
1517 {{error_output "pr21997-1b.err"}} \
1518 "pr21997-1b" \
1519 ] \
1520 [list \
1521 "Build lam-u48.so" \
1522 "-shared -Wl,-z,lam-u48" \
1523 "" \
1524 {dummy.s} \
1525 {{readelf -n lam-u48.rd}} \
1526 "lam-u48.so" \
1527 ] \
1528 [list \
1529 "Build lam-u57.so" \
1530 "-shared -Wl,-z,lam-u57" \
1531 "" \
1532 {dummy.s} \
1533 {{readelf -n lam-u57.rd}} \
1534 "lam-u57.so" \
1535 ] \
1536 ]
1537 }
1538
1539 run_ld_link_exec_tests [list \
1540 [list \
1541 "Run plt-main" \
1542 "-Wl,--no-as-needed tmpdir/plt-main1.o tmpdir/plt-main2.o \
1543 tmpdir/plt-main3.o tmpdir/plt-main4.o tmpdir/libplt-lib.so" \
1544 "-Wa,-mx86-used-note=yes" \
1545 { plt-main5.c } \
1546 "plt-main" \
1547 "plt-main.out" \
1548 ] \
1549 [list \
1550 "Run plt-main with PIE" \
1551 "-Wl,--no-as-needed -pie tmpdir/plt-main1.o tmpdir/plt-main2.o \
1552 tmpdir/plt-main3.o tmpdir/plt-main4.o tmpdir/libplt-lib.so" \
1553 "-Wa,-mx86-used-note=yes" \
1554 { plt-main5.c } \
1555 "plt-main-pie" \
1556 "plt-main.out" \
1557 "-fPIC" \
1558 ] \
1559 [list \
1560 "Run copyreloc-main with PIE without -fPIE" \
1561 "-Wl,--as-needed -pie tmpdir/copyreloc-main.o tmpdir/copyreloc-lib.so" \
1562 "-Wa,-mx86-used-note=yes" \
1563 { dummy.s } \
1564 "copyreloc-main" \
1565 "copyreloc-main.out" \
1566 ] \
1567 [list \
1568 "Run pr17689 with PIE without -fPIE" \
1569 "-Wl,--no-as-needed -pie tmpdir/pr17689b.o tmpdir/pr17689.so" \
1570 "-Wa,-mx86-used-note=yes" \
1571 { dummy.s } \
1572 "pr17689" \
1573 "pr17689.out" \
1574 ] \
1575 [list \
1576 "Run pr17689 with PIE -z now without -fPIE" \
1577 "-Wl,--as-needed,-z,now -pie tmpdir/pr17689b.o tmpdir/pr17689.so" \
1578 "-Wa,-mx86-used-note=yes" \
1579 { dummy.s } \
1580 "pr17689now" \
1581 "pr17689.out" \
1582 ] \
1583 [list \
1584 "Run pr18900" \
1585 "-Wl,--no-as-needed tmpdir/pr18900.o tmpdir/pr18900.so" \
1586 "-Wa,-mx86-used-note=yes" \
1587 { dummy.s } \
1588 "pr18900" \
1589 "pr18900.out" \
1590 ] \
1591 [list \
1592 "Run pr19031" \
1593 "$NOPIE_LDFLAGS -Wl,--no-as-needed tmpdir/pr19031.so" \
1594 "-Wa,-mx86-used-note=yes" \
1595 { pr19031b.S pr19031c.c } \
1596 "pr19031" \
1597 "pr19031.out" \
1598 "$NOPIE_CFLAGS" \
1599 ] \
1600 [list \
1601 "Run gotpcrel1" \
1602 "-Wl,--no-as-needed tmpdir/gotpcrel1d.so" \
1603 "-Wa,-mx86-used-note=yes" \
1604 { gotpcrel1a.S gotpcrel1b.c gotpcrel1c.c } \
1605 "gotpcrel1" \
1606 "gotpcrel1.out" \
1607 ] \
1608 [list \
1609 "Run property 1" \
1610 "" \
1611 "-Wa,-mx86-used-note=yes" \
1612 {pass.c property-no-copy.S} \
1613 "property-1" "pass.out" \
1614 ] \
1615 [list \
1616 "Run property 1 (PIE)" \
1617 "-pie" \
1618 "-Wa,-mx86-used-note=yes" \
1619 {pass.c property-no-copy.S} \
1620 "property-1-pie" "pass.out" "-fPIE" \
1621 ] \
1622 [list \
1623 "Run property 1 (static)" \
1624 "-static" \
1625 "-Wa,-mx86-used-note=yes" \
1626 {pass.c property-no-copy.S} \
1627 "property-1-static" "pass.out" \
1628 ] \
1629 [list \
1630 "Run property 2" \
1631 "" \
1632 "-Wa,-mx86-used-note=yes" \
1633 {pass.c property-stack.S} \
1634 "property-2" "pass.out" \
1635 ] \
1636 [list \
1637 "Run property 2 (PIE)" \
1638 "-pie" \
1639 "-Wa,-mx86-used-note=yes" \
1640 {pass.c property-stack.S} \
1641 "property-2-pie" "pass.out" "-fPIE" \
1642 ] \
1643 [list \
1644 "Run property 2 (static)" \
1645 "-static" \
1646 "-Wa,-mx86-used-note=yes" \
1647 {pass.c property-stack.S} \
1648 "property-3-static" "pass.out" \
1649 ] \
1650 [list \
1651 "Run pr22001-1a (PIC 1)" \
1652 "$NOPIE_LDFLAGS -Wl,-z,nocopyreloc,--no-as-needed tmpdir/pr22001-1.so" \
1653 "-Wa,-mx86-used-note=yes" \
1654 { pr22001-1b.c } \
1655 "pr22001-1a-pic-1" \
1656 "pass.out" \
1657 "-fPIC" \
1658 ] \
1659 [list \
1660 "Run pr22001-1a (PIC 2)" \
1661 "-pie -Wl,-z,nocopyreloc,--no-as-needed tmpdir/pr22001-1.so" \
1662 "-Wa,-mx86-used-note=yes" \
1663 { pr22001-1b.c } \
1664 "pr22001-1a-pic-2" \
1665 "pass.out" \
1666 "-fPIC" \
1667 ] \
1668 [list \
1669 "Run pr22001-1b (PIC 1)" \
1670 "$NOPIE_LDFLAGS -Wl,-z,nocopyreloc,--no-as-needed tmpdir/pr22001-1.so" \
1671 "-Wa,-mx86-used-note=yes" \
1672 { pr22001-1c.c } \
1673 "pr22001-1b-pic-1" \
1674 "pass.out" \
1675 "-fPIC" \
1676 ] \
1677 [list \
1678 "Run pr22001-1b (PIC 2)" \
1679 "-pie -Wl,-z,nocopyreloc,--no-as-needed tmpdir/pr22001-1.so" \
1680 "-Wa,-mx86-used-note=yes" \
1681 { pr22001-1c.c } \
1682 "pr22001-1b-pic-2" \
1683 "pass.out" \
1684 "-fPIC" \
1685 ] \
1686 [list \
1687 "Run pr21997-1a (PIC 1)" \
1688 "$NOPIE_LDFLAGS -Wl,--no-as-needed tmpdir/pr21997-1.so" \
1689 "-Wa,-mx86-used-note=yes" \
1690 { pr21997-1b.c } \
1691 "pr21997-1a-pic-1" \
1692 "pass.out" \
1693 "-fPIC" \
1694 ] \
1695 [list \
1696 "Run pr21997-1a (PIC 2)" \
1697 "-pie -Wl,--no-as-needed tmpdir/pr21997-1.so" \
1698 "-Wa,-mx86-used-note=yes" \
1699 { pr21997-1b.c } \
1700 "pr21997-1a-pic-2" \
1701 "pass.out" \
1702 "-fPIC" \
1703 ] \
1704 [list \
1705 "Run pr21997-1b (PIC 1)" \
1706 "$NOPIE_LDFLAGS -Wl,--no-as-needed tmpdir/pr21997-1.so" \
1707 "-Wa,-mx86-used-note=yes" \
1708 { pr21997-1c.c } \
1709 "pr21997-1b-pic-1" \
1710 "pass.out" \
1711 "-fPIC" \
1712 ] \
1713 [list \
1714 "Run pr21997-1b (PIC 2)" \
1715 "-pie -Wl,--no-as-needed tmpdir/pr21997-1.so" \
1716 "-Wa,-mx86-used-note=yes" \
1717 { pr21997-1c.c } \
1718 "pr21997-1b-pic-2" \
1719 "pass.out" \
1720 "-fPIC" \
1721 ] \
1722 [list \
1723 "Run pr22064" \
1724 "-pie -Wl,--no-as-needed tmpdir/pr22064a.o tmpdir/pr22064.so" \
1725 "-Wa,-mx86-used-note=yes" \
1726 { dummy.s } \
1727 "pr22064-pie" \
1728 "pass.out" \
1729 "-fPIE" \
1730 ] \
1731 [list \
1732 "Run pr22393-3" \
1733 "$NOPIE_LDFLAGS -Wl,-z,separate-code,-z,max-page-size=0x1000,--no-as-needed tmpdir/pr22393-3a.so" \
1734 "-Wa,-mx86-used-note=yes" \
1735 {pr22393-3b.c} \
1736 "pr22393-3" \
1737 "pass.out" \
1738 "$NOPIE_CFLAGS" \
1739 ] \
1740 [list \
1741 "Run pr22393-3 (PIE)" \
1742 "-pie -Wl,-z,separate-code,-z,max-page-size=0x1000,--no-as-needed tmpdir/pr22393-3a-now.so" \
1743 "-Wa,-mx86-used-note=yes" \
1744 {pr22393-3b.c} \
1745 "pr22393-3-pie" \
1746 "pass.out" \
1747 "-fPIE" \
1748 ] \
1749 [list \
1750 "Run pr22393-3 (static)" \
1751 "-static -Wl,-z,separate-code,-z,max-page-size=0x1000" \
1752 "-Wa,-mx86-used-note=yes" \
1753 {pr22393-3a.c pr22393-3b.c} \
1754 "pr22393-3-static" \
1755 "pass.out" \
1756 ] \
1757 [list \
1758 "Run pr22791-2" \
1759 "-pie -Wl,--no-as-needed tmpdir/pr22791-2.so" \
1760 "-Wa,-mx86-used-note=yes" \
1761 { pr22791-2c.s } \
1762 "pr22791-2" \
1763 "pass.out" \
1764 "$NOPIE_CFLAGS" \
1765 ] \
1766 [list \
1767 "Run pr22842" \
1768 "-pie -Wl,--no-as-needed tmpdir/pr22842.so" \
1769 "-Wa,-mx86-used-note=yes" \
1770 { pr22842b.S } \
1771 "pr22842" \
1772 "pass.out" \
1773 ] \
1774 [list \
1775 "Run pr23997" \
1776 "" \
1777 "" \
1778 { pr23997a.s pr23997b.c pr23997c.c } \
1779 "pr23997" \
1780 "pass.out" \
1781 ] \
1782 [list \
1783 "Run protected-func-1 with PIE" \
1784 "-Wl,--no-as-needed -pie tmpdir/libprotected-func-1.so" \
1785 "-Wa,-mx86-used-note=yes" \
1786 { protected-func-1b.c } \
1787 "protected-func-1b" \
1788 "pass.out" \
1789 "-fPIE" \
1790 ] \
1791 [list \
1792 "Run protected-func-2a without PIE" \
1793 "$NOPIE_LDFLAGS -Wl,--no-as-needed tmpdir/libprotected-func-2a.so" \
1794 "-Wa,-mx86-used-note=yes" \
1795 { protected-func-2b.S } \
1796 "protected-func-2a" \
1797 "pass.out" \
1798 "$NOPIE_CFLAGS" \
1799 ] \
1800 [list \
1801 "Run protected-func-2b with PIE" \
1802 "-Wl,--no-as-needed -pie tmpdir/libprotected-func-2a.so" \
1803 "-Wa,-mx86-used-note=yes" \
1804 { protected-func-2b.S } \
1805 "protected-func-2b" \
1806 "pass.out" \
1807 "-fPIE" \
1808 ] \
1809 [list \
1810 "Run protected-func-2c without PIE" \
1811 "$NOPIE_LDFLAGS -Wl,--no-as-needed tmpdir/libprotected-func-2b.so" \
1812 "-Wa,-mx86-used-note=yes" \
1813 { protected-func-2b.S } \
1814 "protected-func-2c" \
1815 "pass.out" \
1816 "$NOPIE_CFLAGS" \
1817 ] \
1818 [list \
1819 "Run protected-func-2d with PIE" \
1820 "-Wl,--no-as-needed -pie tmpdir/libprotected-func-2b.so" \
1821 "-Wa,-mx86-used-note=yes" \
1822 { protected-func-2b.S } \
1823 "protected-func-2d" \
1824 "pass.out" \
1825 "-fPIE" \
1826 ] \
1827 [list \
1828 "Run protected-func-3a without PIE" \
1829 "$NOPIE_LDFLAGS -Wl,--no-as-needed tmpdir/libprotected-func-2a.so" \
1830 "-Wa,-mx86-used-note=yes" \
1831 { protected-func-3.c } \
1832 "protected-func-3a" \
1833 "pass.out" \
1834 "$NOPIE_CFLAGS" \
1835 ] \
1836 [list \
1837 "Run protected-func-3b with PIE" \
1838 "-Wl,--no-as-needed -pie tmpdir/libprotected-func-2a.so" \
1839 "-Wa,-mx86-used-note=yes" \
1840 { protected-func-3.c } \
1841 "protected-func-2b" \
1842 "pass.out" \
1843 "-fPIE" \
1844 ] \
1845 [list \
1846 "Run protected-data-2a without PIE" \
1847 "$NOPIE_LDFLAGS -Wl,--no-as-needed tmpdir/libprotected-data-2a.so" \
1848 "-Wa,-mx86-used-note=yes" \
1849 { protected-data-2b.S } \
1850 "protected-data-2a" \
1851 "pass.out" \
1852 "$NOPIE_CFLAGS" \
1853 ] \
1854 [list \
1855 "Run protected-data-2b with PIE" \
1856 "-Wl,--no-as-needed -pie tmpdir/libprotected-data-2a.so" \
1857 "-Wa,-mx86-used-note=yes" \
1858 { protected-data-2b.S } \
1859 "protected-data-2b" \
1860 "pass.out" \
1861 "-fPIE" \
1862 ] \
1863 [list \
1864 "Run protected-data-2c without PIE" \
1865 "$NOPIE_LDFLAGS -Wl,--no-as-needed tmpdir/libprotected-data-2b.so" \
1866 "-Wa,-mx86-used-note=yes" \
1867 { protected-data-2b.S } \
1868 "protected-data-2c" \
1869 "pass.out" \
1870 "$NOPIE_CFLAGS" \
1871 ] \
1872 [list \
1873 "Run protected-data-2d with PIE" \
1874 "-Wl,--no-as-needed -pie tmpdir/libprotected-data-2b.so" \
1875 "-Wa,-mx86-used-note=yes" \
1876 { protected-data-2b.S } \
1877 "protected-data-2d" \
1878 "pass.out" \
1879 "-fPIE" \
1880 ] \
1881 ]
1882
1883 # Run-time tests which require working ifunc attribute support.
1884 if { [check_ifunc_attribute_available] } {
1885 run_cc_link_tests [list \
1886 [list \
1887 "Build libpr19784a.so" \
1888 "-shared -Wl,-Bsymbolic-functions" \
1889 "-fPIC -O2 -g -Wa,-mx86-used-note=yes" \
1890 { pr19784b.c pr19784c.c } \
1891 {} \
1892 "libpr19784a.so" \
1893 ] \
1894 [list \
1895 "Build libpr19784b.so" \
1896 "-shared -Wl,-Bsymbolic-functions" \
1897 "-fPIC -O2 -g -Wa,-mx86-used-note=yes" \
1898 { pr19784c.c pr19784b.c } \
1899 {} \
1900 "libpr19784b.so" \
1901 ] \
1902 [list \
1903 "Build pr19784a.o" \
1904 "" \
1905 "-Wa,-mx86-used-note=yes" \
1906 { pr19784a.c } \
1907 ] \
1908 ]
1909
1910 run_ld_link_exec_tests [list \
1911 [list \
1912 "Run pr19784a" \
1913 "-Wl,--no-as-needed tmpdir/pr19784a.o tmpdir/libpr19784a.so" \
1914 "-Wa,-mx86-used-note=yes" \
1915 { dummy.s } \
1916 "pr19784a" \
1917 "pass.out" \
1918 ] \
1919 [list \
1920 "Run pr19784b" \
1921 "-Wl,--as-needed tmpdir/pr19784a.o tmpdir/libpr19784b.so" \
1922 "-Wa,-mx86-used-note=yes" \
1923 { dummy.s } \
1924 "pr19784b" \
1925 "pass.out" \
1926 ] \
1927 ]
1928 }
1929
1930 if { [istarget "x86_64-*-linux*"] } {
1931 set pltdump {{objdump {-drw} plt-main-ibt.dd}}
1932 set pltsecdump {{readelf {-SW} plt-main-ibt-now.rd} {objdump {-drw} plt-main-ibt.dd}}
1933 run_cc_link_tests [list \
1934 [list \
1935 "Build plt-main with -z ibtplt" \
1936 "tmpdir/plt-main1.o tmpdir/plt-main2.o tmpdir/plt-main3.o \
1937 tmpdir/plt-main4.o tmpdir/libplt-lib.so -Wl,-z,ibtplt \
1938 -Wl,-z,noseparate-code,-z,max-page-size=0x200000" \
1939 "-Wa,-mx86-used-note=yes" \
1940 { plt-main5.c } \
1941 $pltdump \
1942 "plt-main-ibt" \
1943 ] \
1944 [list \
1945 "Build plt-main with PIE and -z ibtplt" \
1946 "tmpdir/plt-main1.o tmpdir/plt-main2.o tmpdir/plt-main3.o \
1947 tmpdir/plt-main4.o tmpdir/libplt-lib.so -pie \
1948 -Wl,-z,ibtplt,-z,noseparate-code \
1949 -Wl,-z,max-page-size=0x200000" \
1950 "-fPIC -Wa,-mx86-used-note=yes" \
1951 { plt-main5.c } \
1952 $pltdump \
1953 "plt-main-pie-ibt" \
1954 ] \
1955 [list \
1956 "Build plt-main with -z ibtplt -z now" \
1957 "tmpdir/plt-main1.o tmpdir/plt-main2.o tmpdir/plt-main3.o \
1958 tmpdir/plt-main4.o tmpdir/libplt-lib.so -Wl,-z,ibtplt \
1959 -Wl,-z,now,-z,noseparate-code,-z,max-page-size=0x200000" \
1960 "-Wa,-mx86-used-note=yes" \
1961 { plt-main5.c } \
1962 $pltsecdump \
1963 "plt-main-ibt-now" \
1964 ] \
1965 [list \
1966 "Build plt-main with PIE and -z ibtplt -z now" \
1967 "tmpdir/plt-main1.o tmpdir/plt-main2.o tmpdir/plt-main3.o \
1968 tmpdir/plt-main4.o tmpdir/libplt-lib.so -pie \
1969 -Wl,-z,ibtplt,-z,now,-z,noseparate-code \
1970 -Wl,-z,max-page-size=0x200000" \
1971 "-fPIC -Wa,-mx86-used-note=yes" \
1972 { plt-main5.c } \
1973 $pltsecdump \
1974 "plt-main-pie-ibt-now" \
1975 ] \
1976 [list \
1977 "Build libibtplt-lib.so with -z ibtplt" \
1978 "-shared -Wl,-z,ibtplt,-z,noseparate-code \
1979 -Wl,-z,max-page-size=0x200000" \
1980 "-fPIC -Wa,-mx86-used-note=yes" \
1981 { plt-main1.c plt-main2.c plt-main3.c plt-main4.c} \
1982 $pltdump \
1983 "libibtplt-lib.so" \
1984 ] \
1985 [list \
1986 "Build libibtplt--now-lib.so with -z ibtplt -z now" \
1987 "-shared -Wl,-z,ibtplt,-z,now,-z,noseparate-code \
1988 -Wl,-z,max-page-size=0x200000" \
1989 "-fPIC -Wa,-mx86-used-note=yes" \
1990 { plt-main1.c plt-main2.c plt-main3.c plt-main4.c} \
1991 $pltdump \
1992 "libibtplt-now-lib.so" \
1993 ] \
1994 ]
1995
1996 run_ld_link_exec_tests [list \
1997 [list \
1998 "Run plt-main with -z ibtplt" \
1999 "-Wl,--no-as-needed,-z,ibtplt tmpdir/plt-main1.o \
2000 tmpdir/plt-main2.o tmpdir/plt-main3.o \
2001 tmpdir/plt-main4.o tmpdir/libplt-lib.so" \
2002 "-Wa,-mx86-used-note=yes" \
2003 { plt-main5.c } \
2004 "plt-main-ibt" \
2005 "plt-main.out" \
2006 ] \
2007 [list \
2008 "Run plt-main with PIE and -z ibtplt" \
2009 "-Wl,--no-as-needed,-z,ibtplt -pie tmpdir/plt-main1.o \
2010 tmpdir/plt-main2.o tmpdir/plt-main3.o \
2011 tmpdir/plt-main4.o tmpdir/libplt-lib.so" \
2012 "-Wa,-mx86-used-note=yes" \
2013 { plt-main5.c } \
2014 "plt-main-pie-ibt" \
2015 "plt-main.out" \
2016 "-fPIC" \
2017 ] \
2018 [list \
2019 "Run plt-main with -z ibtplt -z now" \
2020 "-Wl,--no-as-needed,-z,ibtplt,-z,now tmpdir/plt-main1.o \
2021 tmpdir/plt-main2.o tmpdir/plt-main3.o \
2022 tmpdir/plt-main4.o tmpdir/libplt-lib.so" \
2023 "-Wa,-mx86-used-note=yes" \
2024 { plt-main5.c } \
2025 "plt-main-ibt-now" \
2026 "plt-main.out" \
2027 ] \
2028 [list \
2029 "Run plt-main with PIE and -z ibtplt -z now" \
2030 "-Wl,--no-as-needed,-z,ibtplt,-z,now -pie tmpdir/plt-main1.o \
2031 tmpdir/plt-main2.o tmpdir/plt-main3.o \
2032 tmpdir/plt-main4.o tmpdir/libplt-lib.so" \
2033 "-Wa,-mx86-used-note=yes" \
2034 { plt-main5.c } \
2035 "plt-main-pie-ibt-now" \
2036 "plt-main.out" \
2037 "-fPIC" \
2038 ] \
2039 [list \
2040 "Run plt-main with libibtplt-lib.so -z ibtplt" \
2041 "-Wl,--no-as-needed,-z,ibtplt tmpdir/libibtplt-lib.so \
2042 tmpdir/libplt-lib.so" \
2043 "-Wa,-mx86-used-note=yes" \
2044 { plt-main5.c } \
2045 "plt-main-ibt-lib" \
2046 "plt-main.out" \
2047 ] \
2048 [list \
2049 "Run plt-main with libibtplt-lib.so -z ibtplt -z now" \
2050 "-Wl,--no-as-needed,-z,ibtplt,-z,now \
2051 tmpdir/libibtplt-now-lib.so tmpdir/libplt-lib.so" \
2052 "-Wa,-mx86-used-note=yes" \
2053 { plt-main5.c } \
2054 "plt-main-ibt-now-lib" \
2055 "plt-main.out" \
2056 ] \
2057 ]
2058
2059 if { [check_ifunc_attribute_available] } {
2060 run_ld_link_exec_tests [list \
2061 [list \
2062 "Run pr21481a" \
2063 "$NOPIE_LDFLAGS -Wl,-z,ibtplt" \
2064 "-Wa,-mx86-used-note=yes" \
2065 { pr21481a.c pr21481b.S } \
2066 "pr21481a" \
2067 "pass.out" \
2068 "$NOPIE_CFLAGS" \
2069 ] \
2070 [list \
2071 "Run pr21481b" \
2072 "$NOPIE_LDFLAGS -Wl,-z,ibtplt,-z,now" \
2073 "-Wa,-mx86-used-note=yes" \
2074 { pr21481a.c pr21481b.S } \
2075 "pr21481b" \
2076 "pass.out" \
2077 "$NOPIE_CFLAGS" \
2078 ] \
2079 ]
2080 }
2081 }
2082
2083 undefined_weak "$NOPIE_CFLAGS" "$NOPIE_LDFLAGS"
2084 undefined_weak "-fPIE" ""
2085 undefined_weak "-fPIE" "-pie"
2086 undefined_weak "-fPIE" "-Wl,-z,nodynamic-undefined-weak"
2087 undefined_weak "-fPIE" "-pie -Wl,-z,nodynamic-undefined-weak"
2088 }
2089
2090 if { ![istarget "x86_64-*-linux*"]} {
2091 set ASFLAGS "$saved_ASFLAGS"
2092 return
2093 }
2094
2095 run_ld_link_tests [list \
2096 [list \
2097 "basic PLT generation (-z now)" \
2098 "-z now -melf_x86_64 --hash-style=sysv tmpdir/libpltlib.so \
2099 -z noseparate-code -z max-page-size=0x200000" \
2100 "" \
2101 "--64" \
2102 {plt2.s} \
2103 {{readelf -SW plt2.rd} {objdump -dwr plt2.dd}} \
2104 "plt2" \
2105 ] \
2106 [list \
2107 "Build property 3" \
2108 "-m elf_x86_64" \
2109 "" \
2110 "--64 -defsym __64_bit__=1 -mx86-used-note=yes" \
2111 {property-stk.s property-x86-1.s} \
2112 {{readelf -n property-3.r}} \
2113 "property-3" \
2114 ] \
2115 [list \
2116 "Build property 3 (.o)" \
2117 "-m elf_x86_64 -r" \
2118 "" \
2119 "--64 -defsym __64_bit__=1 -mx86-used-note=yes" \
2120 {property-x86-1.s property-stk.s} \
2121 {{readelf -n property-3a.r}} \
2122 "property-3.o" \
2123 ] \
2124 [list \
2125 "Build property 3 (.so)" \
2126 "-m elf_x86_64 -shared" \
2127 "" \
2128 "--64 -defsym __64_bit__=1 -mx86-used-note=yes" \
2129 {property-x86-1.s property-stk.s} \
2130 {{readelf -n property-3.r}} \
2131 "property-3.so" \
2132 ] \
2133 [list \
2134 "Build property 4" \
2135 "-m elf_x86_64" \
2136 "" \
2137 "--64 -defsym __64_bit__=1 -mx86-used-note=yes" \
2138 {property-stk.s property-x86-1.s property-x86-2.s} \
2139 {{readelf -n property-4.r}} \
2140 "property-4" \
2141 ] \
2142 [list \
2143 "Build property 4 (.o)" \
2144 "-m elf_x86_64 -r" \
2145 "" \
2146 "--64 -defsym __64_bit__=1 -mx86-used-note=yes" \
2147 {property-x86-2.s property-x86-1.s property-stk.s} \
2148 {{readelf {-n} property-4a.r}} \
2149 "property-4.o" \
2150 ] \
2151 [list \
2152 "Build property 4 (.so)" \
2153 "-m elf_x86_64 -shared" \
2154 "" \
2155 "--64 -defsym __64_bit__=1 -mx86-used-note=yes" \
2156 {property-x86-2.s property-x86-1.s property-stk.s} \
2157 {{readelf -n property-4.r}} \
2158 "property-4.so" \
2159 ] \
2160 [list \
2161 "Build property 4 (-z stack-size=0)" \
2162 "-m elf_x86_64 -z stack-size=0" \
2163 "" \
2164 "--64 -defsym __64_bit__=1 -mx86-used-note=yes" \
2165 {property-stk.s property-x86-1.s property-x86-2.s} \
2166 {{readelf -n property-4.r}} \
2167 "property-4" \
2168 ] \
2169 [list \
2170 "Build property 5" \
2171 "-m elf_x86_64 -z stack-size=0x900000" \
2172 "" \
2173 "--64 -defsym __64_bit__=1 -mx86-used-note=yes" \
2174 {property-stk.s property-x86-1.s property-x86-2.s} \
2175 {{readelf -n property-5.r}} \
2176 "property-5" \
2177 ] \
2178 [list \
2179 "Build property 5 (.o)" \
2180 "-m elf_x86_64 -r -z stack-size=0x900000" \
2181 "" \
2182 "--64 -defsym __64_bit__=1 -mx86-used-note=yes" \
2183 {property-x86-2.s property-x86-1.s property-stk.s} \
2184 {{readelf {-n} property-5a.r}} \
2185 "property-5.o" \
2186 ] \
2187 [list \
2188 "Build property 5 (.so)" \
2189 "-m elf_x86_64 -shared -z stack-size=0x900000" \
2190 "" \
2191 "--64 -defsym __64_bit__=1 -mx86-used-note=yes" \
2192 {property-x86-2.s property-x86-1.s property-stk.s} \
2193 {{readelf -n property-5.r}} \
2194 "property-5.so" \
2195 ] \
2196 [list \
2197 "Build pr21626.so" \
2198 "-shared -melf_x86_64" \
2199 "" \
2200 "--64 -defsym __64_bit__=1 -mx86-used-note=yes" \
2201 {property-x86-3.s} \
2202 "" \
2203 "pr21626.so" \
2204 ] \
2205 [list \
2206 "Build pr21626" \
2207 "-melf_x86_64 tmpdir/pr21626.so" \
2208 "" \
2209 "--64 -mx86-used-note=yes" \
2210 {start.s foo.s} \
2211 "" \
2212 "pr21626" \
2213 ] \
2214 ]
2215
2216 # Linux only tests. Disabled due to large memory requirement.
2217 if { "x$LD_CLASS" == "64bit" } then {
2218 # This test needs 64-bit linker.
2219 run_dump_test "pr17618"
2220 }
2221 run_dump_test "pltgot-1"
2222 run_dump_test "pltgot-2"
2223 run_dump_test "pr20830a"
2224 run_dump_test "pr20830b"
2225 run_dump_test "pr20830a-now"
2226 run_dump_test "pr20830b-now"
2227 run_dump_test "ibt-plt-1"
2228 run_dump_test "ibt-plt-1-x32"
2229 run_dump_test "ibt-plt-2a"
2230 run_dump_test "ibt-plt-2b"
2231 run_dump_test "ibt-plt-2c"
2232 run_dump_test "ibt-plt-2d"
2233 run_dump_test "ibt-plt-2a-x32"
2234 run_dump_test "ibt-plt-2b-x32"
2235 run_dump_test "ibt-plt-2c-x32"
2236 run_dump_test "ibt-plt-2d-x32"
2237 run_dump_test "ibt-plt-3a"
2238 run_dump_test "ibt-plt-3b"
2239 run_dump_test "ibt-plt-3c"
2240 run_dump_test "ibt-plt-3d"
2241 run_dump_test "ibt-plt-3a-x32"
2242 run_dump_test "ibt-plt-3b-x32"
2243 run_dump_test "ibt-plt-3c-x32"
2244 run_dump_test "ibt-plt-3d-x32"
2245 run_dump_test "mark-plt-1a"
2246 run_dump_test "mark-plt-1b"
2247 run_dump_test "mark-plt-1c"
2248 run_dump_test "mark-plt-1d"
2249 run_dump_test "mark-plt-1a-x32"
2250 run_dump_test "mark-plt-1b-x32"
2251 run_dump_test "mark-plt-1c-x32"
2252 run_dump_test "mark-plt-1d-x32"
2253
2254 set ASFLAGS "$saved_ASFLAGS"