No need to check version if symbol is unreferenced and undefined.
bfd/
PR ld/20306
* elflink.c (elf_link_check_versioned_symbol): Return false
for unreferenced undefined symbol.
ld/testsuite/
* testsuite/ld-gc/gc.exp: Run pr20306 test.
* ld-gc/pr20306.c: New file.
* ld-gc/pr20306.d: Likewise.
+2016-06-28 H.J. Lu <hongjiu.lu@intel.com>
+
+ PR ld/20306
+ * elflink.c (elf_link_check_versioned_symbol): Return false
+ for unreferenced undefined symbol.
+
2016-06-28 Nick Clifton <nickc@redhat.com>
* elf32-bfin.c (bfin_adjust_dynamic_symbol): Fail if a COPY reloc
case bfd_link_hash_undefined:
case bfd_link_hash_undefweak:
abfd = h->root.u.undef.abfd;
- if ((abfd->flags & DYNAMIC) == 0
+ if (abfd == NULL
+ || (abfd->flags & DYNAMIC) == 0
|| (elf_dyn_lib_class (abfd) & DYN_DT_NEEDED) == 0)
return FALSE;
break;
+2016-06-28 H.J. Lu <hongjiu.lu@intel.com>
+
+ * testsuite/ld-gc/gc.exp: Run pr20306 test.
+ * ld-gc/pr20306.c: New file.
+ * ld-gc/pr20306.d: Likewise.
+
2016-06-28 Nick Clifton <nickc@redhat.com>
* testsuite/ld-elf/comm-data.exp: Expect comm-data2 test to fail
ld_compile "$CC $CFLAGS $cflags -O0" $srcdir/$subdir/pr19161-2.c tmpdir/pr19161-2.o
run_dump_test "pr19161"
}
+
+if { [is_elf_format] && [check_shared_lib_support] \
+ && ([is_remote host] || [which $CC] != 0) } {
+ run_cc_link_tests [list \
+ [list \
+ "Build libpr20306.so" \
+ "-shared" \
+ "-fPIC" \
+ {pr20306.c} \
+ {} \
+ "libpr20306.so" \
+ ] \
+ ]
+ run_dump_test "pr20306"
+}
--- /dev/null
+extern void foo();
+void bar() {foo();}
--- /dev/null
+#source: dummy.s
+#ld: -u foo --gc-sections tmpdir/libpr20306.so
+#error: .* generated: undefined reference to `foo'