]>
git.saurik.com Git - apple/dyld.git/blob - testing/test-cases/dlopen-realpath.dtest/main.c
c622e9f4257a5660fdf40b22a33c3aba71112883
2 // BUILD: $CC main.c -o $BUILD_DIR/dlopen-realpath.exe
3 // BUILD: cd $BUILD_DIR && ln -s ./IOKit.framework/IOKit IOKit && ln -s /System/Library/Frameworks/IOKit.framework IOKit.framework
5 // RUN: DYLD_FALLBACK_LIBRARY_PATH=/baz ./dlopen-realpath.exe
11 static void tryImage(const char* path
)
13 printf("[BEGIN] dlopen-realpath %s\n", path
);
14 void* handle
= dlopen(path
, RTLD_LAZY
);
15 if ( handle
== NULL
) {
16 printf("dlerror(): %s\n", dlerror());
17 printf("[FAIL] dlopen-realpath %s\n", path
);
21 int result
= dlclose(handle
);
23 printf("dlclose(%p): %s\n", handle
, dlerror());
24 printf("[FAIL] dlopen-realpath %s\n", path
);
28 printf("[PASS] dlopen-realpath %s\n", path
);
35 tryImage("./IOKit.framework/IOKit");
36 tryImage("./././IOKit/../IOKit.framework/IOKit");
39 // Also try libSystem which has an alias in the OS to /usr/lib/libSystem.B.dylib
40 tryImage("/usr/lib/libSystem.dylib");
42 // Also try using non-canonical path
43 // This requires DYLD_FALLBACK_LIBRARY_PATH to be disabled, otherwise it is found that way
44 tryImage("//usr/lib/libSystem.dylib");
45 tryImage("/usr/./lib/libSystem.dylib");