Automatic date update in version.in
[platform/upstream/binutils.git] / gold / testsuite / weak_undef_file1.cc
index 58ab53b..60cf5c3 100644 (file)
@@ -1,6 +1,6 @@
 // weak_undef_file1.cc -- test handling of weak undefined symbols for gold
 
-// Copyright 2008 Free Software Foundation, Inc.
+// Copyright (C) 2008-2014 Free Software Foundation, Inc.
 // Written by Cary Coutant <ccoutant@google.com>.
 
 // This file is part of gold.
 // so that we can detect whether the symbol was left for runtime
 // resolution.
 
-
 #include <cstdio>
 
-int is_such_symbol_ = 0;
+#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;
 
 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;
+}