+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.
"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" \
"" \
] \
]
-
-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]
-}
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"