diff options
author | Igor Tsimbalist <igor.v.tsimbalist@intel.com> | 2018-02-06 16:25:31 +0100 |
---|---|---|
committer | Igor Tsimbalist <itsimbal@gcc.gnu.org> | 2018-02-06 16:25:31 +0100 |
commit | 3ca8e91f0e4452f618dbdc82090ecf47d1bd984c (patch) | |
tree | 76c690f27dae12fbd32060ace81fb460a139592b | |
parent | c88893a0da8fd01f20b4e254f706f054a72fc435 (diff) | |
download | gcc-3ca8e91f0e4452f618dbdc82090ecf47d1bd984c.zip gcc-3ca8e91f0e4452f618dbdc82090ecf47d1bd984c.tar.gz gcc-3ca8e91f0e4452f618dbdc82090ecf47d1bd984c.tar.bz2 |
Fix checking -mibt and -mshstk options for control flow protection
PR target/84145
* config/i386/i386.c: Reimplement the check of possible options
-mibt/-mshstk conbination. Change error messages.
* doc/invoke.texi: Fix a typo: remove extra '='.
* c-c++-common/fcf-protection-1.c: Change a compared message.
* c-c++-common/fcf-protection-2.c: Likewise.
* c-c++-common/fcf-protection-3.c: Likewise.
* c-c++-common/fcf-protection-5.c: Likewise.
* c-c++-common/fcf-protection-6.c: New test.
* c-c++-common/fcf-protection-7.c: Likewise.
From-SVN: r257414
-rw-r--r-- | gcc/ChangeLog | 7 | ||||
-rw-r--r-- | gcc/config/i386/i386.c | 43 | ||||
-rw-r--r-- | gcc/doc/invoke.texi | 4 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 10 | ||||
-rw-r--r-- | gcc/testsuite/c-c++-common/fcf-protection-1.c | 2 | ||||
-rw-r--r-- | gcc/testsuite/c-c++-common/fcf-protection-2.c | 2 | ||||
-rw-r--r-- | gcc/testsuite/c-c++-common/fcf-protection-3.c | 2 | ||||
-rw-r--r-- | gcc/testsuite/c-c++-common/fcf-protection-5.c | 2 | ||||
-rw-r--r-- | gcc/testsuite/c-c++-common/fcf-protection-6.c | 4 | ||||
-rw-r--r-- | gcc/testsuite/c-c++-common/fcf-protection-7.c | 4 |
10 files changed, 59 insertions, 21 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index c4d8c95..56d8917 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,10 @@ +2018-02-06 Igor Tsimbalist <igor.v.tsimbalist@intel.com> + + PR target/84145 + * config/i386/i386.c: Reimplement the check of possible options + -mibt/-mshstk conbination. Change error messages. + * doc/invoke.texi: Fix a typo: remove extra '='. + 2018-02-06 Marek Polacek <polacek@redhat.com> PR tree-optimization/84228 diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c index 70b6775..6c612c7 100644 --- a/gcc/config/i386/i386.c +++ b/gcc/config/i386/i386.c @@ -4915,30 +4915,43 @@ ix86_option_override_internal (bool main_args_p, /* Do not support control flow instrumentation if CET is not enabled. */ if (opts->x_flag_cf_protection != CF_NONE) { - if (!(TARGET_IBT_P (opts->x_ix86_isa_flags2) - || TARGET_SHSTK_P (opts->x_ix86_isa_flags))) + switch (flag_cf_protection) { - if (flag_cf_protection == CF_FULL) + case CF_NONE: + break; + case CF_BRANCH: + if (! TARGET_IBT_P (opts->x_ix86_isa_flags2)) { - error ("%<-fcf-protection=full%> requires CET support " - "on this target. Use -mcet or one of -mibt, " - "-mshstk options to enable CET"); + error ("%<-fcf-protection=branch%> requires Intel CET " + "support. Use -mcet or -mibt option to enable CET"); + flag_cf_protection = CF_NONE; + return false; } - else if (flag_cf_protection == CF_BRANCH) + break; + case CF_RETURN: + if (! TARGET_SHSTK_P (opts->x_ix86_isa_flags)) { - error ("%<-fcf-protection=branch%> requires CET support " - "on this target. Use -mcet or one of -mibt, " - "-mshstk options to enable CET"); + error ("%<-fcf-protection=return%> requires Intel CET " + "support. Use -mcet or -mshstk option to enable CET"); + flag_cf_protection = CF_NONE; + return false; } - else if (flag_cf_protection == CF_RETURN) + break; + case CF_FULL: + if ( ! TARGET_IBT_P (opts->x_ix86_isa_flags2) + || ! TARGET_SHSTK_P (opts->x_ix86_isa_flags)) { - error ("%<-fcf-protection=return%> requires CET support " - "on this target. Use -mcet or one of -mibt, " + error ("%<-fcf-protection=full%> requires Intel CET " + "support. Use -mcet or both of -mibt and " "-mshstk options to enable CET"); + flag_cf_protection = CF_NONE; + return false; } - flag_cf_protection = CF_NONE; - return false; + break; + default: + gcc_unreachable (); } + opts->x_flag_cf_protection = (cf_protection_level) (opts->x_flag_cf_protection | CF_SET); } diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi index cf6d3ae..befebed 100644 --- a/gcc/doc/invoke.texi +++ b/gcc/doc/invoke.texi @@ -463,7 +463,7 @@ Objective-C and Objective-C++ Dialects}. -fchkp-check-read -fchkp-check-write -fchkp-store-bounds @gol -fchkp-instrument-calls -fchkp-instrument-marked-only @gol -fchkp-use-wrappers -fchkp-flexible-struct-trailing-arrays@gol --fcf-protection==@r{[}full@r{|}branch@r{|}return@r{|}none@r{]} @gol +-fcf-protection=@r{[}full@r{|}branch@r{|}return@r{|}none@r{]} @gol -fstack-protector -fstack-protector-all -fstack-protector-strong @gol -fstack-protector-explicit -fstack-check @gol -fstack-limit-register=@var{reg} -fstack-limit-symbol=@var{sym} @gol @@ -11631,7 +11631,7 @@ is used to link a program, the GCC driver automatically links against @file{libmpxwrappers}. See also @option{-static-libmpxwrappers}. Enabled by default. -@item -fcf-protection==@r{[}full@r{|}branch@r{|}return@r{|}none@r{]} +@item -fcf-protection=@r{[}full@r{|}branch@r{|}return@r{|}none@r{]} @opindex fcf-protection Enable code instrumentation of control-flow transfers to increase program security by checking that target addresses of control-flow diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index e8b123d..2e279b4 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,13 @@ +2018-02-06 Igor Tsimbalist <igor.v.tsimbalist@intel.com> + + PR target/84145 + * c-c++-common/fcf-protection-1.c: Change a compared message. + * c-c++-common/fcf-protection-2.c: Likewise. + * c-c++-common/fcf-protection-3.c: Likewise. + * c-c++-common/fcf-protection-5.c: Likewise. + * c-c++-common/fcf-protection-6.c: New test. + * c-c++-common/fcf-protection-7.c: Likewise. + 2018-02-06 Marek Polacek <polacek@redhat.com> PR tree-optimization/84228 diff --git a/gcc/testsuite/c-c++-common/fcf-protection-1.c b/gcc/testsuite/c-c++-common/fcf-protection-1.c index 2e9337c..8e71f47 100644 --- a/gcc/testsuite/c-c++-common/fcf-protection-1.c +++ b/gcc/testsuite/c-c++-common/fcf-protection-1.c @@ -1,4 +1,4 @@ /* { dg-do compile } */ /* { dg-options "-fcf-protection=full" } */ -/* { dg-error "'-fcf-protection=full' requires CET support on this target" "" { target { "i?86-*-* x86_64-*-*" } } 0 } */ +/* { dg-error "'-fcf-protection=full' requires Intel CET.*-mcet.*-mibt and -mshstk option" "" { target { "i?86-*-* x86_64-*-*" } } 0 } */ /* { dg-error "'-fcf-protection=full' is not supported for this target" "" { target { ! "i?86-*-* x86_64-*-*" } } 0 } */ diff --git a/gcc/testsuite/c-c++-common/fcf-protection-2.c b/gcc/testsuite/c-c++-common/fcf-protection-2.c index aa0d2a0..d7d6db0 100644 --- a/gcc/testsuite/c-c++-common/fcf-protection-2.c +++ b/gcc/testsuite/c-c++-common/fcf-protection-2.c @@ -1,4 +1,4 @@ /* { dg-do compile } */ /* { dg-options "-fcf-protection=branch" } */ -/* { dg-error "'-fcf-protection=branch' requires CET support on this target" "" { target { "i?86-*-* x86_64-*-*" } } 0 } */ +/* { dg-error "'-fcf-protection=branch' requires Intel CET.*-mcet or -mibt option" "" { target { "i?86-*-* x86_64-*-*" } } 0 } */ /* { dg-error "'-fcf-protection=branch' is not supported for this target" "" { target { ! "i?86-*-* x86_64-*-*" } } 0 } */ diff --git a/gcc/testsuite/c-c++-common/fcf-protection-3.c b/gcc/testsuite/c-c++-common/fcf-protection-3.c index 028775a..5b903c5 100644 --- a/gcc/testsuite/c-c++-common/fcf-protection-3.c +++ b/gcc/testsuite/c-c++-common/fcf-protection-3.c @@ -1,4 +1,4 @@ /* { dg-do compile } */ /* { dg-options "-fcf-protection=return" } */ -/* { dg-error "'-fcf-protection=return' requires CET support on this target" "" { target { "i?86-*-* x86_64-*-*" } } 0 } */ +/* { dg-error "'-fcf-protection=return' requires Intel CET.*-mcet or -mshstk option" "" { target { "i?86-*-* x86_64-*-*" } } 0 } */ /* { dg-error "'-fcf-protection=return' is not supported for this target" "" { target { ! "i?86-*-* x86_64-*-*" } } 0 } */ diff --git a/gcc/testsuite/c-c++-common/fcf-protection-5.c b/gcc/testsuite/c-c++-common/fcf-protection-5.c index a5f8e11..d7a6780 100644 --- a/gcc/testsuite/c-c++-common/fcf-protection-5.c +++ b/gcc/testsuite/c-c++-common/fcf-protection-5.c @@ -1,4 +1,4 @@ /* { dg-do compile } */ /* { dg-options "-fcf-protection" } */ -/* { dg-error "'-fcf-protection=full' requires CET support on this target" "" { target { "i?86-*-* x86_64-*-*" } } 0 } */ +/* { dg-error "'-fcf-protection=full' requires Intel CET.*-mcet.*-mibt and -mshstk option" "" { target { "i?86-*-* x86_64-*-*" } } 0 } */ /* { dg-error "'-fcf-protection=full' is not supported for this target" "" { target { ! "i?86-*-* x86_64-*-*" } } 0 } */ diff --git a/gcc/testsuite/c-c++-common/fcf-protection-6.c b/gcc/testsuite/c-c++-common/fcf-protection-6.c new file mode 100644 index 0000000..084983e --- /dev/null +++ b/gcc/testsuite/c-c++-common/fcf-protection-6.c @@ -0,0 +1,4 @@ +/* { dg-do compile } */ +/* { dg-options "-fcf-protection=branch -mshstk" } */ +/* { dg-error "'-fcf-protection=branch' requires Intel CET.*-mcet or -mibt option" "" { target { "i?86-*-* x86_64-*-*" } } 0 } */ +/* { dg-error "'-fcf-protection=branch' is not supported for this target" "" { target { ! "i?86-*-* x86_64-*-*" } } 0 } */ diff --git a/gcc/testsuite/c-c++-common/fcf-protection-7.c b/gcc/testsuite/c-c++-common/fcf-protection-7.c new file mode 100644 index 0000000..9baedf5 --- /dev/null +++ b/gcc/testsuite/c-c++-common/fcf-protection-7.c @@ -0,0 +1,4 @@ +/* { dg-do compile } */ +/* { dg-options "-fcf-protection=return -mibt" } */ +/* { dg-error "'-fcf-protection=return' requires Intel CET.*-mcet or -mshstk option" "" { target { "i?86-*-* x86_64-*-*" } } 0 } */ +/* { dg-error "'-fcf-protection=return' is not supported for this target" "" { target { ! "i?86-*-* x86_64-*-*" } } 0 } */ |