diff options
author | Dmitriy Ivanov <dimitry@google.com> | 2015-04-02 16:03:56 -0700 |
---|---|---|
committer | Dmitriy Ivanov <dimitry@google.com> | 2015-04-03 10:50:48 -0700 |
commit | 9b82136b987bc01224e3b42732334ea27c97d188 (patch) | |
tree | 036facba010c670c5d6bfc3fa9dbb2de0f28caf8 /tests/dlext_test.cpp | |
parent | ab7c79e22e5495a2aa171047a044ce1037e461a9 (diff) | |
download | android_bionic-9b82136b987bc01224e3b42732334ea27c97d188.tar.gz android_bionic-9b82136b987bc01224e3b42732334ea27c97d188.tar.bz2 android_bionic-9b82136b987bc01224e3b42732334ea27c97d188.zip |
Add ANDROID_DLEXT_FORCE_LOAD flag
This flag allows to force loading of the library
in the case when for some reason multiple ELF files
share the same filename (because the already-loaded
library has been removed and overwritten, for example).
Change-Id: I798d44409ee13d63eaa75d685e99c4d028d2b0c1
Diffstat (limited to 'tests/dlext_test.cpp')
-rw-r--r-- | tests/dlext_test.cpp | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/tests/dlext_test.cpp b/tests/dlext_test.cpp index ca6a75a95..700abff5e 100644 --- a/tests/dlext_test.cpp +++ b/tests/dlext_test.cpp @@ -173,6 +173,40 @@ TEST_F(DlExtTest, ExtInfoUseOffsetWihtoutFd) { ASSERT_STREQ("dlopen failed: invalid extended flag combination (ANDROID_DLEXT_USE_LIBRARY_FD_OFFSET without ANDROID_DLEXT_USE_LIBRARY_FD): 0x20", dlerror()); } +TEST(dlext, android_dlopen_ext_force_load_smoke) { + // 1. Open actual file + void* handle = dlopen("libdlext_test.so", RTLD_NOW); + ASSERT_DL_NOTNULL(handle); + // 2. Open link with force_load flag set + android_dlextinfo extinfo; + extinfo.flags = ANDROID_DLEXT_FORCE_LOAD; + void* handle2 = android_dlopen_ext("libdlext_test_v2.so", RTLD_NOW, &extinfo); + ASSERT_DL_NOTNULL(handle2); + ASSERT_TRUE(handle != handle2); + + dlclose(handle2); + dlclose(handle); +} + +TEST(dlext, android_dlopen_ext_force_load_soname_exception) { + // Check if soname lookup still returns already loaded library + // when ANDROID_DLEXT_FORCE_LOAD flag is specified. + void* handle = dlopen("libdlext_test_v2.so", RTLD_NOW); + ASSERT_DL_NOTNULL(handle); + + android_dlextinfo extinfo; + extinfo.flags = ANDROID_DLEXT_FORCE_LOAD; + + // Note that 'libdlext_test.so' is dt_soname for libdlext_test_v2.so + void* handle2 = android_dlopen_ext("libdlext_test.so", RTLD_NOW, &extinfo); + + ASSERT_DL_NOTNULL(handle2); + ASSERT_TRUE(handle == handle2); + + dlclose(handle2); + dlclose(handle); +} + TEST(dlfcn, dlopen_from_zip_absolute_path) { const std::string lib_path = std::string(getenv("ANDROID_DATA")) + LIBZIPPATH; |