3 // BUILD: $CC main.c -o $BUILD_DIR/NSAddImage-loaded.exe -Wno-deprecated-declarations
5 // RUN: ./NSAddImage-loaded.exe return
12 #include <mach-o/dyld.h>
15 int main(int argc
, const char* argv
[])
17 printf("[BEGIN] NSAddImage-loaded\n");
19 // verify value is returned for image already loaded
20 const struct mach_header
* mh
= NSAddImage("/usr/lib/libSystem.B.dylib", NSADDIMAGE_OPTION_RETURN_ONLY_IF_LOADED
);
22 printf("[FAIL] NSAddImage-loaded\n");
24 // verify existing dylib is not loaded if it is not already loaded
25 mh
= NSAddImage("/usr/lib/libz.dylib", NSADDIMAGE_OPTION_RETURN_ONLY_IF_LOADED
);
27 printf("[FAIL] NSAddImage-loaded\n");
29 printf("[PASS] NSAddImage-loaded\n");