Reject .so files using ELF TLS.
Bug: http://b/74361956
Test: ran tests
Change-Id: I53e71252eb08c607c2c436dcba433374c8c53887
diff --git a/tests/dlfcn_test.cpp b/tests/dlfcn_test.cpp
index 46f5097..84f525d 100644
--- a/tests/dlfcn_test.cpp
+++ b/tests/dlfcn_test.cpp
@@ -1080,6 +1080,13 @@
ASSERT_SUBSTR("libsysv-hash-table-library.so", dlinfo.dli_fname);
}
+TEST(dlfcn, dlopen_library_with_ELF_TLS) {
+ dlerror(); // Clear any pending errors.
+ void* handle = dlopen("libelf-tls-library.so", RTLD_NOW);
+ ASSERT_TRUE(handle == nullptr);
+ ASSERT_SUBSTR("unsupported ELF TLS", dlerror());
+}
+
TEST(dlfcn, dlopen_bad_flags) {
dlerror(); // Clear any pending errors.
void* handle;
diff --git a/tests/libs/Android.bp b/tests/libs/Android.bp
index 3afda67..ae5f78a 100644
--- a/tests/libs/Android.bp
+++ b/tests/libs/Android.bp
@@ -40,6 +40,16 @@
}
// -----------------------------------------------------------------------------
+// Library to test ELF TLS
+// -----------------------------------------------------------------------------
+cc_test_library {
+ name: "libelf-tls-library",
+ defaults: ["bionic_testlib_defaults"],
+ srcs: ["elf_tls_test_library.cpp"],
+ cflags: ["-fno-emulated-tls"],
+}
+
+// -----------------------------------------------------------------------------
// Library to test gnu-styled hash
// -----------------------------------------------------------------------------
cc_test_library {
diff --git a/tests/libs/elf_tls_test_library.cpp b/tests/libs/elf_tls_test_library.cpp
new file mode 100644
index 0000000..56d0171
--- /dev/null
+++ b/tests/libs/elf_tls_test_library.cpp
@@ -0,0 +1,19 @@
+/*
+ * Copyright (C) 2018 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+thread_local int elf_tls_variable;
+
+extern "C" int* get() { return &elf_tls_variable; }