aboutsummaryrefslogtreecommitdiff
path: root/ld/testsuite
diff options
context:
space:
mode:
authorJiong Wang <jiong.wang@arm.com>2017-02-01 16:44:40 +0000
committerJiong Wang <jiong.wang@arm.com>2017-02-02 09:57:26 +0000
commitfd121c5c45bd2652a78c62812737874e36259e2a (patch)
tree6f6852d734449dcd8958956f44b00940c733a687 /ld/testsuite
parent7a8eb317c5bce0f1ff290a9343777db74adec663 (diff)
downloadgdb-fd121c5c45bd2652a78c62812737874e36259e2a.zip
gdb-fd121c5c45bd2652a78c62812737874e36259e2a.tar.gz
gdb-fd121c5c45bd2652a78c62812737874e36259e2a.tar.bz2
[ld, testsuite] Restrict dl1*main and dl6*main tests on platforms which have libdl support
ld/ * testsuite/lib/ld-lib.exp (check_libdl_available): New function. * testsuite/ld-elf/shared.exp (run_tests): Split tests which require dlopen support into "dlopen_run_tests". These tests include dl1*main and dl6*main. (dlopen_run_tests): New and only run it when check_libdl_available returns true. XFAIL on *-*-netbsdelf*.
Diffstat (limited to 'ld/testsuite')
-rw-r--r--ld/testsuite/ld-elf/shared.exp89
-rw-r--r--ld/testsuite/lib/ld-lib.exp35
2 files changed, 85 insertions, 39 deletions
diff --git a/ld/testsuite/ld-elf/shared.exp b/ld/testsuite/ld-elf/shared.exp
index eea9453..2946262 100644
--- a/ld/testsuite/ld-elf/shared.exp
+++ b/ld/testsuite/ld-elf/shared.exp
@@ -373,12 +373,6 @@ set run_tests [list \
[list "Run hidden libbar.so with versioned libfoo.so" \
"-Wl,--no-as-needed tmpdir/libbarhfoov.so tmpdir/libfoov.so" "" \
{main.c} "hidden" "hidden.out" ] \
- [list "Run dl1a with --dynamic-list=dl1.list and dlopen on libdl1.so" \
- "-Wl,--no-as-needed,--dynamic-list=dl1.list $extralibs" "" \
- {dl1main.c} "dl1a" "dl1.out" ] \
- [list "Run dl1b with --dynamic-list-data and dlopen on libdl1.so" \
- "-Wl,--no-as-needed,--dynamic-list-data $extralibs" "" \
- {dl1main.c} "dl1b" "dl1.out" ] \
[list "Run with libdl2a.so" \
"-Wl,--no-as-needed tmpdir/libdl2a.so" "" \
{dl2main.c} "dl2a" "dl2a.out" ] \
@@ -406,39 +400,6 @@ set run_tests [list \
[list "Run with libdl4f.so" \
"-Wl,--no-as-needed tmpdir/libdl4f.so" "" \
{dl4main.c} "dl4f" "dl4a.out" ] \
- [list "Run dl6a1 with --dynamic-list-data and dlopen on libdl6a.so" \
- "-Wl,--no-as-needed,--dynamic-list-data $extralibs" "" \
- {dl6amain.c} "dl6a1" "dl6a.out" ] \
- [list "Run dl6a2 with -Bsymbolic-functions and dlopen on libdl6a.so" \
- "-Wl,--no-as-needed,-Bsymbolic-functions $extralibs" "" \
- {dl6amain.c} "dl6a2" "dl6b.out" ] \
- [list "Run dl6a3 with -Bsymbolic and dlopen on libdl6a.so" \
- "-Wl,--no-as-needed,-Bsymbolic $extralibs" "" \
- {dl6amain.c} "dl6a3" "dl6b.out" ] \
- [list "Run dl6a4 with -Bsymbolic --dynamic-list-data and dlopen on libdl6a.so" \
- "-Wl,--no-as-needed,-Bsymbolic,--dynamic-list-data $extralibs" "" \
- {dl6amain.c} "dl6a4" "dl6a.out" ] \
- [list "Run dl6a5 with -Bsymbolic-functions --dynamic-list-cpp-new and dlopen on libdl6a.so" \
- "-Wl,--no-as-needed,-Bsymbolic-functions,--dynamic-list-cpp-new $extralibs" "" \
- {dl6amain.c} "dl6a5" "dl6b.out" ] \
- [list "Run dl6a6 with --dynamic-list-cpp-new -Bsymbolic-functions and dlopen on libdl6a.so" \
- "-Wl,--no-as-needed,--dynamic-list-cpp-new,-Bsymbolic-functions $extralibs" "" \
- {dl6amain.c} "dl6a6" "dl6b.out" ] \
- [list "Run dl6a7 with --dynamic-list-data -Bsymbolic and dlopen on libdl6a.so" \
- "-Wl,--no-as-needed,--dynamic-list-data,-Bsymbolic $extralibs" "" \
- {dl6amain.c} "dl6a7" "dl6a.out" ] \
- [list "Run dl6b1 with --dynamic-list-data and dlopen on libdl6b.so" \
- "-Wl,--no-as-needed,--dynamic-list-data $extralibs" "" \
- {dl6bmain.c} "dl6b1" "dl6a.out" ] \
- [list "Run dl6b2 with dlopen on libdl6b.so" \
- "-Wl,--no-as-needed $extralibs" "" \
- {dl6bmain.c} "dl6b2" "dl6b.out" ] \
- [list "Run dl6c1 with --dynamic-list-data and dlopen on libdl6c.so" \
- "-Wl,--no-as-needed,--dynamic-list-data $extralibs" "" \
- {dl6cmain.c} "dl6c1" "dl6b.out" ] \
- [list "Run dl6d1 with --dynamic-list-data and dlopen on libdl6d.so" \
- "-Wl,--no-as-needed,--dynamic-list-data $extralibs" "" \
- {dl6dmain.c} "dl6d1" "dl6b.out" ] \
[list "Run with libdata1.so" \
"-Wl,--no-as-needed tmpdir/libdata1.so" "" \
{dynbss1.c} "dynbss1" "pass.out" ] \
@@ -486,6 +447,56 @@ set run_tests [list \
# NetBSD ELF systems do not currently support the .*_array sections.
run_ld_link_exec_tests $run_tests "*-*-netbsdelf*"
+# These tests require dlopen support.
+set dlopen_run_tests [list \
+ [list "Run dl1a with --dynamic-list=dl1.list and dlopen on libdl1.so" \
+ "-Wl,--no-as-needed,--dynamic-list=dl1.list $extralibs" "" \
+ {dl1main.c} "dl1a" "dl1.out" ] \
+ [list "Run dl1b with --dynamic-list-data and dlopen on libdl1.so" \
+ "-Wl,--no-as-needed,--dynamic-list-data $extralibs" "" \
+ {dl1main.c} "dl1b" "dl1.out" ] \
+ [list "Run dl6a1 with --dynamic-list-data and dlopen on libdl6a.so" \
+ "-Wl,--no-as-needed,--dynamic-list-data $extralibs" "" \
+ {dl6amain.c} "dl6a1" "dl6a.out" ] \
+ [list "Run dl6a2 with -Bsymbolic-functions and dlopen on libdl6a.so" \
+ "-Wl,--no-as-needed,-Bsymbolic-functions $extralibs" "" \
+ {dl6amain.c} "dl6a2" "dl6b.out" ] \
+ [list "Run dl6a3 with -Bsymbolic and dlopen on libdl6a.so" \
+ "-Wl,--no-as-needed,-Bsymbolic $extralibs" "" \
+ {dl6amain.c} "dl6a3" "dl6b.out" ] \
+ [list "Run dl6a4 with -Bsymbolic --dynamic-list-data and dlopen on libdl6a.so" \
+ "-Wl,--no-as-needed,-Bsymbolic,--dynamic-list-data $extralibs" "" \
+ {dl6amain.c} "dl6a4" "dl6a.out" ] \
+ [list "Run dl6a5 with -Bsymbolic-functions --dynamic-list-cpp-new and dlopen on libdl6a.so" \
+ "-Wl,--no-as-needed,-Bsymbolic-functions,--dynamic-list-cpp-new $extralibs" "" \
+ {dl6amain.c} "dl6a5" "dl6b.out" ] \
+ [list "Run dl6a6 with --dynamic-list-cpp-new -Bsymbolic-functions and dlopen on libdl6a.so" \
+ "-Wl,--no-as-needed,--dynamic-list-cpp-new,-Bsymbolic-functions $extralibs" "" \
+ {dl6amain.c} "dl6a6" "dl6b.out" ] \
+ [list "Run dl6a7 with --dynamic-list-data -Bsymbolic and dlopen on libdl6a.so" \
+ "-Wl,--no-as-needed,--dynamic-list-data,-Bsymbolic $extralibs" "" \
+ {dl6amain.c} "dl6a7" "dl6a.out" ] \
+ [list "Run dl6b1 with --dynamic-list-data and dlopen on libdl6b.so" \
+ "-Wl,--no-as-needed,--dynamic-list-data $extralibs" "" \
+ {dl6bmain.c} "dl6b1" "dl6a.out" ] \
+ [list "Run dl6b2 with dlopen on libdl6b.so" \
+ "-Wl,--no-as-needed $extralibs" "" \
+ {dl6bmain.c} "dl6b2" "dl6b.out" ] \
+ [list "Run dl6c1 with --dynamic-list-data and dlopen on libdl6c.so" \
+ "-Wl,--no-as-needed,--dynamic-list-data $extralibs" "" \
+ {dl6cmain.c} "dl6c1" "dl6b.out" ] \
+ [list "Run dl6d1 with --dynamic-list-data and dlopen on libdl6d.so" \
+ "-Wl,--no-as-needed,--dynamic-list-data $extralibs" "" \
+ {dl6dmain.c} "dl6d1" "dl6b.out" ] \
+]
+
+# Only run them when libdl is available.
+if [check_libdl_available] {
+ # XFAIL on NetBSD ELF systems as they do not currently support the .*_array
+ # sections.
+ run_ld_link_exec_tests $dlopen_run_tests "*-*-netbsdelf*"
+}
+
# Check --no-add-needed and --no-copy-dt-needed-entries
set testname "--no-add-needed"
set exec_output [run_host_cmd "$CC" "tmpdir/libneeded1c.o -Wl,--no-add-needed,-rpath-link=tmpdir -Ltmpdir -lneeded1a"]
diff --git a/ld/testsuite/lib/ld-lib.exp b/ld/testsuite/lib/ld-lib.exp
index a44358e..61626ec 100644
--- a/ld/testsuite/lib/ld-lib.exp
+++ b/ld/testsuite/lib/ld-lib.exp
@@ -2120,3 +2120,38 @@ proc istarget { target } {
}
return [istarget_ld $target]
}
+
+# Return true if libdl is supported.
+
+proc check_libdl_available { } {
+ global libdl_available_saved
+ global CC
+
+ if {![info exists libdl_available_saved]} {
+ if { [which $CC] == 0 } {
+ set libdl_available_saved 0
+ return 0
+ }
+
+ set basename "tmpdir/dl_avail_test[pid]"
+ set src ${basename}.c
+ set output ${basename}.out
+ set f [open $src "w"]
+ # Sample test file.
+ puts $f "#include <dlfcn.h>"
+ puts $f "int main (void)"
+ puts $f "{"
+ puts $f " dlopen (\"dummy.so\", RTLD_NOW);"
+ puts $f " return 0; "
+ puts $f "}"
+ close $f
+ if [is_remote host] {
+ set src [remote_download host $src]
+ }
+ set libdl_available_saved [run_host_cmd_yesno "$CC" "$src -o $output -ldl"]
+ remote_file host delete $src
+ remote_file host delete $output
+ file delete $src
+ }
+ return $libdl_available_saved
+}