From b8d8343835b98336b25a3ccff0f8c6df7ad29c90 Mon Sep 17 00:00:00 2001 From: nganhkhoa Date: Mon, 26 Jun 2023 15:19:59 +0700 Subject: [PATCH] update test program for custom loader --- research/custom_loader/a.mm | 32 ++++++++++++++++++++++++-------- 1 file changed, 24 insertions(+), 8 deletions(-) diff --git a/research/custom_loader/a.mm b/research/custom_loader/a.mm index cfbe6c0..a594fd5 100644 --- a/research/custom_loader/a.mm +++ b/research/custom_loader/a.mm @@ -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; }