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) "
19 # define SIGNED_METHOD_LIST_IMP
20 # define SIGNED_STUB_INITIALIZER
24 #define str2(x) str(x)
26 // Swift metadata initializers. Define these in the test.
27 EXTERN_C Class initSuper(Class cls, void *arg);
28 EXTERN_C Class initSub(Class cls, void *arg);
30 @interface SwiftSuper : NSObject @end
31 @interface SwiftSub : SwiftSuper @end
34 // not id to avoid ARC operations because the class doesn't implement RR methods
35 void* nop(void* self) { return self; }
38 #define SWIFT_CLASS(name, superclass, swiftInit) \
40 ".globl _OBJC_CLASS_$_" #name "\n" \
41 ".section __DATA,__objc_data \n" \
43 "_OBJC_CLASS_$_" #name ": \n" \
44 PTR "_OBJC_METACLASS_$_" #name "\n" \
45 PTR "_OBJC_CLASS_$_" #superclass "\n" \
46 PTR "__objc_empty_cache \n" \
48 PTR "L_" #name "_ro + 2 \n" \
49 /* Swift class fields. */ \
50 ".long 0 \n" /* flags */ \
51 ".long 0 \n" /* instanceAddressOffset */ \
52 ".long 16 \n" /* instanceSize */ \
53 ".short 15 \n" /* instanceAlignMask */ \
54 ".short 0 \n" /* reserved */ \
55 ".long 256 \n" /* classSize */ \
56 ".long 0 \n" /* classAddressOffset */ \
57 PTR "0 \n" /* description */ \
58 /* pad to OBJC_MAX_CLASS_SIZE */ \
84 "_OBJC_METACLASS_$_" #name ": \n" \
85 PTR "_OBJC_METACLASS_$_" #superclass "\n" \
86 PTR "_OBJC_METACLASS_$_" #superclass "\n" \
87 PTR "__objc_empty_cache \n" \
89 PTR "L_" #name "_meta_ro \n" \
90 /* pad to OBJC_MAX_CLASS_SIZE */ \
119 "L_" #name "_ro: \n" \
122 ".long " PTRSIZE " \n" \
123 ONLY_LP64(".long 0 \n") \
125 PTR "L_" #name "_name \n" \
126 PTR "L_" #name "_methods \n" \
128 PTR "L_" #name "_ivars \n" \
131 PTR "_" #swiftInit SIGNED_METHOD_LIST_IMP "\n" \
133 "L_" #name "_meta_ro: \n" \
137 ONLY_LP64(".long 0 \n") \
139 PTR "L_" #name "_name \n" \
140 PTR "L_" #name "_meta_methods \n" \
146 "L_" #name "_methods: \n" \
147 "L_" #name "_meta_methods: \n" \
148 ".long 3*" PTRSIZE "\n" \
150 PTR "L_" #name "_self \n" \
151 PTR "L_" #name "_self \n" \
152 PTR "_nop" SIGNED_METHOD_LIST_IMP "\n" \
154 "L_" #name "_ivars: \n" \
155 ".long 4*" PTRSIZE " \n" \
157 PTR "L_" #name "_ivar_offset \n" \
158 PTR "L_" #name "_ivar_name \n" \
159 PTR "L_" #name "_ivar_type \n" \
160 ".long " LOGPTRSIZE "\n" \
161 ".long " PTRSIZE "\n" \
163 "L_" #name "_ivar_offset: \n" \
167 "L_" #name "_name: .ascii \"" #name "\\0\" \n" \
168 "L_" #name "_self: .ascii \"self\\0\" \n" \
169 "L_" #name "_ivar_name: " \
170 " .ascii \"" #name "_ivar\\0\" \n" \
171 "L_" #name "_ivar_type: .ascii \"c\\0\" \n" \
176 extern char OBJC_CLASS_$_ ## name; \
177 Class Raw ## name = (Class)&OBJC_CLASS_$_ ## name
179 #define SWIFT_STUB_CLASSREF(name) \
180 extern char OBJC_CLASS_$_ ## name; \
181 static Class name ## Classref = (Class)(&OBJC_CLASS_$_ ## name + 1)
183 #define SWIFT_STUB_CLASS(name, initializer) \
185 ".globl _OBJC_CLASS_$_" #name "\n" \
186 ".section __DATA,__objc_data \n" \
188 "_dummy" #name ": \n" \
190 ".alt_entry _OBJC_CLASS_$_" #name "\n" \
191 "_OBJC_CLASS_$_" #name ": \n" \
193 PTR "_" #initializer SIGNED_STUB_INITIALIZER "\n" \
196 extern char OBJC_CLASS_$_ ## name; \
197 Class Raw ## name = (Class)&OBJC_CLASS_$_ ## name; \
198 SWIFT_STUB_CLASSREF(name)