1#include <stdio.h>
2
3
4__thread int foo;
5
6
7int
8in_dso (int n, int *caller_foop)
9{
10 int *foop;
11 int result = 0;
12
13 puts (s: "foo"); /* Make sure PLT is used before macros. */
14 asm ("" ::: "memory");
15
16 foop = &foo;
17
18 if (caller_foop != NULL && foop != caller_foop)
19 {
20 printf (format: "callers address of foo differs: %p vs %p\n", caller_foop, foop);
21 result = 1;
22 }
23 else if (*foop != n)
24 {
25 printf (format: "foo != %d\n", n);
26 result = 1;
27 }
28
29 *foop = 16;
30
31 return result;
32}
33

source code of glibc/elf/tst-tlsmod2.c