update test program for custom loader

This commit is contained in:
nganhkhoa 2023-06-26 15:19:59 +07:00
parent e15d1e8d6f
commit b8d8343835

View File

@ -14,21 +14,32 @@
@end @end
@implementation Bar @implementation Bar
static int x;
+ (void)load { + (void)load {
NSLog(@"%@", self); NSLog(@"%@", self);
printf("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\n"); // NSLog(@"x=%d", x)
printf("printf in [Bar load]\n");
x = 1;
}
- (void)dummy {
NSLog(@"dummy bar x=%d", x);
} }
@end @end
// @implementation Baz : Bar
// @end
__attribute__((constructor)) static void __attribute__((constructor)) static void
hmmge() { hmmge(int argc, char** argv) {
// create a dummy blank function to be replaced to call OBJC load // create a dummy blank function to be replaced to call OBJC load
printf("hmmge\n"); printf("hmmge=%p\n", hmmge);
printf("hmmge argc=%d\n", argc);
for (int i = 0; i < argc; i++) {
printf(" hmmge argv[%d]=%s\n", i, argv[i]);
}
NSLog(@"hmmge in objc-c");
Bar *bar = [[Bar alloc] init];
[bar dummy];
} }
int main(int argc, const char * argv[]) { int main(int argc, const char * argv[]) {
@ -37,5 +48,10 @@ int main(int argc, const char * argv[]) {
Foo *foo = [[Foo alloc] init]; Foo *foo = [[Foo alloc] init];
[foo bar]; [foo bar];
} }
printf("argc=%d\n", argc);
for (int i = 0; i < argc; i++) {
printf(" argv[%d]=%s\n", i, argv[i]);
}
return 0; return 0;
} }