1 // BUILD(macos): $CC main.c -o $BUILD_DIR/NSLookupSymbolInImage-basic.exe -Wno-deprecated-declarations
3 // BUILD(ios,tvos,watchos,bridgeos):
5 // RUN: ./NSLookupSymbolInImage-basic.exe
11 #include <mach-o/dyld.h>
13 #include "test_support.h"
15 extern struct mach_header __dso_handle
;
17 int main(int argc
, const char* argv
[], const char* envp
[], const char* apple
[]) {
18 // verify known symbol works
19 NSSymbol sym
= NSLookupSymbolInImage(&__dso_handle
, "_main", NSLOOKUPSYMBOLINIMAGE_OPTION_RETURN_ON_ERROR
);
21 FAIL("Did not find symnbol _main");
24 // verify mode where NSLookupSymbolInImage() returns NULL if symbol not found
25 sym
= NSLookupSymbolInImage(&__dso_handle
, "_42hhg", NSLOOKUPSYMBOLINIMAGE_OPTION_RETURN_ON_ERROR
);
27 FAIL("Did not find symnbol _42hhg");
30 // Note: NSLookupSymbolInImage is documented to abort if symbol not found and NSLOOKUPSYMBOLINIMAGE_OPTION_RETURN_ON_ERROR not used,
31 // but dyld 2 just returned NULL, so no need to test that.