2 * @APPLE_LICENSE_HEADER_START@
4 * Copyright (c) 2018 Apple Inc. All Rights Reserved.
6 * This file contains Original Code and/or Modifications of Original Code
7 * as defined in and that are subject to the Apple Public Source License
8 * Version 2.0 (the 'License'). You may not use this file except in
9 * compliance with the License. Please obtain a copy of the License at
10 * http://www.opensource.apple.com/apsl/ and read it before using this
13 * The Original Code and all software distributed under the License are
14 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
15 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
16 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
18 * Please see the License for the specific language governing rights and
19 * limitations under the License.
21 * @APPLE_LICENSE_HEADER_END@
23 /********************************************************************
25 * arm64-asm.h - asm tools for arm64/arm64_32 and ROP/JOP
27 ********************************************************************/
34 #define SUPPORT_TAGGED_POINTERS 1
37 #define PTRSHIFT 3 // 1<<PTRSHIFT == PTRSIZE
38 // "p" registers are pointer-sized
63 #define SUPPORT_TAGGED_POINTERS 0
66 #define PTRSHIFT 2 // 1<<PTRSHIFT == PTRSIZE
67 // "p" registers are pointer-sized
92 #if __has_feature(ptrauth_returns)
94 # define SignLR pacibsp
95 # define AuthenticateLR autibsp
99 # define AuthenticateLR
102 #if __has_feature(ptrauth_calls)
105 .macro TailCallFunctionPointer
106 // $0 = function pointer value
110 .macro TailCallCachedImp
111 // $0 = cached imp, $1 = address of cached imp, $2 = SEL
112 eor $
1, $
1, $
2 // mix SEL into ptrauth modifier
116 .macro TailCallMethodListImp
117 // $0 = method list imp, $1 = address of method list imp
121 .macro TailCallBlockInvoke
122 // $0 = invoke function, $1 = address of invoke function
126 .macro AuthAndResignAsIMP
127 // $0 = cached imp, $1 = address of cached imp, $2 = SEL
128 // note: assumes the imp is not nil
129 eor $
1, $
1, $
2 // mix SEL into ptrauth modifier
130 autib $
0, $
1 // authenticate cached imp
131 ldr xzr
, [$
0] // crash if authentication failed
132 paciza $
0 // resign cached imp as IMP
139 .macro TailCallFunctionPointer
140 // $0 = function pointer value
144 .macro TailCallCachedImp
145 // $0 = cached imp, $1 = address of cached imp, $2 = SEL
149 .macro TailCallMethodListImp
150 // $0 = method list imp, $1 = address of method list imp
154 .macro TailCallBlockInvoke
155 // $0 = invoke function, $1 = address of invoke function
159 .macro AuthAndResignAsIMP
160 // $0 = cached imp, $1 = address of cached imp, $2 = SEL
167 #define TailCallBlockInvoke TailCallMethodListImp