]>
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 #include "test_support.h"
10 static bool inMalloc
= false;
11 static bool forceSystemMalloc
= false;
13 void* mymalloc(size_t size
)
15 // We are in our own printf, so we need to fall back to the default malloc
16 if (forceSystemMalloc
) {
21 // Recursion! This shouldn't happen.
22 forceSystemMalloc
= true;
23 FAIL("mymalloc() is recursive");
28 // ASan calls dlsym before libdyld has created an image list. Make sure that succeeds
29 void* sym
= dlsym(RTLD_DEFAULT
, "malloc");
31 forceSystemMalloc
= true;
35 if (sym
!= mymalloc
) {
36 forceSystemMalloc
= true;
37 FAIL("dlsym result %p != mymalloc %p", sym
, &mymalloc
);
39 void* result
= malloc(size
);
46 DYLD_INTERPOSE(mymalloc
, malloc
)