aboutsummaryrefslogtreecommitdiffstats
path: root/gcc-4.4.3/gcc/config
diff options
context:
space:
mode:
authorAndrew Hsieh <andrewhsieh@google.com>2012-10-31 21:02:46 -0700
committerAndrew Hsieh <andrewhsieh@google.com>2012-11-01 15:47:39 -0700
commit56ee0e6d36e35bbd4a1cda777359dcb7eaadb232 (patch)
treea9d6d744a3f8059b59d1b13d55779ea25ac8789d /gcc-4.4.3/gcc/config
parentefb5994e8cb17f9b2347baff9d731af0338e5d5e (diff)
downloadtoolchain_gcc-56ee0e6d36e35bbd4a1cda777359dcb7eaadb232.tar.gz
toolchain_gcc-56ee0e6d36e35bbd4a1cda777359dcb7eaadb232.tar.bz2
toolchain_gcc-56ee0e6d36e35bbd4a1cda777359dcb7eaadb232.zip
Add -mstack-protector-guard= to x86 compilers
To choose between "global" (default) and "tls" (new) for -fstack-protector, -fstack-protector-all, and -fstack-protector-strong (GCC 4.6+). Note that this alone doesn't enable any -fstack-protector* For NDK: The default "global" generates code backward compatible with older bionic For AOSP: build may add "-mstack-protector-guard=tls" to build platform code with new bionic (*1) Related CL: https://android-review.googlesource.com/#/c/45416 (*1) https://android-review.googlesource.com/#/c/45784 Change-Id: Iedf5b7ae5148572db2e35f0add93bc3d13511304
Diffstat (limited to 'gcc-4.4.3/gcc/config')
-rw-r--r--gcc-4.4.3/gcc/config/i386/i386.c19
-rw-r--r--gcc-4.4.3/gcc/config/i386/i386.h7
-rw-r--r--gcc-4.4.3/gcc/config/i386/i386.md6
-rw-r--r--gcc-4.4.3/gcc/config/i386/i386.opt4
4 files changed, 33 insertions, 3 deletions
diff --git a/gcc-4.4.3/gcc/config/i386/i386.c b/gcc-4.4.3/gcc/config/i386/i386.c
index 31ce38a58..2ca822040 100644
--- a/gcc-4.4.3/gcc/config/i386/i386.c
+++ b/gcc-4.4.3/gcc/config/i386/i386.c
@@ -1810,6 +1810,9 @@ extern int ix86_force_align_arg_pointer;
static const char ix86_force_align_arg_pointer_string[]
= "force_align_arg_pointer";
+/* Stack protector option. */
+enum stack_protector_guard ix86_stack_protector_guard;
+
static rtx (*ix86_gen_leave) (void);
static rtx (*ix86_gen_pop1) (rtx);
static rtx (*ix86_gen_add3) (rtx, rtx, rtx);
@@ -3435,6 +3438,22 @@ override_options (bool main_args_p)
flag_stack_check = 0;
target_flags |= MASK_STACK_PROBE;
}
+
+ /* Handle stack protector */
+ if (ix86_stack_protector_guard_string != 0)
+ {
+ if (!strcmp (ix86_stack_protector_guard_string, "tls"))
+ ix86_stack_protector_guard = SSP_TLS;
+ else if (!strcmp (ix86_stack_protector_guard_string, "global"))
+ ix86_stack_protector_guard = SSP_GLOBAL;
+ else
+ error ("bad value (%s) for %sstack-protector-guard=%s %s",
+ ix86_stack_protector_guard, prefix, suffix, sw);
+ }
+ else
+ {
+ ix86_stack_protector_guard = TARGET_HAS_BIONIC? SSP_GLOBAL : SSP_TLS;
+ }
}
/* Update register usage after having seen the compiler flags. */
diff --git a/gcc-4.4.3/gcc/config/i386/i386.h b/gcc-4.4.3/gcc/config/i386/i386.h
index d7cb8ac3c..d611fe632 100644
--- a/gcc-4.4.3/gcc/config/i386/i386.h
+++ b/gcc-4.4.3/gcc/config/i386/i386.h
@@ -2517,6 +2517,13 @@ struct machine_function GTY(())
#undef TARG_COND_NOT_TAKEN_BRANCH_COST
#define TARG_COND_NOT_TAKEN_BRANCH_COST ix86_cost->cond_not_taken_branch_cost
+enum stack_protector_guard {
+ SSP_TLS, /* per-thread canary at %gs:20 */
+ SSP_GLOBAL, /* global canary */
+};
+
+extern enum stack_protector_guard ix86_stack_protector_guard;
+
/*
Local variables:
version-control: t
diff --git a/gcc-4.4.3/gcc/config/i386/i386.md b/gcc-4.4.3/gcc/config/i386/i386.md
index 7989c31db..a1d7bcba2 100644
--- a/gcc-4.4.3/gcc/config/i386/i386.md
+++ b/gcc-4.4.3/gcc/config/i386/i386.md
@@ -21926,7 +21926,7 @@
(define_expand "stack_protect_set"
[(match_operand 0 "memory_operand" "")
(match_operand 1 "memory_operand" "")]
- ""
+ "ix86_stack_protector_guard == SSP_TLS"
{
#ifdef TARGET_THREAD_SSP_OFFSET
if (TARGET_64BIT)
@@ -21949,7 +21949,7 @@
(unspec:SI [(match_operand:SI 1 "memory_operand" "m")] UNSPEC_SP_SET))
(set (match_scratch:SI 2 "=&r") (const_int 0))
(clobber (reg:CC FLAGS_REG))]
- ""
+ "ix86_stack_protector_guard == SSP_TLS"
"mov{l}\t{%1, %2|%2, %1}\;mov{l}\t{%2, %0|%0, %2}\;xor{l}\t%2, %2"
[(set_attr "type" "multi")])
@@ -21992,7 +21992,7 @@
[(match_operand 0 "memory_operand" "")
(match_operand 1 "memory_operand" "")
(match_operand 2 "" "")]
- ""
+ "ix86_stack_protector_guard == SSP_TLS"
{
rtx flags = gen_rtx_REG (CCZmode, FLAGS_REG);
ix86_compare_op0 = operands[0];
diff --git a/gcc-4.4.3/gcc/config/i386/i386.opt b/gcc-4.4.3/gcc/config/i386/i386.opt
index c2562e48d..880fc98ca 100644
--- a/gcc-4.4.3/gcc/config/i386/i386.opt
+++ b/gcc-4.4.3/gcc/config/i386/i386.opt
@@ -362,3 +362,7 @@ Support PCLMUL built-in functions and code generation
msse2avx
Target Report Var(ix86_sse2avx)
Encode SSE instructions with VEX prefix
+
+mstack-protector-guard=
+Target RejectNegative Joined Var(ix86_stack_protector_guard_string)
+Use given stack-protector guard