11 static const char modname1[] = "$ORIGIN/tst-tlsmod3.so";
12 static const char modname2[] = "$ORIGIN/tst-tlsmod4.so";
15 int (*fp2) (int, int *);
19 size_t modid1 = (size_t) -1;
20 size_t modid2 = (size_t) -1;
23 for (i = 0; i < 10; ++i)
25 h1 = dlopen (modname1, RTLD_LAZY);
28 printf ("cannot open '%s': %s\n", modname1, dlerror ());
32 /* Dirty test code here: we peek into a private data structure.
33 We make sure that the module gets assigned the same ID every
34 time. The value of the first round is used. */
35 if (modid1 == (size_t) -1)
36 modid1 = ((struct link_map *) h1)->l_tls_modid;
37 else if (((struct link_map *) h1)->l_tls_modid != modid1)
39 printf ("round %d: modid now %zd, initially %zd\n",
40 i, ((struct link_map *) h1)->l_tls_modid, modid1);
44 fp1 = dlsym (h1, "in_dso2");
47 printf ("cannot get symbol 'in_dso2' in %s\n", modname1);
55 h2 = dlopen (modname2, RTLD_LAZY);
58 printf ("cannot open '%s': %s\n", modname2, dlerror ());
62 /* Dirty test code here: we peek into a private data structure.
63 We make sure that the module gets assigned the same ID every
64 time. The value of the first round is used. */
65 if (modid2 == (size_t) -1)
66 modid2 = ((struct link_map *) h1)->l_tls_modid;
67 else if (((struct link_map *) h1)->l_tls_modid != modid2)
69 printf ("round %d: modid now %zd, initially %zd\n",
70 i, ((struct link_map *) h1)->l_tls_modid, modid2);
74 bazp = dlsym (h2, "baz");
77 printf ("cannot get symbol 'baz' in %s\n", modname2);
83 fp2 = dlsym (h2, "in_dso");
86 printf ("cannot get symbol 'in_dso' in %s\n", modname2);
90 result |= fp2 (42 + i, bazp);
96 h1 = dlopen (modname1, RTLD_LAZY);
99 printf ("cannot open '%s': %s\n", modname1, dlerror ());
103 /* Dirty test code here: we peek into a private data structure.
104 We make sure that the module gets assigned the same ID every
105 time. The value of the first round is used. */
106 if (((struct link_map *) h1)->l_tls_modid != modid1)
108 printf ("round %d: modid now %zd, initially %zd\n",
109 i, ((struct link_map *) h1)->l_tls_modid, modid1);
113 fp1 = dlsym (h1, "in_dso2");
116 printf ("cannot get symbol 'in_dso2' in %s\n", modname1);
124 h2 = dlopen (modname2, RTLD_LAZY);
127 printf ("cannot open '%s': %s\n", modname2, dlerror ());
131 /* Dirty test code here: we peek into a private data structure.
132 We make sure that the module gets assigned the same ID every
133 time. The value of the first round is used. */
134 if (((struct link_map *) h1)->l_tls_modid != modid2)
136 printf ("round %d: modid now %zd, initially %zd\n",
137 i, ((struct link_map *) h1)->l_tls_modid, modid2);
141 bazp = dlsym (h2, "baz");
144 printf ("cannot get symbol 'baz' in %s\n", modname2);
150 fp2 = dlsym (h2, "in_dso");
153 printf ("cannot get symbol 'in_dso' in %s\n", modname2);
157 result |= fp2 (62 + i, bazp);
159 /* This time the dlclose calls are in reverse order. */
167 #include <support/test-driver.c>