diff options
author | Andrew Hsieh <andrewhsieh@google.com> | 2013-04-15 12:03:48 +0200 |
---|---|---|
committer | Uros Bizjak <uros@gcc.gnu.org> | 2013-04-15 12:03:48 +0200 |
commit | e0ea8797bb997ccc5ab228580498dfe2b727dcef (patch) | |
tree | ad462b31e486f9859c8d9438bf69a6ce4b33cb6e /gcc/config/i386 | |
parent | adede54ce9d680ab7a0499b76a7f22d3a78d79b8 (diff) | |
download | gcc-e0ea8797bb997ccc5ab228580498dfe2b727dcef.tar.gz |
i386.opt: New option mstack-protector-guard=.
* config/i386/i386.opt: New option mstack-protector-guard=.
* config/i386/i386-opts.h: Add enum stack_protector_guard.
* config/i386/i386.h: Define TARGET_SSP_GLOBAL_GUARD and
TARGET_SSP_TLS_GUARD.
* config/i386/i386.c (ix86_option_override_internal): Set
ix86_stack_protector_guard.
* config/i386/i386.md (stack_protect_set): Enable for
TARGET_SSP_TLS_GUARD only.
(stack_protect_set_<mode>): Ditto.
(stack_protect_test): Ditto.
(stack_protect_test_<mode>): Ditto.
* doc/invoke.texi (i386 Option): Document.
From-SVN: r197963
Diffstat (limited to 'gcc/config/i386')
-rw-r--r-- | gcc/config/i386/i386-opts.h | 5 | ||||
-rw-r--r-- | gcc/config/i386/i386.c | 4 | ||||
-rw-r--r-- | gcc/config/i386/i386.h | 3 | ||||
-rw-r--r-- | gcc/config/i386/i386.md | 8 | ||||
-rw-r--r-- | gcc/config/i386/i386.opt | 14 |
5 files changed, 30 insertions, 4 deletions
diff --git a/gcc/config/i386/i386-opts.h b/gcc/config/i386/i386-opts.h index 11c08457db3..61f04ced53b 100644 --- a/gcc/config/i386/i386-opts.h +++ b/gcc/config/i386/i386-opts.h @@ -85,4 +85,9 @@ enum ix86_veclibabi { ix86_veclibabi_type_acml }; +enum stack_protector_guard { + SSP_TLS, /* per-thread canary in TLS block */ + SSP_GLOBAL /* global canary */ +}; + #endif diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c index 4d4c61876a1..940f388016c 100644 --- a/gcc/config/i386/i386.c +++ b/gcc/config/i386/i386.c @@ -3922,6 +3922,10 @@ ix86_option_override_internal (bool main_args_p) if (main_args_p) target_option_default_node = target_option_current_node = build_target_option_node (); + + /* Handle stack protector */ + if (!global_options_set.x_ix86_stack_protector_guard) + ix86_stack_protector_guard = TARGET_HAS_BIONIC ? SSP_GLOBAL : SSP_TLS; } /* Implement the TARGET_OPTION_OVERRIDE hook. */ diff --git a/gcc/config/i386/i386.h b/gcc/config/i386/i386.h index 5d31f80feb5..037ec3e0dec 100644 --- a/gcc/config/i386/i386.h +++ b/gcc/config/i386/i386.h @@ -486,6 +486,9 @@ extern unsigned char x86_prefetch_sse; #define TARGET_TLS_DIRECT_SEG_REFS_DEFAULT 0 #endif +#define TARGET_SSP_GLOBAL_GUARD (ix86_stack_protector_guard == SSP_GLOBAL) +#define TARGET_SSP_TLS_GUARD (ix86_stack_protector_guard == SSP_TLS) + /* Fence to use after loop using storent. */ extern tree x86_mfence; diff --git a/gcc/config/i386/i386.md b/gcc/config/i386/i386.md index b9ca95b7dd5..27e33c13780 100644 --- a/gcc/config/i386/i386.md +++ b/gcc/config/i386/i386.md @@ -17058,7 +17058,7 @@ (define_expand "stack_protect_set" [(match_operand 0 "memory_operand") (match_operand 1 "memory_operand")] - "!TARGET_HAS_BIONIC" + "TARGET_SSP_TLS_GUARD" { rtx (*insn)(rtx, rtx); @@ -17083,7 +17083,7 @@ UNSPEC_SP_SET)) (set (match_scratch:PTR 2 "=&r") (const_int 0)) (clobber (reg:CC FLAGS_REG))] - "!TARGET_HAS_BIONIC" + "TARGET_SSP_TLS_GUARD" "mov{<imodesuffix>}\t{%1, %2|%2, %1}\;mov{<imodesuffix>}\t{%2, %0|%0, %2}\;xor{l}\t%k2, %k2" [(set_attr "type" "multi")]) @@ -17101,7 +17101,7 @@ [(match_operand 0 "memory_operand") (match_operand 1 "memory_operand") (match_operand 2)] - "!TARGET_HAS_BIONIC" + "TARGET_SSP_TLS_GUARD" { rtx flags = gen_rtx_REG (CCZmode, FLAGS_REG); @@ -17131,7 +17131,7 @@ (match_operand:PTR 2 "memory_operand" "m")] UNSPEC_SP_TEST)) (clobber (match_scratch:PTR 3 "=&r"))] - "!TARGET_HAS_BIONIC" + "TARGET_SSP_TLS_GUARD" "mov{<imodesuffix>}\t{%1, %3|%3, %1}\;xor{<imodesuffix>}\t{%2, %3|%3, %2}" [(set_attr "type" "multi")]) diff --git a/gcc/config/i386/i386.opt b/gcc/config/i386/i386.opt index 084a2486353..f5ad69e26c2 100644 --- a/gcc/config/i386/i386.opt +++ b/gcc/config/i386/i386.opt @@ -626,3 +626,17 @@ Split 32-byte AVX unaligned store mrtm Target Report Mask(ISA_RTM) Var(ix86_isa_flags) Save Support RTM built-in functions and code generation + +mstack-protector-guard= +Target RejectNegative Joined Enum(stack_protector_guard) Var(ix86_stack_protector_guard) Init(SSP_TLS) +Use given stack-protector guard + +Enum +Name(stack_protector_guard) Type(enum stack_protector_guard) +Known stack protector guard (for use with the -mstack-protector-guard= option): + +EnumValue +Enum(stack_protector_guard) String(tls) Value(SSP_TLS) + +EnumValue +Enum(stack_protector_guard) String(global) Value(SSP_GLOBAL) |