]> git.saurik.com Git - apple/objc4.git/blob - test/evil-category-def.m
objc4-756.2.tar.gz
[apple/objc4.git] / test / evil-category-def.m
1 #include <sys/cdefs.h>
2
3 #if __LP64__
4 # define PTR " .quad "
5 #else
6 # define PTR " .long "
7 #endif
8
9 #if __has_feature(ptrauth_calls)
10 # define SIGNED_METHOD_LIST_IMP "@AUTH(ia,0,addr) "
11 #else
12 # define SIGNED_METHOD_LIST_IMP
13 #endif
14
15 #define str(x) #x
16 #define str2(x) str(x)
17
18 __BEGIN_DECLS
19 void nop(void) { }
20 __END_DECLS
21
22 asm(
23 ".section __DATA,__objc_data \n"
24 ".align 3 \n"
25 "L_category: \n"
26 PTR "L_cat_name \n"
27 PTR "_OBJC_CLASS_$_NSObject \n"
28 #if EVIL_INSTANCE_METHOD
29 PTR "L_evil_methods \n"
30 #else
31 PTR "L_good_methods \n"
32 #endif
33 #if EVIL_CLASS_METHOD
34 PTR "L_evil_methods \n"
35 #else
36 PTR "L_good_methods \n"
37 #endif
38 PTR "0 \n"
39 PTR "0 \n"
40
41 "L_evil_methods: \n"
42 ".long 24 \n"
43 ".long 1 \n"
44 PTR "L_load \n"
45 PTR "L_load \n"
46 PTR "_abort" SIGNED_METHOD_LIST_IMP "\n"
47 // assumes that abort is inside the dyld shared cache
48
49 "L_good_methods: \n"
50 ".long 24 \n"
51 ".long 1 \n"
52 PTR "L_load \n"
53 PTR "L_load \n"
54 PTR "_nop" SIGNED_METHOD_LIST_IMP "\n"
55
56 ".cstring \n"
57 "L_cat_name: .ascii \"Evil\\0\" \n"
58 "L_load: .ascii \"load\\0\" \n"
59
60 ".section __DATA,__objc_catlist \n"
61 #if !OMIT_CAT
62 PTR "L_category \n"
63 #endif
64
65 ".section __DATA,__objc_nlcatlist \n"
66 #if !OMIT_NL_CAT
67 PTR "L_category \n"
68 #endif
69
70 ".text \n"
71 );
72
73 void fn(void) { }