Skip to content

Commit

Permalink
[openmp] Support CET in z_Linux_asm.S (llvm#123213)
Browse files Browse the repository at this point in the history
When libomp is built with -cf-protection, add endbr instructions to the
start of functions for Intel CET support.
  • Loading branch information
nikic authored Jan 17, 2025
1 parent c3ba6f3 commit 90a05f3
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions openmp/runtime/src/z_Linux_asm.S
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,16 @@

#if KMP_ARCH_X86 || KMP_ARCH_X86_64

# if defined(__ELF__) && defined(__CET__) && defined(__has_include)
# if __has_include(<cet.h>)
# include <cet.h>
# endif
# endif

# if !defined(_CET_ENDBR)
# define _CET_ENDBR
# endif

# if KMP_MIC
// the 'delay r16/r32/r64' should be used instead of the 'pause'.
// The delay operation has the effect of removing the current thread from
Expand Down Expand Up @@ -66,6 +76,7 @@
ALIGN 4
.globl KMP_PREFIX_UNDERSCORE($0)
KMP_PREFIX_UNDERSCORE($0):
_CET_ENDBR
.endmacro
# else // KMP_OS_DARWIN
# define KMP_PREFIX_UNDERSCORE(x) x //no extra underscore for Linux* OS symbols
Expand All @@ -92,6 +103,7 @@ KMP_PREFIX_UNDERSCORE($0):
.globl KMP_PREFIX_UNDERSCORE(\proc)
KMP_PREFIX_UNDERSCORE(\proc):
.cfi_startproc
_CET_ENDBR
.endm
.macro KMP_CFI_DEF_OFFSET sz
.cfi_def_cfa_offset \sz
Expand Down

0 comments on commit 90a05f3

Please sign in to comment.