aboutsummaryrefslogtreecommitdiff
path: root/gold/testsuite/protected_1.cc
diff options
context:
space:
mode:
authorIan Lance Taylor <ian@airs.com>2011-07-12 22:29:09 +0000
committerIan Lance Taylor <ian@airs.com>2011-07-12 22:29:09 +0000
commit07aa62f2670a590b8f35a7308129bff58bf4a9d6 (patch)
tree15e9038da0603a28ee7e192ed1ddac4b5db6954d /gold/testsuite/protected_1.cc
parenta7035dbbd10c5208e63cc3bc1b45f2dd8d16d7bb (diff)
downloadgdb-07aa62f2670a590b8f35a7308129bff58bf4a9d6.zip
gdb-07aa62f2670a590b8f35a7308129bff58bf4a9d6.tar.gz
gdb-07aa62f2670a590b8f35a7308129bff58bf4a9d6.tar.bz2
PR gold/12980
* i386.cc (Target_i386::Scan::global): For a GOT reloc, use a GLOB_DAT relocation rather than a RELATIVE relocation for a protected symbol when creating a shared library. * x86_64.cc (Target_x86_64::Scan::global): Likewise. * testsuite/protected_1.cc (f2, get_f2_addr): New functions. * testsuite/protected_main_1.cc (main): Test that protected function has same address.
Diffstat (limited to 'gold/testsuite/protected_1.cc')
-rw-r--r--gold/testsuite/protected_1.cc25
1 files changed, 25 insertions, 0 deletions
diff --git a/gold/testsuite/protected_1.cc b/gold/testsuite/protected_1.cc
index 9183312..049bda7 100644
--- a/gold/testsuite/protected_1.cc
+++ b/gold/testsuite/protected_1.cc
@@ -31,3 +31,28 @@ f1()
{
return 1;
}
+
+// The function f2 is used to test that the executable can see the
+// same function address for a protected function in the executable
+// and in the shared library. We can't use the visibility attribute
+// here, becaues that may cause gcc to generate a PC relative reloc;
+// we need it to get the value from the GOT. I'm not sure this is
+// really useful, given that it doesn't work with the visibility
+// attribute. This test exists here mainly because the glibc
+// testsuite has the same test, and we want to make sure that gold
+// passes the glibc testsuite.
+
+extern "C" int f2();
+asm(".protected f2");
+
+extern "C" int
+f2()
+{
+ return 2;
+}
+
+int
+(*get_f2_addr())()
+{
+ return f2;
+}