1 // BUILD(macos): $CC main.c -o $BUILD_DIR/NSAddImage-loaded.exe -Wno-deprecated-declarations
3 // BUILD(ios,tvos,watchos,bridgeos):
5 // RUN: ./NSAddImage-loaded.exe return
12 #include <mach-o/dyld.h>
14 #include "test_support.h"
16 int main(int argc
, const char* argv
[], const char* envp
[], const char* apple
[]) {
17 // verify value is returned for image already loaded
18 const struct mach_header
* mh
= NSAddImage("/usr/lib/libSystem.B.dylib", NSADDIMAGE_OPTION_RETURN_ONLY_IF_LOADED
);
20 FAIL("Could not find mh for libSystem.B.dylib");
22 // verify existing dylib is not loaded if it is not already loaded
23 mh
= NSAddImage("/usr/lib/libz.dylib", NSADDIMAGE_OPTION_RETURN_ONLY_IF_LOADED
);
25 FAIL("Found mh for unloaded dylib libz.dylib");