On 05/13/13 14:09, Jan Hubicka wrote:
Index: varasm.c
===================================================================

I think DECL_COMDAT is not what you really want to return true for.  So perhaps
you really want (TREE_PUBLIC (decl) && decl_binds_to_current_def_p)?

Like this?  This too fixes the problem, tested on powerpc-linux target.

nathan
2013-05-14  Nathan Sidwell  <nat...@codesourcery.com>

        gcc/
        * varasm.c (default_use_anchors_for_symbol_p): Use decl_replaceable_p.

        gcc/testsuite/
        * gcc.dg/visibility-21.c: New.

Index: varasm.c
===================================================================
--- varasm.c    (revision 198771)
+++ varasm.c    (working copy)
@@ -6580,9 +6580,9 @@ default_use_anchors_for_symbol_p (const_
   decl = SYMBOL_REF_DECL (symbol);
   if (decl && DECL_P (decl))
     {
-      /* Don't use section anchors for decls that might be defined by
-        other modules.  */
-      if (!targetm.binds_local_p (decl))
+      /* Don't use section anchors for decls that might be defined or
+        usurped by other modules.  */
+      if (TREE_PUBLIC (decl) && !decl_binds_to_current_def_p (decl))
        return false;
 
       /* Don't use section anchors for decls that will be placed in a
Index: testsuite/gcc.dg/visibility-21.c
===================================================================
--- testsuite/gcc.dg/visibility-21.c    (revision 0)
+++ testsuite/gcc.dg/visibility-21.c    (revision 0)
@@ -0,0 +1,13 @@
+/* Test visibility attribute on function definition. */
+/* { dg-do compile } */
+/* { dg-options "-O2 -fsection-anchors" } */
+/* { dg-require-visibility "" } */
+/* { dg-require-weak "" } */
+/* { dg-final { scan-assembler-not "ANCHOR" } } */
+
+int __attribute__((weak, visibility("hidden"))) weak_hidden[3];
+
+int *f_weak_hidden ()
+{
+  return weak_hidden;
+}

Reply via email to