-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Also set ECF_RETURNS_TWICE for __[sig]setjmp_cancel
__setjmp_cancel and __sigsetjmp_cancel are added to glibc to implement thread cancellation to avoid preserving shadow stack register for CET since there is no space in thread cancellation buffer to save and restore shadow stack register. This works since thread cancellation always leads to exit after longjmp. This patch updates GCC to set ECF_RETURNS_TWICE for __setjmp_cancel and __sigsetjmp_cancel, just like setjmp. gcc/ * calls.c (special_function_p): Also set ECF_RETURNS_TWICE for __setjmp_cancel and __sigsetjmp_cancel. gcc/testsuite/ * gcc.target/i386/cet-sjlj-7.c: New test. * gcc.target/i386/cet-sjlj-8.c: Likewise.
- Loading branch information
Showing
3 changed files
with
37 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
/* { dg-do compile } */ | ||
/* { dg-options "-O -fcf-protection -mcet" } */ | ||
/* { dg-final { scan-assembler-times "endbr32" 2 { target ia32 } } } */ | ||
/* { dg-final { scan-assembler-times "endbr64" 2 { target { ! ia32 } } } } */ | ||
/* { dg-final { scan-assembler-times "call _?__setjmp_cancel" 1 } } */ | ||
|
||
extern int __setjmp_cancel (char *); | ||
extern char env[]; | ||
|
||
int | ||
foo (void) | ||
{ | ||
if (__setjmp_cancel (env)) | ||
return 1; | ||
else | ||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
/* { dg-do compile } */ | ||
/* { dg-options "-O -fcf-protection -mcet" } */ | ||
/* { dg-final { scan-assembler-times "endbr32" 2 { target ia32 } } } */ | ||
/* { dg-final { scan-assembler-times "endbr64" 2 { target { ! ia32 } } } } */ | ||
/* { dg-final { scan-assembler-times "call _?__sigsetjmp_cancel" 1 } } */ | ||
|
||
extern int __sigsetjmp_cancel (char *); | ||
extern char env[]; | ||
|
||
int | ||
foo (void) | ||
{ | ||
if (__sigsetjmp_cancel (env)) | ||
return 1; | ||
else | ||
return 0; | ||
} |