]>
git.saurik.com Git - apple/dyld.git/blob - testing/test-cases/dlsym-re-export.dtest/main.c
b1752d65a95f2913ed29b63f77c1e8461059a2aa
2 // BUILD: mkdir -p $BUILD_DIR/sub1 $BUILD_DIR/sub2
3 // BUILD: $CC sub1.c -dynamiclib -install_name @rpath/libsub1.dylib -o $BUILD_DIR/sub1/libsub1.dylib
4 // BUILD: $CC sub2.c -dynamiclib -install_name @rpath/libsub2.dylib -o $BUILD_DIR/sub2/libsub2.dylib
5 // 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
6 // BUILD: $CC main.c -o $BUILD_DIR/dlsym-reexport.exe -DRUN_DIR="$RUN_DIR" -rpath @loader_path/sub2
8 // RUN: ./dlsym-reexport.exe
10 // rpath for sub1 is found in libfoo.dylib. rpath for sub2 is found in dlsym-reexport.exe
17 printf("[BEGIN] dlsym-re-export\n");
18 // RTLD_FIRST means dlsym() should only search libfoo.dylib (and any re-exports)
19 void* handle
= dlopen(RUN_DIR
"/libfoo.dylib", RTLD_FIRST
);
20 if ( handle
== NULL
) {
21 printf("dlerror(): %s\n", dlerror());
22 printf("[FAIL] dlsym-re-export\n");
26 void* sym1
= dlsym(handle
, "sub1");
28 printf("dlerror(): %s\n", dlerror());
29 printf("[FAIL] dlsym-re-export\n");
33 void* sym2
= dlsym(handle
, "sub2");
35 printf("dlerror(): %s\n", dlerror());
36 printf("[FAIL] dlsym-re-export\n");
40 printf("[PASS] dlsym-re-export\n");