From 6ad05bcc3e3c5f80fac077423dd222cf850f9096 Mon Sep 17 00:00:00 2001 From: "H.J. Lu" Date: Wed, 7 Feb 2018 10:48:39 +0000 Subject: [PATCH] i386: Mask out the CF_SET bit for -fcf-protection check Since ix86_option_override_internal sets the CF_SET bit in flag_cf_protection and it can be called more than once via pragma, we need to mask out the CF_SET bit when checking flag_cf_protection. PR target/84248 * config/i386/i386.c (ix86_option_override_internal): Mask out the CF_SET bit when checking -fcf-protection. From-SVN: r257444 --- gcc/ChangeLog | 7 ++++++- gcc/config/i386/i386.c | 10 +++++----- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 1caefb6aabe..51c45c05320 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2018-02-07 H.J. Lu + + PR target/84248 + * config/i386/i386.c (ix86_option_override_internal): Mask out + the CF_SET bit when checking -fcf-protection. + 2018-02-07 Tom de Vries PR libgomp/84217 @@ -165,7 +171,6 @@ %1, %0|%0, %1, %2, %3}"): ... this. ->>>>>>> .r257416 2018-02-02 Andrew Jenner * config/powerpcspe/powerpcspe.opt: Add Undocumented to irrelevant diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c index faa9d9415f6..fc3d6f0aebc 100644 --- a/gcc/config/i386/i386.c +++ b/gcc/config/i386/i386.c @@ -4909,12 +4909,12 @@ ix86_option_override_internal (bool main_args_p, = build_target_option_node (opts); /* Do not support control flow instrumentation if CET is not enabled. */ - if (opts->x_flag_cf_protection != CF_NONE) + cf_protection_level cf_protection + = (cf_protection_level) (opts->x_flag_cf_protection & ~CF_SET); + if (cf_protection != CF_NONE) { - switch (flag_cf_protection) + switch (cf_protection) { - case CF_NONE: - break; case CF_BRANCH: if (! TARGET_IBT_P (opts->x_ix86_isa_flags2)) { @@ -4949,7 +4949,7 @@ ix86_option_override_internal (bool main_args_p, } opts->x_flag_cf_protection = - (cf_protection_level) (opts->x_flag_cf_protection | CF_SET); + (cf_protection_level) (cf_protection | CF_SET); } if (ix86_tune_features [X86_TUNE_AVOID_128FMA_CHAINS]) -- 2.30.2