Commit a5eef8e9 by H.J. Lu Committed by H.J. Lu

Add default_binds_local_p_2 and use it for x86

Protected data symbol means that it can't be pre-emptied.  It doesn't mean
its address won't be external.  This is true for pointer to protected
function.  With copy relocation, address of protected data defined in the
shared library may also be external.  We only know that for sure at
run-time.  TARGET_BINDS_LOCAL_P should return false on protected data
symbol.

gcc/

	PR target/65248
	* output.h (default_binds_local_p_2): New.
	* varasm.c (default_binds_local_p_2): Renamed to ...
	(default_binds_local_p_3): This.  Don't return true on protected
	data symbol if protected data may be external.
	(default_binds_local_p): Use default_binds_local_p_3.
	(default_binds_local_p_1): Likewise.
	(default_binds_local_p_2): New.
	* config/i386/i386.c (TARGET_BINDS_LOCAL_P): Set to
	default_binds_local_p_2 if TARGET_MACHO is undefined.

gcc/testsuite/

	PR target/65248
	* gcc.target/i386/pr65248-1.c: New file.
	* gcc.target/i386/pr65248-2.c: Likewise.
	* gcc.target/i386/pr65248-3.c: Likewise.
	* gcc.target/i386/pr65248-4.c: Likewise.

