]> git.saurik.com Git - apple/objc4.git/blob - test/evil-class-def.m
objc4-818.2.tar.gz
[apple/objc4.git] / test / evil-class-def.m
1 #include <sys/cdefs.h>
2
3 #if __LP64__
4 # define PTR " .quad "
5 # define PTRSIZE "8"
6 # define LOGPTRSIZE "3"
7 #else
8 # define PTR " .long "
9 # define PTRSIZE "4"
10 # define LOGPTRSIZE "2"
11 #endif
12
13 #if __has_feature(ptrauth_calls)
14 # define SIGNED_METHOD_LIST_IMP "@AUTH(ia,0,addr) "
15 # define SIGNED_METHOD_LIST "@AUTH(da,0xC310,addr) "
16 # define SIGNED_ISA "@AUTH(da, 0x6AE1, addr) "
17 # define SIGNED_SUPER "@AUTH(da, 0xB5AB, addr) "
18 #else
19 # define SIGNED_METHOD_LIST_IMP
20 # define SIGNED_METHOD_LIST
21 # define SIGNED_ISA
22 # define SIGNED_SUPER
23 #endif
24
25 #define str(x) #x
26 #define str2(x) str(x)
27
28 __BEGIN_DECLS
29 // not id to avoid ARC operations because the class doesn't implement RR methods
30 void* nop(void* self) { return self; }
31 __END_DECLS
32
33 asm(
34 ".globl _OBJC_CLASS_$_Super \n"
35 ".section __DATA,__objc_data \n"
36 ".align 3 \n"
37 "_OBJC_CLASS_$_Super: \n"
38 PTR "_OBJC_METACLASS_$_Super" SIGNED_ISA "\n"
39 PTR "0 \n"
40 PTR "__objc_empty_cache \n"
41 PTR "0 \n"
42 PTR "L_ro \n"
43 // pad to OBJC_MAX_CLASS_SIZE
44 PTR "0 \n"
45 PTR "0 \n"
46 PTR "0 \n"
47 PTR "0 \n"
48 PTR "0 \n"
49 PTR "0 \n"
50 PTR "0 \n"
51 PTR "0 \n"
52 PTR "0 \n"
53 PTR "0 \n"
54 PTR "0 \n"
55 PTR "0 \n"
56 PTR "0 \n"
57 PTR "0 \n"
58 PTR "0 \n"
59 PTR "0 \n"
60 PTR "0 \n"
61 PTR "0 \n"
62 PTR "0 \n"
63 PTR "0 \n"
64 PTR "0 \n"
65 PTR "0 \n"
66 PTR "0 \n"
67 PTR "0 \n"
68 PTR "0 \n"
69 PTR "0 \n"
70 PTR "0 \n"
71 ""
72 "_OBJC_METACLASS_$_Super: \n"
73 PTR "_OBJC_METACLASS_$_Super" SIGNED_ISA "\n"
74 PTR "_OBJC_CLASS_$_Super" SIGNED_SUPER "\n"
75 PTR "__objc_empty_cache \n"
76 PTR "0 \n"
77 PTR "L_meta_ro \n"
78 // pad to OBJC_MAX_CLASS_SIZE
79 PTR "0 \n"
80 PTR "0 \n"
81 PTR "0 \n"
82 PTR "0 \n"
83 PTR "0 \n"
84 PTR "0 \n"
85 PTR "0 \n"
86 PTR "0 \n"
87 PTR "0 \n"
88 PTR "0 \n"
89 PTR "0 \n"
90 PTR "0 \n"
91 PTR "0 \n"
92 PTR "0 \n"
93 PTR "0 \n"
94 PTR "0 \n"
95 PTR "0 \n"
96 PTR "0 \n"
97 PTR "0 \n"
98 PTR "0 \n"
99 PTR "0 \n"
100 PTR "0 \n"
101 PTR "0 \n"
102 PTR "0 \n"
103 PTR "0 \n"
104 PTR "0 \n"
105 PTR "0 \n"
106 ""
107 "L_ro: \n"
108 ".long 2 \n"
109 ".long 0 \n"
110 ".long " PTRSIZE " \n"
111 #if __LP64__
112 ".long 0 \n"
113 #endif
114 PTR "0 \n"
115 PTR "L_super_name \n"
116 #if EVIL_SUPER
117 PTR "L_evil_methods" SIGNED_METHOD_LIST "\n"
118 #else
119 PTR "L_good_methods" SIGNED_METHOD_LIST "\n"
120 #endif
121 PTR "0 \n"
122 PTR "L_super_ivars \n"
123 PTR "0 \n"
124 PTR "0 \n"
125 ""
126 "L_meta_ro: \n"
127 ".long 3 \n"
128 ".long 40 \n"
129 ".long 40 \n"
130 #if __LP64__
131 ".long 0 \n"
132 #endif
133 PTR "0 \n"
134 PTR "L_super_name \n"
135 #if EVIL_SUPER_META
136 PTR "L_evil_methods" SIGNED_METHOD_LIST "\n"
137 #else
138 PTR "L_good_methods" SIGNED_METHOD_LIST "\n"
139 #endif
140 PTR "0 \n"
141 PTR "0 \n"
142 PTR "0 \n"
143 PTR "0 \n"
144
145 ".globl _OBJC_CLASS_$_Sub \n"
146 ".section __DATA,__objc_data \n"
147 ".align 3 \n"
148 "_OBJC_CLASS_$_Sub: \n"
149 PTR "_OBJC_METACLASS_$_Sub" SIGNED_ISA "\n"
150 PTR "_OBJC_CLASS_$_Super" SIGNED_SUPER "\n"
151 PTR "__objc_empty_cache \n"
152 PTR "0 \n"
153 PTR "L_sub_ro \n"
154 // pad to OBJC_MAX_CLASS_SIZE
155 PTR "0 \n"
156 PTR "0 \n"
157 PTR "0 \n"
158 PTR "0 \n"
159 PTR "0 \n"
160 PTR "0 \n"
161 PTR "0 \n"
162 PTR "0 \n"
163 PTR "0 \n"
164 PTR "0 \n"
165 PTR "0 \n"
166 PTR "0 \n"
167 PTR "0 \n"
168 PTR "0 \n"
169 PTR "0 \n"
170 PTR "0 \n"
171 PTR "0 \n"
172 PTR "0 \n"
173 PTR "0 \n"
174 PTR "0 \n"
175 PTR "0 \n"
176 PTR "0 \n"
177 PTR "0 \n"
178 PTR "0 \n"
179 PTR "0 \n"
180 PTR "0 \n"
181 PTR "0 \n"
182 ""
183 "_OBJC_METACLASS_$_Sub: \n"
184 PTR "_OBJC_METACLASS_$_Super" SIGNED_ISA "\n"
185 PTR "_OBJC_METACLASS_$_Super" SIGNED_SUPER "\n"
186 PTR "__objc_empty_cache \n"
187 PTR "0 \n"
188 PTR "L_sub_meta_ro \n"
189 // pad to OBJC_MAX_CLASS_SIZE
190 PTR "0 \n"
191 PTR "0 \n"
192 PTR "0 \n"
193 PTR "0 \n"
194 PTR "0 \n"
195 PTR "0 \n"
196 PTR "0 \n"
197 PTR "0 \n"
198 PTR "0 \n"
199 PTR "0 \n"
200 PTR "0 \n"
201 PTR "0 \n"
202 PTR "0 \n"
203 PTR "0 \n"
204 PTR "0 \n"
205 PTR "0 \n"
206 PTR "0 \n"
207 PTR "0 \n"
208 PTR "0 \n"
209 PTR "0 \n"
210 PTR "0 \n"
211 PTR "0 \n"
212 PTR "0 \n"
213 PTR "0 \n"
214 PTR "0 \n"
215 PTR "0 \n"
216 PTR "0 \n"
217 ""
218 "L_sub_ro: \n"
219 ".long 2 \n"
220 ".long 0 \n"
221 ".long " PTRSIZE " \n"
222 #if __LP64__
223 ".long 0 \n"
224 #endif
225 PTR "0 \n"
226 PTR "L_sub_name \n"
227 #if EVIL_SUB
228 PTR "L_evil_methods" SIGNED_METHOD_LIST "\n"
229 #else
230 PTR "L_good_methods" SIGNED_METHOD_LIST "\n"
231 #endif
232 PTR "0 \n"
233 PTR "L_sub_ivars \n"
234 PTR "0 \n"
235 PTR "0 \n"
236 ""
237 "L_sub_meta_ro: \n"
238 ".long 3 \n"
239 ".long 40 \n"
240 ".long 40 \n"
241 #if __LP64__
242 ".long 0 \n"
243 #endif
244 PTR "0 \n"
245 PTR "L_sub_name \n"
246 #if EVIL_SUB_META
247 PTR "L_evil_methods" SIGNED_METHOD_LIST "\n"
248 #else
249 PTR "L_good_methods" SIGNED_METHOD_LIST "\n"
250 #endif
251 PTR "0 \n"
252 PTR "0 \n"
253 PTR "0 \n"
254 PTR "0 \n"
255
256 "L_evil_methods: \n"
257 ".long 3*" PTRSIZE " \n"
258 ".long 1 \n"
259 PTR "L_load \n"
260 PTR "L_load \n"
261 PTR "_abort" SIGNED_METHOD_LIST_IMP "\n"
262 // assumes that abort is inside the dyld shared cache
263
264 "L_good_methods: \n"
265 ".long 3*" PTRSIZE " \n"
266 ".long 2 \n"
267 PTR "L_load \n"
268 PTR "L_load \n"
269 PTR "_nop" SIGNED_METHOD_LIST_IMP "\n"
270 PTR "L_self \n"
271 PTR "L_self \n"
272 PTR "_nop" SIGNED_METHOD_LIST_IMP "\n"
273
274 "L_super_ivars: \n"
275 ".long 4*" PTRSIZE " \n"
276 ".long 1 \n"
277 PTR "L_super_ivar_offset \n"
278 PTR "L_super_ivar_name \n"
279 PTR "L_super_ivar_type \n"
280 ".long " LOGPTRSIZE " \n"
281 ".long " PTRSIZE " \n"
282
283 "L_sub_ivars: \n"
284 ".long 4*" PTRSIZE " \n"
285 ".long 1 \n"
286 PTR "L_sub_ivar_offset \n"
287 PTR "L_sub_ivar_name \n"
288 PTR "L_sub_ivar_type \n"
289 ".long " LOGPTRSIZE " \n"
290 ".long " PTRSIZE " \n"
291
292 "L_super_ivar_offset: \n"
293 ".long 0 \n"
294 "L_sub_ivar_offset: \n"
295 ".long " PTRSIZE " \n"
296
297 ".cstring \n"
298 "L_super_name: .ascii \"Super\\0\" \n"
299 "L_sub_name: .ascii \"Sub\\0\" \n"
300 "L_load: .ascii \"load\\0\" \n"
301 "L_self: .ascii \"self\\0\" \n"
302 "L_super_ivar_name: .ascii \"super_ivar\\0\" \n"
303 "L_super_ivar_type: .ascii \"c\\0\" \n"
304 "L_sub_ivar_name: .ascii \"sub_ivar\\0\" \n"
305 "L_sub_ivar_type: .ascii \"@\\0\" \n"
306
307
308 ".section __DATA,__objc_classlist \n"
309 #if !OMIT_SUPER
310 PTR "_OBJC_CLASS_$_Super \n"
311 #endif
312 #if !OMIT_SUB
313 PTR "_OBJC_CLASS_$_Sub \n"
314 #endif
315
316 ".section __DATA,__objc_nlclslist \n"
317 #if !OMIT_NL_SUPER
318 PTR "_OBJC_CLASS_$_Super \n"
319 #endif
320 #if !OMIT_NL_SUB
321 PTR "_OBJC_CLASS_$_Sub \n"
322 #endif
323
324 ".text \n"
325 );
326
327 void fn(void) { }