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