From 20ada81d43f03301ae29e92a8526b5950430ae00 Mon Sep 17 00:00:00 2001 From: Mark Roszko Date: Wed, 1 Nov 2023 15:53:11 +0000 Subject: [PATCH] Add the BTI C hint to libcontext arm64 (cherry picked from commit 2b3ad808ea0533ddef74f696e81808896b63cd33) --- thirdparty/libcontext/libcontext.cpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/thirdparty/libcontext/libcontext.cpp b/thirdparty/libcontext/libcontext.cpp index a56ff44407..0105939b4c 100644 --- a/thirdparty/libcontext/libcontext.cpp +++ b/thirdparty/libcontext/libcontext.cpp @@ -537,6 +537,10 @@ __asm ( ".balign 16\n" ".global _jump_fcontext\n" "_jump_fcontext:\n" +#if defined(__ARM_FEATURE_BTI_DEFAULT) && (__ARM_FEATURE_BTI_DEFAULT == 1) +" # bti c\n" +" hint #34\n" +#endif " # prepare stack for GP + FPU\n" " sub sp, sp, #0xb0\n" " # test if fpu env should be preserved\n" @@ -598,6 +602,10 @@ __asm ( ".align 2\n" ".global _make_fcontext\n" "_make_fcontext:\n" +#if defined(__ARM_FEATURE_BTI_DEFAULT) && (__ARM_FEATURE_BTI_DEFAULT == 1) +" # bti c\n" +" hint #34\n" +#endif " # shift address in x0 (allocated stack) to lower 16 byte boundary\n" " and x0, x0, ~0xF\n" " # reserve space for context-data on context-stack\n" @@ -700,6 +708,10 @@ __asm ( ".global jump_fcontext\n" ".type jump_fcontext, %function\n" "jump_fcontext:\n" +#if defined(__ARM_FEATURE_BTI_DEFAULT) && (__ARM_FEATURE_BTI_DEFAULT == 1) +" # bti c\n" +" hint #34\n" +#endif " # prepare stack for GP + FPU\n" " sub sp, sp, #0xb0\n" "# Because gcc may save integer registers in fp registers across a\n" @@ -769,6 +781,10 @@ __asm ( ".global make_fcontext\n" ".type make_fcontext, %function\n" "make_fcontext:\n" +#if defined(__ARM_FEATURE_BTI_DEFAULT) && (__ARM_FEATURE_BTI_DEFAULT == 1) +" # bti c\n" +" hint #34\n" +#endif " # shift address in x0 (allocated stack) to lower 16 byte boundary\n" " and x0, x0, ~0xF\n" " # reserve space for context-data on context-stack\n"