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