Skip to content

Commit 7b34070

Browse files
authored
[tsan][aarch64] Fix branch protection in interceptors (#95839)
Start functions with BTI in order to identify the function as a valid branch target. Also add the BTI marker to tsan_rtl_aarch64.S. With this patch, libclang_rt.tsan.so can now be generated with DT_AARCH64_BTI_PLT when built with -mbranch-protection=standard.
1 parent e37ba2c commit 7b34070

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

compiler-rt/lib/tsan/rtl/tsan_rtl_aarch64.S

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
#if defined(__aarch64__)
33

44
#include "sanitizer_common/sanitizer_asm.h"
5+
#include "builtins/assembly.h"
56

67
#if !defined(__APPLE__)
78
.section .text
@@ -16,6 +17,7 @@ ASM_HIDDEN(__tsan_setjmp)
1617
ASM_TYPE_FUNCTION(ASM_SYMBOL_INTERCEPTOR(setjmp))
1718
ASM_SYMBOL_INTERCEPTOR(setjmp):
1819
CFI_STARTPROC
20+
BTI_C
1921

2022
// Save frame/link register
2123
stp x29, x30, [sp, -32]!
@@ -66,6 +68,7 @@ ASM_SIZE(ASM_SYMBOL_INTERCEPTOR(setjmp))
6668
ASM_TYPE_FUNCTION(ASM_SYMBOL_INTERCEPTOR(_setjmp))
6769
ASM_SYMBOL_INTERCEPTOR(_setjmp):
6870
CFI_STARTPROC
71+
BTI_C
6972

7073
// Save frame/link register
7174
stp x29, x30, [sp, -32]!
@@ -116,6 +119,7 @@ ASM_SIZE(ASM_SYMBOL_INTERCEPTOR(_setjmp))
116119
ASM_TYPE_FUNCTION(ASM_SYMBOL_INTERCEPTOR(sigsetjmp))
117120
ASM_SYMBOL_INTERCEPTOR(sigsetjmp):
118121
CFI_STARTPROC
122+
BTI_C
119123

120124
// Save frame/link register
121125
stp x29, x30, [sp, -32]!
@@ -168,6 +172,7 @@ ASM_SIZE(ASM_SYMBOL_INTERCEPTOR(sigsetjmp))
168172
ASM_TYPE_FUNCTION(ASM_SYMBOL_INTERCEPTOR(__sigsetjmp))
169173
ASM_SYMBOL_INTERCEPTOR(__sigsetjmp):
170174
CFI_STARTPROC
175+
BTI_C
171176

172177
// Save frame/link register
173178
stp x29, x30, [sp, -32]!
@@ -217,4 +222,6 @@ ASM_SIZE(ASM_SYMBOL_INTERCEPTOR(__sigsetjmp))
217222

218223
NO_EXEC_STACK_DIRECTIVE
219224

225+
GNU_PROPERTY_BTI_PAC
226+
220227
#endif

0 commit comments

Comments
 (0)