]>
git.saurik.com Git - apple/dyld.git/blob - testing/test-cases/dlclose-static-terminator.dtest/main.c
2 // BUILD: $CC foo.c -dynamiclib -install_name $RUN_DIR/libterm.dylib -o $BUILD_DIR/libterm.dylib
3 // BUILD: $CC main.c -o $BUILD_DIR/dlclose-term.exe -DRUN_DIR="$RUN_DIR"
5 // RUN: ./dlclose-term.exe
10 #include <mach-o/dyld_priv.h>
12 #include "test_support.h"
14 // verify dlclose() runs static terminator
16 typedef void (*NotifyProc
)(void);
18 static bool termDidRun
= false;
20 static void termNotifyFunc()
25 int main(int argc
, const char* argv
[], const char* envp
[], const char* apple
[]) {
27 void* handle
= dlopen(RUN_DIR
"/libterm.dylib", RTLD_LAZY
);
28 if ( handle
== NULL
) {
29 FAIL("libterm.dylib could not be loaded, %s", dlerror());
32 // stuff pointer to my notifier
33 NotifyProc
* pointerAddress
= (NotifyProc
*)dlsym(handle
, "gNotifer");
34 if ( pointerAddress
== NULL
) {
35 FAIL("gNotifer not found in libterm.dylib");
37 *pointerAddress
= &termNotifyFunc
;
45 FAIL("terminator not run");