From: Szabolcs Nagy Date: Tue, 20 Oct 2015 09:37:27 +0000 (+0000) Subject: Fix default_binds_local_p_2 for extern protected data X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=16b340c22400c9a1de543b86d00c97d543374e32;p=gcc.git Fix default_binds_local_p_2 for extern protected data gcc: PR target/66912 * varasm.c (default_binds_local_p_2): Turn on extern_protected_data. gcc/testsuite: PR target/66912 * gcc.target/aarch64/pr66912.c: New. * gcc.target/arm/pr66912.c: New. From-SVN: r229024 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 7f5cbf0c5a2..e3206f43b6c 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,8 @@ +2015-10-20 Szabolcs Nagy + + PR target/66912 + * varasm.c (default_binds_local_p_2): Turn on extern_protected_data. + 2015-10-20 Arkadiusz Drabczyk * doc/extend.texi: Update documentation WRT inline functions. diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 51fb89574d7..4415ac38fe0 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,9 @@ +2015-10-20 Szabolcs Nagy + + PR target/66912 + * gcc.target/aarch64/pr66912.c: New. + * gcc.target/arm/pr66912.c: New. + 2015-10-19 Steven G. Kargl * gfortran.dg/pr67900.f90: New tests. diff --git a/gcc/testsuite/gcc.target/aarch64/pr66912.c b/gcc/testsuite/gcc.target/aarch64/pr66912.c new file mode 100644 index 00000000000..b8aabcd3b13 --- /dev/null +++ b/gcc/testsuite/gcc.target/aarch64/pr66912.c @@ -0,0 +1,42 @@ +/* { dg-do compile { target *-*-linux* } } */ +/* { dg-options "-O2 -fpic" } */ + +__attribute__((visibility("protected"))) +int n_common; + +__attribute__((weak, visibility("protected"))) +int n_weak_common; + +__attribute__((visibility("protected"))) +int n_init = -1; + +__attribute__((weak, visibility("protected"))) +int n_weak_init = -1; + +int +f1 () +{ + /* { dg-final { scan-assembler ":got(page_lo15)?:n_common" } } */ + return n_common; +} + +int +f2 () +{ + /* { dg-final { scan-assembler ":got(page_lo15)?:n_weak_common" } } */ + return n_weak_common; +} + +int +f3 () +{ + /* { dg-final { scan-assembler ":got(page_lo15)?:n_init" } } */ + return n_init; +} + +int +f4 () +{ + /* { dg-final { scan-assembler ":got(page_lo15)?:n_weak_init" } } */ + return n_weak_init; +} diff --git a/gcc/testsuite/gcc.target/arm/pr66912.c b/gcc/testsuite/gcc.target/arm/pr66912.c new file mode 100644 index 00000000000..27e4c452bd3 --- /dev/null +++ b/gcc/testsuite/gcc.target/arm/pr66912.c @@ -0,0 +1,42 @@ +/* { dg-do compile { target *-*-linux* } } */ +/* { dg-options "-O2 -fpic" } */ + +__attribute__((visibility("protected"))) +int n_common; + +__attribute__((weak, visibility("protected"))) +int n_weak_common; + +__attribute__((visibility("protected"))) +int n_init = -1; + +__attribute__((weak, visibility("protected"))) +int n_weak_init = -1; + +int +f1 () +{ + /* { dg-final { scan-assembler "\\.word\\tn_common\\(GOT\\)" } } */ + return n_common; +} + +int +f2 () +{ + /* { dg-final { scan-assembler "\\.word\\tn_weak_common\\(GOT\\)" } } */ + return n_weak_common; +} + +int +f3 () +{ + /* { dg-final { scan-assembler "\\.word\\tn_init\\(GOT\\)" } } */ + return n_init; +} + +int +f4 () +{ + /* { dg-final { scan-assembler "\\.word\\tn_weak_init\\(GOT\\)" } } */ + return n_weak_init; +} diff --git a/gcc/varasm.c b/gcc/varasm.c index f1564bc4955..ff9d271d424 100644 --- a/gcc/varasm.c +++ b/gcc/varasm.c @@ -6898,12 +6898,13 @@ default_binds_local_p (const_tree exp) return default_binds_local_p_3 (exp, flag_shlib != 0, true, false, false); } -/* Similar to default_binds_local_p, but common symbol may be local. */ +/* Similar to default_binds_local_p, but common symbol may be local and + extern protected data is non-local. */ bool default_binds_local_p_2 (const_tree exp) { - return default_binds_local_p_3 (exp, flag_shlib != 0, true, false, + return default_binds_local_p_3 (exp, flag_shlib != 0, true, true, !flag_pic); }