When building with -mbranch-protection=bti, which affects the compiler
codegen only, ensure that the assembler based codegen is aligned with
this, by emitting the BTI C opcode at the start of each exported
function. While most exported functions are not in fact ever called
indirectly, whether or not this is the case is a property of the caller
so annotating every exported function is a reasonable default.
While at it, fix two occurrences in ArmPkg of exported functions that
did not use the ASM_FUNC() macro.
Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
Reviewed-by: Leif Lindholm <quic_llindhol@quicinc.com>
Reviewed-by: Oliver Smith-Denny <osd@smith-denny.com>
.global Name ; \\r
.section #Section, "ax" ; \\r
.type Name, %function ; \\r
- Name:\r
+ Name: ; \\r
+ AARCH64_BTI(c)\r
\r
#define ASM_FUNC(Name) _ASM_FUNC(ASM_PFX(Name), .text. ## Name)\r
\r
\r
GCC_ASM_EXPORT(ExceptionHandlersEnd)\r
GCC_ASM_EXPORT(CommonCExceptionHandler)\r
-GCC_ASM_EXPORT(RegisterEl0Stack)\r
\r
.text\r
\r
\r
eret\r
\r
-ASM_PFX(RegisterEl0Stack):\r
+ASM_FUNC(RegisterEl0Stack)\r
msr sp_el0, x0\r
ret\r
//\r
//\r
\r
+#include <AsmMacroIoLibV8.h>\r
+\r
.text\r
.align 3\r
\r
-GCC_ASM_EXPORT(ArmCallSvc)\r
-\r
-ASM_PFX(ArmCallSvc):\r
+ASM_FUNC(ArmCallSvc)\r
// Push frame pointer and return address on the stack\r
stp x29, x30, [sp, #-32]!\r
mov x29, sp\r