Fix symbol lookup order during relocation
Relocate symbol against DF_1_GLOBAL shared libraries
loaded before this shared library. This includes
main executable, ld_preloads and other libraries
that have DF_1_GLOBAL flag set.
Bug: 2643900
Bug: 15432753
Bug: 18186310
(cherry picked from commit d225a5e65223b375a63548c4b780f04d8f3d7b60)
Change-Id: I4e889cdf2dfbf8230b0790053d311ee6b0d0ee2d
diff --git a/tests/dlfcn_test.cpp b/tests/dlfcn_test.cpp
index e604f5a..a7fe2f8 100644
--- a/tests/dlfcn_test.cpp
+++ b/tests/dlfcn_test.cpp
@@ -499,6 +499,20 @@
ASSERT_TRUE(!is_unloaded);
}
+TEST(dlfcn, dlsym_df_1_global) {
+#if !defined(__arm__)
+ void* handle = dlopen("libtest_dlsym_df_1_global.so", RTLD_NOW);
+ ASSERT_TRUE(handle != nullptr) << dlerror();
+ int (*get_answer)();
+ get_answer = reinterpret_cast<int (*)()>(dlsym(handle, "dl_df_1_global_get_answer"));
+ ASSERT_TRUE(get_answer != nullptr) << dlerror();
+ ASSERT_EQ(42, get_answer());
+ ASSERT_EQ(0, dlclose(handle));
+#else
+ GTEST_LOG_(INFO) << "This test does nothing on arm (to be reenabled once b/18137520 or b/18130452 are fixed).\n";
+#endif
+}
+
TEST(dlfcn, dlopen_failure) {
void* self = dlopen("/does/not/exist", RTLD_NOW);
ASSERT_TRUE(self == NULL);