elf32-arc.c: Don't cast between function pointer and void pointer
[deliverable/binutils-gdb.git] / ld / testsuite / ld-ifunc / ifunc.exp
CommitLineData
d8045f23
NC
1# Expect script for linker support of IFUNC symbols and relocations.
2#
b3adc24a 3# Copyright (C) 2009-2020 Free Software Foundation, Inc.
d8045f23
NC
4# Contributed by Red Hat.
5#
6# This file is part of the GNU Binutils.
7#
8# This program is free software; you can redistribute it and/or modify
9# it under the terms of the GNU General Public License as published by
10# the Free Software Foundation; either version 3 of the License, or
11# (at your option) any later version.
12#
13# This program is distributed in the hope that it will be useful,
14# but WITHOUT ANY WARRANTY; without even the implied warranty of
15# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16# GNU General Public License for more details.
17#
18# You should have received a copy of the GNU General Public License
19# along with this program; if not, write to the Free Software
20# Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
21# MA 02110-1301, USA.
22#
23# Written by Nick Clifton <nickc@redhat.com>
24
25
bb4e012c 26if { ![is_elf_format] || ![supports_gnu_osabi]
2d0a923c 27 || [istarget alpha-*-*]
bb4e012c
AM
28 || [istarget arc*-*-*]
29 || [istarget am33*-*-*]
30 || [istarget bfin-*-*]
31 || [istarget cris*-*-*]
32 || [istarget frv-*-*]
33 || [istarget lm32-*-*]
34 || [istarget m32r-*-*]
35 || [istarget m68k-*-*]
36 || [istarget microblaze-*-*]
37 || [istarget mips*-*-*]
38 || [istarget mn10300-*-*]
39 || [istarget nds32*-*-*]
40 || [istarget nios2-*-*]
41 || [istarget or1k-*-*]
42 || [istarget riscv*-*-*]
43 || [istarget score*-*-*]
44 || [istarget sh*-*-*]
45 || [istarget tic6x-*-*]
46 || [istarget tile*-*-*]
47 || [istarget vax-*-*] } {
d8045f23
NC
48 verbose "IFUNC tests not run - target does not support IFUNC"
49 return
50}
51
47523653
AM
52# Skip targets where -shared is not supported
53
54if ![check_shared_lib_support] {
55 return
56}
57
e9d644e8
L
58set saved_ASFLAGS "$ASFLAGS"
59if { [istarget "i?86-*-*"] || [istarget "x86_64-*-*"] } {
60 set ASFLAGS "$ASFLAGS -mx86-used-note=no"
61}
62
f657f8c4
NC
63# This test does not need a compiler...
64run_dump_test "ifuncmod5"
65
ac98f9e2
L
66set test_list [lsort [glob -nocomplain $srcdir/$subdir/*.d]]
67foreach t $test_list {
68 # We need to strip the ".d", but can leave the dirname.
69 verbose [file rootname $t]
70 run_dump_test [file rootname $t]
71}
72
d8045f23
NC
73# We need a working compiler. (Strictly speaking this is
74# not true, we could use target specific assembler files).
44ed8092 75if { ![check_compiler_available] } {
d8045f23
NC
76 verbose "IFUNC tests not run - no compiler available"
77 return
78}
79
80# A procedure to check the OS/ABI field in the ELF header of a binary file.
81proc check_osabi { binary_file expected_osabi } {
82 global READELF
83 global READELFFLAGS
84
85 catch "exec $READELF $READELFFLAGS --file-header $binary_file > readelf.out" got
86
87 if ![string match "" $got] then {
88 verbose "proc check_osabi: Readelf produced unexpected out processing $binary_file: $got"
89 return 0
90 }
91
92 if { ![regexp "\n\[ \]*OS/ABI:\[ \]*(.+)\n\[ \]*ABI" \
93 [file_contents readelf.out] nil osabi] } {
94 verbose "proc check_osabi: Readelf failed to extract an ELF header from $binary_file"
95 return 0
96 }
97
98 if { $osabi == $expected_osabi } {
99 return 1
100 }
101
102 verbose "Expected OSABI: $expected_osabi, Obtained osabi: $osabi"
5a68afcf 103
d8045f23
NC
104 return 0
105}
106
107# A procedure to confirm that a file contains the IFUNC symbol.
108# Returns -1 upon error, 0 if the symbol was not found and 1 if it was found.
109proc contains_ifunc_symbol { binary_file } {
110 global READELF
111 global READELFFLAGS
112
113 catch "exec $READELF $READELFFLAGS --symbols $binary_file > readelf.out" got
114
115 if ![string match "" $got] then {
116 verbose "proc contains_ifunc_symbol: Readelf produced unexpected out processing $binary_file: $got"
117 return -1
118 }
119
120 # Look for a line like this:
121 # 58: 0000000000400600 30 IFUNC GLOBAL DEFAULT 12 library_func2
4115bfc6 122 # with perhaps some other info between the visibility and section
d8045f23 123
4115bfc6 124 if { ![regexp ".*\[ \]*IFUNC\[ \]+GLOBAL\[ \]+DEFAULT .* \[UND0-9\]+\[ \]+library_func2\n" [file_contents readelf.out]] } {
d8045f23
NC
125 return 0
126 }
127
128 return 1
129}
130
cbe950e9
L
131# A procedure to confirm that a file contains the R_*_IRELATIVE
132# relocation.
133# Returns -1 upon error, 0 if the relocation was not found and 1 if
134# it was found.
135proc contains_irelative_reloc { binary_file } {
136 global READELF
137 global READELFFLAGS
138
139 catch "exec $READELF $READELFFLAGS --relocs --wide $binary_file > readelf.out" got
140
141 if ![string match "" $got] then {
142 verbose "proc contains_irelative_reloc: Readelf produced unexpected out processing $binary_file: $got"
143 return -1
144 }
145
146 # Look for a line like this:
147 # 0000000000600ab0 0000000000000025 R_X86_64_IRELATIVE 000000000040061c
148 # 080496f4 0000002a R_386_IRELATIVE
149
150
bb4e012c 151 if { ![regexp "\[0-9a-f\]+\[ \]+\[0-9a-f\]+\[ \]+R_(\[_0-9A-Z\]+_IREL(|ATIVE)|PARISC_IPLT)\[ \]*\[0-9a-f\]*\n" [file_contents readelf.out]] } {
cbe950e9
L
152 return 0
153 }
154
155 return 1
156}
157
d8045f23
NC
158# A procedure to confirm that a file contains a relocation that references an IFUNC symbol.
159# Returns -1 upon error, 0 if the reloc was not found and 1 if it was found.
160proc contains_ifunc_reloc { binary_file } {
161 global READELF
162 global READELFFLAGS
163
164 catch "exec $READELF $READELFFLAGS --relocs $binary_file > readelf.out" got
165
166 if ![string match "" $got] then {
167 verbose "proc contains_ifunc_reloc: Readelf produced unexpected out processing $binary_file: $got"
168 return -1
169 }
170
171 if [string match "" [file_contents readelf.out]] then {
172 verbose "No relocs found in $binary_file"
173 return 0
174 }
175
176 if { ![regexp "\\(\\)" [file_contents readelf.out]] } {
177 return 0
178 }
179
180 return 1
181}
182
183set fails 0
184
e6a6c767
L
185# Disable LTO for these tests.
186set cc_cmd "$CC"
187if {[check_lto_available]} {
188 append cc_cmd " -fno-lto"
189}
190
d8045f23 191# Create the object files, libraries and executables.
e6a6c767 192if ![ld_compile "$cc_cmd -c -fPIC" "$srcdir/$subdir/prog.c" "tmpdir/shared_prog.o"] {
be19bd51 193 fail "Could not create a PIC object file"
d8045f23
NC
194 set fails [expr $fails + 1]
195}
e6a6c767 196if ![ld_compile "$cc_cmd -c $NOPIE_CFLAGS" "$srcdir/$subdir/prog.c" "tmpdir/static_prog.o"] {
be19bd51 197 fail "Could not create a non-PIC object file"
d8045f23
NC
198 set fails [expr $fails + 1]
199}
e6a6c767 200if ![ld_compile "$cc_cmd -c -fPIC -DWITH_IFUNC" "$srcdir/$subdir/lib.c" "tmpdir/shared_ifunc.o"] {
be19bd51 201 fail "Could not create a PIC object file containing an IFUNC symbol"
d8045f23
NC
202 set fails [expr $fails + 1]
203}
e6a6c767 204if ![ld_compile "$cc_cmd -c $NOPIE_CFLAGS -DWITH_IFUNC" "$srcdir/$subdir/lib.c" "tmpdir/static_ifunc.o"] {
be19bd51 205 fail "Could not create a non-PIC object file containing an IFUNC symbol"
d8045f23
NC
206 set fails [expr $fails + 1]
207}
e6a6c767 208if ![ld_compile "$cc_cmd -c -DWITHOUT_IFUNC" "$srcdir/$subdir/lib.c" "tmpdir/static_noifunc.o"] {
be19bd51
L
209 fail "Could not create an ordinary non-PIC object file"
210 set fails [expr $fails + 1]
211}
212if ![ld_assemble $as "$srcdir/ld-elf/empty.s" "tmpdir/empty.o"] {
213 fail "Could not create an empty object file"
d8045f23
NC
214 set fails [expr $fails + 1]
215}
e6a6c767 216if ![ld_compile "$cc_cmd -c" "$srcdir/$subdir/test-1.c" "tmpdir/test-1.o"] {
2955ec4c
L
217 fail "Could not create test-1.o"
218 set fails [expr $fails + 1]
219}
e6a6c767 220if ![ld_compile "$cc_cmd -fPIC -c" "$srcdir/$subdir/test-2.c" "tmpdir/test-2.o"] {
2955ec4c
L
221 fail "Could not create test-2.o"
222 set fails [expr $fails + 1]
223}
d8045f23
NC
224
225if { $fails != 0 } {
226 return
227}
228
d9816402 229if ![ld_link $ld "tmpdir/libshared_ifunc.so" "-shared tmpdir/shared_ifunc.o"] {
d8045f23
NC
230 fail "Could not create a shared library containing an IFUNC symbol"
231 set fails [expr $fails + 1]
232}
233if ![ar_simple_create $ar "" "tmpdir/libifunc.a" "tmpdir/static_ifunc.o"] {
234 fail "Could not create a static library containing an IFUNC symbol"
235 set fails [expr $fails + 1]
236}
237
238if { $fails != 0 } {
239 return
240}
241
d9816402 242if ![ld_link $CC "tmpdir/dynamic_prog" "-Wl,--no-as-needed,-rpath=./tmpdir,-Bdynamic -Ltmpdir tmpdir/shared_prog.o -lshared_ifunc"] {
d8045f23
NC
243 fail "Could not link a dynamic executable"
244 set fails [expr $fails + 1]
245}
640d0ed8 246if ![ld_link $CC "tmpdir/local_prog" "$NOPIE_LDFLAGS -Wl,--no-as-needed,-rpath=./tmpdir -Ltmpdir tmpdir/static_prog.o -lifunc"] {
e054468f
AM
247 fail "Could not link a dynamic executable using local ifunc"
248 set fails [expr $fails + 1]
249}
98d72909
L
250if ![string match "" $STATIC_LDFLAGS] {
251 if ![ld_link $CC "tmpdir/static_prog" "-static -Ltmpdir tmpdir/static_prog.o -lifunc"] {
252 fail "Could not link a static executable"
253 set fails [expr $fails + 1]
254 }
d0042c6e
L
255}
256if ![ld_link $ld "tmpdir/static_nonifunc_prog" "-static tmpdir/empty.o"] {
257 fail "Could not link a non-ifunc using static executable"
258 set fails [expr $fails + 1]
d8045f23 259}
d9816402 260if ![ld_link $CC "tmpdir/test-1" "-Wl,--no-as-needed,-rpath=./tmpdir tmpdir/test-1.o tmpdir/libshared_ifunc.so"] {
2955ec4c
L
261 fail "Could not link test-1"
262 set fails [expr $fails + 1]
263}
d9816402 264if ![ld_link $ld "tmpdir/libtest-2.so" "-shared tmpdir/test-2.o"] {
2955ec4c
L
265 fail "Could not link libtest-2.so"
266 set fails [expr $fails + 1]
267}
e492d2f8
L
268if ![ld_link $ld "tmpdir/libtest-2-now.so" "-shared -z now tmpdir/test-2.o"] {
269 fail "Could not link libtest-2-now.so"
270 set fails [expr $fails + 1]
271}
d8045f23
NC
272
273if { $fails == 0 } {
274 pass "Building ifunc binaries"
275 set fails 0
276} else {
277 return
278}
279
cbe950e9 280# Check the executables and shared libraries
d8045f23 281#
cbe950e9 282# The linked ifunc using executables and the shared library containing
9c55345c 283# ifunc should have an OSABI field of GNU. The linked non-ifunc using
cbe950e9 284# executable should have an OSABI field of NONE (aka System V).
d8045f23 285
e3696f67
AM
286switch -glob $target_triplet {
287 hppa*-*-linux* { set expected_none {UNIX - GNU} }
d9816402
AM
288 default { set expected_none {UNIX - System V} }
289}
290
9c55345c
TS
291if {! [check_osabi tmpdir/libshared_ifunc.so {UNIX - GNU}]} {
292 fail "Shared libraries containing ifunc does not have an OS/ABI field of GNU"
cbe950e9
L
293 set fails [expr $fails + 1]
294}
9c55345c
TS
295if {! [check_osabi tmpdir/local_prog {UNIX - GNU}]} {
296 fail "Local ifunc-using executable does not have an OS/ABI field of GNU"
e054468f
AM
297 set fails [expr $fails + 1]
298}
98d72909
L
299if { ![string match "" $STATIC_LDFLAGS] \
300 && ![check_osabi tmpdir/static_prog {UNIX - GNU}]} {
9c55345c 301 fail "Static ifunc-using executable does not have an OS/ABI field of GNU"
d8045f23
NC
302 set fails [expr $fails + 1]
303}
d9816402
AM
304if {! [check_osabi tmpdir/dynamic_prog $expected_none]} {
305 fail "Dynamic ifunc-using executable does not have an OS/ABI field of $expected_none"
d8045f23
NC
306 set fails [expr $fails + 1]
307}
d9816402
AM
308if {! [check_osabi tmpdir/static_nonifunc_prog $expected_none]} {
309 fail "Static non-ifunc-using executable does not have an OS/ABI field of $expected_none"
be19bd51
L
310 set fails [expr $fails + 1]
311}
d8045f23 312
cbe950e9
L
313# The linked ifunc using executables and the shared library containing
314# ifunc should contain an IFUNC symbol. The non-ifunc using executable
315# should not.
d8045f23 316
cbe950e9
L
317if {[contains_ifunc_symbol tmpdir/libshared_ifunc.so] != 1} {
318 fail "Shared libraries containing ifunc does not contain an IFUNC symbol"
319 set fails [expr $fails + 1]
320}
e054468f
AM
321if {[contains_ifunc_symbol tmpdir/local_prog] != 1} {
322 fail "Local ifunc-using executable does not contain an IFUNC symbol"
323 set fails [expr $fails + 1]
324}
98d72909
L
325if { ![string match "" $STATIC_LDFLAGS] \
326 && [contains_ifunc_symbol tmpdir/static_prog] != 1} {
d8045f23
NC
327 fail "Static ifunc-using executable does not contain an IFUNC symbol"
328 set fails [expr $fails + 1]
329}
2955ec4c
L
330if {[contains_ifunc_symbol tmpdir/dynamic_prog] != 0} {
331 fail "Dynamic ifunc-using executable contains an IFUNC symbol"
d8045f23
NC
332 set fails [expr $fails + 1]
333}
334if {[contains_ifunc_symbol tmpdir/static_nonifunc_prog] != 0} {
335 fail "Static non-ifunc-using executable contains an IFUNC symbol"
336 set fails [expr $fails + 1]
337}
2955ec4c
L
338if {[contains_ifunc_symbol tmpdir/test-1] != 0} {
339 fail "test-1 contains IFUNC symbols"
340 set fails [expr $fails + 1]
341}
342if {[contains_ifunc_symbol tmpdir/libtest-2.so] != 0} {
343 fail "libtest-2.so contains IFUNC symbols"
344 set fails [expr $fails + 1]
345}
e492d2f8
L
346if {[contains_ifunc_symbol tmpdir/libtest-2-now.so] != 0} {
347 fail "libtest-2-now.so contains IFUNC symbols"
348 set fails [expr $fails + 1]
349}
d8045f23 350
cbe950e9
L
351# The linked ifunc using executables and shared libraries should contain
352# a dynamic reloc referencing the IFUNC symbol. (Even the static
353# executable which should have a dynamic section created for it). The
354# non-ifunc using executable should not.
d8045f23 355
cbe950e9
L
356if {[contains_irelative_reloc tmpdir/libshared_ifunc.so] != 1} {
357 fail "ifunc-using shared library does not contain R_*_IRELATIVE relocation"
358 set fails [expr $fails + 1]
359}
e054468f
AM
360if {[contains_irelative_reloc tmpdir/local_prog] != 1} {
361 fail "Local ifunc-using executable does not contain R_*_IRELATIVE relocation"
362 set fails [expr $fails + 1]
363}
98d72909
L
364if { ![string match "" $STATIC_LDFLAGS] \
365 && [contains_irelative_reloc tmpdir/static_prog] != 1} {
cbe950e9 366 fail "Static ifunc-using executable does not contain R_*_IRELATIVE relocation"
d8045f23
NC
367 set fails [expr $fails + 1]
368}
2955ec4c
L
369if {[contains_ifunc_reloc tmpdir/dynamic_prog] != 0} {
370 fail "Dynamic ifunc-using executable contains a reloc against an IFUNC symbol"
d8045f23
NC
371 set fails [expr $fails + 1]
372}
373if {[contains_ifunc_reloc tmpdir/static_nonifunc_prog] == 1} {
374 fail "Static non-ifunc-using executable contains a reloc against an IFUNC symbol!"
375 set fails [expr $fails + 1]
376}
377
378if { $fails == 0 } {
379 pass "Checking ifunc binaries"
380}
381
4584ec12
L
382run_cc_link_tests [list \
383 [list \
384 "Build libpr16467a.so" \
385 "-shared -Wl,--version-script=pr16467a.map" \
386 "-fPIC" \
387 { pr16467a.c } \
388 {} \
389 "libpr16467a.so" \
390 ] \
391 [list \
392 "Build libpr16467b.a" \
393 "" \
394 "-fPIC" \
395 { pr16467b.c } \
396 {} \
397 "libpr16467b.a" \
398 ] \
399 [list \
400 "Build libpr16467b.so" \
401 "-shared tmpdir/pr16467b.o tmpdir/libpr16467a.so \
402 -Wl,--version-script=pr16467b.map" \
403 "-fPIC" \
404 { dummy.c } \
405 {} \
406 "libpr16467b.so" \
407 ] \
408 [list \
409 "Build libpr16467c.a" \
410 "" \
411 "" \
412 { pr16467c.c } \
413 {} \
414 "libpr16467c.a" \
415 ] \
d6f48aed
L
416 [list \
417 "Build libpr16467an.so" \
418 "-shared -Wl,-z,now -Wl,--version-script=pr16467a.map" \
419 "-fPIC" \
420 { pr16467a.c } \
421 {} \
422 "libpr16467an.so" \
423 ] \
424 [list \
425 "Build libpr16467bn.so" \
426 "-shared tmpdir/pr16467b.o tmpdir/libpr16467an.so \
427 -Wl,--version-script=pr16467b.map" \
428 "-fPIC" \
429 { dummy.c } \
430 {} \
431 "libpr16467bn.so" \
432 ] \
4584ec12
L
433]
434
982c6f26 435run_ld_link_exec_tests [list \
37a9e49a
L
436 [list \
437 "Common symbol override ifunc test 1a" \
438 "-static" \
439 "" \
440 { ifunc-common-1a.c ifunc-common-1b.c } \
441 "ifunc-common-1a" \
442 "ifunc-common-1.out" \
443 "-g" \
444 ] \
445 [list \
446 "Common symbol override ifunc test 1b" \
447 "-static" \
448 "" \
449 { ifunc-common-1b.c ifunc-common-1a.c } \
450 "ifunc-common-1b" \
451 "ifunc-common-1.out" \
452 "-g" \
453 ] \
c22ee0ad
L
454]
455
c22ee0ad
L
456# Run-time tests which require working IFUNC support.
457if { ![check_ifunc_available] } {
458 return
459}
460
5f7cbeec
L
461run_cc_link_tests [list \
462 [list \
463 "Build ifunc-lib.so" \
464 "-shared" \
465 "-fPIC" \
466 { ifunc-lib.c } \
467 {} \
468 "libifunc-lib.so" \
469 ] \
d6f48aed
L
470 [list \
471 "Build ifunc-libn.so" \
472 "-shared -Wl,-z,now" \
473 "-fPIC" \
474 { ifunc-lib.c } \
475 {} \
476 "libifunc-libn.so" \
477 ] \
5f7cbeec
L
478]
479
982c6f26 480run_ld_link_exec_tests [list \
4584ec12
L
481 [list \
482 "Run pr16467" \
d9816402 483 "-Wl,--no-as-needed tmpdir/pr16467c.o tmpdir/libpr16467b.so tmpdir/libpr16467a.so" \
4584ec12
L
484 "" \
485 { dummy.c } \
486 "pr16467" \
487 "pr16467.out" \
488 "" \
489 ] \
d6f48aed
L
490 [list \
491 "Run pr16467 (-z now)" \
492 "-Wl,-z,now -Wl,--no-as-needed tmpdir/pr16467c.o tmpdir/libpr16467bn.so tmpdir/libpr16467an.so" \
493 "" \
494 { dummy.c } \
495 "pr16467n" \
496 "pr16467.out" \
497 "" \
498 ] \
5f7cbeec
L
499 [list \
500 "Run ifunc-main" \
d9816402 501 "-Wl,--no-as-needed tmpdir/libifunc-lib.so" \
5f7cbeec
L
502 "" \
503 { ifunc-main.c } \
504 "ifunc-main" \
505 "ifunc-main.out" \
506 ] \
507 [list \
508 "Run ifunc-main with -fpic" \
d9816402 509 "-Wl,--no-as-needed tmpdir/libifunc-lib.so" \
5f7cbeec
L
510 "" \
511 { ifunc-main.c } \
512 "ifunc-main" \
513 "ifunc-main.out" \
514 "-fpic" \
515 ] \
d6f48aed
L
516 [list \
517 "Run ifunc-main (-z now)" \
518 "-Wl,-z,now -Wl,--no-as-needed tmpdir/libifunc-libn.so" \
519 "" \
520 { ifunc-main.c } \
521 "ifunc-mainn" \
522 "ifunc-main.out" \
523 ] \
524 [list \
525 "Run ifunc-main with PIE (-z now)" \
526 "-pie -Wl,-z,now -Wl,--no-as-needed tmpdir/libifunc-libn.so" \
527 "" \
528 { ifunc-main.c } \
529 "ifunc-mainpn" \
530 "ifunc-main.out" \
531 "-fpie" \
532 ] \
37a9e49a 533]
97dc35c8
L
534
535# Run-time tests which require working ifunc attribute support.
536if { ![check_ifunc_attribute_available] } {
537 return
538}
539
540run_cc_link_tests [list \
205ac185
L
541 [list \
542 "Build pr18808a.o" \
543 "" \
544 "" \
545 { pr18808a.c } \
546 "" \
547 "" \
548 ] \
97dc35c8
L
549 [list \
550 "Build libpr18808.so" \
551 "-shared" \
552 "-fPIC -O2 -g" \
553 { pr18808b.c } \
554 {} \
555 "libpr18808.so" \
556 ] \
d6f48aed
L
557 [list \
558 "Build libpr18808n.so" \
559 "-shared -Wl,-z,now" \
560 "-fPIC -O2 -g" \
561 { pr18808b.c } \
562 {} \
563 "libpr18808n.so" \
564 ] \
205ac185
L
565 [list \
566 "Build pr18841a.o" \
567 "" \
470cd0fa 568 "$NOPIE_CFLAGS" \
205ac185
L
569 { pr18841a.c } \
570 "" \
571 "" \
572 ] \
cae1fbbb 573 [list \
4e1626f5 574 "Build libpr18841b.so" \
cae1fbbb
L
575 "-shared" \
576 "-fPIC -O0 -g" \
577 { pr18841b.c } \
578 {} \
4e1626f5
L
579 "libpr18841b.so" \
580 ] \
581 [list \
582 "Build libpr18841c.so" \
583 "-shared" \
584 "-fPIC -O0 -g" \
585 { pr18841c.c } \
586 {} \
587 "libpr18841c.so" \
cae1fbbb 588 ] \
d6f48aed
L
589 [list \
590 "Build libpr18841bn.so" \
591 "-Wl,-z,now -shared" \
592 "-fPIC -O0 -g" \
593 { pr18841b.c } \
594 {} \
595 "libpr18841bn.so" \
596 ] \
597 [list \
598 "Build libpr18841cn.so" \
599 "-shared" \
600 "-Wl,-z,now -fPIC -O0 -g" \
601 { pr18841c.c } \
602 {} \
603 "libpr18841cn.so" \
604 ] \
4ec09950
L
605 [list \
606 "Build libpr23169a.so" \
607 "-shared" \
608 "-fPIC -O2 -g" \
609 { pr23169a.c } \
610 {} \
611 "libpr23169a.so" \
612 ] \
613 [list \
614 "Build libpr23169b.so" \
615 "-shared -Wl,-z,now" \
616 "-fPIC -O2 -g" \
617 { pr23169a.c } \
618 {} \
619 "libpr23169b.so" \
620 ] \
621 [list \
622 "Build pr23169a" \
623 "$NOPIE_LDFLAGS -Wl,--no-as-needed tmpdir/libpr23169a.so" \
624 "$NOPIE_CFLAGS -O2 -g" \
625 { pr23169b.c pr23169c.c } \
626 {{readelf {--dyn-syms} pr23169a.rd} \
627 {readelf {-r -W} pr23169b.rd}} \
628 "pr23169a" \
629 ] \
630 [list \
631 "Build pr23169b" \
632 "-pie -Wl,--no-as-needed tmpdir/libpr23169a.so" \
633 "-fPIE -O2 -g" \
634 { pr23169b.c pr23169c.c } \
635 {{readelf {--dyn-syms} pr23169c.rd} \
636 {readelf {-r -W} pr23169b.rd}} \
637 "pr23169b" \
638 ] \
639 [list \
640 "Build pr23169c" \
641 "$NOPIE_LDFLAGS -Wl,--no-as-needed tmpdir/libpr23169a.so" \
642 "-fPIE -O2 -g" \
643 { pr23169b.c pr23169c.c } \
644 {{readelf {--dyn-syms} pr23169c.rd} \
645 {readelf {-r -W} pr23169b.rd}} \
646 "pr23169c" \
647 ] \
648 [list \
649 "Build pr23169d" \
650 "$NOPIE_LDFLAGS -Wl,--no-as-needed,-z,now tmpdir/libpr23169b.so" \
651 "$NOPIE_CFLAGS -O2 -g" \
652 { pr23169b.c pr23169c.c } \
653 {{readelf {--dyn-syms} pr23169a.rd} \
654 {readelf {-r -W} pr23169b.rd}} \
655 "pr23169d" \
656 ] \
657 [list \
658 "Build pr23169e" \
659 "-pie -Wl,--no-as-needed,-z,now tmpdir/libpr23169b.so" \
660 "-fPIE -O2 -g" \
661 { pr23169b.c pr23169c.c } \
662 {{readelf {--dyn-syms} pr23169c.rd} \
663 {readelf {-r -W} pr23169b.rd}} \
664 "pr23169e" \
665 ] \
666 [list \
667 "Build pr23169f" \
668 "$NOPIE_LDFLAGS -Wl,--no-as-needed,-z,now tmpdir/libpr23169b.so" \
669 "-fPIE -O2 -g" \
670 { pr23169b.c pr23169c.c } \
671 {{readelf {--dyn-syms} pr23169c.rd} \
672 {readelf {-r -W} pr23169b.rd}} \
673 "pr23169f" \
674 ] \
97dc35c8
L
675]
676
982c6f26 677run_ld_link_exec_tests [list \
97dc35c8
L
678 [list \
679 "Run pr18808" \
d9816402 680 "-Wl,--no-as-needed tmpdir/pr18808a.o tmpdir/libpr18808.so" \
97dc35c8 681 "" \
205ac185 682 { dummy.c } \
97dc35c8
L
683 "pr18808" \
684 "pr18808.out" \
685 ] \
d6f48aed
L
686 [list \
687 "Run pr18808 (-z now)" \
688 "-Wl,-z,now -Wl,--no-as-needed tmpdir/pr18808a.o tmpdir/libpr18808n.so" \
689 "" \
690 { dummy.c } \
691 "pr18808n" \
692 "pr18808.out" \
693 ] \
cae1fbbb 694 [list \
4e1626f5 695 "Run pr18841 with libpr18841b.so" \
470cd0fa
AM
696 "$NOPIE_LDFLAGS -Wl,--no-as-needed tmpdir/pr18841a.o tmpdir/libpr18841b.so" \
697 "$NOPIE_CFLAGS" \
205ac185 698 { dummy.c } \
4e1626f5
L
699 "pr18841b" \
700 "pr18841.out" \
701 ] \
702 [list \
703 "Run pr18841 with libpr18841c.so" \
470cd0fa
AM
704 "$NOPIE_LDFLAGS -Wl,--as-needed tmpdir/pr18841a.o tmpdir/libpr18841c.so" \
705 "$NOPIE_CFLAGS" \
205ac185 706 { dummy.c } \
4e1626f5 707 "pr18841c" \
cae1fbbb
L
708 "pr18841.out" \
709 ] \
d6f48aed
L
710 [list \
711 "Run pr18841 with libpr18841bn.so (-z now)" \
470cd0fa
AM
712 "$NOPIE_LDFLAGS -Wl,-z,now -Wl,--no-as-needed tmpdir/pr18841a.o tmpdir/libpr18841bn.so" \
713 "$NOPIE_CFLAGS" \
d6f48aed
L
714 { dummy.c } \
715 "pr18841bn" \
716 "pr18841.out" \
717 ] \
718 [list \
719 "Run pr18841 with libpr18841cn.so (-z now)" \
470cd0fa
AM
720 "$NOPIE_LDFLAGS -Wl,-z,now -Wl,--as-needed tmpdir/pr18841a.o tmpdir/libpr18841cn.so" \
721 "$NOPIE_CFLAGS" \
d6f48aed
L
722 { dummy.c } \
723 "pr18841cn" \
724 "pr18841.out" \
725 ] \
2822b09f
AM
726]
727
728# The pr23169 testcase is not valid. In general, you can't call ifunc
729# resolvers in another binary unless you know what you're doing. In
730# particular you must ensure that the binary containing the resolver
731# is relocated before the resolver is called (for example, the
732# function addresses returned by the resolver may be loaded from the
733# GOT).
734# That does not happen for the pr23169 testcase where the resolver is
735# in the executable (which is relocated last by ld.so).
736if { [isnative]
c49829c3
EB
737 && !([istarget "powerpc-*-*"]
738 || [istarget "aarch64*-*-*"]
739 || [istarget "sparc*-*-*"]) } {
2822b09f 740run_ld_link_exec_tests [list \
4ec09950
L
741 [list \
742 "Run pr23169a" \
743 "$NOPIE_LDFLAGS -Wl,--no-as-needed tmpdir/libpr23169a.so" \
744 "" \
745 { pr23169b.c pr23169c.c } \
746 "pr23169a" \
747 "pass.out" \
748 "$NOPIE_CFLAGS -O2 -g" \
749 ] \
750 [list \
751 "Run pr23169b" \
752 "-pie -Wl,--no-as-needed tmpdir/libpr23169a.so" \
753 "" \
754 { pr23169b.c pr23169c.c } \
755 "pr23169b" \
756 "pass.out" \
757 "-fPIE -O2 -g" \
758 ] \
759 [list \
760 "Run pr23169c" \
761 "$NOPIE_LDFLAGS -Wl,--no-as-needed tmpdir/libpr23169a.so" \
762 "" \
763 { pr23169b.c pr23169c.c } \
764 "pr23169c" \
765 "pass.out" \
766 "-fPIE -O2 -g" \
767 ] \
768 [list \
769 "Run pr23169d" \
770 "$NOPIE_LDFLAGS -Wl,--no-as-needed,-z,now tmpdir/libpr23169b.so" \
771 "" \
772 { pr23169b.c pr23169c.c } \
773 "pr23169d" \
774 "pass.out" \
775 "$NOPIE_CFLAGS -O2 -g" \
776 ] \
777 [list \
778 "Run pr23169e" \
779 "-pie -Wl,--no-as-needed,-z,now tmpdir/libpr23169b.so" \
780 "" \
781 { pr23169b.c pr23169c.c } \
782 "pr23169e" \
783 "pass.out" \
784 "-fPIE -O2 -g" \
785 ] \
786 [list \
787 "Run pr23169f" \
788 "$NOPIE_LDFLAGS -Wl,--no-as-needed,-z,now tmpdir/libpr23169b.so" \
789 "" \
790 { pr23169b.c pr23169c.c } \
791 "pr23169f" \
792 "pass.out" \
793 "-fPIE -O2 -g" \
794 ] \
b3d7a867
L
795]
796if { $STATIC_PIE_LDFLAGS != "" } then {
797 run_ld_link_exec_tests [list \
798 [list \
799 "Run pr23169g" \
800 "$STATIC_PIE_LDFLAGS" \
801 "" \
802 { pr23169a.c pr23169b.c pr23169c.c } \
803 "pr23169g" \
804 "pass.out" \
805 "-fPIE -O2 -g" \
806 ] \
807]
808}
809}
e9d644e8
L
810
811set ASFLAGS "$saved_ASFLAGS"
This page took 0.565083 seconds and 4 git commands to generate.