From e15bac63bad1cae4efa93f9b783e0397bca13f1d Mon Sep 17 00:00:00 2001 From: Jakub Jelinek Date: Thu, 22 Nov 2018 10:48:43 +0100 Subject: [PATCH] re PR target/85644 (-fstack-protector generates invalid read to %fs:0x0 on mac) PR target/85644 PR target/86832 * config/i386/i386.c (ix86_option_override_internal): Default ix86_stack_protector_guard to SSP_TLS only if TARGET_THREAD_SSP_OFFSET is defined. * config/i386/i386.md (stack_protect_set, stack_protect_set_, stack_protect_test, stack_protect_test_): Use empty condition instead of TARGET_SSP_TLS_GUARD. From-SVN: r266370 --- gcc/ChangeLog | 11 +++++++++++ gcc/config/i386/i386.c | 10 ++++++++-- gcc/config/i386/i386.md | 8 ++++---- 3 files changed, 23 insertions(+), 6 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 2ae6ce71c10..98993207d32 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,14 @@ +2018-11-22 Jakub Jelinek + + PR target/85644 + PR target/86832 + * config/i386/i386.c (ix86_option_override_internal): Default + ix86_stack_protector_guard to SSP_TLS only if TARGET_THREAD_SSP_OFFSET + is defined. + * config/i386/i386.md (stack_protect_set, stack_protect_set_, + stack_protect_test, stack_protect_test_): Use empty condition + instead of TARGET_SSP_TLS_GUARD. + 2018-11-22 Martin Liska PR sanitizer/88017 diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c index edf6dcfb441..21eb6a2d42c 100644 --- a/gcc/config/i386/i386.c +++ b/gcc/config/i386/i386.c @@ -4559,8 +4559,14 @@ ix86_option_override_internal (bool main_args_p, /* Handle stack protector */ if (!opts_set->x_ix86_stack_protector_guard) - opts->x_ix86_stack_protector_guard - = TARGET_HAS_BIONIC ? SSP_GLOBAL : SSP_TLS; + { +#ifdef TARGET_THREAD_SSP_OFFSET + if (!TARGET_HAS_BIONIC) + opts->x_ix86_stack_protector_guard = SSP_TLS; + else +#endif + opts->x_ix86_stack_protector_guard = SSP_GLOBAL; + } #ifdef TARGET_THREAD_SSP_OFFSET ix86_stack_protector_guard_offset = TARGET_THREAD_SSP_OFFSET; diff --git a/gcc/config/i386/i386.md b/gcc/config/i386/i386.md index 2231204b29c..37a92f5bb30 100644 --- a/gcc/config/i386/i386.md +++ b/gcc/config/i386/i386.md @@ -19010,7 +19010,7 @@ (define_expand "stack_protect_set" [(match_operand 0 "memory_operand") (match_operand 1 "memory_operand")] - "TARGET_SSP_TLS_GUARD" + "" { rtx (*insn)(rtx, rtx); @@ -19028,7 +19028,7 @@ UNSPEC_SP_SET)) (set (match_scratch:PTR 2 "=&r") (const_int 0)) (clobber (reg:CC FLAGS_REG))] - "TARGET_SSP_TLS_GUARD" + "" "mov{}\t{%1, %2|%2, %1}\;mov{}\t{%2, %0|%0, %2}\;xor{l}\t%k2, %k2" [(set_attr "type" "multi")]) @@ -19036,7 +19036,7 @@ [(match_operand 0 "memory_operand") (match_operand 1 "memory_operand") (match_operand 2)] - "TARGET_SSP_TLS_GUARD" + "" { rtx flags = gen_rtx_REG (CCZmode, FLAGS_REG); @@ -19059,7 +19059,7 @@ (match_operand:PTR 2 "memory_operand" "m")] UNSPEC_SP_TEST)) (clobber (match_scratch:PTR 3 "=&r"))] - "TARGET_SSP_TLS_GUARD" + "" "mov{}\t{%1, %3|%3, %1}\;xor{}\t{%2, %3|%3, %2}" [(set_attr "type" "multi")]) -- 2.30.2