aboutsummaryrefslogtreecommitdiff
path: root/gold
diff options
context:
space:
mode:
authorIan Lance Taylor <ian@airs.com>2008-04-09 22:45:08 +0000
committerIan Lance Taylor <ian@airs.com>2008-04-09 22:45:08 +0000
commit99a37bfda08542d871bd81bd83680ad547eb015e (patch)
tree434e31347ae3a1244cbe8a0b25460589905da421 /gold
parentde051565dfd9173f9ca885ac8e294ae2c90e409c (diff)
downloadgdb-99a37bfda08542d871bd81bd83680ad547eb015e.zip
gdb-99a37bfda08542d871bd81bd83680ad547eb015e.tar.gz
gdb-99a37bfda08542d871bd81bd83680ad547eb015e.tar.bz2
* symtab.cc (Symbol_table::add_from_dynobj): Only look for weak
aliases for symbols defined in the same object. * testsuite/Makefile.am (check_PROGRAMS): Add weak_alias_test. (weak_alias_test_SOURCES): New variable. (weak_alias_test_DEPENDENCIES): New variable. (weak_alias_test_LDFLAGS): New variable. (weak_alias_test_LDADD): New variable. (weak_alias_test_1_pic.o, weak_alias_test_1.so): New targets. (weak_alias_test_2_pic.o, weak_alias_test_2.so): New targets. (weak_alias_test_3.o): New target. (weak_alias_test_4_pic.o, weak_alias_test_4.so): New targets. * testsuite/weak_alias_test_main.cc: New file. * testsuite/weak_alias_test_1.cc: New file. * testsuite/weak_alias_test_2.cc: New file. * testsuite/weak_alias_test_3.cc: New file.
Diffstat (limited to 'gold')
-rw-r--r--gold/ChangeLog18
-rw-r--r--gold/symtab.cc6
-rw-r--r--gold/testsuite/Makefile.am24
-rw-r--r--gold/testsuite/Makefile.in42
-rw-r--r--gold/testsuite/weak_alias_test_1.cc52
-rw-r--r--gold/testsuite/weak_alias_test_2.cc41
-rw-r--r--gold/testsuite/weak_alias_test_3.cc26
-rw-r--r--gold/testsuite/weak_alias_test_4.cc68
-rw-r--r--gold/testsuite/weak_alias_test_main.cc67
9 files changed, 340 insertions, 4 deletions
diff --git a/gold/ChangeLog b/gold/ChangeLog
index e79fd7b..b6e2ac4 100644
--- a/gold/ChangeLog
+++ b/gold/ChangeLog
@@ -1,3 +1,21 @@
+2008-04-09 Ian Lance Taylor <iant@google.com>
+
+ * symtab.cc (Symbol_table::add_from_dynobj): Only look for weak
+ aliases for symbols defined in the same object.
+ * testsuite/Makefile.am (check_PROGRAMS): Add weak_alias_test.
+ (weak_alias_test_SOURCES): New variable.
+ (weak_alias_test_DEPENDENCIES): New variable.
+ (weak_alias_test_LDFLAGS): New variable.
+ (weak_alias_test_LDADD): New variable.
+ (weak_alias_test_1_pic.o, weak_alias_test_1.so): New targets.
+ (weak_alias_test_2_pic.o, weak_alias_test_2.so): New targets.
+ (weak_alias_test_3.o): New target.
+ (weak_alias_test_4_pic.o, weak_alias_test_4.so): New targets.
+ * testsuite/weak_alias_test_main.cc: New file.
+ * testsuite/weak_alias_test_1.cc: New file.
+ * testsuite/weak_alias_test_2.cc: New file.
+ * testsuite/weak_alias_test_3.cc: New file.
+
2008-04-08 Ian Lance Taylor <iant@google.com>
* options.h (class General_options): Add --noinhibit-exec option.
diff --git a/gold/symtab.cc b/gold/symtab.cc
index 91a2b1e..6acdcc8 100644
--- a/gold/symtab.cc
+++ b/gold/symtab.cc
@@ -1006,8 +1006,12 @@ Symbol_table::add_from_dynobj(
}
}
+ // Note that it is possible that RES was overridden by an
+ // earlier object, in which case it can be aliased here.
if (sym.get_st_shndx() != elfcpp::SHN_UNDEF
- && sym.get_st_type() == elfcpp::STT_OBJECT)
+ && sym.get_st_type() == elfcpp::STT_OBJECT
+ && res->source() == Symbol::FROM_OBJECT
+ && res->object() == dynobj)
object_symbols.push_back(res);
}
diff --git a/gold/testsuite/Makefile.am b/gold/testsuite/Makefile.am
index c3a0969..ffb99c4 100644
--- a/gold/testsuite/Makefile.am
+++ b/gold/testsuite/Makefile.am
@@ -380,6 +380,30 @@ alt/weak_undef_lib.so: weak_undef_file2.o
test -d alt || mkdir -p alt
$(CXXLINK) -Bgcctestdir/ -shared weak_undef_file2.o
+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_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_1_pic.o: weak_alias_test_1.cc
+ $(CXXCOMPILE) -c -fpic -o $@ $<
+weak_alias_test_1.so: weak_alias_test_1_pic.o
+ $(CXXLINK) -Bgcctestdir/ -shared weak_alias_test_1_pic.o
+weak_alias_test_2_pic.o: weak_alias_test_2.cc
+ $(CXXCOMPILE) -c -fpic -o $@ $<
+weak_alias_test_2.so: weak_alias_test_2_pic.o
+ $(CXXLINK) -Bgcctestdir/ -shared weak_alias_test_2_pic.o
+weak_alias_test_3.o: weak_alias_test_3.cc
+ $(CXXCOMPILE) -c -o $@ $<
+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
+ $(CXXLINK) -Bgcctestdir/ -shared weak_alias_test_4_pic.o
+
if TLS
check_PROGRAMS += tls_test
diff --git a/gold/testsuite/Makefile.in b/gold/testsuite/Makefile.in
index c9a696e..fea5a39 100644
--- a/gold/testsuite/Makefile.in
+++ b/gold/testsuite/Makefile.in
@@ -112,7 +112,8 @@ check_PROGRAMS = object_unittest$(EXEEXT) binary_unittest$(EXEEXT) \
@GCC_TRUE@@NATIVE_LINKER_TRUE@ exception_same_shared_test \
@GCC_TRUE@@NATIVE_LINKER_TRUE@ exception_separate_shared_12_test \
@GCC_TRUE@@NATIVE_LINKER_TRUE@ exception_separate_shared_21_test \
-@GCC_TRUE@@NATIVE_LINKER_TRUE@ weak_test weak_undef_test
+@GCC_TRUE@@NATIVE_LINKER_TRUE@ weak_test weak_undef_test \
+@GCC_TRUE@@NATIVE_LINKER_TRUE@ weak_alias_test
@GCC_FALSE@common_test_1_DEPENDENCIES = libgoldtest.a ../libgold.a \
@GCC_FALSE@ ../../libiberty/libiberty.a $(am__DEPENDENCIES_1) \
@GCC_FALSE@ $(am__DEPENDENCIES_1)
@@ -297,7 +298,8 @@ libgoldtest_a_OBJECTS = $(am_libgoldtest_a_OBJECTS)
@GCC_TRUE@@NATIVE_LINKER_TRUE@ exception_separate_shared_12_test$(EXEEXT) \
@GCC_TRUE@@NATIVE_LINKER_TRUE@ exception_separate_shared_21_test$(EXEEXT) \
@GCC_TRUE@@NATIVE_LINKER_TRUE@ weak_test$(EXEEXT) \
-@GCC_TRUE@@NATIVE_LINKER_TRUE@ weak_undef_test$(EXEEXT)
+@GCC_TRUE@@NATIVE_LINKER_TRUE@ weak_undef_test$(EXEEXT) \
+@GCC_TRUE@@NATIVE_LINKER_TRUE@ weak_alias_test$(EXEEXT)
@GCC_TRUE@@NATIVE_LINKER_TRUE@@TLS_TRUE@am__EXEEXT_4 = \
@GCC_TRUE@@NATIVE_LINKER_TRUE@@TLS_TRUE@ tls_test$(EXEEXT) \
@GCC_TRUE@@NATIVE_LINKER_TRUE@@TLS_TRUE@ tls_pic_test$(EXEEXT) \
@@ -642,6 +644,10 @@ am__ver_test_6_SOURCES_DIST = ver_test_6.c
@GCC_TRUE@@NATIVE_LINKER_TRUE@am_ver_test_6_OBJECTS = \
@GCC_TRUE@@NATIVE_LINKER_TRUE@ ver_test_6.$(OBJEXT)
ver_test_6_OBJECTS = $(am_ver_test_6_OBJECTS)
+am__weak_alias_test_SOURCES_DIST = weak_alias_test_main.cc
+@GCC_TRUE@@NATIVE_LINKER_TRUE@am_weak_alias_test_OBJECTS = \
+@GCC_TRUE@@NATIVE_LINKER_TRUE@ weak_alias_test_main.$(OBJEXT)
+weak_alias_test_OBJECTS = $(am_weak_alias_test_OBJECTS)
am__weak_test_SOURCES_DIST = weak_test.cc
@GCC_TRUE@@NATIVE_LINKER_TRUE@am_weak_test_OBJECTS = \
@GCC_TRUE@@NATIVE_LINKER_TRUE@ weak_test.$(OBJEXT)
@@ -702,7 +708,8 @@ SOURCES = $(libgoldtest_a_SOURCES) basic_pic_test.c \
$(two_file_static_test_SOURCES) two_file_strip_test.c \
$(two_file_test_SOURCES) $(ver_test_SOURCES) \
$(ver_test_2_SOURCES) $(ver_test_6_SOURCES) \
- $(weak_test_SOURCES) $(weak_undef_test_SOURCES)
+ $(weak_alias_test_SOURCES) $(weak_test_SOURCES) \
+ $(weak_undef_test_SOURCES)
DIST_SOURCES = $(libgoldtest_a_SOURCES) basic_pic_test.c \
basic_static_pic_test.c basic_static_test.c basic_test.c \
$(am__binary_test_SOURCES_DIST) $(binary_unittest_SOURCES) \
@@ -748,6 +755,7 @@ DIST_SOURCES = $(libgoldtest_a_SOURCES) basic_pic_test.c \
$(am__two_file_static_test_SOURCES_DIST) two_file_strip_test.c \
$(am__two_file_test_SOURCES_DIST) $(am__ver_test_SOURCES_DIST) \
$(am__ver_test_2_SOURCES_DIST) $(am__ver_test_6_SOURCES_DIST) \
+ $(am__weak_alias_test_SOURCES_DIST) \
$(am__weak_test_SOURCES_DIST) \
$(am__weak_undef_test_SOURCES_DIST)
ETAGS = etags
@@ -1102,6 +1110,16 @@ binary_unittest_SOURCES = binary_unittest.cc
@GCC_TRUE@@NATIVE_LINKER_TRUE@weak_undef_test_DEPENDENCIES = gcctestdir/ld weak_undef_lib.so alt/weak_undef_lib.so
@GCC_TRUE@@NATIVE_LINKER_TRUE@weak_undef_test_LDFLAGS = -Bgcctestdir/ -Wl,-R,alt
@GCC_TRUE@@NATIVE_LINKER_TRUE@weak_undef_test_LDADD = -L . weak_undef_lib.so
+@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_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@@TLS_TRUE@tls_test_SOURCES = tls_test.cc tls_test_file2.cc tls_test_main.cc tls_test.h
@GCC_TRUE@@NATIVE_LINKER_TRUE@@TLS_TRUE@tls_test_DEPENDENCIES = gcctestdir/ld
@GCC_TRUE@@NATIVE_LINKER_TRUE@@TLS_TRUE@tls_test_LDFLAGS = -Bgcctestdir/
@@ -1398,6 +1416,9 @@ ver_test_2$(EXEEXT): $(ver_test_2_OBJECTS) $(ver_test_2_DEPENDENCIES)
ver_test_6$(EXEEXT): $(ver_test_6_OBJECTS) $(ver_test_6_DEPENDENCIES)
@rm -f ver_test_6$(EXEEXT)
$(LINK) $(ver_test_6_LDFLAGS) $(ver_test_6_OBJECTS) $(ver_test_6_LDADD) $(LIBS)
+weak_alias_test$(EXEEXT): $(weak_alias_test_OBJECTS) $(weak_alias_test_DEPENDENCIES)
+ @rm -f weak_alias_test$(EXEEXT)
+ $(CXXLINK) $(weak_alias_test_LDFLAGS) $(weak_alias_test_OBJECTS) $(weak_alias_test_LDADD) $(LIBS)
weak_test$(EXEEXT): $(weak_test_OBJECTS) $(weak_test_DEPENDENCIES)
@rm -f weak_test$(EXEEXT)
$(CXXLINK) $(weak_test_LDFLAGS) $(weak_test_OBJECTS) $(weak_test_LDADD) $(LIBS)
@@ -1447,6 +1468,7 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ver_test_6.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ver_test_main.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ver_test_main_2.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/weak_alias_test_main.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/weak_test.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/weak_undef_test.Po@am__quote@
@@ -1805,6 +1827,20 @@ uninstall-am: uninstall-info-am
@GCC_TRUE@@NATIVE_LINKER_TRUE@alt/weak_undef_lib.so: weak_undef_file2.o
@GCC_TRUE@@NATIVE_LINKER_TRUE@ test -d alt || mkdir -p alt
@GCC_TRUE@@NATIVE_LINKER_TRUE@ $(CXXLINK) -Bgcctestdir/ -shared weak_undef_file2.o
+@GCC_TRUE@@NATIVE_LINKER_TRUE@weak_alias_test_1_pic.o: weak_alias_test_1.cc
+@GCC_TRUE@@NATIVE_LINKER_TRUE@ $(CXXCOMPILE) -c -fpic -o $@ $<
+@GCC_TRUE@@NATIVE_LINKER_TRUE@weak_alias_test_1.so: weak_alias_test_1_pic.o
+@GCC_TRUE@@NATIVE_LINKER_TRUE@ $(CXXLINK) -Bgcctestdir/ -shared weak_alias_test_1_pic.o
+@GCC_TRUE@@NATIVE_LINKER_TRUE@weak_alias_test_2_pic.o: weak_alias_test_2.cc
+@GCC_TRUE@@NATIVE_LINKER_TRUE@ $(CXXCOMPILE) -c -fpic -o $@ $<
+@GCC_TRUE@@NATIVE_LINKER_TRUE@weak_alias_test_2.so: weak_alias_test_2_pic.o
+@GCC_TRUE@@NATIVE_LINKER_TRUE@ $(CXXLINK) -Bgcctestdir/ -shared weak_alias_test_2_pic.o
+@GCC_TRUE@@NATIVE_LINKER_TRUE@weak_alias_test_3.o: weak_alias_test_3.cc
+@GCC_TRUE@@NATIVE_LINKER_TRUE@ $(CXXCOMPILE) -c -o $@ $<
+@GCC_TRUE@@NATIVE_LINKER_TRUE@weak_alias_test_4_pic.o: weak_alias_test_4.cc
+@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
+@GCC_TRUE@@NATIVE_LINKER_TRUE@ $(CXXLINK) -Bgcctestdir/ -shared weak_alias_test_4_pic.o
@GCC_TRUE@@NATIVE_LINKER_TRUE@@TLS_TRUE@tls_test_pic.o: tls_test.cc
@GCC_TRUE@@NATIVE_LINKER_TRUE@@TLS_TRUE@ $(CXXCOMPILE) -c -fpic -o $@ $<
@GCC_TRUE@@NATIVE_LINKER_TRUE@@TLS_TRUE@tls_test_file2_pic.o: tls_test_file2.cc
diff --git a/gold/testsuite/weak_alias_test_1.cc b/gold/testsuite/weak_alias_test_1.cc
new file mode 100644
index 0000000..0ad9265
--- /dev/null
+++ b/gold/testsuite/weak_alias_test_1.cc
@@ -0,0 +1,52 @@
+// weak_alias_test_1.cc -- test weak aliases 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.
+
+// Define a weak symbol.
+
+extern int weak_symbol __attribute__ ((weak));
+int weak_symbol = 1;
+
+// Define a strong symbol with a weak alias.
+
+int strong_aliased = 2;
+extern int weak_aliased __attribute__ ((weak, alias ("strong_aliased")));
+
+// And another one.
+
+int strong_aliased_2 = 5;
+extern int weak_aliased_2 __attribute__ ((weak, alias ("strong_aliased_2")));
+
+// And a third.
+
+int strong_aliased_3 = 7;
+extern int weak_aliased_3 __attribute__ ((weak, alias ("strong_aliased_3")));
+
+// And a fourth.
+
+int strong_aliased_4 = 8;
+extern int weak_aliased_4 __attribute__ ((weak, alias ("strong_aliased_4")));
+
+// We want a symbol whose name is the same length as "strong_symbol",
+// so that weak_symbol here lines up with weak_symbol in
+// weak_alias_test_2.so.
+
+int Strong_Symbol = 101;
diff --git a/gold/testsuite/weak_alias_test_2.cc b/gold/testsuite/weak_alias_test_2.cc
new file mode 100644
index 0000000..8294525
--- /dev/null
+++ b/gold/testsuite/weak_alias_test_2.cc
@@ -0,0 +1,41 @@
+// weak_alias_test_2.cc -- test weak aliases 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.
+
+// Define a strong symbol.
+
+int strong_symbol = 2;
+
+// Define a weak symbol. This will be overridden by the weak symbol
+// in weak_alias_test_1.cc.
+
+extern int weak_symbol __attribute__ ((weak));
+int weak_symbol = 3;
+
+// These are overridden by weak_alias_test_1.cc
+int strong_aliased = 100;
+extern int weak_aliased __attribute__ ((weak, alias ("strong_aliased")));
+int strong_aliased_2 = 102;
+extern int weak_aliased_2 __attribute__ ((weak, alias ("strong_aliased_2")));
+int strong_aliased_3 = 104;
+extern int weak_aliased_3 __attribute__ ((weak, alias ("strong_aliased_3")));
+int strong_aliased_4 = 106;
+extern int weak_aliased_4 __attribute__ ((weak, alias ("strong_aliased_4")));
diff --git a/gold/testsuite/weak_alias_test_3.cc b/gold/testsuite/weak_alias_test_3.cc
new file mode 100644
index 0000000..99152e2
--- /dev/null
+++ b/gold/testsuite/weak_alias_test_3.cc
@@ -0,0 +1,26 @@
+// weak_alias_test_3.cc -- test weak aliases 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 is linked into the main program.
+
+extern int weak_symbol __attribute__ ((weak));
+int weak_symbol = 4;
diff --git a/gold/testsuite/weak_alias_test_4.cc b/gold/testsuite/weak_alias_test_4.cc
new file mode 100644
index 0000000..714c6d6
--- /dev/null
+++ b/gold/testsuite/weak_alias_test_4.cc
@@ -0,0 +1,68 @@
+// weak_alias_test_4.cc -- test weak aliases 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.
+
+// Verify that all the symbols look right from a shared library.
+
+extern int weak_symbol;
+extern int strong_aliased;
+extern int weak_aliased;
+extern int strong_aliased_2;
+extern int weak_aliased_2;
+extern int strong_aliased_3;
+extern int weak_aliased_3;
+extern int strong_aliased_4;
+extern int weak_aliased_4;
+extern int strong_symbol;
+
+bool
+t1()
+{
+ // Should come from weak_alias_test_3.cc.
+ if (weak_symbol != 4)
+ return false;
+
+ // Should come from weak_alias_test_main.cc.
+ if (strong_aliased != 3)
+ return false;
+
+ // weak_aliased need not match strong_aliased, which is overridden
+ // by weak_test_main.cc.
+
+ // Should come from weak_alias_test_main.cc.
+ if (weak_aliased_2 != 6)
+ return false;
+
+ // strong_aliased_2 need not match weak_aliased_2, which is
+ // overidden by weak_test_main.cc.
+
+ // The others should match.
+ if (weak_aliased_3 != 7 || strong_aliased_3 != 7)
+ return false;
+ if (weak_aliased_4 != 8 || strong_aliased_4 != 8)
+ return false;
+
+ // Should come from weak_alias_test_2.cc.
+ if (strong_symbol != 2)
+ return false;
+
+ return true;
+}
diff --git a/gold/testsuite/weak_alias_test_main.cc b/gold/testsuite/weak_alias_test_main.cc
new file mode 100644
index 0000000..070eb2f
--- /dev/null
+++ b/gold/testsuite/weak_alias_test_main.cc
@@ -0,0 +1,67 @@
+// weak_alias_test_main.cc -- test weak aliases 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 <assert.h>
+
+// Defined in both weak_alias_test_1.cc and weak_alias_test_2.cc, but
+// we should get the one in weak_alias_test_1.cc.
+extern int weak_symbol;
+
+// Defined in weak_alias_test_2.cc.
+extern int strong_symbol;
+
+// weak_aliased is an alias for this.
+int strong_aliased = 3;
+
+// Defined as a weak alias in weak_alias_test_1.cc.
+int weak_aliased_2 = 6;
+
+// Defined in weak_alias_test_1.cc
+extern int strong_aliased_3;
+extern int weak_aliased_4;
+
+extern bool t1();
+
+int
+main()
+{
+ // weak_symbol should come from weak_alias_test_3.cc.
+ assert(weak_symbol == 4);
+
+ // strong_symbol should come from weak_alias_test_2.cc.
+ assert(strong_symbol == 2);
+
+ // strong_aliased should come from this file, above.
+ assert(strong_aliased == 3);
+
+ // weak_aliased_2 should come from this file, above.
+ assert(weak_aliased_2 == 6);
+
+ // strong_aliased_3 should come from weak_alias_test_1.cc.
+ assert(strong_aliased_3 == 7);
+
+ // weak_aliased_4 should come from weak_alias_test_1.cc.
+ assert(weak_aliased_4 == 8);
+
+ // Make sure the symbols look right from a shared library.
+ assert(t1());
+}