Richard Earnshaw <richard.earns...@foss.arm.com> writes: > On 28/04/2022 10:48, Andrea Corallo via Gcc-patches wrote: >> This change add bti instructions at the beginning of arm specific >> libgcc hand written assembly routines. >> 2022-03-31 Andrea Corallo <andrea.cora...@arm.com> >> * libgcc/config/arm/crti.S (FUNC_START): Add bti instruction >> if >> necessary. >> * libgcc/config/arm/lib1funcs.S (THUMB_FUNC_START, FUNC_START): >> Likewise. >> > > +#if defined(__ARM_FEATURE_BTI) > > Wouldn't it be better to use __ARM_FEATURE_BTI_DEFAULT? That way we > only get BTI instructions in multilib variants that have asked for > BTI. > > R.
Hi Richard, good point, yes I think so. Please find attached the updated patch. BR Andrea
>From 6975c9ddbc8a4b790a765589c6fd07fea92173e5 Mon Sep 17 00:00:00 2001 From: Andrea Corallo <andrea.cora...@arm.com> Date: Tue, 8 Feb 2022 10:58:31 +0100 Subject: [PATCH] [PATCH 9/12] arm: Make libgcc bti compatible This change add bti instructions at the beginning of arm specific libgcc hand written assembly routines. 2022-03-31 Andrea Corallo <andrea.cora...@arm.com> * libgcc/config/arm/crti.S (FUNC_START): Add bti instruction if necessary. * libgcc/config/arm/lib1funcs.S (THUMB_FUNC_START, FUNC_START): Likewise. --- libgcc/config/arm/crti.S | 4 +++- libgcc/config/arm/lib1funcs.S | 6 ++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/libgcc/config/arm/crti.S b/libgcc/config/arm/crti.S index 0192972a7e6..4098353af1c 100644 --- a/libgcc/config/arm/crti.S +++ b/libgcc/config/arm/crti.S @@ -51,7 +51,9 @@ .macro FUNC_START #ifdef __thumb__ .thumb - +#if defined(__ARM_FEATURE_BTI_DEFAULT) + bti +#endif push {r3, r4, r5, r6, r7, lr} #else .arm diff --git a/libgcc/config/arm/lib1funcs.S b/libgcc/config/arm/lib1funcs.S index 8c39c9f20a2..de98edcc300 100644 --- a/libgcc/config/arm/lib1funcs.S +++ b/libgcc/config/arm/lib1funcs.S @@ -345,6 +345,9 @@ LSYM(Ldiv0): TYPE (\name) .thumb_func SYM (\name): +#if defined(__ARM_FEATURE_BTI_DEFAULT) + bti +#endif .endm /* Function start macros. Variants for ARM and Thumb. */ @@ -372,6 +375,9 @@ SYM (\name): THUMB_FUNC THUMB_SYNTAX SYM (__\name): +#if defined(__ARM_FEATURE_BTI_DEFAULT) + bti +#endif .endm .macro ARM_SYM_START name -- 2.25.1