3 // BUILD: $CC main.c -o $BUILD_DIR/NSLookupSymbolInImage-basic.exe -Wno-deprecated-declarations
5 // RUN: ./NSLookupSymbolInImage-basic.exe
11 #include <mach-o/dyld.h>
13 extern struct mach_header __dso_handle
;
15 int main(int argc
, const char* argv
[])
17 printf("[BEGIN] NSLookupSymbolInImage-basic\n");
19 // verify known symbol works
20 NSSymbol sym
= NSLookupSymbolInImage(&__dso_handle
, "_main", NSLOOKUPSYMBOLINIMAGE_OPTION_RETURN_ON_ERROR
);
22 printf("[FAIL] NSLookupSymbolInImage-basic _main\n");
26 // verify mode where NSLookupSymbolInImage() returns NULL if symbol not found
27 sym
= NSLookupSymbolInImage(&__dso_handle
, "_42hhg", NSLOOKUPSYMBOLINIMAGE_OPTION_RETURN_ON_ERROR
);
29 printf("[FAIL] NSLookupSymbolInImage-basic _42hhg\n");
33 // Note: NSLookupSymbolInImage is documented to abort if symbol not found and NSLOOKUPSYMBOLINIMAGE_OPTION_RETURN_ON_ERROR not used,
34 // but dyld 2 just returned NULL, so no need to test that.
36 printf("[PASS] NSLookupSymbolInImage-basic\n");