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, $3 = isa
112 eor $
1, $
1, $
2 // mix SEL into ptrauth modifier
113 eor $
1, $
1, $
3 // mix isa into ptrauth modifier
117 .macro TailCallMethodListImp
118 // $0 = method list imp, $1 = address of method list imp
122 .macro TailCallBlockInvoke
123 // $0 = invoke function, $1 = address of invoke function
127 .macro AuthAndResignAsIMP
128 // $0 = cached imp, $1 = address of cached imp, $2 = SEL, $3 = isa
129 // note: assumes the imp is not nil
130 eor $
1, $
1, $
2 // mix SEL into ptrauth modifier
131 eor $
1, $
1, $
3 // mix isa into ptrauth modifier
132 autib $
0, $
1 // authenticate cached imp
133 ldr xzr
, [$
0] // crash if authentication failed
134 paciza $
0 // resign cached imp as IMP
141 .macro TailCallFunctionPointer
142 // $0 = function pointer value
146 .macro TailCallCachedImp
147 // $0 = cached imp, $1 = address of cached imp, $2 = SEL, $3 = isa
152 .macro TailCallMethodListImp
153 // $0 = method list imp, $1 = address of method list imp
157 .macro TailCallBlockInvoke
158 // $0 = invoke function, $1 = address of invoke function
162 .macro AuthAndResignAsIMP
163 // $0 = cached imp, $1 = address of cached imp, $2 = SEL
170 #define TailCallBlockInvoke TailCallMethodListImp