===================================================================
@@ -2344,29 +2354,40 @@ write_symbol (struct lto_streamer_cache_
else
kind = GCCPK_DEF;
/* When something is defined, it should have a node attached.
FIXME: For fortran this is still not the case since wrapup global
decls is done after streaming. */
gcc_assert (alias || TREE_CODE (t) != FUNCTION_DECL
|| (cgraph_get_node (t)
&& 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;
- }
+ /* Immitate 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 visiblity
+ 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)