summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIan Lance Taylor <ian@airs.com>2008-03-29 07:19:02 +0000
committerIan Lance Taylor <ian@airs.com>2008-03-29 07:19:02 +0000
commit7b2620a9d274c224e9b16ba346a6d444030ac01a (patch)
tree8c4b08872a591577a19b400a5ec1089b98186734
parenta6cf69f4657926d532e83f757a9be3a8906d8751 (diff)
downloadbinutils-redhat-7b2620a9d274c224e9b16ba346a6d444030ac01a.tar.gz
* symtab.cc (Symbol_table::add_from_object): If we don't use the
new symbol when resolving, don't call set_is_default. * testsuite/ver_test_7.cc: New file. * testsuite/ver_test_7.sh: New file. * testsuite/Makefile.am (ver_test_7.so): New target. (ver_test_7.o): New target. (check_SCRIPTS): Add ver_test_7.sh. (check_DATA): Add ver_test_7.syms. (ver_test_7.syms): New target.
-rw-r--r--gold/ChangeLog12
-rw-r--r--gold/symtab.cc2
-rw-r--r--gold/testsuite/Makefile.am13
-rw-r--r--gold/testsuite/Makefile.in13
-rw-r--r--gold/testsuite/ver_test_7.cc37
-rwxr-xr-xgold/testsuite/ver_test_7.sh44
6 files changed, 119 insertions, 2 deletions
diff --git a/gold/ChangeLog b/gold/ChangeLog
index a43fa21fb7..bdbac5d938 100644
--- a/gold/ChangeLog
+++ b/gold/ChangeLog
@@ -1,3 +1,15 @@
+2008-03-29 Ian Lance Taylor <iant@google.com>
+
+ * symtab.cc (Symbol_table::add_from_object): If we don't use the
+ new symbol when resolving, don't call set_is_default.
+ * testsuite/ver_test_7.cc: New file.
+ * testsuite/ver_test_7.sh: New file.
+ * testsuite/Makefile.am (ver_test_7.so): New target.
+ (ver_test_7.o): New target.
+ (check_SCRIPTS): Add ver_test_7.sh.
+ (check_DATA): Add ver_test_7.syms.
+ (ver_test_7.syms): New target.
+
2008-03-28 Ian Lance Taylor <iant@google.com>
* layout.cc (Layout::layout): If we see an input section with a
diff --git a/gold/symtab.cc b/gold/symtab.cc
index a2ae22f926..08e5f9265f 100644
--- a/gold/symtab.cc
+++ b/gold/symtab.cc
@@ -577,6 +577,8 @@ Symbol_table::add_from_object(Object* object,
this->make_forwarder(insdef.first->second, ret);
insdef.first->second = ret;
}
+ else
+ def = false;
}
}
else
diff --git a/gold/testsuite/Makefile.am b/gold/testsuite/Makefile.am
index 58ed906e0a..93aa0f01b7 100644
--- a/gold/testsuite/Makefile.am
+++ b/gold/testsuite/Makefile.am
@@ -582,6 +582,19 @@ ver_test_6_DEPENDENCIES = gcctestdir/ld ver_test_2.so
ver_test_6_LDFLAGS = -Bgcctestdir/ -Wl,-R,.
ver_test_6_LDADD = ver_test_2.so
+if READELF
+
+ver_test_7.so: ver_test_4.o $(srcdir)/ver_test_4.script ver_test_7.o gcctestdir/ld
+ $(CXXLINK) -Bgcctestdir/ -shared -Wl,--version-script,$(srcdir)/ver_test_4.script ver_test_4.o ver_test_7.o
+ver_test_7.o: ver_test_7.cc
+ $(CXXCOMPILE) -c -fpic -o $@ $<
+check_SCRIPTS += ver_test_7.sh
+check_DATA += ver_test_7.syms
+ver_test_7.syms: ver_test_7.so
+ readelf -s $< >$@ 2>/dev/null
+
+endif
+
check_PROGRAMS += script_test_1
script_test_1_SOURCES = script_test_1.cc
script_test_1_DEPENDENCIES = gcctestdir/ld script_test_1.t
diff --git a/gold/testsuite/Makefile.in b/gold/testsuite/Makefile.in
index 0e68b9ac9c..9b88707d4b 100644
--- a/gold/testsuite/Makefile.in
+++ b/gold/testsuite/Makefile.in
@@ -201,10 +201,12 @@ check_PROGRAMS = object_unittest$(EXEEXT) binary_unittest$(EXEEXT) \
@GCC_TRUE@@NATIVE_LINKER_TRUE@ justsyms binary_test
@GCC_TRUE@@NATIVE_LINKER_TRUE@@READELF_TRUE@am__append_12 = \
@GCC_TRUE@@NATIVE_LINKER_TRUE@@READELF_TRUE@ ver_test_2.sh \
-@GCC_TRUE@@NATIVE_LINKER_TRUE@@READELF_TRUE@ ver_test_5.sh
+@GCC_TRUE@@NATIVE_LINKER_TRUE@@READELF_TRUE@ ver_test_5.sh \
+@GCC_TRUE@@NATIVE_LINKER_TRUE@@READELF_TRUE@ ver_test_7.sh
@GCC_TRUE@@NATIVE_LINKER_TRUE@@READELF_TRUE@am__append_13 = \
@GCC_TRUE@@NATIVE_LINKER_TRUE@@READELF_TRUE@ ver_test_2.syms \
-@GCC_TRUE@@NATIVE_LINKER_TRUE@@READELF_TRUE@ ver_test_5.syms
+@GCC_TRUE@@NATIVE_LINKER_TRUE@@READELF_TRUE@ ver_test_5.syms \
+@GCC_TRUE@@NATIVE_LINKER_TRUE@@READELF_TRUE@ ver_test_7.syms
@GCC_FALSE@script_test_1_DEPENDENCIES = libgoldtest.a ../libgold.a \
@GCC_FALSE@ ../../libiberty/libiberty.a $(am__DEPENDENCIES_1) \
@GCC_FALSE@ $(am__DEPENDENCIES_1)
@@ -1843,6 +1845,13 @@ uninstall-am: uninstall-info-am
@GCC_TRUE@@NATIVE_LINKER_TRUE@@READELF_TRUE@ $(CXXCOMPILE) -c -fpic -o $@ $<
@GCC_TRUE@@NATIVE_LINKER_TRUE@@READELF_TRUE@ver_test_5.syms: ver_test_5.so
@GCC_TRUE@@NATIVE_LINKER_TRUE@@READELF_TRUE@ readelf -s $< >$@ 2>/dev/null
+
+@GCC_TRUE@@NATIVE_LINKER_TRUE@@READELF_TRUE@ver_test_7.so: ver_test_4.o $(srcdir)/ver_test_4.script ver_test_7.o gcctestdir/ld
+@GCC_TRUE@@NATIVE_LINKER_TRUE@@READELF_TRUE@ $(CXXLINK) -Bgcctestdir/ -shared -Wl,--version-script,$(srcdir)/ver_test_4.script ver_test_4.o ver_test_7.o
+@GCC_TRUE@@NATIVE_LINKER_TRUE@@READELF_TRUE@ver_test_7.o: ver_test_7.cc
+@GCC_TRUE@@NATIVE_LINKER_TRUE@@READELF_TRUE@ $(CXXCOMPILE) -c -fpic -o $@ $<
+@GCC_TRUE@@NATIVE_LINKER_TRUE@@READELF_TRUE@ver_test_7.syms: ver_test_7.so
+@GCC_TRUE@@NATIVE_LINKER_TRUE@@READELF_TRUE@ readelf -s $< >$@ 2>/dev/null
@GCC_TRUE@@NATIVE_LINKER_TRUE@justsyms_2.o: justsyms_2.cc
@GCC_TRUE@@NATIVE_LINKER_TRUE@ $(CXXCOMPILE) -c -o $@ $<
@GCC_TRUE@@NATIVE_LINKER_TRUE@justsyms_2r.o: justsyms_2.o gcctestdir/ld
diff --git a/gold/testsuite/ver_test_7.cc b/gold/testsuite/ver_test_7.cc
new file mode 100644
index 0000000000..d602a48fd0
--- /dev/null
+++ b/gold/testsuite/ver_test_7.cc
@@ -0,0 +1,37 @@
+// ver_test_7.cc -- test weak duplicate symbol with version
+
+// Copyright 2008 Free Software Foundation, Inc.
+// Written by Ian Lance Taylor <iant@google.com>
+
+// This file is part of gold.
+
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; either version 3 of the License, or
+// (at your option) any later version.
+
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
+// MA 02110-1301, USA.
+
+#include "ver_test.h"
+
+// This tests having a weak symbol which matches an entry in the
+// version script following a hidden definition from .symver. There
+// was a bug in which the weak symbol would cause the earlier symbol
+// to become globally visible when it should have been hidden.
+
+extern "C" int t2_2() __attribute__ ((weak));
+
+extern "C"
+int
+t2_2()
+{
+ return 23;
+}
diff --git a/gold/testsuite/ver_test_7.sh b/gold/testsuite/ver_test_7.sh
new file mode 100755
index 0000000000..04d35fc9e9
--- /dev/null
+++ b/gold/testsuite/ver_test_7.sh
@@ -0,0 +1,44 @@
+#!/bin/sh
+
+# ver_test_7.sh -- test that symbol has correct version
+
+# Copyright 2008 Free Software Foundation, Inc.
+# Written by Ian Lance Taylor <iant@google.com>.
+
+# This file is part of gold.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
+# MA 02110-1301, USA.
+
+# This file goes with ver_test_4.script and ver_test_5.script. The
+# symbol t2_2 is not defined when ver_test_5.script is used.
+
+check()
+{
+ if ! grep -q "$2" "$1"
+ then
+ echo "Did not find expected symbol in $1:"
+ echo " $2"
+ echo ""
+ echo "Actual output below:"
+ cat "$1"
+ exit 1
+ fi
+}
+
+check ver_test_7.syms "t2_2@@VER2"
+check ver_test_7.syms "t2_2@VER1"
+
+exit 0