* cipher/asm-common-amd64.h (ENDBRANCH): New. (CFI_STARTPROC): Add ENDBRANCH. [__CET__] (note.gnu.property): Add CET property section. --
GnuPG-bug-id: 7220 Signed-off-by: Jussi Kivilinna <jussi.kivili...@iki.fi> --- cipher/asm-common-amd64.h | 30 ++++++++++++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) diff --git a/cipher/asm-common-amd64.h b/cipher/asm-common-amd64.h index 3fa065e8..465ef62b 100644 --- a/cipher/asm-common-amd64.h +++ b/cipher/asm-common-amd64.h @@ -76,9 +76,15 @@ # endif #endif +#ifdef __CET__ +#define ENDBRANCH endbr64 +#else +#define ENDBRANCH /*_*/ +#endif + #ifdef HAVE_GCC_ASM_CFI_DIRECTIVES /* CFI directives to emit DWARF stack unwinding information. */ -# define CFI_STARTPROC() .cfi_startproc +# define CFI_STARTPROC() .cfi_startproc; ENDBRANCH # define CFI_ENDPROC() .cfi_endproc # define CFI_REMEMBER_STATE() .cfi_remember_state # define CFI_RESTORE_STATE() .cfi_restore_state @@ -146,7 +152,7 @@ DW_SLEB128_28BIT(rsp_offs) #else -# define CFI_STARTPROC() +# define CFI_STARTPROC() ENDBRANCH # define CFI_ENDPROC() # define CFI_REMEMBER_STATE() # define CFI_RESTORE_STATE() @@ -214,4 +220,24 @@ vpopcntb xmm16, xmm16; /* Supported only by newer AVX512 CPUs. */ \ vpxord ymm16, ymm16, ymm16; +#ifdef __CET__ +/* Generate CET property for all assembly files including this header. */ +ELF(.section .note.gnu.property,"a") +ELF(.align 8) +ELF(.long 1f - 0f) +ELF(.long 4f - 1f) +ELF(.long 5) +ELF(0:) +ELF(.byte 0x47, 0x4e, 0x55, 0) /* string "GNU" */ +ELF(1:) +ELF(.align 8) +ELF(.long 0xc0000002) +ELF(.long 3f - 2f) +ELF(2:) +ELF(.long 0x3) +ELF(3:) +ELF(.align 8) +ELF(4:) +#endif + #endif /* GCRY_ASM_COMMON_AMD64_H */ -- 2.43.0 _______________________________________________ Gcrypt-devel mailing list Gcrypt-devel@gnupg.org https://lists.gnupg.org/mailman/listinfo/gcrypt-devel