Allow -fcf-protection with external thunk since the external thunk can be
made compatible with -fcf-protection.
gcc/
Backport from master
PR target/93654
* config/i386/i386-options.c (ix86_set_indirect_branch_type):
Allow -fcf-protection with -mindirect-branch=thunk-extern and
-mfunction-return=thunk-extern.
* doc/invoke.texi: Update notes for -fcf-protection=branch with
-mindirect-branch=thunk-extern and -mindirect-return=thunk-extern.
gcc/testsuite/
Backport from master
PR target/93654
* gcc.target/i386/pr93654.c: New test.
(cherry picked from commit
9be3bb2c0a258fd6a7d3d05d232a21930c757d3c)
+2020-04-29 H.J. Lu <hongjiu.lu@intel.com>
+
+ Backport from master
+ 2020-04-29 H.J. Lu <hongjiu.lu@intel.com>
+
+ PR target/93654
+ * config/i386/i386.c (ix86_set_indirect_branch_type): Allow
+ -fcf-protection with -mindirect-branch=thunk-extern and
+ -mfunction-return=thunk-extern.
+ * doc/invoke.texi: Update notes for -fcf-protection=branch with
+ -mindirect-branch=thunk-extern and -mindirect-return=thunk-extern.
+
2020-04-21 Martin Jambor <mjambor@suse.cz>
Backport from master
? "thunk-extern" : "thunk"));
if (cfun->machine->indirect_branch_type != indirect_branch_keep
+ && (cfun->machine->indirect_branch_type
+ != indirect_branch_thunk_extern)
&& (flag_cf_protection & CF_RETURN))
error ("%<-mindirect-branch%> and %<-fcf-protection%> are not "
"compatible");
? "thunk-extern" : "thunk"));
if (cfun->machine->function_return_type != indirect_branch_keep
+ && (cfun->machine->function_return_type
+ != indirect_branch_thunk_extern)
&& (flag_cf_protection & CF_RETURN))
error ("%<-mfunction-return%> and %<-fcf-protection%> are not "
"compatible");
@option{-mindirect-branch=thunk-extern} since the thunk function may
not be reachable in the large code model.
-Note that @option{-mindirect-branch=thunk-extern} is incompatible with
-@option{-fcf-protection=branch} since the external thunk cannot be modified
-to disable control-flow check.
+Note that @option{-mindirect-branch=thunk-extern} is compatible with
+@option{-fcf-protection=branch} since the external thunk can be made
+to enable control-flow check.
@item -mfunction-return=@var{choice}
@opindex mfunction-return
using the function attribute @code{function_return}.
@xref{Function Attributes}.
+Note that @option{-mindirect-return=thunk-extern} is compatible with
+@option{-fcf-protection=branch} since the external thunk can be made
+to enable control-flow check.
+
Note that @option{-mcmodel=large} is incompatible with
@option{-mfunction-return=thunk} and
@option{-mfunction-return=thunk-extern} since the thunk function may
+2020-04-29 H.J. Lu <hongjiu.lu@intel.com>
+
+ Backport from master
+ 2020-04-29 H.J. Lu <hongjiu.lu@intel.com>
+
+ PR target/93654
+ * gcc.target/i386/pr93654.c: New test.
+
2020-04-24 Thomas Koenig <tkoenig@gcc.gnu.org>
Backport from trunk
--- /dev/null
+/* { dg-do compile } */
+/* { dg-options "-O2 -fcf-protection -mfunction-return=thunk-extern -mindirect-branch=thunk-extern" } */
+
+int
+bar (void (*foo) (void))
+{
+ foo ();
+ return 0;
+}