# Expect script for linker support of IFUNC symbols and relocations.
#
-# Copyright 2009, 2010, 2012 Free Software Foundation, Inc.
+# Copyright (C) 2009-2016 Free Software Foundation, Inc.
# Contributed by Red Hat.
#
# This file is part of the GNU Binutils.
# IFUNC support has only been implemented for the ix86, x86_64, powerpc,
-# and sparc so far.
+# aarch64, sparc, and S/390 so far.
if {!(([istarget "i?86-*-*"]
|| [istarget "x86_64-*-*"]
|| [istarget "powerpc*-*-*"]
- || [istarget "sparc*-*-*"])
+ || [istarget "aarch64*-*-*"]
+ || [istarget "sparc*-*-*"]
+ || [istarget "s390*-*-*"])
&& ([istarget "*-*-elf*"]
|| [istarget "*-*-nacl*"]
|| (([istarget "*-*-linux*"]
# Look for a line like this:
# 58: 0000000000400600 30 IFUNC GLOBAL DEFAULT 12 library_func2
+ # with perhaps some other info between the visibility and section
- if { ![regexp ".*\[ \]*IFUNC\[ \]+GLOBAL\[ \]+DEFAULT\[ \]+\[UND0-9\]+\[ \]+library_func2\n" [file_contents readelf.out]] } {
+ if { ![regexp ".*\[ \]*IFUNC\[ \]+GLOBAL\[ \]+DEFAULT .* \[UND0-9\]+\[ \]+library_func2\n" [file_contents readelf.out]] } {
return 0
}
remote_file host delete "tmpdir/static_nonifunc_prog"
}
+run_cc_link_tests [list \
+ [list \
+ "Build libpr16467a.so" \
+ "-shared -Wl,--version-script=pr16467a.map" \
+ "-fPIC" \
+ { pr16467a.c } \
+ {} \
+ "libpr16467a.so" \
+ ] \
+ [list \
+ "Build libpr16467b.a" \
+ "" \
+ "-fPIC" \
+ { pr16467b.c } \
+ {} \
+ "libpr16467b.a" \
+ ] \
+ [list \
+ "Build libpr16467b.so" \
+ "-shared tmpdir/pr16467b.o tmpdir/libpr16467a.so \
+ -Wl,--version-script=pr16467b.map" \
+ "-fPIC" \
+ { dummy.c } \
+ {} \
+ "libpr16467b.so" \
+ ] \
+ [list \
+ "Build libpr16467c.a" \
+ "" \
+ "" \
+ { pr16467c.c } \
+ {} \
+ "libpr16467c.a" \
+ ] \
+]
+
+run_ld_link_exec_tests [] [list \
+ [list \
+ "Common symbol override ifunc test 1a" \
+ "-static" \
+ "" \
+ { ifunc-common-1a.c ifunc-common-1b.c } \
+ "ifunc-common-1a" \
+ "ifunc-common-1.out" \
+ "-g" \
+ ] \
+ [list \
+ "Common symbol override ifunc test 1b" \
+ "-static" \
+ "" \
+ { ifunc-common-1b.c ifunc-common-1a.c } \
+ "ifunc-common-1b" \
+ "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_cc_link_tests [list \
+ [list \
+ "Build ifunc-lib.so" \
+ "-shared" \
+ "-fPIC" \
+ { ifunc-lib.c } \
+ {} \
+ "libifunc-lib.so" \
+ ] \
+]
+
+run_ld_link_exec_tests [] [list \
+ [list \
+ "Run pr16467" \
+ "tmpdir/pr16467c.o tmpdir/libpr16467b.so tmpdir/libpr16467a.so" \
+ "" \
+ { dummy.c } \
+ "pr16467" \
+ "pr16467.out" \
+ "" \
+ ] \
+ [list \
+ "Run ifunc-main" \
+ "tmpdir/libifunc-lib.so" \
+ "" \
+ { ifunc-main.c } \
+ "ifunc-main" \
+ "ifunc-main.out" \
+ ] \
+ [list \
+ "Run ifunc-main with -fpic" \
+ "tmpdir/libifunc-lib.so" \
+ "" \
+ { ifunc-main.c } \
+ "ifunc-main" \
+ "ifunc-main.out" \
+ "-fpic" \
+ ] \
+]
+
+# Run-time tests which require working ifunc attribute support.
+if { ![check_ifunc_attribute_available] } {
+ return
+}
+
+run_cc_link_tests [list \
+ [list \
+ "Build pr18808a.o" \
+ "" \
+ "" \
+ { pr18808a.c } \
+ "" \
+ "" \
+ ] \
+ [list \
+ "Build libpr18808.so" \
+ "-shared" \
+ "-fPIC -O2 -g" \
+ { pr18808b.c } \
+ {} \
+ "libpr18808.so" \
+ ] \
+ [list \
+ "Build pr18841a.o" \
+ "" \
+ "" \
+ { pr18841a.c } \
+ "" \
+ "" \
+ ] \
+ [list \
+ "Build libpr18841b.so" \
+ "-shared" \
+ "-fPIC -O0 -g" \
+ { pr18841b.c } \
+ {} \
+ "libpr18841b.so" \
+ ] \
+ [list \
+ "Build libpr18841c.so" \
+ "-shared" \
+ "-fPIC -O0 -g" \
+ { pr18841c.c } \
+ {} \
+ "libpr18841c.so" \
+ ] \
+ [list \
+ "Build libpr19784a.so" \
+ "-shared -Wl,-Bsymbolic-functions" \
+ "-fPIC -O2 -g" \
+ { pr19784b.c pr19784c.c } \
+ {} \
+ "libpr19784a.so" \
+ ] \
+ [list \
+ "Build libpr19784b.so" \
+ "-shared -Wl,-Bsymbolic-functions" \
+ "-fPIC -O2 -g" \
+ { pr19784c.c pr19784b.c } \
+ {} \
+ "libpr19784b.so" \
+ ] \
+ [list \
+ "Build pr19784a.o" \
+ "" \
+ "" \
+ { pr19784a.c } \
+ "" \
+ "" \
+ ] \
+]
+
+run_ld_link_exec_tests [] [list \
+ [list \
+ "Run pr18808" \
+ "tmpdir/pr18808a.o tmpdir/libpr18808.so" \
+ "" \
+ { dummy.c } \
+ "pr18808" \
+ "pr18808.out" \
+ ] \
+ [list \
+ "Run pr18841 with libpr18841b.so" \
+ "tmpdir/pr18841a.o tmpdir/libpr18841b.so" \
+ "" \
+ { dummy.c } \
+ "pr18841b" \
+ "pr18841.out" \
+ ] \
+ [list \
+ "Run pr18841 with libpr18841c.so" \
+ "--as-needed tmpdir/pr18841a.o tmpdir/libpr18841c.so" \
+ "" \
+ { dummy.c } \
+ "pr18841c" \
+ "pr18841.out" \
+ ] \
+ [list \
+ "Run pr19784a" \
+ "tmpdir/pr19784a.o tmpdir/libpr19784a.so" \
+ "" \
+ { dummy.c } \
+ "pr19784a" \
+ "pass.out" \
+ ] \
+ [list \
+ "Run pr19784b" \
+ "--as-needed tmpdir/pr19784a.o tmpdir/libpr19784b.so" \
+ "" \
+ { dummy.c } \
+ "pr19784b" \
+ "pass.out" \
+ ] \
+]