]> git.ipfire.org Git - thirdparty/glibc.git/blob - elf/tst-tls4.c
[BZ #2510, BZ #2830, BZ #3137, BZ #3313, BZ #3426, BZ #3465, BZ #3480, BZ #3483,...
[thirdparty/glibc.git] / elf / tst-tls4.c
1 #include <dlfcn.h>
2 #include <stdio.h>
3 #include <stdlib.h>
4
5 #include <tls.h>
6
7
8 #define TEST_FUNCTION do_test ()
9 static int
10 do_test (void)
11 {
12 static const char modname[] = "tst-tlsmod2.so";
13 int result = 0;
14 int *foop;
15 int (*fp) (int, int *);
16 void *h;
17
18 h = dlopen (modname, RTLD_LAZY);
19 if (h == NULL)
20 {
21 printf ("cannot open '%s': %s\n", modname, dlerror ());
22 exit (1);
23 }
24
25 fp = dlsym (h, "in_dso");
26 if (fp == NULL)
27 {
28 printf ("cannot get symbol 'in_dso': %s\n", dlerror ());
29 exit (1);
30 }
31
32 result |= fp (0, NULL);
33
34 foop = dlsym (h, "foo");
35 if (foop == NULL)
36 {
37 printf ("cannot get symbol 'foo' the second time: %s\n", dlerror ());
38 exit (1);
39 }
40 if (*foop != 16)
41 {
42 puts ("foo != 16");
43 result = 1;
44 }
45
46 dlclose (h);
47
48 return result;
49 }
50
51
52 #include "../test-skeleton.c"