]>
git.saurik.com Git - apple/dyld.git/blob - testing/test-cases/dlopen-in-init3.dtest/main.c
4f6b3629f55e5ad192b803a80e417bd8d9621b55
3 // BUILD: $CC bar.c -dynamiclib -o $BUILD_DIR/libbar.dylib -install_name $RUN_DIR/libbar.dylib -DRUN_DIR="$RUN_DIR"
4 // BUILD: $CC baz.c -dynamiclib -o $BUILD_DIR/libbaz.dylib -install_name $RUN_DIR/libbaz.dylib
5 // BUILD: $CC foo.c -dynamiclib -o $BUILD_DIR/libfoo.dylib -install_name $RUN_DIR/libfoo.dylib $BUILD_DIR/libbar.dylib $BUILD_DIR/libbaz.dylib
6 // BUILD: $CC main.c -o $BUILD_DIR/dlopen-in-init3.exe -DRUN_DIR="$RUN_DIR"
8 // RUN: ./dlopen-in-init3.exe
10 // This test uses dlopen to jump ahead in the initializer graph
11 // main doesn't directly link any of the libraries here, but dlopen's libfoo which links libbar and libbar.
12 // We should run initializers in the order libbar, libbaz, libfoo.
13 // However, libbar has a static init with a dlopen of libbaz and so libbaz needs to be initialized by libbar instead of by libfoo
20 printf("[BEGIN] dlopen-in-init3\n");
21 void* fooHandle
= dlopen(RUN_DIR
"/libfoo.dylib", 0);
22 if ( fooHandle
== NULL
) {
23 printf("[FAIL] dlopen-in-init3, dlopen libfoo.dylib: %s\n", dlerror());
26 void* fooSymbol
= dlsym(RTLD_DEFAULT
, "foo");
27 if ( fooSymbol
== NULL
) {
28 printf("[FAIL] dlopen-in-init3, dlsym libfoo.dylib\n");
31 if ( ((int(*)())fooSymbol
)() != 0 )
33 printf("[PASS] dlopen-in-init3\n");