aboutsummaryrefslogtreecommitdiff
path: root/gold/testsuite
diff options
context:
space:
mode:
Diffstat (limited to 'gold/testsuite')
-rw-r--r--gold/testsuite/weak_undef_file1.cc10
-rw-r--r--gold/testsuite/weak_undef_file2.cc4
-rw-r--r--gold/testsuite/weak_undef_test.cc17
3 files changed, 27 insertions, 4 deletions
diff --git a/gold/testsuite/weak_undef_file1.cc b/gold/testsuite/weak_undef_file1.cc
index 743eea6..fd28870 100644
--- a/gold/testsuite/weak_undef_file1.cc
+++ b/gold/testsuite/weak_undef_file1.cc
@@ -1,6 +1,6 @@
// weak_undef_file1.cc -- test handling of weak undefined symbols for gold
-// Copyright 2008 Free Software Foundation, Inc.
+// Copyright 2008, 2010 Free Software Foundation, Inc.
// Written by Cary Coutant <ccoutant@google.com>.
// This file is part of gold.
@@ -33,13 +33,19 @@
// so that we can detect whether the symbol was left for runtime
// resolution.
-
#include <cstdio>
#include "weak_undef.h"
int is_such_symbol_ = 1;
+// We also define a symbol that is not defined by the alternate
+// library. The main program contains a weak reference to this
+// symbol, and tests that the reference remains weak even after
+// the definition was found at link time.
+
+int link_time_only = 1;
+
extern int v2 __attribute__ ((weak));
int *v3 = &v2;
diff --git a/gold/testsuite/weak_undef_file2.cc b/gold/testsuite/weak_undef_file2.cc
index 610c25e..33701b2 100644
--- a/gold/testsuite/weak_undef_file2.cc
+++ b/gold/testsuite/weak_undef_file2.cc
@@ -1,6 +1,6 @@
-// weak_undef_file1.cc -- test handling of weak undefined symbols for gold
+// weak_undef_file2.cc -- test handling of weak undefined symbols for gold
-// Copyright 2008 Free Software Foundation, Inc.
+// Copyright 2008, 2010 Free Software Foundation, Inc.
// Written by Cary Coutant <ccoutant@google.com>.
// This file is part of gold.
diff --git a/gold/testsuite/weak_undef_test.cc b/gold/testsuite/weak_undef_test.cc
index 962b6bf..880d5cd 100644
--- a/gold/testsuite/weak_undef_test.cc
+++ b/gold/testsuite/weak_undef_test.cc
@@ -34,14 +34,24 @@
// so that we can detect whether the symbol was left for runtime
// resolution.
+// Similarly, this file will be linked with a shared library that
+// does define a different symbol, and loaded with an alternate
+// shared library that does not define that symbol. We check that
+// the weak reference remains weak, and that it is resolved to
+// zero at runtime.
+
#include <cstdio>
#include "weak_undef.h"
extern int no_such_symbol_ __attribute__ ((weak));
+extern int link_time_only __attribute__ ((weak));
+
int *p1 = &no_such_symbol_;
+int *p2 = &link_time_only;
+
int v2 = 42;
int
@@ -85,5 +95,12 @@ main()
status = 1;
}
+ if (p2 != NULL)
+ {
+ fprintf(stderr, "FAILED weak undef test 6: %s\n",
+ "p2 is not NULL");
+ status = 1;
+ }
+
return status;
}