This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug target/65780] [5 Regression] Uninitialized common handling in executables
- From: "jakub at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Thu, 16 Apr 2015 07:33:26 +0000
- Subject: [Bug target/65780] [5 Regression] Uninitialized common handling in executables
- Auto-submitted: auto-generated
- References: <bug-65780-4 at http dot gcc dot gnu dot org/bugzilla/>
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65780
--- Comment #10 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
(In reply to H.J. Lu from comment #9)
> Created attachment 35327 [details]
> A different patch
>
> On x86, this issue only shows up with PIE. Here is a different
> patch to treat common symbol defined locally only if the backend
> passes true common_maybe_local. For x86-64, it is true only if
> HAVE_LD_PIE_COPYRELOC is 1. For i386, it is always false. If
> we aren't building PIE, common_maybe_local is true or false
> doesn't make a difference for x86 since the common symbol is
> always referenced normally with copy reloc. For PIE on x86-64,
> common symbol is local only if HAVE_LD_PIE_COPYRELOC is 1.
+
+ /* For common symbol, it is defined locally only if common_maybe_local
+ is true. */
+ bool defined_locally = (!DECL_EXTERNAL (exp)
+ && (!DECL_COMMON (exp) || common_maybe_local));
I think better would be:
bool uninited_common = (DECL_COMMON (exp)
&& (DECL_INITIAL (exp) == NULL
|| (!in_lto_p && DECL_INITIAL (exp) ==
error_mark_node)));
/* For common symbol, it is defined locally only if common_maybe_local
is true. */
bool defined_locally = (!DECL_EXTERNAL (exp) && (!uninited_common ||
common_maybe_local));
...
and then use
/* Uninitialized COMMON variable may be unified with symbols
resolved from other modules. */
if (uninited_common && !resolved_locally)
return false;