]> git.saurik.com Git - apple/dyld.git/blob - testing/test-cases/dlopen-rpath-prev.dtest/main.c
dyld-750.5.tar.gz
[apple/dyld.git] / testing / test-cases / dlopen-rpath-prev.dtest / main.c
1
2 // BUILD: $CC sub1.c -dynamiclib -install_name @rpath/librpathstatic.dylib -o $BUILD_DIR/dir1/librpathstatic.dylib
3 // BUILD: $CC sub2.c -dynamiclib -install_name @rpath/libdynamic.dylib -o $BUILD_DIR/dir2/libdynamic.dylib $BUILD_DIR/dir1/librpathstatic.dylib
4 // BUILD: $CC foo.c -dynamiclib -install_name $RUN_DIR/libstatic.dylib -o $BUILD_DIR/libstatic.dylib -rpath @loader_path/dir1 $BUILD_DIR/dir1/librpathstatic.dylib
5 // BUILD: $CC main.c $BUILD_DIR/libstatic.dylib -DRUN_DIR="$RUN_DIR" -o $BUILD_DIR/dlopen-rpath-prev.exe
6
7 // RUN: ./dlopen-rpath-prev.exe
8
9 // main links with libstatic.dylib which uses rpath to link with dir1/librpathstatic.dylib
10 // main dlopen()s libdynamic.dylib which links with dir1/librpathstatic.dylib, but has no rpath for it and depends on it being already loaded
11
12 #include <stdio.h>
13 #include <dlfcn.h>
14
15 #include "test_support.h"
16
17 int main(int argc, const char* argv[], const char* envp[], const char* apple[]) {
18 void* handle = dlopen(RUN_DIR "/dir2/libdynamic.dylib", RTLD_LAZY);
19 if ( handle == NULL ) {
20 FAIL("dlerror(): %s", dlerror());
21 }
22
23 PASS("Success");
24 }
25