blob: 4547c9716d89a530c81f0f728326026fcf2b90f3 [file] [log] [blame]
lh9ed821d2023-04-07 01:36:19 -07001#include <stdio.h>
2
3#include <tls.h>
4
5#ifdef USE_TLS
6#include "tls-macros.h"
7
8
9COMMON_INT_DEF(foo);
10
11
12int
13in_dso (int n, int *caller_foop)
14{
15 int *foop;
16 int result = 0;
17
18 puts ("foo"); /* Make sure PLT is used before macros. */
19 __asm__ ("" ::: "memory");
20
21 foop = TLS_GD (foo);
22
23 if (caller_foop != NULL && foop != caller_foop)
24 {
25 printf ("callers address of foo differs: %p vs %p\n", caller_foop, foop);
26 result = 1;
27 }
28 else if (*foop != n)
29 {
30 printf ("foo != %d\n", n);
31 result = 1;
32 }
33
34 *foop = 16;
35
36 return result;
37}
38#endif