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
@implementation Bar
static int x;
+ (void)load {
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
// @implementation Baz : Bar
// @end
__attribute__((constructor)) static void
hmmge() {
// create a dummy blank function to be replaced to call OBJC load
printf("hmmge\n");
hmmge(int argc, char** argv) {
// create a dummy blank function to be replaced to call OBJC load
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[]) {
@ -37,5 +48,10 @@ int main(int argc, const char * argv[]) {
Foo *foo = [[Foo alloc] init];
[foo bar];
}
printf("argc=%d\n", argc);
for (int i = 0; i < argc; i++) {
printf(" argv[%d]=%s\n", i, argv[i]);
}
return 0;
}