Always process TLS relocs using general code path
This is important for enabling the error about unsupported TLS
relocations to local symbols. The fast path tends to skip this error,
because it fails during lookup_symbol(). Add a test for this error.
I didn't see a performance regression in the linker_relocation
benchmark.
Bug: http://b/226978634
Test: m bionic-unit-tests
Change-Id: Ibef9bde2973cf8c2d420ecc9e8fe2c69a5097ce2
diff --git a/tests/dlfcn_test.cpp b/tests/dlfcn_test.cpp
index e3664fd..940e726 100644
--- a/tests/dlfcn_test.cpp
+++ b/tests/dlfcn_test.cpp
@@ -1654,6 +1654,21 @@
ASSERT_SUBSTR(expected_dlerror.c_str(), dlerror());
}
+TEST(dlfcn, dlopen_invalid_local_tls) {
+ const std::string libpath = GetPrebuiltElfDir() + "/libtest_invalid-local-tls.so";
+
+ void* handle = dlopen(libpath.c_str(), RTLD_NOW);
+ ASSERT_TRUE(handle == nullptr);
+#if defined(__arm__)
+ const char* referent = "local section";
+#else
+ const char* referent = "local symbol \"tls_var_2\"";
+#endif
+ std::string expected_dlerror = std::string("dlopen failed: unexpected TLS reference to ") +
+ referent + " in \"" + libpath + "\"";
+ ASSERT_SUBSTR(expected_dlerror.c_str(), dlerror());
+}
+
TEST(dlfcn, dlopen_df_1_global) {
void* handle = dlopen("libtest_dlopen_df_1_global.so", RTLD_NOW);
ASSERT_TRUE(handle != nullptr) << dlerror();