OSDN Git Service

* lto-streamer-out.c (write_symbol): Fix visibilities of external
authorhubicka <hubicka@138bc75d-0d04-0410-961f-82ee72b054a4>
Sat, 24 Jul 2010 01:04:29 +0000 (01:04 +0000)
committerhubicka <hubicka@138bc75d-0d04-0410-961f-82ee72b054a4>
Sat, 24 Jul 2010 01:04:29 +0000 (01:04 +0000)
references.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@162497 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/ChangeLog
gcc/lto-streamer-out.c

index 3b9aa26..cfdd938 100644 (file)
@@ -1,3 +1,8 @@
+2010-07-23  Jan Hubicka  <jh@suse.cz>
+
+       * lto-streamer-out.c (write_symbol): Fix visibilities of external
+       references.
+
 2010-07-23  Le-Chun Wu  <lcwu@google.com>
 
        * omega.c (omega_eliminate_redundant): Remove a self-assign statement.
index c96c13a..98d9442 100644 (file)
@@ -2352,21 +2352,32 @@ write_symbol (struct lto_streamer_cache_d *cache,
                      && cgraph_get_node (t)->analyzed));
     }
 
-  switch (DECL_VISIBILITY(t))
-    {
-    case VISIBILITY_DEFAULT:
-      visibility = GCCPV_DEFAULT;
-      break;
-    case VISIBILITY_PROTECTED:
-      visibility = GCCPV_PROTECTED;
-      break;
-    case VISIBILITY_HIDDEN:
-      visibility = GCCPV_HIDDEN;
-      break;
-    case VISIBILITY_INTERNAL:
-      visibility = GCCPV_INTERNAL;
-      break;
-    }
+  /* Imitate what default_elf_asm_output_external do.
+     When symbol is external, we need to output it with DEFAULT visibility
+     when compiling with -fvisibility=default, while with HIDDEN visibility
+     when symbol has attribute (visibility("hidden")) specified.
+     targetm.binds_local_p check DECL_VISIBILITY_SPECIFIED and gets this
+     right. */
+     
+  if (DECL_EXTERNAL (t)
+      && !targetm.binds_local_p (t))
+    visibility = GCCPV_DEFAULT;
+  else
+    switch (DECL_VISIBILITY(t))
+      {
+      case VISIBILITY_DEFAULT:
+       visibility = GCCPV_DEFAULT;
+       break;
+      case VISIBILITY_PROTECTED:
+       visibility = GCCPV_PROTECTED;
+       break;
+      case VISIBILITY_HIDDEN:
+       visibility = GCCPV_HIDDEN;
+       break;
+      case VISIBILITY_INTERNAL:
+       visibility = GCCPV_INTERNAL;
+       break;
+      }
 
   if (kind == GCCPK_COMMON
       && DECL_SIZE (t)