Merge "Correctly resolve realpath for absolute paths"
This commit is contained in:
commit
30cd7065b6
@ -1318,6 +1318,10 @@ static int open_library(ZipArchiveCache* zip_archive_cache,
|
|||||||
int fd = TEMP_FAILURE_RETRY(open(name, O_RDONLY | O_CLOEXEC));
|
int fd = TEMP_FAILURE_RETRY(open(name, O_RDONLY | O_CLOEXEC));
|
||||||
if (fd != -1) {
|
if (fd != -1) {
|
||||||
*file_offset = 0;
|
*file_offset = 0;
|
||||||
|
if (!realpath_fd(fd, realpath)) {
|
||||||
|
PRINT("warning: unable to get realpath for the library \"%s\". Will use given path.", name);
|
||||||
|
*realpath = name;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return fd;
|
return fd;
|
||||||
}
|
}
|
||||||
|
@ -830,10 +830,11 @@ TEST(dlfcn, dladdr_executable) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#if defined(__LP64__)
|
#if defined(__LP64__)
|
||||||
#define BIONIC_PATH_TO_LIBC "/system/lib64/libc.so"
|
#define PATH_TO_SYSTEM_LIB "/system/lib64/"
|
||||||
#else
|
#else
|
||||||
#define BIONIC_PATH_TO_LIBC "/system/lib/libc.so"
|
#define PATH_TO_SYSTEM_LIB "/system/lib/"
|
||||||
#endif
|
#endif
|
||||||
|
#define PATH_TO_LIBC PATH_TO_SYSTEM_LIB "libc.so"
|
||||||
|
|
||||||
TEST(dlfcn, dladdr_libc) {
|
TEST(dlfcn, dladdr_libc) {
|
||||||
#if defined(__BIONIC__)
|
#if defined(__BIONIC__)
|
||||||
@ -843,7 +844,7 @@ TEST(dlfcn, dladdr_libc) {
|
|||||||
|
|
||||||
// /system/lib is symlink when this test is executed on host.
|
// /system/lib is symlink when this test is executed on host.
|
||||||
char libc_realpath[PATH_MAX];
|
char libc_realpath[PATH_MAX];
|
||||||
ASSERT_TRUE(realpath(BIONIC_PATH_TO_LIBC, libc_realpath) == libc_realpath);
|
ASSERT_TRUE(realpath(PATH_TO_LIBC, libc_realpath) == libc_realpath);
|
||||||
|
|
||||||
ASSERT_STREQ(libc_realpath, info.dli_fname);
|
ASSERT_STREQ(libc_realpath, info.dli_fname);
|
||||||
// TODO: add check for dfi_fbase
|
// TODO: add check for dfi_fbase
|
||||||
@ -1063,7 +1064,7 @@ extern "C" int version_zero_function2() {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(dlfcn, dt_runpath) {
|
TEST(dlfcn, dt_runpath_smoke) {
|
||||||
void* handle = dlopen("libtest_dt_runpath_d.so", RTLD_NOW);
|
void* handle = dlopen("libtest_dt_runpath_d.so", RTLD_NOW);
|
||||||
ASSERT_TRUE(handle != nullptr) << dlerror();
|
ASSERT_TRUE(handle != nullptr) << dlerror();
|
||||||
|
|
||||||
@ -1076,3 +1077,17 @@ TEST(dlfcn, dt_runpath) {
|
|||||||
|
|
||||||
dlclose(handle);
|
dlclose(handle);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST(dlfcn, dt_runpath_absolute_path) {
|
||||||
|
void* handle = dlopen(PATH_TO_SYSTEM_LIB "libtest_dt_runpath_d.so", RTLD_NOW);
|
||||||
|
ASSERT_TRUE(handle != nullptr) << dlerror();
|
||||||
|
|
||||||
|
typedef void *(* dlopen_b_fn)();
|
||||||
|
dlopen_b_fn fn = (dlopen_b_fn)dlsym(handle, "dlopen_b");
|
||||||
|
ASSERT_TRUE(fn != nullptr) << dlerror();
|
||||||
|
|
||||||
|
void *p = fn();
|
||||||
|
ASSERT_TRUE(p != nullptr);
|
||||||
|
|
||||||
|
dlclose(handle);
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user