Add test for --hash-style=sysv
With build system switched to gnu-hash we need
a test for sysv-hashed library.
Change-Id: I34adc216fa79199aa46066cf13fcc1c1f2581f0e
diff --git a/tests/Android.mk b/tests/Android.mk
index 5e0c593..14a5e83 100644
--- a/tests/Android.mk
+++ b/tests/Android.mk
@@ -301,9 +301,7 @@
libdl_preempt_test_1 \
libdl_preempt_test_2
-ifneq ($(filter $(TARGET_ARCH),arm arm64),$(TARGET_ARCH))
bionic-unit-tests-glibc_shared_libraries += libdl_test_df_1_global
-endif
bionic-unit-tests-glibc_whole_static_libraries := \
libBionicStandardTests \
diff --git a/tests/dlfcn_test.cpp b/tests/dlfcn_test.cpp
index cd97d55..88f0b19 100644
--- a/tests/dlfcn_test.cpp
+++ b/tests/dlfcn_test.cpp
@@ -669,12 +669,32 @@
ASSERT_TRUE(fn == dlinfo.dli_saddr);
ASSERT_STREQ("getRandomNumber", dlinfo.dli_sname);
- ASSERT_STREQ("libgnu-hash-table-library.so", dlinfo.dli_fname);
+ ASSERT_SUBSTR("libgnu-hash-table-library.so", dlinfo.dli_fname);
#else
GTEST_LOG_(INFO) << "This test does nothing for mips/mips64; mips toolchain does not support '--hash-style=gnu'\n";
#endif
}
+TEST(dlfcn, dlopen_library_with_only_sysv_hash) {
+ void* handle = dlopen("libsysv-hash-table-library.so", RTLD_NOW);
+ ASSERT_TRUE(handle != nullptr) << dlerror();
+ auto guard = make_scope_guard([&]() {
+ dlclose(handle);
+ });
+ void* sym = dlsym(handle, "getRandomNumber");
+ ASSERT_TRUE(sym != nullptr) << dlerror();
+ int (*fn)(void);
+ fn = reinterpret_cast<int (*)(void)>(sym);
+ EXPECT_EQ(4, fn());
+
+ Dl_info dlinfo;
+ ASSERT_TRUE(0 != dladdr(reinterpret_cast<void*>(fn), &dlinfo));
+
+ ASSERT_TRUE(fn == dlinfo.dli_saddr);
+ ASSERT_STREQ("getRandomNumber", dlinfo.dli_sname);
+ ASSERT_SUBSTR("libsysv-hash-table-library.so", dlinfo.dli_fname);
+}
+
TEST(dlfcn, dlopen_bad_flags) {
dlerror(); // Clear any pending errors.
void* handle;
diff --git a/tests/libs/Android.mk b/tests/libs/Android.mk
index 0793019..777ae4b 100644
--- a/tests/libs/Android.mk
+++ b/tests/libs/Android.mk
@@ -28,7 +28,7 @@
$(TEST_PATH)/Android.build.mk
# -----------------------------------------------------------------------------
-# Library used by dlfcn tests.
+# Library to test gnu-styled hash
# -----------------------------------------------------------------------------
ifneq ($(TARGET_ARCH),$(filter $(TARGET_ARCH),mips mips64))
libgnu-hash-table-library_src_files := \
@@ -43,6 +43,19 @@
endif
# -----------------------------------------------------------------------------
+# Library to test sysv-styled hash
+# -----------------------------------------------------------------------------
+libsysv-hash-table-library_src_files := \
+ dlext_test_library.cpp \
+
+libsysv-hash-table-library_ldflags := \
+ -Wl,--hash-style=sysv \
+
+module := libsysv-hash-table-library
+module_tag := optional
+include $(LOCAL_PATH)/Android.build.testlib.mk
+
+# -----------------------------------------------------------------------------
# Library used by dlext tests - with GNU RELRO program header
# -----------------------------------------------------------------------------
libdlext_test_src_files := \