From-SVN: r221742
parent f21a5899
2015-03-27 H.J. Lu <hongjiu.lu@intel.com>
PR target/65248
* output.h (default_binds_local_p_2): New.
* varasm.c (default_binds_local_p_2): Renamed to ...
(default_binds_local_p_3): This. Don't return true on protected
data symbol if protected data may be external.
(default_binds_local_p): Use default_binds_local_p_3.
(default_binds_local_p_1): Likewise.
(default_binds_local_p_2): New.
* config/i386/i386.c (TARGET_BINDS_LOCAL_P): Set to
default_binds_local_p_2 if TARGET_MACHO is undefined.
2015-03-27 Jakub Jelinek <jakub@redhat.com> 2015-03-27 Jakub Jelinek <jakub@redhat.com>
PR target/65593 PR target/65593
......
...@@ -51900,6 +51900,9 @@ ix86_initialize_bounds (tree var, tree lb, tree ub, tree *stmts) ...@@ -51900,6 +51900,9 @@ ix86_initialize_bounds (tree var, tree lb, tree ub, tree *stmts)
#if TARGET_MACHO #if TARGET_MACHO
#undef TARGET_BINDS_LOCAL_P #undef TARGET_BINDS_LOCAL_P
#define TARGET_BINDS_LOCAL_P darwin_binds_local_p #define TARGET_BINDS_LOCAL_P darwin_binds_local_p
#else
#undef TARGET_BINDS_LOCAL_P
#define TARGET_BINDS_LOCAL_P default_binds_local_p_2
#endif #endif
#if TARGET_DLLIMPORT_DECL_ATTRIBUTES #if TARGET_DLLIMPORT_DECL_ATTRIBUTES
#undef TARGET_BINDS_LOCAL_P #undef TARGET_BINDS_LOCAL_P
...@@ -586,6 +586,7 @@ extern void default_asm_output_anchor (rtx); ...@@ -586,6 +586,7 @@ extern void default_asm_output_anchor (rtx);
extern bool default_use_anchors_for_symbol_p (const_rtx); extern bool default_use_anchors_for_symbol_p (const_rtx);
extern bool default_binds_local_p (const_tree); extern bool default_binds_local_p (const_tree);
extern bool default_binds_local_p_1 (const_tree, int); extern bool default_binds_local_p_1 (const_tree, int);
extern bool default_binds_local_p_2 (const_tree);
extern void default_globalize_label (FILE *, const char *); extern void default_globalize_label (FILE *, const char *);
extern void default_globalize_decl_name (FILE *, tree); extern void default_globalize_decl_name (FILE *, tree);
extern void default_emit_unwind_label (FILE *, tree, int, int); extern void default_emit_unwind_label (FILE *, tree, int, int);
......
2015-03-27 H.J. Lu <hongjiu.lu@intel.com>
PR target/65248
* gcc.target/i386/pr65248-1.c: New file.
* gcc.target/i386/pr65248-2.c: Likewise.
* gcc.target/i386/pr65248-3.c: Likewise.
* gcc.target/i386/pr65248-4.c: Likewise.
2015-03-27 Jakub Jelinek <jakub@redhat.com> 2015-03-27 Jakub Jelinek <jakub@redhat.com>
PR target/65593 PR target/65593
......
/* { dg-do compile { target *-*-linux* } } */
/* { dg-options "-O2 -fpic" } */
/* Common symbol with -fpic. */
__attribute__((visibility("protected")))
int xxx;
int
foo ()
{
return xxx;
}
/* { dg-final { scan-assembler-not "xxx\\(%rip\\)" { target { ! ia32 } } } } */
/* { dg-final { scan-assembler "xxx@GOTPCREL" { target { ! ia32 } } } } */
/* { dg-final { scan-assembler-not "xxx@GOTOFF" { target ia32 } } } */
/* { dg-final { scan-assembler "xxx@GOT\\(" { target ia32 } } } */
/* { dg-do compile { target *-*-linux* } } */
/* { dg-options "-O2 -fpic" } */
/* Weak common symbol with -fpic. */
__attribute__((weak, visibility("protected")))
int xxx;
int
foo ()
{
return xxx;
}
/* { dg-final { scan-assembler-not "xxx\\(%rip\\)" { target { ! ia32 } } } } */
/* { dg-final { scan-assembler "xxx@GOTPCREL" { target { ! ia32 } } } } */
/* { dg-final { scan-assembler-not "xxx@GOTOFF" { target ia32 } } } */
/* { dg-final { scan-assembler "xxx@GOT\\(" { target ia32 } } } */
/* { dg-do compile { target *-*-linux* } } */
/* { dg-options "-O2 -fpic" } */
/* Initialized symbol with -fpic. */
__attribute__((visibility("protected")))
int xxx = -1;
int
foo ()
{
return xxx;
}
/* { dg-final { scan-assembler-not "xxx\\(%rip\\)" { target { ! ia32 } } } } */
/* { dg-final { scan-assembler "xxx@GOTPCREL" { target { ! ia32 } } } } */
/* { dg-final { scan-assembler-not "xxx@GOTOFF" { target ia32 } } } */
/* { dg-final { scan-assembler "xxx@GOT\\(" { target ia32 } } } */
/* { dg-do compile { target *-*-linux* } } */
/* { dg-options "-O2 -fpic" } */
/* Weak initialized symbol with -fpic. */
__attribute__((weak, visibility("protected")))
int xxx = -1;
int
foo ()
{
return xxx;
}
/* { dg-final { scan-assembler-not "xxx\\(%rip\\)" { target { ! ia32 } } } } */
/* { dg-final { scan-assembler "xxx@GOTPCREL" { target { ! ia32 } } } } */
/* { dg-final { scan-assembler-not "xxx@GOTOFF" { target ia32 } } } */
/* { dg-final { scan-assembler "xxx@GOT\\(" { target ia32 } } } */
...@@ -6809,7 +6809,8 @@ resolution_local_p (enum ld_plugin_symbol_resolution resolution) ...@@ -6809,7 +6809,8 @@ resolution_local_p (enum ld_plugin_symbol_resolution resolution)
} }
static bool static bool
default_binds_local_p_2 (const_tree exp, bool shlib, bool weak_dominate) default_binds_local_p_3 (const_tree exp, bool shlib, bool weak_dominate,
bool extern_protected_data)
{ {
/* A non-decl is an entry in the constant pool. */ /* A non-decl is an entry in the constant pool. */
if (!DECL_P (exp)) if (!DECL_P (exp))
...@@ -6855,6 +6856,9 @@ default_binds_local_p_2 (const_tree exp, bool shlib, bool weak_dominate) ...@@ -6855,6 +6856,9 @@ default_binds_local_p_2 (const_tree exp, bool shlib, bool weak_dominate)
or if we have a definition for the symbol. We cannot infer visibility or if we have a definition for the symbol. We cannot infer visibility
for undefined symbols. */ for undefined symbols. */
if (DECL_VISIBILITY (exp) != VISIBILITY_DEFAULT if (DECL_VISIBILITY (exp) != VISIBILITY_DEFAULT
&& (TREE_CODE (exp) == FUNCTION_DECL
|| !extern_protected_data
|| DECL_VISIBILITY (exp) != VISIBILITY_PROTECTED)
&& (DECL_VISIBILITY_SPECIFIED (exp) || defined_locally)) && (DECL_VISIBILITY_SPECIFIED (exp) || defined_locally))
return true; return true;
...@@ -6890,13 +6894,21 @@ default_binds_local_p_2 (const_tree exp, bool shlib, bool weak_dominate) ...@@ -6890,13 +6894,21 @@ default_binds_local_p_2 (const_tree exp, bool shlib, bool weak_dominate)
bool bool
default_binds_local_p (const_tree exp) default_binds_local_p (const_tree exp)
{ {
return default_binds_local_p_2 (exp, flag_shlib != 0, true); return default_binds_local_p_3 (exp, flag_shlib != 0, true, false);
}
/* Similar to default_binds_local_p, but protected data may be
external. */
bool
default_binds_local_p_2 (const_tree exp)
{
return default_binds_local_p_3 (exp, flag_shlib != 0, true, true);
} }
bool bool
default_binds_local_p_1 (const_tree exp, int shlib) default_binds_local_p_1 (const_tree exp, int shlib)
{ {
return default_binds_local_p_2 (exp, shlib != 0, false); return default_binds_local_p_3 (exp, shlib != 0, false, false);
} }
/* Return true when references to DECL must bind to current definition in /* Return true when references to DECL must bind to current definition in
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment