From 89d801850ac03d0531f7eef3d6978bec17a30a2d Mon Sep 17 00:00:00 2001 From: "H.J. Lu" Date: Fri, 31 May 2024 21:30:34 -0700 Subject: gold: Properly remove the versioned symbol When the versioned symbol foo is removed from the shared library, the ".symver foo,foo@VER" directive provides binary compatibility for foo@VER. In this case, the unversioned symbol foo should be hidden and shouldn't generate a multiple definition error. PR gold/31830 * resolve.cc (Symbol_table::resolve): Move symbol version handling to ... * symtab.cc (Symbol_table::add_from_object): Here. If the hidden version from .symver is the same as the default version from the unversioned symbol, don't make the unversioned symbol the default versioned symbol. * testsuite/Makefile.am (check_SCRIPTS): Add ver_test_pr31830.sh. (check_DATA): ver_test_pr31830_a.syms and ver_test_pr31830_b.syms. (ver_test_pr31830_a.syms): New. (ver_test_pr31830_b.syms): Likewise. (ver_test_pr31830_a.so): Likewise. (ver_test_pr31830_b.so): Likewise. * testsuite/Makefile.in: Regenerated. * testsuite/ver_test_pr31830.script: New file. * testsuite/ver_test_pr31830.sh: Likewise. * testsuite/ver_test_pr31830_a.c: Likewise. * testsuite/ver_test_pr31830_b.c: Likewise. * testsuite/ver_test_pr31830_lto.c: Likewise. * testsuite/ver_test_pr31830_lto.sh: Likewise. Signed-off-by: H.J. Lu --- gold/testsuite/Makefile.am | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'gold/testsuite/Makefile.am') diff --git a/gold/testsuite/Makefile.am b/gold/testsuite/Makefile.am index 0685e91..2f1348f 100644 --- a/gold/testsuite/Makefile.am +++ b/gold/testsuite/Makefile.am @@ -1963,6 +1963,28 @@ ver_test_pr23409_1.so: gcctestdir/ld ver_test_1.o $(srcdir)/ver_test_pr23409_1.s ver_test_pr23409_2.so: gcctestdir/ld ver_test_1.o $(srcdir)/ver_test_pr23409_2.script gcctestdir/ld -shared -o $@ ver_test_1.o --version-script $(srcdir)/ver_test_pr23409_2.script +check_SCRIPTS += ver_test_pr31830.sh +check_DATA += ver_test_pr31830_a.syms ver_test_pr31830_b.syms +ver_test_pr31830_a.syms: ver_test_pr31830_a.so + $(TEST_READELF) --dyn-syms -W $< >$@ +ver_test_pr31830_b.syms: ver_test_pr31830_b.so + $(TEST_READELF) --dyn-syms -W $< >$@ +ver_test_pr31830_a.so: gcctestdir/ld ver_test_pr31830_a.o ver_test_pr31830_b.o $(srcdir)/ver_test_pr31830.script + gcctestdir/ld -shared -o $@ ver_test_pr31830_a.o ver_test_pr31830_b.o --version-script $(srcdir)/ver_test_pr31830.script +ver_test_pr31830_b.so: gcctestdir/ld ver_test_pr31830_a.o ver_test_pr31830_b.o $(srcdir)/ver_test_pr31830.script + gcctestdir/ld -shared -o $@ ver_test_pr31830_b.o ver_test_pr31830_a.o --version-script $(srcdir)/ver_test_pr31830.script + +check_SCRIPTS += ver_test_pr31830_lto.sh +check_DATA += ver_test_pr31830_lto_a.syms ver_test_pr31830_lto_b.syms +ver_test_pr31830_lto_a.syms: ver_test_pr31830_lto_a.so + $(TEST_READELF) --dyn-syms -W $< >$@ +ver_test_pr31830_lto_a.so: gcctestdir/ld $(srcdir)/ver_test_pr31830_lto.c $(srcdir)/ver_test_pr31830.script + $(LINK) -Bgcctestdir/ -shared -o $@ -O2 -fPIC -flto-partition=max $(srcdir)/ver_test_pr31830_lto.c -Wl,--version-script,$(srcdir)/ver_test_pr31830.script +ver_test_pr31830_lto_b.syms: ver_test_pr31830_lto_b.so + $(TEST_READELF) --dyn-syms -W $< >$@ +ver_test_pr31830_lto_b.so: gcctestdir/ld $(srcdir)/ver_test_pr31830_lto.c $(srcdir)/ver_test_pr31830.script + $(LINK) -Bgcctestdir/ -shared -o $@ -O2 -fPIC -flto-partition=max -flto=2 $(srcdir)/ver_test_pr31830_lto.c -Wl,--version-script,$(srcdir)/ver_test_pr31830.script + check_SCRIPTS += weak_as_needed.sh check_DATA += weak_as_needed.stdout weak_as_needed.stdout: weak_as_needed_a.so -- cgit v1.1