]>
git.saurik.com Git - apple/dyld.git/blob - testing/test-cases/dlsym-in-interposed-malloc.dtest/interposer.c
6 #include <mach-o/dyld-interposing.h>
8 static bool inMalloc
= false;
9 static bool forceSystemMalloc
= false;
11 void* mymalloc(size_t size
)
13 // We are in our own printf, so we need to fall back to the default malloc
14 if (forceSystemMalloc
) {
19 // Recursion! This shouldn't happen.
20 forceSystemMalloc
= true;
21 printf("[FAIL] dlsym-in-interposed-malloc mymalloc() is recursive\n");
27 // ASan calls dlsym before libdyld has created an image list. Make sure that succeeds
28 void* sym
= dlsym(RTLD_DEFAULT
, "malloc");
30 forceSystemMalloc
= true;
31 printf("[FAIL] dlsym-in-interposed-malloc dlsym failed\n");
35 if (sym
!= mymalloc
) {
36 forceSystemMalloc
= true;
37 printf("[FAIL] dlsym-in-interposed-malloc dlsym result %p != mymalloc %p\n", sym
, &mymalloc
);
40 void* result
= malloc(size
);
47 DYLD_INTERPOSE(mymalloc
, malloc
)