aboutsummaryrefslogtreecommitdiff
path: root/ld/testsuite
diff options
context:
space:
mode:
authorH.J. Lu <hjl.tools@gmail.com>2012-12-04 17:44:43 +0000
committerH.J. Lu <hjl.tools@gmail.com>2012-12-04 17:44:43 +0000
commit63406f0ab746d10e5e66b6a0604b35f5272e98b4 (patch)
treecc509f5a9a42507a0e7cc4d7b274e1c3943e829f /ld/testsuite
parent56bf0743058aa1fff07b32ba50c1e9bfaf9e2bcc (diff)
downloadgdb-63406f0ab746d10e5e66b6a0604b35f5272e98b4.zip
gdb-63406f0ab746d10e5e66b6a0604b35f5272e98b4.tar.gz
gdb-63406f0ab746d10e5e66b6a0604b35f5272e98b4.tar.bz2
Add tests for --add-needed/--copy-dt-needed-entries
* 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.
Diffstat (limited to 'ld/testsuite')
-rw-r--r--ld/testsuite/ChangeLog12
-rw-r--r--ld/testsuite/ld-elf/needed1.out2
-rw-r--r--ld/testsuite/ld-elf/needed1a.c7
-rw-r--r--ld/testsuite/ld-elf/needed1b.c7
-rw-r--r--ld/testsuite/ld-elf/needed1c.c10
-rw-r--r--ld/testsuite/ld-elf/shared.exp31
6 files changed, 69 insertions, 0 deletions
diff --git a/ld/testsuite/ChangeLog b/ld/testsuite/ChangeLog
index 7234743..6f68d80 100644
--- a/ld/testsuite/ChangeLog
+++ b/ld/testsuite/ChangeLog
@@ -1,3 +1,15 @@
+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.
diff --git a/ld/testsuite/ld-elf/needed1.out b/ld/testsuite/ld-elf/needed1.out
new file mode 100644
index 0000000..2c94e48
--- /dev/null
+++ b/ld/testsuite/ld-elf/needed1.out
@@ -0,0 +1,2 @@
+OK
+OK
diff --git a/ld/testsuite/ld-elf/needed1a.c b/ld/testsuite/ld-elf/needed1a.c
new file mode 100644
index 0000000..8b23ec8
--- /dev/null
+++ b/ld/testsuite/ld-elf/needed1a.c
@@ -0,0 +1,7 @@
+extern void bar (void);
+
+void
+foo (void)
+{
+ bar ();
+}
diff --git a/ld/testsuite/ld-elf/needed1b.c b/ld/testsuite/ld-elf/needed1b.c
new file mode 100644
index 0000000..1b9b393
--- /dev/null
+++ b/ld/testsuite/ld-elf/needed1b.c
@@ -0,0 +1,7 @@
+#include <stdio.h>
+
+void
+bar (void)
+{
+ printf ("OK\n");
+}
diff --git a/ld/testsuite/ld-elf/needed1c.c b/ld/testsuite/ld-elf/needed1c.c
new file mode 100644
index 0000000..e03c380
--- /dev/null
+++ b/ld/testsuite/ld-elf/needed1c.c
@@ -0,0 +1,10 @@
+extern void foo (void);
+extern void bar (void);
+
+int
+main ()
+{
+ foo ();
+ bar ();
+ return 0;
+}
diff --git a/ld/testsuite/ld-elf/shared.exp b/ld/testsuite/ld-elf/shared.exp
index 9b35d53..2e679d9 100644
--- a/ld/testsuite/ld-elf/shared.exp
+++ b/ld/testsuite/ld-elf/shared.exp
@@ -179,6 +179,15 @@ set build_tests {
{"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
@@ -317,11 +326,33 @@ set run_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