]> git.saurik.com Git - apple/objc4.git/blob - test/fakeRealizedClass2.m
objc4-818.2.tar.gz
[apple/objc4.git] / test / fakeRealizedClass2.m
1 /*
2 Variant on fakeRealizedClass which tests a fake class with no superclass rdar://problem/67692760
3 TEST_CONFIG OS=macosx
4 TEST_CRASHES
5 TEST_RUN_OUTPUT
6 objc\[\d+\]: realized class 0x[0-9a-fA-F]+ has corrupt data pointer 0x[0-9a-fA-F]+
7 objc\[\d+\]: HALTED
8 END
9 */
10
11 #include "test.h"
12
13 #include <objc/NSObject.h>
14
15 #define RW_REALIZED (1U<<31)
16
17 struct ObjCClass {
18 struct ObjCClass * __ptrauth_objc_isa_pointer isa;
19 struct ObjCClass * __ptrauth_objc_super_pointer superclass;
20 void *cachePtr;
21 uintptr_t zero;
22 uintptr_t data;
23 };
24
25 struct ObjCClass_ro {
26 uint32_t flags;
27 uint32_t instanceStart;
28 uint32_t instanceSize;
29 #ifdef __LP64__
30 uint32_t reserved;
31 #endif
32
33 union {
34 const uint8_t * ivarLayout;
35 struct ObjCClass * nonMetaClass;
36 };
37
38 const char * name;
39 struct ObjCMethodList * __ptrauth_objc_method_list_pointer baseMethodList;
40 struct protocol_list_t * baseProtocols;
41 const struct ivar_list_t * ivars;
42
43 const uint8_t * weakIvarLayout;
44 struct property_list_t *baseProperties;
45 };
46
47 extern struct ObjCClass OBJC_METACLASS_$_NSObject;
48 extern struct ObjCClass OBJC_CLASS_$_NSObject;
49
50 struct ObjCClass_ro FakeSuperclassRO = {
51 .flags = RW_REALIZED
52 };
53
54 struct ObjCClass FakeSuperclass = {
55 &OBJC_METACLASS_$_NSObject,
56 NULL,
57 NULL,
58 0,
59 (uintptr_t)&FakeSuperclassRO
60 };
61
62 struct ObjCClass_ro FakeSubclassRO;
63
64 struct ObjCClass FakeSubclass = {
65 &FakeSuperclass,
66 &FakeSuperclass,
67 NULL,
68 0,
69 (uintptr_t)&FakeSubclassRO
70 };
71
72 static struct ObjCClass *class_ptr __attribute__((used)) __attribute((section("__DATA,__objc_nlclslist"))) = &FakeSubclass;
73
74 int main() {}