]> git.saurik.com Git - apple/objc4.git/blob - test/evil-class-def.m
objc4-756.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 #else
16 # define SIGNED_METHOD_LIST_IMP
17 #endif
18
19 #define str(x) #x
20 #define str2(x) str(x)
21
22 __BEGIN_DECLS
23 // not id to avoid ARC operations because the class doesn't implement RR methods
24 void* nop(void* self) { return self; }
25 __END_DECLS
26
27 asm(
28 ".globl _OBJC_CLASS_$_Super \n"
29 ".section __DATA,__objc_data \n"
30 ".align 3 \n"
31 "_OBJC_CLASS_$_Super: \n"
32 PTR "_OBJC_METACLASS_$_Super \n"
33 PTR "0 \n"
34 PTR "__objc_empty_cache \n"
35 PTR "0 \n"
36 PTR "L_ro \n"
37 // pad to OBJC_MAX_CLASS_SIZE
38 PTR "0 \n"
39 PTR "0 \n"
40 PTR "0 \n"
41 PTR "0 \n"
42 PTR "0 \n"
43 PTR "0 \n"
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 ""
66 "_OBJC_METACLASS_$_Super: \n"
67 PTR "_OBJC_METACLASS_$_Super \n"
68 PTR "_OBJC_CLASS_$_Super \n"
69 PTR "__objc_empty_cache \n"
70 PTR "0 \n"
71 PTR "L_meta_ro \n"
72 // pad to OBJC_MAX_CLASS_SIZE
73 PTR "0 \n"
74 PTR "0 \n"
75 PTR "0 \n"
76 PTR "0 \n"
77 PTR "0 \n"
78 PTR "0 \n"
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 ""
101 "L_ro: \n"
102 ".long 2 \n"
103 ".long 0 \n"
104 ".long "PTRSIZE" \n"
105 #if __LP64__
106 ".long 0 \n"
107 #endif
108 PTR "0 \n"
109 PTR "L_super_name \n"
110 #if EVIL_SUPER
111 PTR "L_evil_methods \n"
112 #else
113 PTR "L_good_methods \n"
114 #endif
115 PTR "0 \n"
116 PTR "L_super_ivars \n"
117 PTR "0 \n"
118 PTR "0 \n"
119 ""
120 "L_meta_ro: \n"
121 ".long 3 \n"
122 ".long 40 \n"
123 ".long 40 \n"
124 #if __LP64__
125 ".long 0 \n"
126 #endif
127 PTR "0 \n"
128 PTR "L_super_name \n"
129 #if EVIL_SUPER_META
130 PTR "L_evil_methods \n"
131 #else
132 PTR "L_good_methods \n"
133 #endif
134 PTR "0 \n"
135 PTR "0 \n"
136 PTR "0 \n"
137 PTR "0 \n"
138
139 ".globl _OBJC_CLASS_$_Sub \n"
140 ".section __DATA,__objc_data \n"
141 ".align 3 \n"
142 "_OBJC_CLASS_$_Sub: \n"
143 PTR "_OBJC_METACLASS_$_Sub \n"
144 PTR "_OBJC_CLASS_$_Super \n"
145 PTR "__objc_empty_cache \n"
146 PTR "0 \n"
147 PTR "L_sub_ro \n"
148 // pad to OBJC_MAX_CLASS_SIZE
149 PTR "0 \n"
150 PTR "0 \n"
151 PTR "0 \n"
152 PTR "0 \n"
153 PTR "0 \n"
154 PTR "0 \n"
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 ""
177 "_OBJC_METACLASS_$_Sub: \n"
178 PTR "_OBJC_METACLASS_$_Super \n"
179 PTR "_OBJC_METACLASS_$_Super \n"
180 PTR "__objc_empty_cache \n"
181 PTR "0 \n"
182 PTR "L_sub_meta_ro \n"
183 // pad to OBJC_MAX_CLASS_SIZE
184 PTR "0 \n"
185 PTR "0 \n"
186 PTR "0 \n"
187 PTR "0 \n"
188 PTR "0 \n"
189 PTR "0 \n"
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 ""
212 "L_sub_ro: \n"
213 ".long 2 \n"
214 ".long 0 \n"
215 ".long "PTRSIZE" \n"
216 #if __LP64__
217 ".long 0 \n"
218 #endif
219 PTR "0 \n"
220 PTR "L_sub_name \n"
221 #if EVIL_SUB
222 PTR "L_evil_methods \n"
223 #else
224 PTR "L_good_methods \n"
225 #endif
226 PTR "0 \n"
227 PTR "L_sub_ivars \n"
228 PTR "0 \n"
229 PTR "0 \n"
230 ""
231 "L_sub_meta_ro: \n"
232 ".long 3 \n"
233 ".long 40 \n"
234 ".long 40 \n"
235 #if __LP64__
236 ".long 0 \n"
237 #endif
238 PTR "0 \n"
239 PTR "L_sub_name \n"
240 #if EVIL_SUB_META
241 PTR "L_evil_methods \n"
242 #else
243 PTR "L_good_methods \n"
244 #endif
245 PTR "0 \n"
246 PTR "0 \n"
247 PTR "0 \n"
248 PTR "0 \n"
249
250 "L_evil_methods: \n"
251 ".long 3*"PTRSIZE" \n"
252 ".long 1 \n"
253 PTR "L_load \n"
254 PTR "L_load \n"
255 PTR "_abort" SIGNED_METHOD_LIST_IMP "\n"
256 // assumes that abort is inside the dyld shared cache
257
258 "L_good_methods: \n"
259 ".long 3*"PTRSIZE" \n"
260 ".long 2 \n"
261 PTR "L_load \n"
262 PTR "L_load \n"
263 PTR "_nop" SIGNED_METHOD_LIST_IMP "\n"
264 PTR "L_self \n"
265 PTR "L_self \n"
266 PTR "_nop" SIGNED_METHOD_LIST_IMP "\n"
267
268 "L_super_ivars: \n"
269 ".long 4*"PTRSIZE" \n"
270 ".long 1 \n"
271 PTR "L_super_ivar_offset \n"
272 PTR "L_super_ivar_name \n"
273 PTR "L_super_ivar_type \n"
274 ".long "LOGPTRSIZE" \n"
275 ".long "PTRSIZE" \n"
276
277 "L_sub_ivars: \n"
278 ".long 4*"PTRSIZE" \n"
279 ".long 1 \n"
280 PTR "L_sub_ivar_offset \n"
281 PTR "L_sub_ivar_name \n"
282 PTR "L_sub_ivar_type \n"
283 ".long "LOGPTRSIZE" \n"
284 ".long "PTRSIZE" \n"
285
286 "L_super_ivar_offset: \n"
287 ".long 0 \n"
288 "L_sub_ivar_offset: \n"
289 ".long "PTRSIZE" \n"
290
291 ".cstring \n"
292 "L_super_name: .ascii \"Super\\0\" \n"
293 "L_sub_name: .ascii \"Sub\\0\" \n"
294 "L_load: .ascii \"load\\0\" \n"
295 "L_self: .ascii \"self\\0\" \n"
296 "L_super_ivar_name: .ascii \"super_ivar\\0\" \n"
297 "L_super_ivar_type: .ascii \"c\\0\" \n"
298 "L_sub_ivar_name: .ascii \"sub_ivar\\0\" \n"
299 "L_sub_ivar_type: .ascii \"@\\0\" \n"
300
301
302 ".section __DATA,__objc_classlist \n"
303 #if !OMIT_SUPER
304 PTR "_OBJC_CLASS_$_Super \n"
305 #endif
306 #if !OMIT_SUB
307 PTR "_OBJC_CLASS_$_Sub \n"
308 #endif
309
310 ".section __DATA,__objc_nlclslist \n"
311 #if !OMIT_NL_SUPER
312 PTR "_OBJC_CLASS_$_Super \n"
313 #endif
314 #if !OMIT_NL_SUB
315 PTR "_OBJC_CLASS_$_Sub \n"
316 #endif
317
318 ".text \n"
319 );
320
321 void fn(void) { }