summaryrefslogtreecommitdiff
path: root/ld/testsuite/ld-gc
diff options
context:
space:
mode:
authorH.J. Lu <hjl.tools@gmail.com>2010-01-26 13:21:35 +0000
committerH.J. Lu <hjl.tools@gmail.com>2010-01-26 13:21:35 +0000
commit9d0a14244a702b4e285513b8378ab1883441a425 (patch)
tree7bd098fec45adcb7e62f756b7dd49712c6a007dd /ld/testsuite/ld-gc
parente10a4d0a71f95397fad48d8ca05cf774a1cc2d11 (diff)
downloadbinutils-redhat-9d0a14244a702b4e285513b8378ab1883441a425.tar.gz
Properly check undefined symbols when gc_sections is active.
bfd/ 2010-01-26 Alan Modra <amodra@gmail.com> H.J. Lu <hongjiu.lu@intel.com> PR ld/11218 * elflink.c (elf_link_output_extsym): Do not ignore undefined symbols with ref_regular set when gc_sections is active. ld/testsuite/ 2010-01-26 H.J. Lu <hongjiu.lu@intel.com> PR ld/11218 * ld-gc/dummy.s: New. * ld-gc/pr11218-1.c: Likewise. * ld-gc/pr11218-2.c: Likewise. * ld-gc/pr11218.d: Likewise.
Diffstat (limited to 'ld/testsuite/ld-gc')
-rw-r--r--ld/testsuite/ld-gc/dummy.s1
-rw-r--r--ld/testsuite/ld-gc/gc.exp8
-rw-r--r--ld/testsuite/ld-gc/pr11218-1.c5
-rw-r--r--ld/testsuite/ld-gc/pr11218-2.c13
-rw-r--r--ld/testsuite/ld-gc/pr11218.d5
5 files changed, 32 insertions, 0 deletions
diff --git a/ld/testsuite/ld-gc/dummy.s b/ld/testsuite/ld-gc/dummy.s
new file mode 100644
index 0000000000..403f98000d
--- /dev/null
+++ b/ld/testsuite/ld-gc/dummy.s
@@ -0,0 +1 @@
+# Dummy
diff --git a/ld/testsuite/ld-gc/gc.exp b/ld/testsuite/ld-gc/gc.exp
index c271a3d254..700544289c 100644
--- a/ld/testsuite/ld-gc/gc.exp
+++ b/ld/testsuite/ld-gc/gc.exp
@@ -92,3 +92,11 @@ test_gc "Check --gc-section/-r/-u" "gcrel" $ld "-r --gc-sections -u used_func"
run_dump_test "noent"
run_dump_test "abi-note"
run_dump_test "start"
+if { [is_remote host] || [which $CC] != 0 } {
+ if { [istarget "*-*-linux*"] } {
+ ld_compile "$CC -fPIC $CFLAGS $cflags" $srcdir/$subdir/pr11218-1.c tmpdir/pr11218-1.o
+ ld_simple_link $ld tmpdir/pr11218-1.so "-shared tmpdir/pr11218-1.o"
+ ld_compile "$CC -c $CFLAGS $cflags" $srcdir/$subdir/pr11218-2.c tmpdir/pr11218-2.o
+ run_dump_test "pr11218"
+ }
+}
diff --git a/ld/testsuite/ld-gc/pr11218-1.c b/ld/testsuite/ld-gc/pr11218-1.c
new file mode 100644
index 0000000000..9cc79f019f
--- /dev/null
+++ b/ld/testsuite/ld-gc/pr11218-1.c
@@ -0,0 +1,5 @@
+extern void unresolved_detected_at_runtime_not_at_linktime(void);
+void foo_in_so(void)
+{
+ unresolved_detected_at_runtime_not_at_linktime();
+}
diff --git a/ld/testsuite/ld-gc/pr11218-2.c b/ld/testsuite/ld-gc/pr11218-2.c
new file mode 100644
index 0000000000..2515bc6013
--- /dev/null
+++ b/ld/testsuite/ld-gc/pr11218-2.c
@@ -0,0 +1,13 @@
+extern void foo_in_so(void);
+
+void call_unresolved(void)
+{
+ unresolved_detected_at_runtime_not_at_linktime();
+}
+
+int main(int argc, char *argv[])
+{
+ foo_in_so();
+
+ return 0;
+}
diff --git a/ld/testsuite/ld-gc/pr11218.d b/ld/testsuite/ld-gc/pr11218.d
new file mode 100644
index 0000000000..27019a801f
--- /dev/null
+++ b/ld/testsuite/ld-gc/pr11218.d
@@ -0,0 +1,5 @@
+# name: --gc-sections with shared library
+# source: dummy.s
+# ld: --gc-sections -e main tmpdir/pr11218-2.o tmpdir/pr11218-1.so
+# target: *-*-linux*
+# error: undefined reference to `unresolved_detected_at_runtime_not_at_linktime'