diff options
Diffstat (limited to 'test/asan/TestCases/Linux/static_tls.cc')
-rw-r--r-- | test/asan/TestCases/Linux/static_tls.cc | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/test/asan/TestCases/Linux/static_tls.cc b/test/asan/TestCases/Linux/static_tls.cc new file mode 100644 index 000000000000..785228b29238 --- /dev/null +++ b/test/asan/TestCases/Linux/static_tls.cc @@ -0,0 +1,29 @@ +// REQUIRES: asan-64-bits +// Regression test: __tls_get_addr interceptor must recognize static TLS. +// +// RUN: %clangxx_asan -DSHARED %s -shared -o %t-so.so -fPIC +// RUN: %clangxx_asan %s -ldl -pthread -o %t %t-so.so +// RUN: env ASAN_OPTIONS=$ASAN_OPTIONS:verbosity=2 %run %t 2>&1 | FileCheck %s + +// CHECK: before +// CHECK: __tls_get_addr: static tls +// CHECK: after + +// XFAIL: powerpc64 + +#ifndef SHARED +#include <stdio.h> + +unsigned *f(); +int main(int argc, char *argv[]) { + fprintf(stderr, "before\n"); + f(); + fprintf(stderr, "after\n"); + return 0; +} +#else // SHARED +static __thread unsigned ThreadLocal; +unsigned *f() { + return &ThreadLocal; +} +#endif |