Define NO_COMPAT_NEEDED.
[glibc/history.git] / elf / tst-tls16.c
blobb3519858a0d601a4010bc3e0825888bc1c44ddd5
1 #include <dlfcn.h>
2 #include <stdio.h>
4 static int
5 do_test (void)
7 void *h = dlopen ("tst-tlsmod16a.so", RTLD_LAZY | RTLD_GLOBAL);
8 if (h == NULL)
10 puts ("unexpectedly failed to open tst-tlsmod16a.so");
11 exit (1);
14 void *p = dlsym (h, "tlsvar");
16 /* This dlopen should indeed fail, because tlsvar was assigned to
17 dynamic TLS, and the new module requests it to be in static TLS.
18 However, there's a possibility that dlopen succeeds if the
19 variable is, for whatever reason, assigned to static TLS, or if
20 the module fails to require static TLS, or even if TLS is not
21 supported. */
22 h = dlopen ("tst-tlsmod16b.so", RTLD_NOW | RTLD_GLOBAL);
23 if (h == NULL)
25 return 0;
28 puts ("unexpectedly succeeded to open tst-tlsmod16b.so");
31 void *(*fp) (void) = (void *(*) (void)) dlsym (h, "in_dso");
32 if (fp == NULL)
34 puts ("cannot find in_dso");
35 exit (1);
38 /* If the dlopen passes, at least make sure the address returned by
39 dlsym is the same as that returned by the initial-exec access.
40 If the variable was assigned to dynamic TLS during dlsym, this
41 portion will fail. */
42 if (fp () != p)
44 puts ("returned values do not match");
45 exit (1);
48 return 0;
51 #define TEST_FUNCTION do_test ()
52 #include "../test-skeleton.c"