Diff below fixes libgcrypt/gnupg on my m2. CFI_STARTPROC() seemed like a good place to add the bti instructions since it is called in all the right places. If this is too hacky I'm also fine with adding explicit instructions everywhere or even a new macro.
opinions? ok? Index: patches/patch-cipher_asm-common-aarch64_h =================================================================== RCS file: patches/patch-cipher_asm-common-aarch64_h diff -N patches/patch-cipher_asm-common-aarch64_h --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ patches/patch-cipher_asm-common-aarch64_h 19 Nov 2023 20:22:40 -0000 @@ -0,0 +1,21 @@ +Index: cipher/asm-common-aarch64.h +--- cipher/asm-common-aarch64.h.orig ++++ cipher/asm-common-aarch64.h +@@ -45,7 +45,7 @@ + + #ifdef HAVE_GCC_ASM_CFI_DIRECTIVES + /* CFI directives to emit DWARF stack unwinding information. */ +-# define CFI_STARTPROC() .cfi_startproc ++# define CFI_STARTPROC() bti c; .cfi_startproc; + # define CFI_ENDPROC() .cfi_endproc + # define CFI_REMEMBER_STATE() .cfi_remember_state + # define CFI_RESTORE_STATE() .cfi_restore_state +@@ -87,7 +87,7 @@ + DW_SLEB128_28BIT(rsp_offs) + + #else +-# define CFI_STARTPROC() ++# define CFI_STARTPROC() bti c; + # define CFI_ENDPROC() + # define CFI_REMEMBER_STATE() + # define CFI_RESTORE_STATE()
