This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug target/65780] [5 Regression] Uninitialized common handling in executables


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65780

--- Comment #40 from hjl at gcc dot gnu.org <hjl at gcc dot gnu.org> ---
Author: hjl
Date: Fri Apr 17 16:36:22 2015
New Revision: 222185

URL: https://gcc.gnu.org/viewcvs?rev=222185&root=gcc&view=rev
Log:
Properly handle uninitialized common symbol

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 the linker can guarantee that an uninitialized
common symbol in the executable will still be defined (through COPY
relocation) in the executable.  If common symbol is local to executable,
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.

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.

Added:
    branches/gcc-5-branch/gcc/testsuite/gcc.dg/pr65780-1.c
    branches/gcc-5-branch/gcc/testsuite/gcc.dg/pr65780-2.c
    branches/gcc-5-branch/gcc/testsuite/gcc.target/i386/pr32219-9.c
Modified:
    branches/gcc-5-branch/gcc/ChangeLog
    branches/gcc-5-branch/gcc/config/i386/i386.c
    branches/gcc-5-branch/gcc/output.h
    branches/gcc-5-branch/gcc/testsuite/ChangeLog
    branches/gcc-5-branch/gcc/testsuite/gcc.target/i386/pr32219-1.c
    branches/gcc-5-branch/gcc/testsuite/gcc.target/i386/pr64317.c
    branches/gcc-5-branch/gcc/varasm.c


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]