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

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