PR27311, ld.bfd (symbol from plugin): undefined reference

Alan Modra amodra@gmail.com
Wed Feb 3 02:38:53 GMT 2021


On Tue, Feb 02, 2021 at 08:28:46PM +1030, Alan Modra wrote:
> A default versioned symbol definition in a shared library is
> overridden by an unversioned definition in a regular object file, and
> thus should not be reason to make an as-needed library needed.

Eh well, that one introduced a regression with the pr16467 testcases
if you happen to be using a compiler that defaults to --as-needed.

bfd/
	PR 27311
	* elflink.c (_bfd_elf_add_default_symbol): Clear override when
	undecorated symbol will have a different version.
ld/
	* testsuite/ld-ifunc/ifunc.exp (libpr16467b.so, libpr16467bn.so):
	Link with --as-needed.

diff --git a/bfd/elflink.c b/bfd/elflink.c
index 7ac38cac691..5af32ef0a81 100644
--- a/bfd/elflink.c
+++ b/bfd/elflink.c
@@ -1946,12 +1946,16 @@ _bfd_elf_add_default_symbol (bfd *abfd,
 	  if (hi->verinfo.vertree != NULL && hide)
 	    {
 	      (*bed->elf_backend_hide_symbol) (info, hi, TRUE);
+	      *override = FALSE;
 	      goto nondefault;
 	    }
 	}
       if (hi->verinfo.vertree != NULL
 	  && strcmp (p + 1 + (p[1] == '@'), hi->verinfo.vertree->name) != 0)
-	goto nondefault;
+	{
+	  *override = FALSE;
+	  goto nondefault;
+	}
     }
 
   if (!*override)
diff --git a/ld/testsuite/ld-ifunc/ifunc.exp b/ld/testsuite/ld-ifunc/ifunc.exp
index 9d3ace65216..45b47d7d6a8 100644
--- a/ld/testsuite/ld-ifunc/ifunc.exp
+++ b/ld/testsuite/ld-ifunc/ifunc.exp
@@ -397,7 +397,7 @@ run_cc_link_tests [list \
     ] \
     [list \
 	"Build libpr16467b.so" \
-	"-shared tmpdir/pr16467b.o tmpdir/libpr16467a.so \
+	"-shared -Wl,--as-needed tmpdir/pr16467b.o tmpdir/libpr16467a.so \
 	 -Wl,--version-script=pr16467b.map" \
 	"-fPIC" \
 	{ dummy.c } \
@@ -422,7 +422,7 @@ run_cc_link_tests [list \
     ] \
     [list \
 	"Build libpr16467bn.so" \
-	"-shared tmpdir/pr16467b.o tmpdir/libpr16467an.so \
+	"-shared -Wl,--as-needed tmpdir/pr16467b.o tmpdir/libpr16467an.so \
 	 -Wl,--version-script=pr16467b.map" \
 	"-fPIC" \
 	{ dummy.c } \

-- 
Alan Modra
Australia Development Lab, IBM


More information about the Binutils mailing list