Make dt_runpath work for libraries opened from apk
This patch also fixes realpath for libraries opened directly
from apks.
Bug: http://b/21960914
Bug: http://b/21961857
Change-Id: I35ade661c87f1d448191f385811f6e9fd3cacf11
diff --git a/tests/dlext_test.cpp b/tests/dlext_test.cpp
index 9d8b71d..d5a5e56 100644
--- a/tests/dlext_test.cpp
+++ b/tests/dlext_test.cpp
@@ -59,6 +59,7 @@
#define LIBPATH LIBPATH_PREFIX "libdlext_test_fd/libdlext_test_fd.so"
#define LIBZIPPATH LIBPATH_PREFIX "libdlext_test_zip/libdlext_test_zip_zipaligned.zip"
+#define LIBZIPPATH_WITH_RUNPATH LIBPATH_PREFIX "libdlext_test_runpath_zip/libdlext_test_runpath_zip_zipaligned.zip"
#define LIBZIP_OFFSET PAGE_SIZE
@@ -228,6 +229,24 @@
dlclose(handle);
}
+TEST(dlfcn, dlopen_from_zip_with_dt_runpath) {
+ const std::string lib_path = std::string(getenv("ANDROID_DATA")) + LIBZIPPATH_WITH_RUNPATH;
+
+ void* handle = dlopen((lib_path + "!/libdir/libtest_dt_runpath_d_zip.so").c_str(), 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) << dlerror();
+
+ dlclose(p);
+ dlclose(handle);
+}
+
TEST(dlfcn, dlopen_from_zip_ld_library_path) {
const std::string lib_path = std::string(getenv("ANDROID_DATA")) + LIBZIPPATH + "!/libdir";