6 # define LOGPTRSIZE "3"
7 # define ONLY_LP64(x) x
11 # define LOGPTRSIZE "2"
15 #if __has_feature(ptrauth_calls)
16 # define SIGNED_METHOD_LIST_IMP "@AUTH(ia,0,addr) "
17 # define SIGNED_STUB_INITIALIZER "@AUTH(ia,0xc671,addr) "
18 # define SIGNED_METHOD_LIST "@AUTH(da,0xC310,addr) "
19 # define SIGNED_ISA "@AUTH(da, 0x6AE1, addr) "
20 # define SIGNED_SUPER "@AUTH(da, 0xB5AB, addr) "
22 # define SIGNED_METHOD_LIST_IMP
23 # define SIGNED_STUB_INITIALIZER
24 # define SIGNED_METHOD_LIST
30 #define str2(x) str(x)
32 // Swift metadata initializers. Define these in the test.
33 EXTERN_C Class initSuper(Class cls, void *arg);
34 EXTERN_C Class initSub(Class cls, void *arg);
36 @interface SwiftSuper : NSObject @end
37 @interface SwiftSub : SwiftSuper @end
40 // not id to avoid ARC operations because the class doesn't implement RR methods
41 void* nop(void* self) { return self; }
44 #define SWIFT_CLASS(name, superclass, swiftInit) \
46 ".globl _OBJC_CLASS_$_" #name "\n" \
47 ".section __DATA,__objc_data \n" \
49 "_OBJC_CLASS_$_" #name ": \n" \
50 PTR "_OBJC_METACLASS_$_" #name SIGNED_ISA "\n" \
51 PTR "_OBJC_CLASS_$_" #superclass SIGNED_SUPER "\n" \
52 PTR "__objc_empty_cache \n" \
54 PTR "L_" #name "_ro + 2 \n" \
55 /* Swift class fields. */ \
56 ".long 0 \n" /* flags */ \
57 ".long 0 \n" /* instanceAddressOffset */ \
58 ".long 16 \n" /* instanceSize */ \
59 ".short 15 \n" /* instanceAlignMask */ \
60 ".short 0 \n" /* reserved */ \
61 ".long 256 \n" /* classSize */ \
62 ".long 0 \n" /* classAddressOffset */ \
63 PTR "0 \n" /* description */ \
64 /* pad to OBJC_MAX_CLASS_SIZE */ \
90 "_OBJC_METACLASS_$_" #name ": \n" \
91 PTR "_OBJC_METACLASS_$_" #superclass SIGNED_ISA "\n" \
92 PTR "_OBJC_METACLASS_$_" #superclass SIGNED_SUPER "\n" \
93 PTR "__objc_empty_cache \n" \
95 PTR "L_" #name "_meta_ro \n" \
96 /* pad to OBJC_MAX_CLASS_SIZE */ \
125 "L_" #name "_ro: \n" \
128 ".long " PTRSIZE " \n" \
129 ONLY_LP64(".long 0 \n") \
131 PTR "L_" #name "_name \n" \
132 PTR "L_" #name "_methods" SIGNED_METHOD_LIST "\n" \
134 PTR "L_" #name "_ivars \n" \
137 PTR "_" #swiftInit SIGNED_METHOD_LIST_IMP "\n" \
139 "L_" #name "_meta_ro: \n" \
143 ONLY_LP64(".long 0 \n") \
145 PTR "L_" #name "_name \n" \
146 PTR "L_" #name "_meta_methods" SIGNED_METHOD_LIST "\n" \
152 "L_" #name "_methods: \n" \
153 "L_" #name "_meta_methods: \n" \
154 ".long 3*" PTRSIZE "\n" \
156 PTR "L_" #name "_self \n" \
157 PTR "L_" #name "_self \n" \
158 PTR "_nop" SIGNED_METHOD_LIST_IMP "\n" \
160 "L_" #name "_ivars: \n" \
161 ".long 4*" PTRSIZE " \n" \
163 PTR "L_" #name "_ivar_offset \n" \
164 PTR "L_" #name "_ivar_name \n" \
165 PTR "L_" #name "_ivar_type \n" \
166 ".long " LOGPTRSIZE "\n" \
167 ".long " PTRSIZE "\n" \
169 "L_" #name "_ivar_offset: \n" \
173 "L_" #name "_name: .ascii \"" #name "\\0\" \n" \
174 "L_" #name "_self: .ascii \"self\\0\" \n" \
175 "L_" #name "_ivar_name: " \
176 " .ascii \"" #name "_ivar\\0\" \n" \
177 "L_" #name "_ivar_type: .ascii \"c\\0\" \n" \
182 extern char OBJC_CLASS_$_ ## name; \
183 Class Raw ## name = (Class)&OBJC_CLASS_$_ ## name
185 #define SWIFT_STUB_CLASSREF(name) \
186 extern char OBJC_CLASS_$_ ## name; \
187 static Class name ## Classref = (Class)(&OBJC_CLASS_$_ ## name + 1)
189 #define SWIFT_STUB_CLASS(name, initializer) \
191 ".globl _OBJC_CLASS_$_" #name "\n" \
192 ".section __DATA,__objc_data \n" \
194 "_dummy" #name ": \n" \
196 ".alt_entry _OBJC_CLASS_$_" #name "\n" \
197 "_OBJC_CLASS_$_" #name ": \n" \
199 PTR "_" #initializer SIGNED_STUB_INITIALIZER "\n" \
202 extern char OBJC_CLASS_$_ ## name; \
203 Class Raw ## name = (Class)&OBJC_CLASS_$_ ## name; \
204 SWIFT_STUB_CLASSREF(name)