Merge "Add bootstrap directory to bootstrap linker's search path."

This commit is contained in:
Peter Collingbourne 2019-05-17 02:26:29 +00:00 committed by Gerrit Code Review
commit 8bb97d7781
2 changed files with 11 additions and 0 deletions

View file

@ -1162,6 +1162,13 @@ static int open_library(android_namespace_t* ns,
}
}
#if !defined(__ANDROID_APEX__)
if (fd == -1) {
std::vector<std::string> bootstrap_paths = { std::string(kSystemLibDir) + "/bootstrap" };
fd = open_library_on_paths(zip_archive_cache, name, file_offset, bootstrap_paths, realpath);
}
#endif
if (fd == -1) {
fd = open_library_on_paths(zip_archive_cache, name, file_offset, ns->get_default_library_paths(), realpath);
}

View file

@ -999,6 +999,7 @@ TEST(dlfcn, dlopen_executable_by_absolute_path) {
#error "Unknown architecture"
#endif
#define PATH_TO_LIBC PATH_TO_SYSTEM_LIB "libc.so"
#define PATH_TO_BOOTSTRAP_LIBC PATH_TO_SYSTEM_LIB "bootstrap/libc.so"
#define ALTERNATE_PATH_TO_LIBC ALTERNATE_PATH_TO_SYSTEM_LIB "libc.so"
TEST(dlfcn, dladdr_libc) {
@ -1018,6 +1019,9 @@ TEST(dlfcn, dladdr_libc) {
sizeof(ALTERNATE_PATH_TO_SYSTEM_LIB) - 1) == 0) {
// Platform with emulated architecture. Symlink on ARC++.
ASSERT_TRUE(realpath(ALTERNATE_PATH_TO_LIBC, libc_realpath) == libc_realpath);
} else if (strncmp(PATH_TO_BOOTSTRAP_LIBC, info.dli_fname,
sizeof(PATH_TO_BOOTSTRAP_LIBC) - 1) == 0) {
ASSERT_TRUE(realpath(PATH_TO_BOOTSTRAP_LIBC, libc_realpath) == libc_realpath);
} else {
// /system/lib is symlink when this test is executed on host.
ASSERT_TRUE(realpath(PATH_TO_LIBC, libc_realpath) == libc_realpath);