]>
git.saurik.com Git - apple/dyld.git/blob - testing/test-cases/dlopen-atpath-restricted.dtest/main.c
bd55fb4d24cf59d3fd9365d2e914346932c464dd
3 // BUILD: mkdir -p $BUILD_DIR/test1
4 // BUILD: $CC bar.c -dynamiclib -o $BUILD_DIR/test1/libtest1.dylib -install_name @rpath/libtest1.dylib
5 // BUILD: $CC foo.c -bundle -o $BUILD_DIR/test1.bundle -Wl,-rpath,@loader_path/test1/ $BUILD_DIR/test1/libtest1.dylib
7 // BUILD: mkdir -p $BUILD_DIR/test2
8 // BUILD: $CC bar.c -dynamiclib -o $BUILD_DIR/test2/libtest2.dylib -install_name @loader_path/test2/libtest2.dylib
9 // BUILD: $CC foo.c -bundle -o $BUILD_DIR/test2.bundle $BUILD_DIR/test2/libtest2.dylib
11 // BUILD: mkdir -p $BUILD_DIR/test3
12 // BUILD: $CC bar.c -dynamiclib -o $BUILD_DIR/test3/libtest3.dylib -install_name @rpath/libtest3.dylib
13 // BUILD: $CC foo.c -bundle -o $BUILD_DIR/test3.bundle -Wl,-rpath,$RUN_DIR/test3 $BUILD_DIR/test3/libtest3.dylib
15 // BUILD: mkdir -p $BUILD_DIR/test4
16 // BUILD: $CC bar.c -dynamiclib -o $BUILD_DIR/test4/libtest4.dylib -install_name @rpath/libtest4.dylib
17 // BUILD: $CC foo.c -bundle -o $BUILD_DIR/test4.bundle -Wl,-rpath,@executable_path/test4/ $BUILD_DIR/test4/libtest4.dylib
19 // BUILD: mkdir -p $BUILD_DIR/test5
20 // BUILD: $CC bar.c -dynamiclib -o $BUILD_DIR/test5/libtest5.dylib -install_name @executable_path/test5/libtest5.dylib
21 // BUILD: $CC foo.c -bundle -o $BUILD_DIR/test5.bundle $BUILD_DIR/test5/libtest5.dylib
25 // BUILD: $CC main.c -o $BUILD_DIR/dlopen-restricted.exe -DRUN_DIR="$RUN_DIR" -sectcreate __RESTRICT __restrict /dev/null
27 // RUN: ./dlopen-restricted.exe
33 int main(int argc
, const char* argv
[])
35 printf("[BEGIN] dlopen-restricted\n");
37 // test1: LC_RPATH not in main executable uses @loader_path
38 void* handle
= dlopen(RUN_DIR
"/test1.bundle", RTLD_LAZY
);
39 if ( handle
== NULL
) {
40 printf("dlerror(): %s\n", dlerror());
41 printf("[FAIL] dlopen-restricted test1.bundle\n");
45 // test2: @loader_path not in main executable
46 handle
= dlopen(RUN_DIR
"/test2.bundle", RTLD_LAZY
);
47 if ( handle
== NULL
) {
48 printf("dlerror(): %s\n", dlerror());
49 printf("[FAIL] dlopen-restricted test2.bundle\n");
53 // test3: LC_RPATH not in main executable uses absolute path
54 handle
= dlopen(RUN_DIR
"/test3.bundle", RTLD_LAZY
);
55 if ( handle
== NULL
) {
56 printf("dlerror(): %s\n", dlerror());
57 printf("[FAIL] dlopen-restricted test3.bundle\n");
61 // test4: [SHOULD FAIL] LC_RPATH not in main executable uses @executable_path
62 handle
= dlopen(RUN_DIR
"/test4.bundle", RTLD_LAZY
);
63 if ( handle
!= NULL
) {
64 printf("[FAIL] dlopen-restricted test4.bundle dlopen() should not work\n");
68 // test5: [SHOULD FAIL] @executable_path in LC_LOAD_DYLIB
69 handle
= dlopen(RUN_DIR
"/test5.bundle", RTLD_LAZY
);
70 if ( handle
!= NULL
) {
71 printf("[FAIL] dlopen-restricted test5.bundle dlopen() should not work\n");
77 printf("[PASS] dlopen-restricted\n");