aboutsummaryrefslogtreecommitdiff
path: root/lib/lsan/lit_tests/TestCases/SharedLibs/huge_tls_lib_so.cc
diff options
context:
space:
mode:
Diffstat (limited to 'lib/lsan/lit_tests/TestCases/SharedLibs/huge_tls_lib_so.cc')
-rw-r--r--lib/lsan/lit_tests/TestCases/SharedLibs/huge_tls_lib_so.cc12
1 files changed, 12 insertions, 0 deletions
diff --git a/lib/lsan/lit_tests/TestCases/SharedLibs/huge_tls_lib_so.cc b/lib/lsan/lit_tests/TestCases/SharedLibs/huge_tls_lib_so.cc
new file mode 100644
index 000000000000..475a66ec12a4
--- /dev/null
+++ b/lib/lsan/lit_tests/TestCases/SharedLibs/huge_tls_lib_so.cc
@@ -0,0 +1,12 @@
+// A loadable module with a large thread local section, which would require
+// allocation of a new TLS storage chunk when loaded with dlopen(). We use it
+// to test the reachability of such chunks in LSan tests.
+
+// This must be large enough that it doesn't fit into preallocated static TLS
+// space (see STATIC_TLS_SURPLUS in glibc).
+__thread void *huge_thread_local_array[(1 << 20) / sizeof(void *)]; // NOLINT
+
+extern "C" void **StoreToTLS(void *p) {
+ huge_thread_local_array[0] = p;
+ return &huge_thread_local_array[0];
+}