Skip to content

Commit 4a79181

Browse files
committed
[llvm][Support] Add ARM64e support for split stacks
ARM64e needs to use the authenticated version of blr for this call as the target function pointer is signed. This also adds the pacibsp/retab pair. This is not strictly required, but is a standard part of the prolog/epilog.
1 parent e8b2c31 commit 4a79181

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

llvm/lib/Support/ProgramStack.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,9 @@ __asm__ (
7070
".p2align 2\n\t"
7171
"_ZN4llvm17runOnNewStackImplEPvPFvS0_ES0_:\n\t"
7272
".cfi_startproc\n\t"
73+
#if __arm64e__
74+
"pacibsp\n\t" // sign x30 using sp
75+
#endif
7376
"mov x16, sp\n\t"
7477
"sub x0, x0, #0x20\n\t" // subtract space from stack
7578
"stp xzr, x16, [x0, #0x00]\n\t" // save old sp
@@ -81,12 +84,20 @@ __asm__ (
8184
".cfi_offset w29, -16\n\t" // fp
8285

8386
"mov x0, x2\n\t" // Ctx is the only argument
87+
#if __arm64e__
88+
"blraaz x1\n\t" // authenticate x1 then call Fn
89+
#else
8490
"blr x1\n\t" // call Fn
91+
#endif
8592

8693
"ldp x29, x30, [sp, #0x10]\n\t" // restore fp, lr
8794
"ldp xzr, x16, [sp, #0x00]\n\t" // load old sp
8895
"mov sp, x16\n\t"
96+
#if __arm64e__
97+
"retab\n\t" // authenticate x30 then return
98+
#else
8999
"ret\n\t"
100+
#endif
90101
".cfi_endproc"
91102
);
92103
#endif

0 commit comments

Comments
 (0)