Skip to content

Commit a7ef83f

Browse files
[AArch64][SME] Add BTI and No Exec Stack markers to sme-abi.S (#84895)
Adding BTI landing pads compiler-rt is built with -mbranch-protectoin. Tabulators are changed to 2 spaces for consistency.
1 parent 3358838 commit a7ef83f

File tree

1 file changed

+22
-12
lines changed

1 file changed

+22
-12
lines changed

compiler-rt/lib/builtins/aarch64/sme-abi.S

Lines changed: 22 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -26,32 +26,34 @@
2626
// abort(). Note that there is no need to preserve any state before the call,
2727
// because the function does not return.
2828
DEFINE_COMPILERRT_PRIVATE_FUNCTION(do_abort)
29-
.cfi_startproc
30-
.variant_pcs SYMBOL_NAME(do_abort)
31-
stp x29, x30, [sp, #-32]!
29+
.cfi_startproc
30+
.variant_pcs SYMBOL_NAME(do_abort)
31+
BTI_C
32+
stp x29, x30, [sp, #-32]!
3233
cntd x0
3334
// Store VG to a stack location that we describe with .cfi_offset
3435
str x0, [sp, #16]
3536
.cfi_def_cfa_offset 32
3637
.cfi_offset w30, -24
3738
.cfi_offset w29, -32
3839
.cfi_offset 46, -16
39-
bl __arm_sme_state
40-
tbz x0, #0, 2f
40+
bl __arm_sme_state
41+
tbz x0, #0, 2f
4142
1:
42-
smstop sm
43+
smstop sm
4344
2:
4445
// We can't make this into a tail-call because the unwinder would
4546
// need to restore the value of VG.
46-
bl SYMBOL_NAME(abort)
47-
.cfi_endproc
47+
bl SYMBOL_NAME(abort)
48+
.cfi_endproc
4849
END_COMPILERRT_FUNCTION(do_abort)
4950

5051
// __arm_sme_state fills the result registers based on a local
5152
// that is set as part of the compiler-rt startup code.
5253
// __aarch64_has_sme_and_tpidr2_el0
5354
DEFINE_COMPILERRT_OUTLINE_FUNCTION_UNMANGLED(__arm_sme_state)
54-
.variant_pcs __arm_sme_state
55+
.variant_pcs __arm_sme_state
56+
BTI_C
5557
mov x0, xzr
5658
mov x1, xzr
5759

@@ -68,7 +70,8 @@ DEFINE_COMPILERRT_OUTLINE_FUNCTION_UNMANGLED(__arm_sme_state)
6870
END_COMPILERRT_OUTLINE_FUNCTION(__arm_sme_state)
6971

7072
DEFINE_COMPILERRT_OUTLINE_FUNCTION_UNMANGLED(__arm_tpidr2_restore)
71-
.variant_pcs __arm_tpidr2_restore
73+
.variant_pcs __arm_tpidr2_restore
74+
BTI_C
7275
// If TPIDR2_EL0 is nonnull, the subroutine aborts in some platform-specific
7376
// manner.
7477
mrs x14, TPIDR2_EL0
@@ -103,7 +106,8 @@ DEFINE_COMPILERRT_OUTLINE_FUNCTION_UNMANGLED(__arm_tpidr2_restore)
103106
END_COMPILERRT_OUTLINE_FUNCTION(__arm_tpidr2_restore)
104107

105108
DEFINE_COMPILERRT_OUTLINE_FUNCTION_UNMANGLED(__arm_tpidr2_save)
106-
.variant_pcs __arm_tpidr2_restore
109+
.variant_pcs __arm_tpidr2_restore
110+
BTI_C
107111
// If the current thread does not have access to TPIDR2_EL0, the subroutine
108112
// does nothing.
109113
adrp x14, TPIDR2_SYMBOL
@@ -143,7 +147,8 @@ DEFINE_COMPILERRT_OUTLINE_FUNCTION_UNMANGLED(__arm_tpidr2_save)
143147
END_COMPILERRT_OUTLINE_FUNCTION(__arm_tpidr2_save)
144148

145149
DEFINE_COMPILERRT_OUTLINE_FUNCTION_UNMANGLED(__arm_za_disable)
146-
.variant_pcs __arm_tpidr2_restore
150+
.variant_pcs __arm_tpidr2_restore
151+
BTI_C
147152
// If the current thread does not have access to SME, the subroutine does
148153
// nothing.
149154
adrp x14, TPIDR2_SYMBOL
@@ -174,3 +179,8 @@ DEFINE_COMPILERRT_OUTLINE_FUNCTION_UNMANGLED(__arm_za_disable)
174179
0:
175180
ret
176181
END_COMPILERRT_OUTLINE_FUNCTION(__arm_za_disable)
182+
183+
NO_EXEC_STACK_DIRECTIVE
184+
185+
// GNU property note for BTI and PAC
186+
GNU_PROPERTY_BTI_PAC

0 commit comments

Comments
 (0)