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