# - the shared library symbols have been swept in section garbage collection.
# Verify that the symbols are global rather than local and that a version
# script adjusts them accordingly.
+# Also verify that a version definition supplied by an object rather than
+# a version script and forcibly exported is unaffected by section GC.
if { [check_gc_sections_available] } {
run_ld_link_tests [list \
[list \
"PR ld/20828 dynamic symbols with section GC\
- (auxiliary shared library)" \
- "$LFLAGS -shared --gc-sections -T pr20828.ld" "" "$AFLAGS_PIC" \
- {pr20828.s} \
- {{readelf --dyn-syms pr20828-1.sd}} \
- "libpr20828.so"] \
+ (auxiliary shared library)" \
+ "$LFLAGS -shared --gc-sections -T pr20828.ld" "" "$AFLAGS_PIC" \
+ {pr20828.s} \
+ {{readelf --dyn-syms pr20828-a.sd} \
+ {readelf --dyn-syms pr20828-b.sd}} \
+ "libpr20828.so"] \
[list \
"PR ld/20828 dynamic symbols with section GC (plain)" \
- "$LFLAGS -shared --gc-sections -T pr20828.ld" \
- "tmpdir/libpr20828.so" "$AFLAGS_PIC" \
- {pr20828.s} \
- {{readelf --dyn-syms pr20828-1.sd}} \
- "pr20828-1.so"] \
+ "$LFLAGS -shared --gc-sections -T pr20828.ld" \
+ "tmpdir/libpr20828.so" "$AFLAGS_PIC" \
+ {pr20828.s} \
+ {{readelf --dyn-syms pr20828-a.sd} \
+ {readelf --dyn-syms pr20828-b.sd}} \
+ "pr20828-1.so"] \
[list \
"PR ld/20828 dynamic symbols with section GC (version script)" \
- "$LFLAGS -shared --gc-sections -T pr20828.ld\
- --version-script=pr20828.ver" \
- "tmpdir/libpr20828.so" \
- "$AFLAGS_PIC" \
- {pr20828.s} \
- {{readelf --dyn-syms pr20828-2a.sd} \
- {readelf --dyn-syms pr20828-2b.sd}} \
- "pr20828-2.so"]]
+ "$LFLAGS -shared --gc-sections -T pr20828.ld\
+ --version-script=pr20828.ver" \
+ "tmpdir/libpr20828.so" \
+ "$AFLAGS_PIC" \
+ {pr20828.s} \
+ {{readelf --dyn-syms pr20828-b.sd} \
+ {readelf --dyn-syms pr20828-c.sd}} \
+ "pr20828-2.so"] \
+ [list \
+ "PR ld/20828 dynamic symbols with section GC\
+ (versioned shared library)" \
+ "$LFLAGS -shared --gc-sections -T pr20828.ld\
+ --version-script=pr20828-v.ver" \
+ "" "$AFLAGS_PIC" \
+ {pr20828.s} \
+ {{readelf --dyn-syms pr20828-c.sd} \
+ {readelf --dyn-syms pr20828-d.sd} \
+ {readelf --dyn-syms pr20828-e.sd}} \
+ "libpr20828-v.so"] \
+ [list \
+ "PR ld/20828 dynamic symbols with section GC (versioned)" \
+ "$LFLAGS -shared --gc-sections -T pr20828.ld\
+ --version-script=pr20828-v.ver" \
+ "tmpdir/libpr20828-v.so" \
+ "$AFLAGS_PIC" \
+ {pr20828.s} \
+ {{readelf --dyn-syms pr20828-c.sd} \
+ {readelf --dyn-syms pr20828-d.sd} \
+ {readelf --dyn-syms pr20828-e.sd}} \
+ "pr20828-v.so"] \
+ [list \
+ "PR ld/20828 forcibly exported symbol version without section GC" \
+ "$LFLAGS -e foo -E -T pr20828-v.ld" "" "" \
+ {pr20828-v.s} \
+ {{objdump -p pr20828-v.od}} \
+ "pr20828-v-1"] \
+ [list \
+ "PR ld/20828 forcibly exported symbol version with section GC" \
+ "$LFLAGS -e foo --gc-sections -E -T pr20828-v.ld" "" "" \
+ {pr20828-v.s} \
+ {{objdump -p pr20828-v.od}} \
+ "pr20828-v-2"]]
}
# Check to see if the C compiler works
{begin.c end.c} {} "libbar.so"}
{"Build warn libbar.so"
"-shared" "-fPIC"
- {beginwarn.c end.c} {{readelf {-S --wide} libbarw.rd}} "libbarw.so"
- "c" {^.*\): warning: function foo is deprecated$} }
+ {beginwarn.c end.c}
+ {{readelf {-S --wide} libbarw.rd}
+ {warning "^.*beginwarn.c:7: warning: function foo is deprecated$"}}
+ "libbarw.so" "c"}
{"Build hidden libbar.so"
"-shared" "-fPIC"
{begin.c endhidden.c} {} "libbarh.so"}
[list "Run warn with versioned libfoo.so" \
"-Wl,--no-as-needed tmpdir/beginwarn.o tmpdir/libfoov.so" "" \
{main.c} "warn" "warn.out" \
- "" "c" {^.*\): warning: function foo is deprecated$} ] \
+ "" "c" {^.*beginwarn.c:7: warning: function foo is deprecated$} ] \
[list "Run protected with versioned libfoo.so" \
"-Wl,--no-as-needed tmpdir/begin.o tmpdir/libfoov.so tmpdir/endprotected.o" "" \
{main.c} "protected" "normal.out" ] \
[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" ] \
[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" ] \
# 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"]
"-shared -Wl,--dynamic-list-cpp-typeinfo" "-fPIC"
{dl3.cc} {} "libdl3c.so" "c++"}
{"Build libdnew1a.so with --Bsymbolic-functions --dynamic-list-cpp-new"
- "-shared -Wl,-Bsymbolic-functions,--dynamic-list-cpp-new" "-fPIC"
+ "-shared -Wl,-Bsymbolic-functions,--dynamic-list-cpp-new" "-fPIC -ansi"
{del.cc new.cc} {} "libnew1a.so" "c++"}
{"Build libdnew1b.so with --dynamic-list-data --dynamic-list-cpp-new"
- "-shared -Wl,--dynamic-list-data,--dynamic-list-cpp-new" "-fPIC"
+ "-shared -Wl,--dynamic-list-data,--dynamic-list-cpp-new" "-fPIC -ansi"
{del.cc new.cc} {} "libnew1b.so" "c++"}
}
{dl3main.cc} "dl3c" "dl3a.out" "" "c++"}
{"Run with libnew1a.so"
"-Wl,--no-as-needed tmpdir/libnew1a.so" ""
- {dl5.cc} "dl5a" "dl5.out" "" "c++"}
+ {dl5.cc} "dl5a" "dl5.out" "-ansi" "c++"}
{"Run with libnew1b.so"
"-Wl,--no-as-needed tmpdir/libnew1b.so" ""
- {dl5.cc} "dl5b" "dl5.out" "" "c++"}
+ {dl5.cc} "dl5b" "dl5.out" "-ansi" "c++"}
}
run_cc_link_tests $build_cxx_tests