diff options
author | H.J. Lu <hjl.tools@gmail.com> | 2015-04-16 05:16:09 -0700 |
---|---|---|
committer | H.J. Lu <hjl.tools@gmail.com> | 2015-04-16 11:32:02 -0700 |
commit | 9d5cbde13160e61eabd6eb35083dfdc5608b4d1e (patch) | |
tree | 46ef3cdcb2b67477db97b1056fcc1cd589006cd9 /gcc/testsuite/gcc.dg/pr65780-1.c | |
parent | 7f1296d948811370d7d30f71f27c1ccb6d637bcc (diff) | |
download | gcc-9d5cbde13160e61eabd6eb35083dfdc5608b4d1e.tar.gz |
Properly handle uninitialized common symbolhjl/pr65780/master
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.
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.
Diffstat (limited to 'gcc/testsuite/gcc.dg/pr65780-1.c')
-rw-r--r-- | gcc/testsuite/gcc.dg/pr65780-1.c | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/gcc/testsuite/gcc.dg/pr65780-1.c b/gcc/testsuite/gcc.dg/pr65780-1.c new file mode 100644 index 00000000000..b586211b649 --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr65780-1.c @@ -0,0 +1,12 @@ +/* PR target/65780 */ +/* { dg-do link { target *-*-linux* *-*-gnu* } } */ +/* { dg-options "-O2" } */ + +int optopt; + +int +main () +{ + optopt = 4; + return 0; +} |