aboutsummaryrefslogtreecommitdiff
path: root/gcc/config
diff options
context:
space:
mode:
authorAndrew Pinski <pinskia@physics.uc.edu>2004-12-17 00:25:16 +0000
committerAndrew Pinski <pinskia@gcc.gnu.org>2004-12-16 16:25:16 -0800
commit16515e5c198127bd9d9c4e313b6e061f29c3e3d5 (patch)
treec058662cf524322a32e75bb25f7fb217c41f764e /gcc/config
parent67ba1be668b25ae8d52d6e22d4a78f9b8f197cc3 (diff)
downloadgcc-16515e5c198127bd9d9c4e313b6e061f29c3e3d5.zip
gcc-16515e5c198127bd9d9c4e313b6e061f29c3e3d5.tar.gz
gcc-16515e5c198127bd9d9c4e313b6e061f29c3e3d5.tar.bz2
re PR target/19041 (-fvisibility=hidden causes bad codegen for common symbols)
2004-12-16 Andrew Pinski <pinskia@physics.uc.edu> PR target/19041 * config/darwin.c (machopic_symbol_defined_p): Return false if the binds local and is a common symbol. 2004-12-16 Andrew Pinski <pinskia@physics.uc.edu> PR target/19041 * gcc.dg/visibility-c.c: New test. From-SVN: r92292
Diffstat (limited to 'gcc/config')
-rw-r--r--gcc/config/darwin.c28
1 files changed, 21 insertions, 7 deletions
diff --git a/gcc/config/darwin.c b/gcc/config/darwin.c
index e4a3997..7b4943b 100644
--- a/gcc/config/darwin.c
+++ b/gcc/config/darwin.c
@@ -90,16 +90,30 @@ name_needs_quotes (const char *name)
return 0;
}
-/*
- * flag_pic = 1 ... generate only indirections
- * flag_pic = 2 ... generate indirections and pure code
- */
-
+/* Return true if SYM_REF can be used without an indirection. */
static int
machopic_symbol_defined_p (rtx sym_ref)
{
- return (SYMBOL_REF_FLAGS (sym_ref) & MACHO_SYMBOL_FLAG_DEFINED)
- || (SYMBOL_REF_LOCAL_P (sym_ref) && ! SYMBOL_REF_EXTERNAL_P (sym_ref));
+ if (SYMBOL_REF_FLAGS (sym_ref) & MACHO_SYMBOL_FLAG_DEFINED)
+ return true;
+
+ /* If a symbol references local and is not an extern to this
+ file, then the symbol might be able to declared as defined. */
+ if (SYMBOL_REF_LOCAL_P (sym_ref) && ! SYMBOL_REF_EXTERNAL_P (sym_ref))
+ {
+ /* If the symbol references a variable and the variable is a
+ common symbol, then this symbol is not defined. */
+ if (SYMBOL_REF_FLAGS (sym_ref) & MACHO_SYMBOL_FLAG_VARIABLE)
+ {
+ tree decl = SYMBOL_REF_DECL (sym_ref);
+ if (!decl)
+ return true;
+ if (DECL_COMMON (decl))
+ return false;
+ }
+ return true;
+ }
+ return false;
}
/* This module assumes that (const (symbol_ref "foo")) is a legal pic