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