* symtab.cc (Symbol_table::add_from_relobj): Don't set the version
authorIan Lance Taylor <ian@airs.com>
Thu, 27 Mar 2008 06:11:57 +0000 (06:11 +0000)
committerIan Lance Taylor <ian@airs.com>
Thu, 27 Mar 2008 06:11:57 +0000 (06:11 +0000)
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.

gold/ChangeLog
gold/Makefile.in
gold/symtab.cc
gold/testsuite/Makefile.am
gold/testsuite/Makefile.in
gold/testsuite/ver_test_5.cc [new file with mode: 0644]
gold/testsuite/ver_test_5.script [new file with mode: 0644]
gold/testsuite/ver_test_5.sh [new file with mode: 0755]

index 0e207acaaeae351aa13fb042b3ba5d380fccdb97..b2c076d732d8b49f737e6f1e152f3ce055c52ffe 100644 (file)
@@ -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.
index 08f87eb5035c541571b8d5037d80ffae30f82743..fdc0b164d65e9f26961b6bf74f294598b2ddae68 100644 (file)
@@ -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 \
index 5ad5ae83c717685914c68f186b16eaa5339fe714..c7170a38fbac5dee2881507d9866a8c9198d0bb9 100644 (file)
@@ -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.
index 191618a670f6b0f70c43927b97b8a21c97427063..e529629544d21aa385a6f053ee1236209033ad2e 100644 (file)
@@ -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
index bf385041755067dfc17061b3a3eb6c46c265118a..cd81bcde0ddc396d81ab9909f34a98242fe41505 100644 (file)
@@ -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 (file)
index 0000000..cffeae6
--- /dev/null
@@ -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 (file)
index 0000000..028cdd6
--- /dev/null
@@ -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 (executable)
index 0000000..2eacb45
--- /dev/null
@@ -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
This page took 0.037586 seconds and 4 git commands to generate.