ARM64: Add support for ARM64e pointer authentication codes (PAC).
Contributed by Peter Cawley. #559
This commit is contained in:
@@ -348,16 +348,22 @@ static void emit_cnb(ASMState *as, A64Ins ai, Reg r, MCode *target)
|
||||
|
||||
#define emit_jmp(as, target) emit_branch(as, A64I_B, (target))
|
||||
|
||||
static void emit_call(ASMState *as, void *target)
|
||||
static void emit_call(ASMState *as, ASMFunction target)
|
||||
{
|
||||
MCode *p = --as->mcp;
|
||||
ptrdiff_t delta = (char *)target - (char *)p;
|
||||
#if LJ_ABI_PAUTH
|
||||
char *targetp = ptrauth_auth_data((char *)target,
|
||||
ptrauth_key_function_pointer, 0);
|
||||
#else
|
||||
char *targetp = (char *)target;
|
||||
#endif
|
||||
ptrdiff_t delta = targetp - (char *)p;
|
||||
if (A64F_S_OK(delta>>2, 26)) {
|
||||
*p = A64I_BL | A64F_S26(delta>>2);
|
||||
} else { /* Target out of range: need indirect call. But don't use R0-R7. */
|
||||
Reg r = ra_allock(as, i64ptr(target),
|
||||
RSET_RANGE(RID_X8, RID_MAX_GPR)-RSET_FIXED);
|
||||
*p = A64I_BLR | A64F_N(r);
|
||||
*p = A64I_BLR_AUTH | A64F_N(r);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user