Run IFUNC run-time tests only if IFUNC is supported

* lib/ld-lib.exp (check_ifunc_available): New.
	* ld-ifunc/ifunc.exp: Run IFUNC run-time tests only if IFUNC
	is supported.
This commit is contained in:
H.J. Lu 2014-11-20 08:59:42 -08:00
parent 43f3e411c4
commit c22ee0ad9d
3 changed files with 68 additions and 7 deletions

View file

@ -1,3 +1,9 @@
2014-11-20 H.J. Lu <hongjiu.lu@intel.com>
* lib/ld-lib.exp (check_ifunc_available): New.
* ld-ifunc/ifunc.exp: Run IFUNC run-time tests only if IFUNC
is supported.
2014-11-20 Terry Guo <terry.guo@arm.com>
* ld-arm/attr-merge-nosection-1.d: New file.

View file

@ -404,6 +404,21 @@ run_ld_link_exec_tests [] [list \
"ifunc-common-1.out" \
"-g" \
] \
]
set test_list [lsort [glob -nocomplain $srcdir/$subdir/*.d]]
foreach t $test_list {
# We need to strip the ".d", but can leave the dirname.
verbose [file rootname $t]
run_dump_test [file rootname $t]
}
# Run-time tests which require working IFUNC support.
if { ![check_ifunc_available] } {
return
}
run_ld_link_exec_tests [] [list \
[list \
"Run pr16467" \
"tmpdir/pr16467c.o tmpdir/libpr16467b.so tmpdir/libpr16467a.so" \
@ -414,10 +429,3 @@ run_ld_link_exec_tests [] [list \
"" \
] \
]
set test_list [lsort [glob -nocomplain $srcdir/$subdir/*.d]]
foreach t $test_list {
# We need to strip the ".d", but can leave the dirname.
verbose [file rootname $t]
run_dump_test [file rootname $t]
}

View file

@ -1820,6 +1820,53 @@ proc check_as_cfi { } {
return $success
}
# Returns true if IFUNC works.
proc check_ifunc_available { } {
global ifunc_available_saved
global CC
if {![info exists ifunc_available_saved]} {
if { [which $CC] == 0 } {
set ifunc_available_saved 0
return 0
}
# Check if gcc supports -flto -fuse-linker-plugin
set flags ""
if [board_info [target_info name] exists cflags] {
append flags " [board_info [target_info name] cflags]"
}
if [board_info [target_info name] exists ldflags] {
append flags " [board_info [target_info name] ldflags]"
}
set basename "tmpdir/ifunc[pid]"
set src ${basename}.c
set output ${basename}.out
set f [open $src "w"]
puts $f "extern int library_func2 (void);"
puts $f "int main (void)"
puts $f "{"
puts $f " if (library_func2 () != 2) __builtin_abort ();"
puts $f " return 0; "
puts $f "}"
puts $f "static int library_func1 (void) {return 2; }"
puts $f "void *foo (void) __asm__ (\"library_func2\");"
puts $f "void *foo (void) { return library_func1; }"
puts $f "__asm__(\".type library_func2, %gnu_indirect_function\");"
close $f
remote_download host $src
set ifunc_available_saved [run_host_cmd_yesno "$CC" "$flags $src -o $output"]
if { $ifunc_available_saved == 1 } {
set ifunc_available_saved [run_host_cmd_yesno "$output" ""]
}
remote_file host delete $src
remote_file host delete $output
file delete $src
}
return $ifunc_available_saved
}
# Provide virtual target "cfi" for targets supporting CFI.
rename "istarget" "istarget_ld"