[Bug lto/85801] LTO linking fails to reconcile symbol from common an data sections (-fPIE -Wl,--as-needed -flto): unresolvable R_ARM_REL32 relocation against symbol `progname'

rguenth at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Thu May 17 07:28:00 GMT 2018


Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2018-05-17
                 CC|                            |hubicka at gcc dot gnu.org
     Ever confirmed|0                           |1

--- Comment #11 from Richard Biener <rguenth at gcc dot gnu.org> ---
(In reply to H.J. Lu from comment #10)
> For LDPR_PREVAILING_DEF_IRONLY_EXP, if the IR definition is common,
> compiler can't assume that the IR definition will prevail during the
> final link.  This is another COMMON symbol issue like
> https://sourceware.org/bugzilla/show_bug.cgi?id=23079

So the following might help (and shows bad abstraction of
resolution_to_local_definition_p which depends on symbol type).
Similar fixes would be needed for decl_binds_to_current_def_p
(somehow split out code computing defined_locally and resolved_locally
based on resolution from the former function).
In other places the cgraph code seems to honor the fact that a
common might be prevailed.


diff --git a/gcc/varasm.c b/gcc/varasm.c
index 85296b4a2ec..1021237389e 100644
--- a/gcc/varasm.c
+++ b/gcc/varasm.c
@@ -7075,7 +7075,9 @@ default_binds_local_p_3 (const_tree exp, bool shlib, bool
        defined_locally = true;
       if (node->can_be_discarded_p ())
-      else if (resolution_to_local_definition_p (node->resolution))
+      else if (resolution_to_local_definition_p (node->resolution)
+              && (defined_locally
+                  || node->resolution != LDPR_PREVAILING_DEF_IRONLY_EXP))
        defined_locally = resolved_locally = true;
       else if (resolution_local_p (node->resolution))
        resolved_locally = true;

More information about the Gcc-bugs mailing list