* symtab.cc (Symbol_table::add_from_object): If we don't use the
authorIan Lance Taylor <ian@airs.com>
Sat, 29 Mar 2008 07:19:02 +0000 (07:19 +0000)
committerIan Lance Taylor <ian@airs.com>
Sat, 29 Mar 2008 07:19:02 +0000 (07:19 +0000)
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.

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

index a43fa21..bdbac5d 100644 (file)
@@ -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
index a2ae22f..08e5f92 100644 (file)
@@ -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
index 58ed906..93aa0f0 100644 (file)
@@ -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
index 0e68b9a..9b88707 100644 (file)
@@ -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 (file)
index 0000000..d602a48
--- /dev/null
@@ -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 (executable)
index 0000000..04d35fc
--- /dev/null
@@ -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