summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIan Lance Taylor <ian@airs.com>2008-03-27 06:11:57 +0000
committerIan Lance Taylor <ian@airs.com>2008-03-27 06:11:57 +0000
commite667bbe5e13fd1514f020af27aa9e035630fe206 (patch)
treec1b97c5565e26b503e40f0635ddc84d7d5c0595d
parent0150d95b4630165c9d882e501b4ff7f1927485a5 (diff)
downloadbinutils-redhat-e667bbe5e13fd1514f020af27aa9e035630fe206.tar.gz
* symtab.cc (Symbol_table::add_from_relobj): Don't set the version
of an undefined symbol from a version script. * testsuite/Makefile.am (ver_test_5.so): New target. (ver_test_5.o): New target. (check_SCRIPTS): Add ver_test_5.sh. (check_DATA): Add ver_test_5.syms. (ver_test_5.syms): New target. * testsuite/ver_test_5.cc: New file. * testsuite/ver_test_5.script: New file. * testsuite/ver_test_5.sh: New file. * Makefile.in, testsuite/Makefile.in: Rebuild.
-rw-r--r--gold/ChangeLog12
-rw-r--r--gold/Makefile.in4
-rw-r--r--gold/symtab.cc6
-rw-r--r--gold/testsuite/Makefile.am13
-rw-r--r--gold/testsuite/Makefile.in15
-rw-r--r--gold/testsuite/ver_test_5.cc29
-rw-r--r--gold/testsuite/ver_test_5.script31
-rwxr-xr-xgold/testsuite/ver_test_5.sh44
8 files changed, 149 insertions, 5 deletions
diff --git a/gold/ChangeLog b/gold/ChangeLog
index 0e207acaae..b2c076d732 100644
--- a/gold/ChangeLog
+++ b/gold/ChangeLog
@@ -1,5 +1,17 @@
2008-03-26 Ian Lance Taylor <iant@google.com>
+ * symtab.cc (Symbol_table::add_from_relobj): Don't set the version
+ of an undefined symbol from a version script.
+ * testsuite/Makefile.am (ver_test_5.so): New target.
+ (ver_test_5.o): New target.
+ (check_SCRIPTS): Add ver_test_5.sh.
+ (check_DATA): Add ver_test_5.syms.
+ (ver_test_5.syms): New target.
+ * testsuite/ver_test_5.cc: New file.
+ * testsuite/ver_test_5.script: New file.
+ * testsuite/ver_test_5.sh: New file.
+ * Makefile.in, testsuite/Makefile.in: Rebuild.
+
PR gold/5986
Fix problems building gold with gcc 4.3.0.
* gold.h (TEMPLATE_ATTRIBUTE_PRINTF_4): Define.
diff --git a/gold/Makefile.in b/gold/Makefile.in
index 08f87eb503..fdc0b164d6 100644
--- a/gold/Makefile.in
+++ b/gold/Makefile.in
@@ -49,8 +49,8 @@ DIST_COMMON = README $(am__configure_deps) $(srcdir)/../config.guess \
$(srcdir)/../install-sh $(srcdir)/../missing \
$(srcdir)/../mkinstalldirs $(srcdir)/Makefile.am \
$(srcdir)/Makefile.in $(srcdir)/config.in \
- $(top_srcdir)/configure $(top_srcdir)/po/Make-in pread.c \
- yyscript.c yyscript.h
+ $(top_srcdir)/configure $(top_srcdir)/po/Make-in ChangeLog \
+ NEWS pread.c yyscript.c yyscript.h
subdir = .
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/../config/depstand.m4 \
diff --git a/gold/symtab.cc b/gold/symtab.cc
index 5ad5ae83c7..c7170a38fb 100644
--- a/gold/symtab.cc
+++ b/gold/symtab.cc
@@ -719,7 +719,11 @@ Symbol_table::add_from_relobj(
++ver;
}
}
- else if (!version_script_.empty())
+ // We don't want to assign a version to an undefined symbol,
+ // even if it is listed in the version script. FIXME: What
+ // about a common symbol?
+ else if (!version_script_.empty()
+ && psym->get_st_shndx() != elfcpp::SHN_UNDEF)
{
// The symbol name did not have a version, but
// the version script may assign a version anyway.
diff --git a/gold/testsuite/Makefile.am b/gold/testsuite/Makefile.am
index 191618a670..e529629544 100644
--- a/gold/testsuite/Makefile.am
+++ b/gold/testsuite/Makefile.am
@@ -549,6 +549,19 @@ ver_test_2.syms: ver_test_2
endif
+if READELF
+
+ver_test_5.so: ver_test_5.o $(srcdir)/ver_test_5.script ver_test_4.so gcctestdir/ld
+ $(CXXLINK) -Bgcctestdir/ -shared -Wl,--version-script,$(srcdir)/ver_test_5.script ver_test_5.o ver_test_4.so
+ver_test_5.o: ver_test_5.cc
+ $(CXXCOMPILE) -c -fpic -o $@ $<
+check_SCRIPTS += ver_test_5.sh
+check_DATA += ver_test_5.syms
+ver_test_5.syms: ver_test_5.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 bf38504175..cd81bcde0d 100644
--- a/gold/testsuite/Makefile.in
+++ b/gold/testsuite/Makefile.in
@@ -178,8 +178,12 @@ check_PROGRAMS = object_unittest$(EXEEXT) binary_unittest$(EXEEXT) \
@GCC_TRUE@@NATIVE_LINKER_TRUE@ ver_test ver_test_2 \
@GCC_TRUE@@NATIVE_LINKER_TRUE@ script_test_1 script_test_2 \
@GCC_TRUE@@NATIVE_LINKER_TRUE@ justsyms binary_test
-@GCC_TRUE@@NATIVE_LINKER_TRUE@@READELF_TRUE@am__append_11 = ver_test_2.sh
-@GCC_TRUE@@NATIVE_LINKER_TRUE@@READELF_TRUE@am__append_12 = ver_test_2.syms
+@GCC_TRUE@@NATIVE_LINKER_TRUE@@READELF_TRUE@am__append_11 = \
+@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@am__append_12 = \
+@GCC_TRUE@@NATIVE_LINKER_TRUE@@READELF_TRUE@ ver_test_2.syms \
+@GCC_TRUE@@NATIVE_LINKER_TRUE@@READELF_TRUE@ ver_test_5.syms
@GCC_FALSE@script_test_1_DEPENDENCIES = libgoldtest.a ../libgold.a \
@GCC_FALSE@ ../../libiberty/libiberty.a $(am__DEPENDENCIES_1) \
@GCC_FALSE@ $(am__DEPENDENCIES_1)
@@ -1767,6 +1771,13 @@ uninstall-am: uninstall-info-am
@GCC_TRUE@@NATIVE_LINKER_TRUE@ $(CXXCOMPILE) -c -fpic -o $@ $<
@GCC_TRUE@@NATIVE_LINKER_TRUE@@READELF_TRUE@ver_test_2.syms: ver_test_2
@GCC_TRUE@@NATIVE_LINKER_TRUE@@READELF_TRUE@ readelf -s $< >$@ 2>/dev/null
+
+@GCC_TRUE@@NATIVE_LINKER_TRUE@@READELF_TRUE@ver_test_5.so: ver_test_5.o $(srcdir)/ver_test_5.script ver_test_4.so gcctestdir/ld
+@GCC_TRUE@@NATIVE_LINKER_TRUE@@READELF_TRUE@ $(CXXLINK) -Bgcctestdir/ -shared -Wl,--version-script,$(srcdir)/ver_test_5.script ver_test_5.o ver_test_4.so
+@GCC_TRUE@@NATIVE_LINKER_TRUE@@READELF_TRUE@ver_test_5.o: ver_test_5.cc
+@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@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_5.cc b/gold/testsuite/ver_test_5.cc
new file mode 100644
index 0000000000..cffeae649b
--- /dev/null
+++ b/gold/testsuite/ver_test_5.cc
@@ -0,0 +1,29 @@
+// ver_test_5.cc -- a test case for gold
+
+// 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"
+
+int
+t3_2()
+{
+ return t2_2();
+}
diff --git a/gold/testsuite/ver_test_5.script b/gold/testsuite/ver_test_5.script
new file mode 100644
index 0000000000..028cdd62b6
--- /dev/null
+++ b/gold/testsuite/ver_test_5.script
@@ -0,0 +1,31 @@
+## ver_test_5.script -- a test case for gold
+
+## 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 tests that we don't break when assigning a version to an
+# undefined symbol. This is used with ver_test_2.cc, which defines
+# t3_2 but only refers to t2_2.
+
+VER5 {
+ global:
+ t2_2;
+ t3_2;
+};
diff --git a/gold/testsuite/ver_test_5.sh b/gold/testsuite/ver_test_5.sh
new file mode 100755
index 0000000000..2eacb455ee
--- /dev/null
+++ b/gold/testsuite/ver_test_5.sh
@@ -0,0 +1,44 @@
+#!/bin/sh
+
+# ver_test_5.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_5.syms "t3_2@@VER5"
+check ver_test_5.syms "t2_2@VER2"
+
+exit 0