From: Jakub Jelinek Date: Thu, 22 Nov 2018 09:48:43 +0000 (+0100) Subject: re PR target/85644 (-fstack-protector generates invalid read to %fs:0x0 on mac) X-Git-Tag: upstream/12.2.0~27894 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=e15bac63bad1cae4efa93f9b783e0397bca13f1d;p=platform%2Fupstream%2Fgcc.git 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 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 2ae6ce7..9899320 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 edf6dcf..21eb6a2 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 2231204..37a92f5 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")])