Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1 | From e0d15f4f8bf28c351b9215ca37f1caa24df0e1fd Mon Sep 17 00:00:00 2001 |
| 2 | From: Khem Raj <raj.khem@gmail.com> |
| 3 | Date: Fri, 29 Mar 2013 09:18:54 +0400 |
| 4 | Subject: [PATCH 24/35] PR target/32219 |
| 5 | |
| 6 | * varasm.c (default_binds_local_p_1): Weak data is not local. |
| 7 | |
| 8 | Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com> |
| 9 | Signed-off-by: Khem Raj <raj.khem@gmail.com> |
| 10 | |
| 11 | Upstream-Status: Backport |
| 12 | --- |
| 13 | gcc/testsuite/gcc.dg/visibility-21.c | 14 ++++++++++++++ |
| 14 | gcc/varasm.c | 9 ++++----- |
| 15 | 2 files changed, 18 insertions(+), 5 deletions(-) |
| 16 | create mode 100644 gcc/testsuite/gcc.dg/visibility-21.c |
| 17 | |
| 18 | diff --git a/gcc/testsuite/gcc.dg/visibility-21.c b/gcc/testsuite/gcc.dg/visibility-21.c |
| 19 | new file mode 100644 |
| 20 | index 0000000..be7deda |
| 21 | --- /dev/null |
| 22 | +++ b/gcc/testsuite/gcc.dg/visibility-21.c |
| 23 | @@ -0,0 +1,14 @@ |
| 24 | +/* PR target/32219 */ |
| 25 | +/* { dg-do run } */ |
| 26 | +/* { dg-require-visibility "" } */ |
| 27 | +/* { dg-options "-fPIC" { target fpic } } */ |
| 28 | + |
| 29 | +extern void f() __attribute__((weak,visibility("hidden"))); |
| 30 | +extern int puts( char const* ); |
| 31 | +int main() |
| 32 | +{ |
| 33 | + if (f) |
| 34 | + f(); |
| 35 | + return 0; |
| 36 | +} |
| 37 | + |
| 38 | diff --git a/gcc/varasm.c b/gcc/varasm.c |
| 39 | index 6648103..fadba78 100644 |
| 40 | --- a/gcc/varasm.c |
| 41 | +++ b/gcc/varasm.c |
| 42 | @@ -6675,6 +6675,10 @@ default_binds_local_p_1 (const_tree exp, int shlib) |
| 43 | /* Static variables are always local. */ |
| 44 | else if (! TREE_PUBLIC (exp)) |
| 45 | local_p = true; |
| 46 | + /* hidden weak can't be overridden by something non-local, all |
| 47 | + that is possible is that it is not defined at all. */ |
| 48 | + else if (DECL_WEAK (exp)) |
| 49 | + local_p = false; |
| 50 | /* A variable is local if the user has said explicitly that it will |
| 51 | be. */ |
| 52 | else if ((DECL_VISIBILITY_SPECIFIED (exp) |
| 53 | @@ -6688,11 +6692,6 @@ default_binds_local_p_1 (const_tree exp, int shlib) |
| 54 | local. */ |
| 55 | else if (DECL_VISIBILITY (exp) != VISIBILITY_DEFAULT) |
| 56 | local_p = true; |
| 57 | - /* Default visibility weak data can be overridden by a strong symbol |
| 58 | - in another module and so are not local. */ |
| 59 | - else if (DECL_WEAK (exp) |
| 60 | - && !resolved_locally) |
| 61 | - local_p = false; |
| 62 | /* If PIC, then assume that any global name can be overridden by |
| 63 | symbols resolved from other modules. */ |
| 64 | else if (shlib) |
| 65 | -- |
| 66 | 1.7.10.4 |
| 67 | |