summaryrefslogtreecommitdiffstats
path: root/gold/testsuite/weak_undef_file1.cc
diff options
context:
space:
mode:
authorCary Coutant <ccoutant@google.com>2008-04-17 00:14:36 +0000
committerCary Coutant <ccoutant@google.com>2008-04-17 00:14:36 +0000
commitf3c69fcab18257246fa945f4a85388b54a34e512 (patch)
tree1ace720949b4dac7cdfa149283f578069babf9df /gold/testsuite/weak_undef_file1.cc
parented83b9532695798e07c6f615d32e9c12109ff04e (diff)
downloadppe42-binutils-f3c69fcab18257246fa945f4a85388b54a34e512.tar.gz
ppe42-binutils-f3c69fcab18257246fa945f4a85388b54a34e512.zip
* symtab.h (Symbol::is_strong_undefined): Removed unused function.
(Symbol::needs_plt_entry): Allow weak undefined symbols. (Symbol::needs_dynamic_reloc): Allow weak undefined symbols when building shared libraries. * testsuite/Makefile.am (weak_undef_nonpic_test): New target. (weak_undef_file1_nonpic.o, weak_undef_file2_nonpic.o) (weak_undef_lib_nonpic.so, alt/weak_undef_lib_nonpic.so): New targets. * testsuite/Makefile.in: Rebuild. * testsuite/weak_undef.h: New file. * testsuite/weak_undef_file1.cc: Add extra test cases. * testsuite/weak_undef_file2.cc: Likewise. * testsuite/weak_undef_test.cc: Likewise.
Diffstat (limited to 'gold/testsuite/weak_undef_file1.cc')
-rw-r--r--gold/testsuite/weak_undef_file1.cc26
1 files changed, 25 insertions, 1 deletions
diff --git a/gold/testsuite/weak_undef_file1.cc b/gold/testsuite/weak_undef_file1.cc
index 58ab53b073..743eea641e 100644
--- a/gold/testsuite/weak_undef_file1.cc
+++ b/gold/testsuite/weak_undef_file1.cc
@@ -36,10 +36,34 @@
#include <cstdio>
-int is_such_symbol_ = 0;
+#include "weak_undef.h"
+
+int is_such_symbol_ = 1;
+
+extern int v2 __attribute__ ((weak));
+
+int *v3 = &v2;
int
t1()
{
return is_such_symbol_;
}
+
+// Test that a weak reference from a shared library to a symbol
+// defined in the main program does get resolved.
+
+int
+t2()
+{
+ return (&v2 == NULL) ? -1 : v2;
+}
+
+// Test that a weak reference from a shared library to a symbol
+// defined in the main program does get resolved.
+
+int
+t3()
+{
+ return (v3 == NULL) ? -1 : *v3;
+}
OpenPOWER on IntegriCloud