On Fri, Apr 17, 2015 at 9:12 AM, Jeff Law <l...@redhat.com> wrote: > On 04/16/2015 12:57 PM, H.J. Lu wrote: >> >> Uninitialized common symbol behavior in executables is target and linker >> dependent. default_binds_local_p_3 is made public and updated to take an >> argument to indicate if common symbol may be local. If common symbol >> may be local, default_binds_local_p_3 will treat non-external variable >> as defined locally. default_binds_local_p_2 is changed to treat common >> symbol as local for non-PIE binaries. >> >> For i386, common symbol is local only for non-PIE binaries. For x86-64, >> common symbol is local only for non-PIE binaries or linker supports copy >> reloc in PIE binaries. If a target treats common symbol as local only >> for non-PIE binaries, it can define TARGET_BINDS_LOCAL_P as >> default_binds_local_p_2. >> >> Tested on Linux/x86-64 using -m32 with binutils master and 2.24. OK for >> trunk and 5 branch? >> >> >> H.J. >> --- >> gcc/ >> >> PR target/65780 >> * output.h (default_binds_local_p_3): New. >> * varasm.c (default_binds_local_p_3): Make it public. Take an >> argument to indicate if common symbol may be local. If common >> symbol may be local, treat non-external variable as defined >> locally. >> (default_binds_local_p_2): Pass !flag_pic to >> default_binds_local_p_3. >> (default_binds_local_p_1): Pass false to default_binds_local_p_3. >> * config/i386/i386.c (ix86_binds_local_p): New. >> (TARGET_BINDS_LOCAL_P): Replace default_binds_local_p_2 with >> ix86_binds_local_p. >> >> gcc/testsuite/ >> >> PR target/65780 >> * gcc.dg/pr65780-1.c: New test. >> * gcc.dg/pr65780-2.c: Likewise. >> * gcc.target/i386/pr32219-9.c: Likewise. >> * gcc.target/i386/pr32219-1.c (xxx): Make it initialized common >> symbol. >> * gcc.target/i386/pr64317.c (c): Initialize. > > I approved the slightly different version of this attached to pr 65780, > c#35. >
This patch is needed for MacOS and Windows. OK for trunk and 5 branch? -- H.J.
* config/i386/i386.c (ix86_binds_local_p): Define only if TARGET_MACHO and TARGET_DLLIMPORT_DECL_ATTRIBUTES are false. diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c index da69186..d870ab8 100644 --- a/gcc/config/i386/i386.c +++ b/gcc/config/i386/i386.c @@ -51737,6 +51737,7 @@ ix86_initialize_bounds (tree var, tree lb, tree ub, tree *stmts) return 2; } +#if !TARGET_MACHO && !TARGET_DLLIMPORT_DECL_ATTRIBUTES /* For i386, common symbol is local only for non-PIE binaries. For x86-64, common symbol is local only for non-PIE binaries or linker supports copy reloc in PIE binaries. */ @@ -51749,6 +51750,7 @@ ix86_binds_local_p (const_tree exp) || (TARGET_64BIT && HAVE_LD_PIE_COPYRELOC != 0))); } +#endif /* Initialize the GCC target structure. */ #undef TARGET_RETURN_IN_MEMORY