From fd121c5c45bd2652a78c62812737874e36259e2a Mon Sep 17 00:00:00 2001 From: Jiong Wang Date: Wed, 1 Feb 2017 16:44:40 +0000 Subject: [PATCH] [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*. --- ld/ChangeLog | 9 ++++ ld/testsuite/ld-elf/shared.exp | 89 +++++++++++++++++++--------------- ld/testsuite/lib/ld-lib.exp | 35 +++++++++++++ 3 files changed, 94 insertions(+), 39 deletions(-) diff --git a/ld/ChangeLog b/ld/ChangeLog index 6b0484f7d5..1ce8439e86 100644 --- a/ld/ChangeLog +++ b/ld/ChangeLog @@ -1,3 +1,12 @@ +2017-02-02 Jiong Wang + + * 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*. + 2017-02-01 Maciej W. Rozycki * testsuite/ld-mips-elf/vxworks-forced-local-1.d: Correct the diff --git a/ld/testsuite/ld-elf/shared.exp b/ld/testsuite/ld-elf/shared.exp index eea9453d0e..29462629fa 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 a44358e0aa..61626ec579 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 " + 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 +} -- 2.34.1