tst-tlsmod2.c 559 B

123456789101112131415161718192021222324252627282930313233343536
  1. #include <stdio.h>
  2. #ifdef USE_TLS
  3. #include "tls-macros.h"
  4. COMMON_INT_DEF(foo);
  5. int
  6. in_dso (int n, int *caller_foop)
  7. {
  8. int *foop;
  9. int result = 0;
  10. puts ("foo"); /* Make sure PLT is used before macros. */
  11. __asm__ ("" ::: "memory");
  12. foop = TLS_GD (foo);
  13. if (caller_foop != NULL && foop != caller_foop)
  14. {
  15. printf ("callers address of foo differs: %p vs %p\n", caller_foop, foop);
  16. result = 1;
  17. }
  18. else if (*foop != n)
  19. {
  20. printf ("foo != %d\n", n);
  21. result = 1;
  22. }
  23. *foop = 16;
  24. return result;
  25. }
  26. #endif