+2012-12-04 H.J. Lu <hongjiu.lu@intel.com>
+
+ * ld-elf/shared.exp (build_tests): Build libneeded1b.so,
+ libneeded1a.so and libneeded1c.o.
+ (run_tests): Test --add-needed and --copy-dt-needed-entries.
+ Add tests for --no-add-needed and --no-copy-dt-needed-entries.
+
+ * ld-elf/needed1.out: New file.
+ * ld-elf/needed1a.c: Likewise.
+ * ld-elf/needed1b.c: Likewise.
+ * ld-elf/needed1c.c: Likewise.
+
2012-12-03 Maciej W. Rozycki <macro@codesourcery.com>
* ld-mips-elf/attr-gnu-4-45.d: Add missing "readelf" keyword.
{"Build libpr14862.so"
"-shared -Wl,--version-script=pr11138-1.map" "-fPIC"
{pr14862-2.c} {} "libpr14862.so"}
+ {"Build libneeded1b.so"
+ "-shared" "-fPIC"
+ {needed1b.c} {} "libneeded1b.so"}
+ {"Build libneeded1a.so"
+ "-shared -Ltmpdir -lneeded1b" "-fPIC"
+ {needed1a.c} {} "libneeded1a.so"}
+ {"Build libneeded1c.o"
+ "-r -nostdlib" ""
+ {needed1c.c} {} "libneeded1c.o"}
}
run_cc_link_tests $build_tests
{"Run with pr14862-1.c libpr14862.so"
"--as-needed tmpdir/libpr14862-1.o tmpdir/libpr14862.so" ""
{dummy.c} "pr14862" "pr14862.out"}
+ {"Link with --add-needed"
+ "tmpdir/libneeded1c.o --add-needed -rpath=tmpdir -Ltmpdir -lneeded1a" ""
+ {dummy.c} "needed1a" "needed1.out"}
+ {"Link with --copy-dt-needed-entries"
+ "tmpdir/libneeded1c.o --copy-dt-needed-entries -rpath=tmpdir -Ltmpdir -lneeded1a" ""
+ {dummy.c} "needed1b" "needed1.out"}
}
# NetBSD ELF systems do not currently support the .*_array sections.
run_ld_link_exec_tests [list "*-*-netbsdelf*"] $run_tests
+# Check --no-add-needed and --no-copy-dt-needed-entries
+set testname "--no-add-needed"
+set exec_output [run_host_cmd "$CC" "$gcc_gas_flag $gcc_ld_flag tmpdir/libneeded1c.o -Wl,--no-add-needed,-rpath-link=tmpdir -Ltmpdir -lneeded1a"]
+if { [ regexp "'bar' is defined in DSO tmpdir/libneeded1b.so" $exec_output ] } {
+ pass $testname
+} {
+ fail $testname
+}
+set testname "--no-copy-dt-needed-entries"
+set exec_output [run_host_cmd "$CC" "$gcc_gas_flag $gcc_ld_flag tmpdir/libneeded1c.o -Wl,--no-copy-dt-needed-entries,-rpath-link=tmpdir -Ltmpdir -lneeded1a"]
+if { [ regexp "'bar' is defined in DSO tmpdir/libneeded1b.so" $exec_output ] } {
+ pass $testname
+} {
+ fail $testname
+}
+
# Check to see if the C++ compiler works
if { [which $CXX] == 0 } {
return