Skip to content

Commit 90a05f3

Browse files
authored
[openmp] Support CET in z_Linux_asm.S (#123213)
When libomp is built with -cf-protection, add endbr instructions to the start of functions for Intel CET support.
1 parent c3ba6f3 commit 90a05f3

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

openmp/runtime/src/z_Linux_asm.S

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,16 @@
1919

2020
#if KMP_ARCH_X86 || KMP_ARCH_X86_64
2121

22+
# if defined(__ELF__) && defined(__CET__) && defined(__has_include)
23+
# if __has_include(<cet.h>)
24+
# include <cet.h>
25+
# endif
26+
# endif
27+
28+
# if !defined(_CET_ENDBR)
29+
# define _CET_ENDBR
30+
# endif
31+
2232
# if KMP_MIC
2333
// the 'delay r16/r32/r64' should be used instead of the 'pause'.
2434
// The delay operation has the effect of removing the current thread from
@@ -66,6 +76,7 @@
6676
ALIGN 4
6777
.globl KMP_PREFIX_UNDERSCORE($0)
6878
KMP_PREFIX_UNDERSCORE($0):
79+
_CET_ENDBR
6980
.endmacro
7081
# else // KMP_OS_DARWIN
7182
# define KMP_PREFIX_UNDERSCORE(x) x //no extra underscore for Linux* OS symbols
@@ -92,6 +103,7 @@ KMP_PREFIX_UNDERSCORE($0):
92103
.globl KMP_PREFIX_UNDERSCORE(\proc)
93104
KMP_PREFIX_UNDERSCORE(\proc):
94105
.cfi_startproc
106+
_CET_ENDBR
95107
.endm
96108
.macro KMP_CFI_DEF_OFFSET sz
97109
.cfi_def_cfa_offset \sz

0 commit comments

Comments
 (0)