tst-tls4.c 882 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. #include <dlfcn.h>
  2. #include <stdio.h>
  3. #include <stdlib.h>
  4. #define TEST_FUNCTION do_test ()
  5. static int
  6. do_test (void)
  7. {
  8. #ifdef USE_TLS
  9. static const char modname[] = "tst-tlsmod2.so";
  10. int result = 0;
  11. int *foop;
  12. int (*fp) (int, int *);
  13. void *h;
  14. h = dlopen (modname, RTLD_LAZY);
  15. if (h == NULL)
  16. {
  17. printf ("cannot open '%s': %s\n", modname, dlerror ());
  18. exit (1);
  19. }
  20. fp = dlsym (h, "in_dso");
  21. if (fp == NULL)
  22. {
  23. printf ("cannot get symbol 'in_dso': %s\n", dlerror ());
  24. exit (1);
  25. }
  26. result |= fp (0, NULL);
  27. foop = dlsym (h, "foo");
  28. if (foop == NULL)
  29. {
  30. printf ("cannot get symbol 'foo' the second time: %s\n", dlerror ());
  31. exit (1);
  32. }
  33. if (*foop != 16)
  34. {
  35. puts ("foo != 16");
  36. result = 1;
  37. }
  38. dlclose (h);
  39. return result;
  40. #else
  41. return 0;
  42. #endif
  43. }
  44. #include "../test-skeleton.c"