Fix unwind info in x86 memcmp-ssse3.
[glibc.git] / elf / tst-tls8.c
blob36b1baca63625b28ac157ec2231a71cd4ffb9585
1 #include <dlfcn.h>
2 #include <stdio.h>
3 #include <stdlib.h>
5 #include <link.h>
6 #include <tls.h>
9 #define TEST_FUNCTION do_test ()
10 static int
11 do_test (void)
13 static const char modname1[] = "$ORIGIN/tst-tlsmod3.so";
14 static const char modname2[] = "$ORIGIN/tst-tlsmod4.so";
15 int result = 0;
16 int (*fp1) (void);
17 int (*fp2) (int, int *);
18 void *h1;
19 void *h2;
20 int i;
21 size_t modid1 = (size_t) -1;
22 size_t modid2 = (size_t) -1;
23 int *bazp;
25 for (i = 0; i < 10; ++i)
27 h1 = dlopen (modname1, RTLD_LAZY);
28 if (h1 == NULL)
30 printf ("cannot open '%s': %s\n", modname1, dlerror ());
31 exit (1);
34 /* Dirty test code here: we peek into a private data structure.
35 We make sure that the module gets assigned the same ID every
36 time. The value of the first round is used. */
37 if (modid1 == (size_t) -1)
38 modid1 = ((struct link_map *) h1)->l_tls_modid;
39 else if (((struct link_map *) h1)->l_tls_modid != modid1)
41 printf ("round %d: modid now %zd, initially %zd\n",
42 i, ((struct link_map *) h1)->l_tls_modid, modid1);
43 result = 1;
46 fp1 = dlsym (h1, "in_dso2");
47 if (fp1 == NULL)
49 printf ("cannot get symbol 'in_dso2' in %s\n", modname1);
50 exit (1);
53 result |= fp1 ();
57 h2 = dlopen (modname2, RTLD_LAZY);
58 if (h2 == NULL)
60 printf ("cannot open '%s': %s\n", modname2, dlerror ());
61 exit (1);
64 /* Dirty test code here: we peek into a private data structure.
65 We make sure that the module gets assigned the same ID every
66 time. The value of the first round is used. */
67 if (modid2 == (size_t) -1)
68 modid2 = ((struct link_map *) h1)->l_tls_modid;
69 else if (((struct link_map *) h1)->l_tls_modid != modid2)
71 printf ("round %d: modid now %zd, initially %zd\n",
72 i, ((struct link_map *) h1)->l_tls_modid, modid2);
73 result = 1;
76 bazp = dlsym (h2, "baz");
77 if (bazp == NULL)
79 printf ("cannot get symbol 'baz' in %s\n", modname2);
80 exit (1);
83 *bazp = 42 + i;
85 fp2 = dlsym (h2, "in_dso");
86 if (fp2 == NULL)
88 printf ("cannot get symbol 'in_dso' in %s\n", modname2);
89 exit (1);
92 result |= fp2 (42 + i, bazp);
94 dlclose (h1);
95 dlclose (h2);
98 h1 = dlopen (modname1, RTLD_LAZY);
99 if (h1 == NULL)
101 printf ("cannot open '%s': %s\n", modname1, dlerror ());
102 exit (1);
105 /* Dirty test code here: we peek into a private data structure.
106 We make sure that the module gets assigned the same ID every
107 time. The value of the first round is used. */
108 if (((struct link_map *) h1)->l_tls_modid != modid1)
110 printf ("round %d: modid now %zd, initially %zd\n",
111 i, ((struct link_map *) h1)->l_tls_modid, modid1);
112 result = 1;
115 fp1 = dlsym (h1, "in_dso2");
116 if (fp1 == NULL)
118 printf ("cannot get symbol 'in_dso2' in %s\n", modname1);
119 exit (1);
122 result |= fp1 ();
126 h2 = dlopen (modname2, RTLD_LAZY);
127 if (h2 == NULL)
129 printf ("cannot open '%s': %s\n", modname2, dlerror ());
130 exit (1);
133 /* Dirty test code here: we peek into a private data structure.
134 We make sure that the module gets assigned the same ID every
135 time. The value of the first round is used. */
136 if (((struct link_map *) h1)->l_tls_modid != modid2)
138 printf ("round %d: modid now %zd, initially %zd\n",
139 i, ((struct link_map *) h1)->l_tls_modid, modid2);
140 result = 1;
143 bazp = dlsym (h2, "baz");
144 if (bazp == NULL)
146 printf ("cannot get symbol 'baz' in %s\n", modname2);
147 exit (1);
150 *bazp = 62 + i;
152 fp2 = dlsym (h2, "in_dso");
153 if (fp2 == NULL)
155 printf ("cannot get symbol 'in_dso' in %s\n", modname2);
156 exit (1);
159 result |= fp2 (62 + i, bazp);
161 /* This time the dlclose calls are in reverse order. */
162 dlclose (h2);
163 dlclose (h1);
166 return result;
170 #include "../test-skeleton.c"