cfgexpand.c (record_or_union_type_has_array_p): New function.
2013-05-07 Han Shen <shenhan@google.com> gcc/ * cfgexpand.c (record_or_union_type_has_array_p): New function. (expand_used_vars): Add logic handling '-fstack-protector-strong'. * common.opt (fstack-protector-strong): New option. * doc/cpp.texi (__SSP_STRONG__): New builtin "__SSP_STRONG__". * doc/invoke.texi (Optimization Options): Document "-fstack-protector-strong". * gcc.c (LINK_SSP_SPEC): Add 'fstack-protector-strong'. gcc/testsuite/ * gcc.dg/fstack-protector-strong.c: New. * g++.dg/fstack-protector-strong.C: New. gcc/c-family/ * c-cppbuiltin.c (c_cpp_builtins): Added "__SSP_STRONG__=3". From-SVN: r198699
This commit is contained in:
parent
703f140fb8
commit
f6bc1c4a12
|
@ -1,3 +1,13 @@
|
||||||
|
2013-05-07 Han Shen <shenhan@google.com>
|
||||||
|
|
||||||
|
* cfgexpand.c (record_or_union_type_has_array_p): New function.
|
||||||
|
(expand_used_vars): Add logic handling '-fstack-protector-strong'.
|
||||||
|
* common.opt (fstack-protector-strong): New option.
|
||||||
|
* doc/cpp.texi (__SSP_STRONG__): New builtin "__SSP_STRONG__".
|
||||||
|
* doc/invoke.texi (Optimization Options): Document
|
||||||
|
"-fstack-protector-strong".
|
||||||
|
* gcc.c (LINK_SSP_SPEC): Add 'fstack-protector-strong'.
|
||||||
|
|
||||||
2013-05-06 Steven Bosscher <steven@gcc.gnu.org>
|
2013-05-06 Steven Bosscher <steven@gcc.gnu.org>
|
||||||
|
|
||||||
* config/mips/mips.c (mips_machine_reorg2): Return 0.
|
* config/mips/mips.c (mips_machine_reorg2): Return 0.
|
||||||
|
|
|
@ -1,3 +1,7 @@
|
||||||
|
2013-05-07 Han Shen <shenhan@google.com>
|
||||||
|
|
||||||
|
* c-cppbuiltin.c (c_cpp_builtins): Added "__SSP_STRONG__=3".
|
||||||
|
|
||||||
2013-04-29 Senthil Kumar Selvaraj <senthil_kumar.selvaraj@atmel.com>
|
2013-04-29 Senthil Kumar Selvaraj <senthil_kumar.selvaraj@atmel.com>
|
||||||
|
|
||||||
* c-common.c (check_user_alignment): Emit error for negative values.
|
* c-common.c (check_user_alignment): Emit error for negative values.
|
||||||
|
|
|
@ -888,6 +888,8 @@ c_cpp_builtins (cpp_reader *pfile)
|
||||||
/* Make the choice of the stack protector runtime visible to source code.
|
/* Make the choice of the stack protector runtime visible to source code.
|
||||||
The macro names and values here were chosen for compatibility with an
|
The macro names and values here were chosen for compatibility with an
|
||||||
earlier implementation, i.e. ProPolice. */
|
earlier implementation, i.e. ProPolice. */
|
||||||
|
if (flag_stack_protect == 3)
|
||||||
|
cpp_define (pfile, "__SSP_STRONG__=3");
|
||||||
if (flag_stack_protect == 2)
|
if (flag_stack_protect == 2)
|
||||||
cpp_define (pfile, "__SSP_ALL__=2");
|
cpp_define (pfile, "__SSP_ALL__=2");
|
||||||
else if (flag_stack_protect == 1)
|
else if (flag_stack_protect == 1)
|
||||||
|
|
|
@ -1291,6 +1291,12 @@ clear_tree_used (tree block)
|
||||||
clear_tree_used (t);
|
clear_tree_used (t);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
enum {
|
||||||
|
SPCT_FLAG_DEFAULT = 1,
|
||||||
|
SPCT_FLAG_ALL = 2,
|
||||||
|
SPCT_FLAG_STRONG = 3
|
||||||
|
};
|
||||||
|
|
||||||
/* Examine TYPE and determine a bit mask of the following features. */
|
/* Examine TYPE and determine a bit mask of the following features. */
|
||||||
|
|
||||||
#define SPCT_HAS_LARGE_CHAR_ARRAY 1
|
#define SPCT_HAS_LARGE_CHAR_ARRAY 1
|
||||||
|
@ -1360,7 +1366,8 @@ stack_protect_decl_phase (tree decl)
|
||||||
if (bits & SPCT_HAS_SMALL_CHAR_ARRAY)
|
if (bits & SPCT_HAS_SMALL_CHAR_ARRAY)
|
||||||
has_short_buffer = true;
|
has_short_buffer = true;
|
||||||
|
|
||||||
if (flag_stack_protect == 2)
|
if (flag_stack_protect == SPCT_FLAG_ALL
|
||||||
|
|| flag_stack_protect == SPCT_FLAG_STRONG)
|
||||||
{
|
{
|
||||||
if ((bits & (SPCT_HAS_SMALL_CHAR_ARRAY | SPCT_HAS_LARGE_CHAR_ARRAY))
|
if ((bits & (SPCT_HAS_SMALL_CHAR_ARRAY | SPCT_HAS_LARGE_CHAR_ARRAY))
|
||||||
&& !(bits & SPCT_HAS_AGGREGATE))
|
&& !(bits & SPCT_HAS_AGGREGATE))
|
||||||
|
@ -1514,6 +1521,27 @@ estimated_stack_frame_size (struct cgraph_node *node)
|
||||||
return size;
|
return size;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Helper routine to check if a record or union contains an array field. */
|
||||||
|
|
||||||
|
static int
|
||||||
|
record_or_union_type_has_array_p (const_tree tree_type)
|
||||||
|
{
|
||||||
|
tree fields = TYPE_FIELDS (tree_type);
|
||||||
|
tree f;
|
||||||
|
|
||||||
|
for (f = fields; f; f = DECL_CHAIN (f))
|
||||||
|
if (TREE_CODE (f) == FIELD_DECL)
|
||||||
|
{
|
||||||
|
tree field_type = TREE_TYPE (f);
|
||||||
|
if (RECORD_OR_UNION_TYPE_P (field_type)
|
||||||
|
&& record_or_union_type_has_array_p (field_type))
|
||||||
|
return 1;
|
||||||
|
if (TREE_CODE (field_type) == ARRAY_TYPE)
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
/* Expand all variables used in the function. */
|
/* Expand all variables used in the function. */
|
||||||
|
|
||||||
static rtx
|
static rtx
|
||||||
|
@ -1525,6 +1553,7 @@ expand_used_vars (void)
|
||||||
struct pointer_map_t *ssa_name_decls;
|
struct pointer_map_t *ssa_name_decls;
|
||||||
unsigned i;
|
unsigned i;
|
||||||
unsigned len;
|
unsigned len;
|
||||||
|
bool gen_stack_protect_signal = false;
|
||||||
|
|
||||||
/* Compute the phase of the stack frame for this function. */
|
/* Compute the phase of the stack frame for this function. */
|
||||||
{
|
{
|
||||||
|
@ -1576,6 +1605,24 @@ expand_used_vars (void)
|
||||||
}
|
}
|
||||||
pointer_map_destroy (ssa_name_decls);
|
pointer_map_destroy (ssa_name_decls);
|
||||||
|
|
||||||
|
if (flag_stack_protect == SPCT_FLAG_STRONG)
|
||||||
|
FOR_EACH_LOCAL_DECL (cfun, i, var)
|
||||||
|
if (!is_global_var (var))
|
||||||
|
{
|
||||||
|
tree var_type = TREE_TYPE (var);
|
||||||
|
/* Examine local referenced variables that have their addresses taken,
|
||||||
|
contain an array, or are arrays. */
|
||||||
|
if (TREE_CODE (var) == VAR_DECL
|
||||||
|
&& (TREE_CODE (var_type) == ARRAY_TYPE
|
||||||
|
|| TREE_ADDRESSABLE (var)
|
||||||
|
|| (RECORD_OR_UNION_TYPE_P (var_type)
|
||||||
|
&& record_or_union_type_has_array_p (var_type))))
|
||||||
|
{
|
||||||
|
gen_stack_protect_signal = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* At this point all variables on the local_decls with TREE_USED
|
/* At this point all variables on the local_decls with TREE_USED
|
||||||
set are not associated with any block scope. Lay them out. */
|
set are not associated with any block scope. Lay them out. */
|
||||||
|
|
||||||
|
@ -1662,12 +1709,26 @@ expand_used_vars (void)
|
||||||
dump_stack_var_partition ();
|
dump_stack_var_partition ();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* There are several conditions under which we should create a
|
switch (flag_stack_protect)
|
||||||
stack guard: protect-all, alloca used, protected decls present. */
|
{
|
||||||
if (flag_stack_protect == 2
|
case SPCT_FLAG_ALL:
|
||||||
|| (flag_stack_protect
|
create_stack_guard ();
|
||||||
&& (cfun->calls_alloca || has_protected_decls)))
|
break;
|
||||||
create_stack_guard ();
|
|
||||||
|
case SPCT_FLAG_STRONG:
|
||||||
|
if (gen_stack_protect_signal
|
||||||
|
|| cfun->calls_alloca || has_protected_decls)
|
||||||
|
create_stack_guard ();
|
||||||
|
break;
|
||||||
|
|
||||||
|
case SPCT_FLAG_DEFAULT:
|
||||||
|
if (cfun->calls_alloca || has_protected_decls)
|
||||||
|
create_stack_guard();
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
;
|
||||||
|
}
|
||||||
|
|
||||||
/* Assign rtl to each variable based on these partitions. */
|
/* Assign rtl to each variable based on these partitions. */
|
||||||
if (stack_vars_num > 0)
|
if (stack_vars_num > 0)
|
||||||
|
|
|
@ -1942,6 +1942,10 @@ fstack-protector-all
|
||||||
Common Report RejectNegative Var(flag_stack_protect, 2)
|
Common Report RejectNegative Var(flag_stack_protect, 2)
|
||||||
Use a stack protection method for every function
|
Use a stack protection method for every function
|
||||||
|
|
||||||
|
fstack-protector-strong
|
||||||
|
Common Report RejectNegative Var(flag_stack_protect, 3)
|
||||||
|
Use a smart stack protection method for certain functions
|
||||||
|
|
||||||
fstack-usage
|
fstack-usage
|
||||||
Common RejectNegative Var(flag_stack_usage)
|
Common RejectNegative Var(flag_stack_usage)
|
||||||
Output stack usage information on a per-function basis
|
Output stack usage information on a per-function basis
|
||||||
|
|
|
@ -2349,6 +2349,10 @@ use.
|
||||||
This macro is defined, with value 2, when @option{-fstack-protector-all} is
|
This macro is defined, with value 2, when @option{-fstack-protector-all} is
|
||||||
in use.
|
in use.
|
||||||
|
|
||||||
|
@item __SSP_STRONG__
|
||||||
|
This macro is defined, with value 3, when @option{-fstack-protector-strong} is
|
||||||
|
in use.
|
||||||
|
|
||||||
@item __SANITIZE_ADDRESS__
|
@item __SANITIZE_ADDRESS__
|
||||||
This macro is defined, with value 1, when @option{-fsanitize=address} is
|
This macro is defined, with value 1, when @option{-fsanitize=address} is
|
||||||
in use.
|
in use.
|
||||||
|
|
|
@ -407,8 +407,8 @@ Objective-C and Objective-C++ Dialects}.
|
||||||
-fsel-sched-pipelining -fsel-sched-pipelining-outer-loops @gol
|
-fsel-sched-pipelining -fsel-sched-pipelining-outer-loops @gol
|
||||||
-fshrink-wrap -fsignaling-nans -fsingle-precision-constant @gol
|
-fshrink-wrap -fsignaling-nans -fsingle-precision-constant @gol
|
||||||
-fsplit-ivs-in-unroller -fsplit-wide-types -fstack-protector @gol
|
-fsplit-ivs-in-unroller -fsplit-wide-types -fstack-protector @gol
|
||||||
-fstack-protector-all -fstrict-aliasing -fstrict-overflow @gol
|
-fstack-protector-all -fstack-protector-strong -fstrict-aliasing @gol
|
||||||
-fthread-jumps -ftracer -ftree-bit-ccp @gol
|
-fstrict-overflow -fthread-jumps -ftracer -ftree-bit-ccp @gol
|
||||||
-ftree-builtin-call-dce -ftree-ccp -ftree-ch @gol
|
-ftree-builtin-call-dce -ftree-ccp -ftree-ch @gol
|
||||||
-ftree-coalesce-inline-vars -ftree-coalesce-vars -ftree-copy-prop @gol
|
-ftree-coalesce-inline-vars -ftree-coalesce-vars -ftree-copy-prop @gol
|
||||||
-ftree-copyrename -ftree-dce -ftree-dominator-opts -ftree-dse @gol
|
-ftree-copyrename -ftree-dce -ftree-dominator-opts -ftree-dse @gol
|
||||||
|
@ -8957,6 +8957,12 @@ If a guard check fails, an error message is printed and the program exits.
|
||||||
@opindex fstack-protector-all
|
@opindex fstack-protector-all
|
||||||
Like @option{-fstack-protector} except that all functions are protected.
|
Like @option{-fstack-protector} except that all functions are protected.
|
||||||
|
|
||||||
|
@item -fstack-protector-strong
|
||||||
|
@opindex fstack-protector-strong
|
||||||
|
Like @option{-fstack-protector} but includes additional functions to
|
||||||
|
be protected --- those that have local array definitions, or have
|
||||||
|
references to local frame addresses.
|
||||||
|
|
||||||
@item -fsection-anchors
|
@item -fsection-anchors
|
||||||
@opindex fsection-anchors
|
@opindex fsection-anchors
|
||||||
Try to reduce the number of symbolic address calculations by using
|
Try to reduce the number of symbolic address calculations by using
|
||||||
|
|
|
@ -655,7 +655,7 @@ proper position among the other output files. */
|
||||||
#ifdef TARGET_LIBC_PROVIDES_SSP
|
#ifdef TARGET_LIBC_PROVIDES_SSP
|
||||||
#define LINK_SSP_SPEC "%{fstack-protector:}"
|
#define LINK_SSP_SPEC "%{fstack-protector:}"
|
||||||
#else
|
#else
|
||||||
#define LINK_SSP_SPEC "%{fstack-protector|fstack-protector-all:-lssp_nonshared -lssp}"
|
#define LINK_SSP_SPEC "%{fstack-protector|fstack-protector-strong|fstack-protector-all:-lssp_nonshared -lssp}"
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,9 @@
|
||||||
|
2013-04-16 Han Shen <shenhan@google.com>
|
||||||
|
|
||||||
|
Test cases for '-fstack-protector-strong'.
|
||||||
|
* gcc.dg/fstack-protector-strong.c: New.
|
||||||
|
* g++.dg/fstack-protector-strong.C: New.
|
||||||
|
|
||||||
2013-05-07 Ian Bolton <ian.bolton@arm.com>
|
2013-05-07 Ian Bolton <ian.bolton@arm.com>
|
||||||
|
|
||||||
* gcc.target/aarch64/ands_1.c: New test.
|
* gcc.target/aarch64/ands_1.c: New test.
|
||||||
|
@ -807,6 +813,7 @@
|
||||||
|
|
||||||
* gcc.target/aarch64/negs.c: New.
|
* gcc.target/aarch64/negs.c: New.
|
||||||
|
|
||||||
|
>>>>>>> trunk
|
||||||
2013-04-11 Jakub Jelinek <jakub@redhat.com>
|
2013-04-11 Jakub Jelinek <jakub@redhat.com>
|
||||||
|
|
||||||
PR c++/56895
|
PR c++/56895
|
||||||
|
|
Loading…
Reference in New Issue