From acf0137445f29291900795ab76cc4807cff71db7 Mon Sep 17 00:00:00 2001 From: "H.J. Lu" Date: Thu, 28 Jul 2016 10:00:43 -0700 Subject: Add __attribute__((visibility("protected"))) tests --- gcc/config/i386/i386.c | 5 ++++- gcc/testsuite/gcc.target/i386/no-copy-reloc-10.c | 15 +++++++++++++++ gcc/testsuite/gcc.target/i386/no-copy-reloc-11.c | 15 +++++++++++++++ 3 files changed, 34 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/gcc.target/i386/no-copy-reloc-10.c create mode 100644 gcc/testsuite/gcc.target/i386/no-copy-reloc-11.c 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 } } } } */ -- cgit v1.2.1