3 // BUILD: $CC main.c -o $BUILD_DIR/NSAddressOfSymbol-basic.exe -Wno-deprecated-declarations
5 // RUN: ./NSAddressOfSymbol-basic.exe
12 #include <mach-o/dyld.h>
14 #include "test_support.h"
16 extern struct mach_header __dso_handle
;
18 int main(int argc
, const char* argv
[], const char* envp
[], const char* apple
[]) {
19 NSSymbol sym
= NSLookupSymbolInImage(&__dso_handle
, "_main", NSLOOKUPSYMBOLINIMAGE_OPTION_RETURN_ON_ERROR
);
21 FAIL("can't find main");
23 void* mainAddr
= NSAddressOfSymbol(sym
);
24 if ( mainAddr
!= &main
) {
25 FAIL("address returned %p is not &main=%p", mainAddr
, &main
);
29 if ( NSAddressOfSymbol(NULL
) != NULL
) {
30 FAIL("NULL not handle");