summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorH.J. Lu <hjl.tools@gmail.com>2016-07-28 10:00:43 -0700
committerH.J. Lu <hjl.tools@gmail.com>2017-08-25 08:22:38 -0700
commitacf0137445f29291900795ab76cc4807cff71db7 (patch)
tree67afa4faafc663b66b8e53b91b2082915864db06
parent1fca099f39461203f3bed41e191623b94eac841d (diff)
downloadgcc-hjl/copyreloc/master.tar.gz
Add __attribute__((visibility("protected"))) testshjl/copyreloc/master
-rw-r--r--gcc/config/i386/i386.c5
-rw-r--r--gcc/testsuite/gcc.target/i386/no-copy-reloc-10.c15
-rw-r--r--gcc/testsuite/gcc.target/i386/no-copy-reloc-11.c15
3 files changed, 34 insertions, 1 deletions
diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c
index 268df5c5e6d..086d234637d 100644
--- a/gcc/config/i386/i386.c
+++ b/gcc/config/i386/i386.c
@@ -52237,7 +52237,10 @@ ix86_initialize_bounds (tree var, tree lb, tree ub, tree *stmts)
static bool
ix86_binds_local_p (const_tree exp)
{
- return default_binds_local_p_3 (exp, flag_shlib != 0, true, true,
+ return default_binds_local_p_3 (exp, flag_shlib != 0, true,
+ (flag_copy_reloc
+ || !(TARGET_64BIT
+ || HAVE_AS_IX86_GOT32X)),
(!flag_pic
|| (TARGET_64BIT
&& HAVE_LD_PIE_COPYRELOC != 0)));
diff --git a/gcc/testsuite/gcc.target/i386/no-copy-reloc-10.c b/gcc/testsuite/gcc.target/i386/no-copy-reloc-10.c
new file mode 100644
index 00000000000..1869f46b3f3
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/no-copy-reloc-10.c
@@ -0,0 +1,15 @@
+/* { dg-do compile { target *-*-linux* } } */
+/* { dg-options "-O2 -fpic -mno-copy-reloc" } */
+
+extern int bar __attribute__((visibility("protected")));
+
+int *
+foo (void)
+{
+ return &bar;
+}
+
+/* { dg-final { scan-assembler "lea\(l|q\)\[ \t\]*bar\\(%rip\\)" { target { ! ia32 } } } } */
+/* { dg-final { scan-assembler "leal\[ \t\]*bar@GOTOFF\\(" { target { ia32 && got32x_reloc } } } } */
+/* { dg-final { scan-assembler-not "mov\(l|q\)\[ \t\]*bar@GOTPCREL" { target { ! ia32 } } } } */
+/* { dg-final { scan-assembler-not "movl\[ \t\]*bar@GOT\\(" { target { ia32 && got32x_reloc } } } } */
diff --git a/gcc/testsuite/gcc.target/i386/no-copy-reloc-11.c b/gcc/testsuite/gcc.target/i386/no-copy-reloc-11.c
new file mode 100644
index 00000000000..b1836cb6598
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/no-copy-reloc-11.c
@@ -0,0 +1,15 @@
+/* { dg-do compile { target *-*-linux* } } */
+/* { dg-options "-O2 -fpic -mno-copy-reloc" } */
+
+extern int bar __attribute__((visibility("protected")));
+
+int
+foo (void)
+{
+ return bar;
+}
+
+/* { dg-final { scan-assembler "mov\(l|q\)\[ \t\]*bar\\(%rip\\)" { target { ! ia32 } } } } */
+/* { dg-final { scan-assembler "movl\[ \t\]*bar@GOTOFF\\(" { target { ia32 && got32x_reloc } } } } */
+/* { dg-final { scan-assembler-not "mov\(l|q\)\[ \t\]*bar@GOTPCREL" { target { ! ia32 } } } } */
+/* { dg-final { scan-assembler-not "movl\[ \t\]*bar@GOT\\(" { target { ia32 && got32x_reloc } } } } */