xref: /llvm-project/compiler-rt/test/sanitizer_common/TestCases/Linux/use_tls_test.cpp (revision b834d6309455e340d6f5dcb8b8de885da5cf25a0)
1 // Test that executable with ELF-TLS will link/run successfully
2 // RUN: %clangxx -fno-emulated-tls %s -o %t
3 // RUN: %run %t 2>&1
4 // REQUIRES: android-29
5 
6 #include <stdio.h>
7 #include <stdlib.h>
8 
9 __thread void *tls_var;
10 int var;
11 
set_var()12 void set_var() {
13   var = 123;
14   tls_var = &var;
15 }
main()16 int main() {
17   set_var();
18   fprintf(stderr, "Test alloc: %p\n", tls_var);
19   fflush(stderr);
20   return 0;
21 }
22