aboutsummaryrefslogtreecommitdiff
path: root/tests/dlfcn_test.cpp
diff options
context:
space:
mode:
authorRyan Prichard <rprichard@google.com>2022-03-24 21:14:27 -0700
committerRyan Prichard <rprichard@google.com>2022-03-25 15:51:11 -0700
commit8ea6af53e201027c63bd90f5e203798dd94e708f (patch)
tree92907086fc889e2b928d5dcaa12b2b35b09c796c /tests/dlfcn_test.cpp
parent8321ff1468792db1cb6881f5a537a0ef2311c1bb (diff)
downloadbionic-8ea6af53e201027c63bd90f5e203798dd94e708f.tar.gz
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
Diffstat (limited to 'tests/dlfcn_test.cpp')
-rw-r--r--tests/dlfcn_test.cpp15
1 files changed, 15 insertions, 0 deletions
diff --git a/tests/dlfcn_test.cpp b/tests/dlfcn_test.cpp
index e3664fd97..940e7268c 100644
--- a/tests/dlfcn_test.cpp
+++ b/tests/dlfcn_test.cpp
@@ -1654,6 +1654,21 @@ TEST(dlfcn, dlopen_invalid_textrels2) {
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();