aboutsummaryrefslogtreecommitdiff
path: root/gold
diff options
context:
space:
mode:
authorIan Lance Taylor <ian@airs.com>2011-07-02 05:30:00 +0000
committerIan Lance Taylor <ian@airs.com>2011-07-02 05:30:00 +0000
commit2113106124ff094741fc3a0edacf118739ce766d (patch)
treefccdcee567edc60e4efddc45993f1d8c8eca416c /gold
parent9e3dc3160bdf3e40e72ae1a174aaf44f7553a269 (diff)
downloadbinutils-2113106124ff094741fc3a0edacf118739ce766d.zip
binutils-2113106124ff094741fc3a0edacf118739ce766d.tar.gz
binutils-2113106124ff094741fc3a0edacf118739ce766d.tar.bz2
PR gold/12525
PR gold/12952 * resolve.cc (Symbol::override_base_with_special): Don't override the version if the overriding symbol has a different name. * dynobj.cc (Versions::add_def): Add dynpool parameter. Change all callers. If we give an error about an undefined version, define the base version if necessary. * dynobj.h (class Versions): Update declaration. * testsuite/weak_alias_test_5.cc: New file. * testsuite/weak_alias_test.script: New file. * testsuite/weak_alias_test_main.cc: Check that versioned_symbol and versioned_alias have the right value, and call t2. * testsuite/Makefile.am (weak_alias_test_DEPENDENCIES): Add weak_alias_test_5.so. (weak_alias_test_LDADD): Likewise. (weak_alias_test_5_pic.o, weak_alias_test_5.so): New targets. * testsuite/Makefile.in: Rebuild.
Diffstat (limited to 'gold')
-rw-r--r--gold/ChangeLog20
-rw-r--r--gold/dynobj.cc14
-rw-r--r--gold/dynobj.h3
-rw-r--r--gold/resolve.cc6
-rw-r--r--gold/testsuite/Makefile.am9
-rw-r--r--gold/testsuite/Makefile.in9
-rw-r--r--gold/testsuite/weak_alias_test.script8
-rw-r--r--gold/testsuite/weak_alias_test_5.cc39
-rw-r--r--gold/testsuite/weak_alias_test_main.cc13
9 files changed, 109 insertions, 12 deletions
diff --git a/gold/ChangeLog b/gold/ChangeLog
index a744cfa..28ade01 100644
--- a/gold/ChangeLog
+++ b/gold/ChangeLog
@@ -1,6 +1,26 @@
2011-07-01 Ian Lance Taylor <iant@google.com>
PR gold/12525
+ PR gold/12952
+ * resolve.cc (Symbol::override_base_with_special): Don't override
+ the version if the overriding symbol has a different name.
+ * dynobj.cc (Versions::add_def): Add dynpool parameter. Change
+ all callers. If we give an error about an undefined version,
+ define the base version if necessary.
+ * dynobj.h (class Versions): Update declaration.
+ * testsuite/weak_alias_test_5.cc: New file.
+ * testsuite/weak_alias_test.script: New file.
+ * testsuite/weak_alias_test_main.cc: Check that versioned_symbol
+ and versioned_alias have the right value, and call t2.
+ * testsuite/Makefile.am (weak_alias_test_DEPENDENCIES): Add
+ weak_alias_test_5.so.
+ (weak_alias_test_LDADD): Likewise.
+ (weak_alias_test_5_pic.o, weak_alias_test_5.so): New targets.
+ * testsuite/Makefile.in: Rebuild.
+
+2011-07-01 Ian Lance Taylor <iant@google.com>
+
+ PR gold/12525
* options.h (class General_options): Support -z notext.
* testsuite/Makefile.am (two_file_shared_1_nonpic.so): Use
-Wl,-z,notext.
diff --git a/gold/dynobj.cc b/gold/dynobj.cc
index 8ddb3f7..4404a35 100644
--- a/gold/dynobj.cc
+++ b/gold/dynobj.cc
@@ -1,6 +1,6 @@
// dynobj.cc -- dynamic object support for gold
-// Copyright 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
+// Copyright 2006, 2007, 2008, 2009, 2010, 2011 Free Software Foundation, Inc.
// Written by Ian Lance Taylor <iant@google.com>.
// This file is part of gold.
@@ -1483,7 +1483,7 @@ Versions::record_version(const Symbol_table* symtab,
if (!sym->is_from_dynobj() && !sym->is_copied_from_dynobj())
{
if (parameters->options().shared())
- this->add_def(sym, version, version_key);
+ this->add_def(dynpool, sym, version, version_key);
}
else
{
@@ -1496,7 +1496,7 @@ Versions::record_version(const Symbol_table* symtab,
// We've found a symbol SYM defined in version VERSION.
void
-Versions::add_def(const Symbol* sym, const char* version,
+Versions::add_def(Stringpool* dynpool, const Symbol* sym, const char* version,
Stringpool::Key version_key)
{
Key k(version_key, 0);
@@ -1520,8 +1520,12 @@ Versions::add_def(const Symbol* sym, const char* version,
// find a definition of a symbol with a version which is not
// in the version script.
if (parameters->options().shared())
- gold_error(_("symbol %s has undefined version %s"),
- sym->demangled_name().c_str(), version);
+ {
+ gold_error(_("symbol %s has undefined version %s"),
+ sym->demangled_name().c_str(), version);
+ if (this->needs_base_version_)
+ this->define_base_version(dynpool);
+ }
else
// We only insert a base version for shared library.
gold_assert(!this->needs_base_version_);
diff --git a/gold/dynobj.h b/gold/dynobj.h
index 1f3243f..186b67c 100644
--- a/gold/dynobj.h
+++ b/gold/dynobj.h
@@ -599,7 +599,8 @@ class Versions
// Handle a symbol SYM defined with version VERSION.
void
- add_def(const Symbol* sym, const char* version, Stringpool::Key);
+ add_def(Stringpool*, const Symbol* sym, const char* version,
+ Stringpool::Key);
// Add a reference to version NAME in file FILENAME.
void
diff --git a/gold/resolve.cc b/gold/resolve.cc
index 71d5109..8850a3d 100644
--- a/gold/resolve.cc
+++ b/gold/resolve.cc
@@ -887,7 +887,8 @@ Symbol_table::should_override_with_special(const Symbol* to, Defined defined)
void
Symbol::override_base_with_special(const Symbol* from)
{
- gold_assert(this->name_ == from->name_ || this->has_alias());
+ bool same_name = this->name_ == from->name_;
+ gold_assert(same_name || this->has_alias());
this->source_ = from->source_;
switch (from->source_)
@@ -909,7 +910,8 @@ Symbol::override_base_with_special(const Symbol* from)
break;
}
- this->override_version(from->version_);
+ if (same_name)
+ this->override_version(from->version_);
this->type_ = from->type_;
this->binding_ = from->binding_;
this->override_visibility(from->visibility_);
diff --git a/gold/testsuite/Makefile.am b/gold/testsuite/Makefile.am
index 31b39be..2b90057 100644
--- a/gold/testsuite/Makefile.am
+++ b/gold/testsuite/Makefile.am
@@ -631,11 +631,11 @@ check_PROGRAMS += weak_alias_test
weak_alias_test_SOURCES = weak_alias_test_main.cc
weak_alias_test_DEPENDENCIES = \
gcctestdir/ld weak_alias_test_1.so weak_alias_test_2.so \
- weak_alias_test_3.o weak_alias_test_4.so
+ weak_alias_test_3.o weak_alias_test_4.so weak_alias_test_5.so
weak_alias_test_LDFLAGS = -Bgcctestdir/ -Wl,-R,.
weak_alias_test_LDADD = \
weak_alias_test_1.so weak_alias_test_2.so weak_alias_test_3.o \
- weak_alias_test_4.so
+ weak_alias_test_4.so weak_alias_test_5.so
weak_alias_test_1_pic.o: weak_alias_test_1.cc
$(CXXCOMPILE) -c -fpic -o $@ $<
weak_alias_test_1.so: weak_alias_test_1_pic.o gcctestdir/ld
@@ -650,6 +650,11 @@ weak_alias_test_4_pic.o: weak_alias_test_4.cc
$(CXXCOMPILE) -c -fpic -o $@ $<
weak_alias_test_4.so: weak_alias_test_4_pic.o gcctestdir/ld
$(CXXLINK) -Bgcctestdir/ -shared weak_alias_test_4_pic.o
+weak_alias_test_5_pic.o: weak_alias_test_5.cc
+ $(CXXCOMPILE) -c -fpic -o $@ $<
+weak_alias_test_5.so: weak_alias_test_5_pic.o $(srcdir)/weak_alias_test.script gcctestdir/ld
+ $(CXXLINK) -Bgcctestdir/ -shared weak_alias_test_5_pic.o \
+ -Wl,--version-script,$(srcdir)/weak_alias_test.script
check_SCRIPTS += weak_plt.sh
check_PROGRAMS += weak_plt
diff --git a/gold/testsuite/Makefile.in b/gold/testsuite/Makefile.in
index f48a9b1..2dab4c3 100644
--- a/gold/testsuite/Makefile.in
+++ b/gold/testsuite/Makefile.in
@@ -2077,12 +2077,12 @@ LDADD = libgoldtest.a ../libgold.a ../../libiberty/libiberty.a $(LIBINTL) \
@GCC_TRUE@@NATIVE_LINKER_TRUE@weak_alias_test_SOURCES = weak_alias_test_main.cc
@GCC_TRUE@@NATIVE_LINKER_TRUE@weak_alias_test_DEPENDENCIES = \
@GCC_TRUE@@NATIVE_LINKER_TRUE@ gcctestdir/ld weak_alias_test_1.so weak_alias_test_2.so \
-@GCC_TRUE@@NATIVE_LINKER_TRUE@ weak_alias_test_3.o weak_alias_test_4.so
+@GCC_TRUE@@NATIVE_LINKER_TRUE@ weak_alias_test_3.o weak_alias_test_4.so weak_alias_test_5.so
@GCC_TRUE@@NATIVE_LINKER_TRUE@weak_alias_test_LDFLAGS = -Bgcctestdir/ -Wl,-R,.
@GCC_TRUE@@NATIVE_LINKER_TRUE@weak_alias_test_LDADD = \
@GCC_TRUE@@NATIVE_LINKER_TRUE@ weak_alias_test_1.so weak_alias_test_2.so weak_alias_test_3.o \
-@GCC_TRUE@@NATIVE_LINKER_TRUE@ weak_alias_test_4.so
+@GCC_TRUE@@NATIVE_LINKER_TRUE@ weak_alias_test_4.so weak_alias_test_5.so
@GCC_TRUE@@NATIVE_LINKER_TRUE@copy_test_SOURCES = copy_test.cc
@GCC_TRUE@@NATIVE_LINKER_TRUE@copy_test_DEPENDENCIES = gcctestdir/ld copy_test_1.so copy_test_2.so
@@ -4169,6 +4169,11 @@ uninstall-am:
@GCC_TRUE@@NATIVE_LINKER_TRUE@ $(CXXCOMPILE) -c -fpic -o $@ $<
@GCC_TRUE@@NATIVE_LINKER_TRUE@weak_alias_test_4.so: weak_alias_test_4_pic.o gcctestdir/ld
@GCC_TRUE@@NATIVE_LINKER_TRUE@ $(CXXLINK) -Bgcctestdir/ -shared weak_alias_test_4_pic.o
+@GCC_TRUE@@NATIVE_LINKER_TRUE@weak_alias_test_5_pic.o: weak_alias_test_5.cc
+@GCC_TRUE@@NATIVE_LINKER_TRUE@ $(CXXCOMPILE) -c -fpic -o $@ $<
+@GCC_TRUE@@NATIVE_LINKER_TRUE@weak_alias_test_5.so: weak_alias_test_5_pic.o $(srcdir)/weak_alias_test.script gcctestdir/ld
+@GCC_TRUE@@NATIVE_LINKER_TRUE@ $(CXXLINK) -Bgcctestdir/ -shared weak_alias_test_5_pic.o \
+@GCC_TRUE@@NATIVE_LINKER_TRUE@ -Wl,--version-script,$(srcdir)/weak_alias_test.script
@GCC_TRUE@@NATIVE_LINKER_TRUE@weak_plt_main_pic.o: weak_plt_main.cc
@GCC_TRUE@@NATIVE_LINKER_TRUE@ $(CXXCOMPILE) -c -fpic -o $@ $<
@GCC_TRUE@@NATIVE_LINKER_TRUE@weak_plt: weak_plt_main_pic.o gcctestdir/ld
diff --git a/gold/testsuite/weak_alias_test.script b/gold/testsuite/weak_alias_test.script
new file mode 100644
index 0000000..1911631
--- /dev/null
+++ b/gold/testsuite/weak_alias_test.script
@@ -0,0 +1,8 @@
+VER1 {
+ global:
+ versioned_symbol;
+};
+VER2 {
+ global:
+ versioned_alias;
+};
diff --git a/gold/testsuite/weak_alias_test_5.cc b/gold/testsuite/weak_alias_test_5.cc
new file mode 100644
index 0000000..df48092
--- /dev/null
+++ b/gold/testsuite/weak_alias_test_5.cc
@@ -0,0 +1,39 @@
+// weak_alias_test_5.cc -- test versioned weak aliases for gold
+
+// Copyright 2011 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.
+
+// Define a versioned symbol.
+int versioned_symbol = 1;
+__asm__(".symver versioned_symbol,versioned_symbol@@VER1");
+
+// Define a weak alias for the versioned symbol, with a different version.
+extern int versioned_alias __attribute__ ((weak, alias("versioned_symbol")));
+__asm__(".symver versioned_alias,versioned_alias@@VER2");
+
+bool
+t2()
+{
+ if (versioned_symbol != 1)
+ return false;
+ if (versioned_alias != 1)
+ return false;
+ return true;
+}
diff --git a/gold/testsuite/weak_alias_test_main.cc b/gold/testsuite/weak_alias_test_main.cc
index 070eb2f..e3f8620 100644
--- a/gold/testsuite/weak_alias_test_main.cc
+++ b/gold/testsuite/weak_alias_test_main.cc
@@ -39,7 +39,12 @@ int weak_aliased_2 = 6;
extern int strong_aliased_3;
extern int weak_aliased_4;
+// Defined in weak_alias_test_5.cc
+extern int versioned_symbol;
+extern int versioned_alias;
+
extern bool t1();
+extern bool t2();
int
main()
@@ -64,4 +69,12 @@ main()
// Make sure the symbols look right from a shared library.
assert(t1());
+
+ // versioned_symbol comes from weak_alias_test_5.cc.
+ assert(versioned_symbol == 1);
+ // So does versioned_alias.
+ assert(versioned_alias == 1);
+
+ // Make sure the versioned symbols look right from a shared library.
+ assert(t2());
}