This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH] PR32219
- From: Bernhard Reutner-Fischer <rep dot dot dot nop at gmail dot com>
- To: gcc-patches at gcc dot gnu dot org
- Cc: rguenth at gcc dot gnu dot org, Bernhard Reutner-Fischer <rep dot dot dot nop at gmail dot com>
- Date: Tue, 16 Mar 2010 14:42:27 +0100
- Subject: [PATCH] PR32219
Hi,
As suggested by richi.
regtested on i686-linux-gnu with all default languages and no regressions.
Ok for trunk?
gcc/ChangeLog
2010-03-15 Bernhard Reutner-Fischer <aldot@gcc.gnu.org>
PR target/32219
* varasm.c (default_binds_local_p_1): Weak data is not local.
gcc/testsuite/ChangeLog
2010-03-15 Bernhard Reutner-Fischer <aldot@gcc.gnu.org>
PR target/32219
* gcc.dg/visibility-21.c: New test.
Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
---
gcc/testsuite/gcc.dg/visibility-21.c | 14 ++++++++++++++
gcc/varasm.c | 8 ++++----
2 files changed, 18 insertions(+), 4 deletions(-)
create mode 100644 gcc/testsuite/gcc.dg/visibility-21.c
diff --git a/gcc/testsuite/gcc.dg/visibility-21.c b/gcc/testsuite/gcc.dg/visibility-21.c
new file mode 100644
index 0000000..be7deda
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/visibility-21.c
@@ -0,0 +1,14 @@
+/* PR target/32219 */
+/* { dg-do run } */
+/* { dg-require-visibility "" } */
+/* { dg-options "-fPIC" { target fpic } } */
+
+extern void f() __attribute__((weak,visibility("hidden")));
+extern int puts( char const* );
+int main()
+{
+ if (f)
+ f();
+ return 0;
+}
+
diff --git a/gcc/varasm.c b/gcc/varasm.c
index 6b8222f..6b9269a 100644
--- a/gcc/varasm.c
+++ b/gcc/varasm.c
@@ -6613,6 +6613,10 @@ default_binds_local_p_1 (const_tree exp, int shlib)
/* Static variables are always local. */
else if (! TREE_PUBLIC (exp))
local_p = true;
+ /* Weak data can be overridden by a strong symbol
+ in another module and so are not local. */
+ else if (DECL_WEAK (exp))
+ local_p = false;
/* A variable is local if the user has said explicitly that it will
be. */
else if (DECL_VISIBILITY_SPECIFIED (exp)
@@ -6625,10 +6629,6 @@ default_binds_local_p_1 (const_tree exp, int shlib)
local. */
else if (DECL_VISIBILITY (exp) != VISIBILITY_DEFAULT)
local_p = true;
- /* Default visibility weak data can be overridden by a strong symbol
- in another module and so are not local. */
- else if (DECL_WEAK (exp))
- local_p = false;
/* If PIC, then assume that any global name can be overridden by
symbols resolved from other modules, unless we are compiling with
-fwhole-program, which assumes that names are local. */
--
1.7.0