@@ -6826,7 +6826,15 @@ default_binds_local_p_1 (const_tree exp, int shlib)
&& (TREE_STATIC (exp) || DECL_EXTERNAL (exp)))
{
varpool_node *vnode = varpool_node::get (exp);
- if (vnode && (resolution_local_p (vnode->resolution) || vnode->in_other_partition))
+ /* If not building shared library, common or initialized symbols
+ are also resolved locally, regardless they are weak or not. */
+ if ((!shlib
+ && (DECL_COMMON (exp)
+ || (DECL_INITIAL (exp) != NULL
+ && (in_lto_p
+ || DECL_INITIAL (exp) != error_mark_node))))
+ || (vnode && (resolution_local_p (vnode->resolution)
+ || vnode->in_other_partition)))
resolved_locally = true;
if (vnode
&& resolution_to_local_definition_p (vnode->resolution))