]>
git.saurik.com Git - apple/dyld.git/blob - testing/test-cases/static-terminators.dtest/main.c
2 // BUILD: $CC base.c -dynamiclib -install_name $RUN_DIR/libbase.dylib -o $BUILD_DIR/libbase.dylib
3 // BUILD: $CC foo.c -dynamiclib -install_name $RUN_DIR/libdynamic.dylib -o $BUILD_DIR/libdynamic.dylib $BUILD_DIR/libbase.dylib
4 // BUILD: $CC main.c -o $BUILD_DIR/static-terminators.exe -DRUN_DIR="$RUN_DIR" $BUILD_DIR/libbase.dylib
6 // RUN: ./static-terminators.exe
11 #include <mach-o/dyld_priv.h>
13 #include "test_support.h"
15 // verify all static terminators run in proper order
18 extern void mainTerminated();
20 static __attribute__((destructor
))
23 LOG("main's static terminator");
28 int main(int argc
, const char* argv
[], const char* envp
[], const char* apple
[]) {
30 void* handle
= dlopen(RUN_DIR
"/libdynamic.dylib", RTLD_LAZY
);
31 if ( handle
== NULL
) {
32 FAIL("libdynamic.dylib could not be loaded, %s", dlerror());
35 // PASS is printed in libbase.dylib terminator