Commit eb74a883 by H.J. Lu Committed by H.J. Lu

i386: Check -mindirect-branch/-mfunction-return with -fcf-protection

Issue an error when -mindirect-branch or -mfunction-return are used
with incompatible -fcf-protection.

gcc/

	PR target/87412
	* config/i386/i386.c (ix86_set_indirect_branch_type): Issue an
	error for -mindirect-branch/-mfunction-return with incompatible
	-fcf-protection.

gcc/testsuite/

	PR target/87412
	* gcc.target/i386/pr87412-1.c: New file.
	* gcc.target/i386/pr87412-2.c: Likewise.
	* gcc.target/i386/pr87412-3.c: Likewise.
	* gcc.target/i386/pr87412-4.c: Likewise.

From-SVN: r269068
parent 8be53488
2019-02-21 H.J. Lu <hongjiu.lu@intel.com>
PR target/87412
* config/i386/i386.c (ix86_set_indirect_branch_type): Issue an
error for -mindirect-branch/-mfunction-return with incompatible
-fcf-protection.
2019-02-21 Jakub Jelinek <jakub@redhat.com> 2019-02-21 Jakub Jelinek <jakub@redhat.com>
PR bootstrap/88714 PR bootstrap/88714
......
...@@ -5667,6 +5667,11 @@ ix86_set_indirect_branch_type (tree fndecl) ...@@ -5667,6 +5667,11 @@ ix86_set_indirect_branch_type (tree fndecl)
((cfun->machine->indirect_branch_type ((cfun->machine->indirect_branch_type
== indirect_branch_thunk_extern) == indirect_branch_thunk_extern)
? "thunk-extern" : "thunk")); ? "thunk-extern" : "thunk"));
if (cfun->machine->indirect_branch_type != indirect_branch_keep
&& (flag_cf_protection & CF_RETURN))
error ("%<-mindirect-branch%> and %<-fcf-protection%> are not "
"compatible");
} }
if (cfun->machine->function_return_type == indirect_branch_unset) if (cfun->machine->function_return_type == indirect_branch_unset)
...@@ -5705,6 +5710,11 @@ ix86_set_indirect_branch_type (tree fndecl) ...@@ -5705,6 +5710,11 @@ ix86_set_indirect_branch_type (tree fndecl)
((cfun->machine->function_return_type ((cfun->machine->function_return_type
== indirect_branch_thunk_extern) == indirect_branch_thunk_extern)
? "thunk-extern" : "thunk")); ? "thunk-extern" : "thunk"));
if (cfun->machine->function_return_type != indirect_branch_keep
&& (flag_cf_protection & CF_RETURN))
error ("%<-mfunction-return%> and %<-fcf-protection%> are not "
"compatible");
} }
} }
2019-02-21 H.J. Lu <hongjiu.lu@intel.com>
PR target/87412
* gcc.target/i386/pr87412-1.c: New file.
* gcc.target/i386/pr87412-2.c: Likewise.
* gcc.target/i386/pr87412-3.c: Likewise.
* gcc.target/i386/pr87412-4.c: Likewise.
2019-02-20 Jakub Jelinek <jakub@redhat.com> 2019-02-20 Jakub Jelinek <jakub@redhat.com>
PR c++/89403 PR c++/89403
......
/* { dg-do compile } */
/* { dg-options "-O2 -fcf-protection -mfunction-return=thunk -mindirect-branch=thunk" } */
void
bar (void)
{
/* { dg-error "'-mindirect-branch' and '-fcf-protection' are not compatible" "" { target *-*-* } .-1 } */
/* { dg-error "'-mfunction-return' and '-fcf-protection' are not compatible" "" { target *-*-* } .-2 } */
}
/* { dg-do compile } */
/* { dg-options "-O2 -fcf-protection -mfunction-return=keep -mindirect-branch=keep" } */
void
__attribute__ ((indirect_branch("thunk"), function_return("thunk")))
bar (void)
{
/* { dg-error "'-mindirect-branch' and '-fcf-protection' are not compatible" "" { target *-*-* } .-1 } */
/* { dg-error "'-mfunction-return' and '-fcf-protection' are not compatible" "" { target *-*-* } .-2 } */
}
/* { dg-do compile } */
/* { dg-options "-O2 -fcf-protection=return -mfunction-return=thunk -mindirect-branch=thunk" } */
void
bar (void)
{
/* { dg-error "'-mindirect-branch' and '-fcf-protection' are not compatible" "" { target *-*-* } .-1 } */
/* { dg-error "'-mfunction-return' and '-fcf-protection' are not compatible" "" { target *-*-* } .-2 } */
}
/* { dg-do compile } */
/* { dg-options "-O2 -fcf-protection=branch -mfunction-return=thunk -mindirect-branch=thunk" } */
void
bar (void)
{
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment