]>
git.saurik.com Git - apple/dyld.git/blob - testing/test-cases/dlsym-re-export.dtest/main.c
2 // BUILD: $CC sub1.c -dynamiclib -install_name @rpath/libsub1.dylib -o $BUILD_DIR/sub1/libsub1.dylib
3 // BUILD: $CC sub2.c -dynamiclib -install_name @rpath/libsub2.dylib -o $BUILD_DIR/sub2/libsub2.dylib
4 // BUILD: $CC foo.c -dynamiclib -install_name $RUN_DIR/libfoo.dylib -o $BUILD_DIR/libfoo.dylib -rpath @loader_path/sub1 -Wl,-reexport_library,$BUILD_DIR/sub1/libsub1.dylib -Wl,-reexport_library,$BUILD_DIR/sub2/libsub2.dylib
5 // BUILD: $CC main.c -o $BUILD_DIR/dlsym-reexport.exe -DRUN_DIR="$RUN_DIR" -rpath @loader_path/sub2
7 // RUN: ./dlsym-reexport.exe
9 // rpath for sub1 is found in libfoo.dylib. rpath for sub2 is found in dlsym-reexport.exe
14 #include "test_support.h"
16 int main(int argc
, const char* argv
[], const char* envp
[], const char* apple
[]) {
17 // RTLD_FIRST means dlsym() should only search libfoo.dylib (and any re-exports)
18 void* handle
= dlopen(RUN_DIR
"/libfoo.dylib", RTLD_FIRST
);
19 if ( handle
== NULL
) {
20 FAIL("dlerror(): %s", dlerror());
23 void* sym1
= dlsym(handle
, "sub1");
25 FAIL("dlerror(): %s", dlerror());
28 void* sym2
= dlsym(handle
, "sub2");
30 FAIL("dlerror(): %s", dlerror());