13 #define TEST_FUNCTION do_test ()
18 static const char modname1
[] = "tst-tlsmod3.so";
19 static const char modname2
[] = "tst-tlsmod4.so";
22 int (*fp2
) (int, int *);
26 size_t modid1
= (size_t) -1;
27 size_t modid2
= (size_t) -1;
30 for (i
= 0; i
< 10; ++i
)
32 h1
= dlopen (modname1
, RTLD_LAZY
);
35 printf ("cannot open '%s': %s\n", modname1
, dlerror ());
39 /* Dirty test code here: we peek into a private data structure.
40 We make sure that the module gets assigned the same ID every
41 time. The value of the first round is used. */
43 if (modid1
== (size_t) -1)
44 modid1
= ((struct dyn_elf
*) h1
)->dyn
->l_tls_modid
;
45 else if (((struct dyn_elf
*)h1
)->dyn
->l_tls_modid
!= (size_t) modid1
)
47 printf ("round %d: modid now %zd, initially %zd\n",
49 ((struct dyn_elf
*)h1
)->dyn
->l_tls_modid
,
54 if (modid1
== (size_t) -1)
55 modid1
= ((struct link_map
*) h1
)->l_tls_modid
;
56 else if (((struct link_map
*) h1
)->l_tls_modid
!= modid1
)
58 printf ("round %d: modid now %zd, initially %zd\n",
59 i
, ((struct link_map
*) h1
)->l_tls_modid
, modid1
);
64 fp1
= dlsym (h1
, "in_dso2");
67 printf ("cannot get symbol 'in_dso2' in %s\n", modname1
);
75 h2
= dlopen (modname2
, RTLD_LAZY
);
78 printf ("cannot open '%s': %s\n", modname2
, dlerror ());
82 /* Dirty test code here: we peek into a private data structure.
83 We make sure that the module gets assigned the same ID every
84 time. The value of the first round is used. */
86 if (modid2
== (size_t) -1)
87 modid2
= ((struct dyn_elf
*)h2
)->dyn
->l_tls_modid
;
88 else if (((struct dyn_elf
*)h2
)->dyn
->l_tls_modid
91 printf ("round %d: modid now %zd, initially %zd\n",
93 ((struct dyn_elf
*)h2
)->dyn
->l_tls_modid
,
98 if (modid2
== (size_t) -1)
99 modid2
= ((struct link_map
*) h2
)->l_tls_modid
;
100 else if (((struct link_map
*) h2
)->l_tls_modid
!= modid2
)
102 printf ("round %d: modid now %zd, initially %zd\n",
103 i
, ((struct link_map
*) h2
)->l_tls_modid
, modid2
);
108 bazp
= dlsym (h2
, "baz");
111 printf ("cannot get symbol 'baz' in %s\n", modname2
);
117 fp2
= dlsym (h2
, "in_dso");
120 printf ("cannot get symbol 'in_dso' in %s\n", modname2
);
124 result
|= fp2 (42 + i
, bazp
);
130 h1
= dlopen (modname1
, RTLD_LAZY
);
133 printf ("cannot open '%s': %s\n", modname1
, dlerror ());
137 /* Dirty test code here: we peek into a private data structure.
138 We make sure that the module gets assigned the same ID every
139 time. The value of the first round is used. */
141 if (((struct dyn_elf
*)h1
)->dyn
->l_tls_modid
144 printf ("round %d: modid now %zd, initially %zd\n",
146 ((struct dyn_elf
*)h1
)->dyn
->l_tls_modid
,
151 if (((struct link_map
*) h1
)->l_tls_modid
!= modid1
)
153 printf ("round %d: modid now %zd, initially %zd\n",
154 i
, ((struct link_map
*) h1
)->l_tls_modid
, modid1
);
159 fp1
= dlsym (h1
, "in_dso2");
162 printf ("cannot get symbol 'in_dso2' in %s\n", modname1
);
170 h2
= dlopen (modname2
, RTLD_LAZY
);
173 printf ("cannot open '%s': %s\n", modname2
, dlerror ());
177 /* Dirty test code here: we peek into a private data structure.
178 We make sure that the module gets assigned the same ID every
179 time. The value of the first round is used. */
181 if (((struct dyn_elf
*)h2
)->dyn
->l_tls_modid
184 printf ("round %d: modid now %zd, initially %zd\n",
186 ((struct dyn_elf
*)h2
)->dyn
->l_tls_modid
,
191 if (((struct link_map
*) h2
)->l_tls_modid
!= modid2
)
193 printf ("round %d: modid now %zd, initially %zd\n",
194 i
, ((struct link_map
*) h2
)->l_tls_modid
, modid2
);
199 bazp
= dlsym (h2
, "baz");
202 printf ("cannot get symbol 'baz' in %s\n", modname2
);
208 fp2
= dlsym (h2
, "in_dso");
211 printf ("cannot get symbol 'in_dso' in %s\n", modname2
);
215 result
|= fp2 (62 + i
, bazp
);
217 /* This time the dlclose calls are in reverse order. */
229 #include "../test-skeleton.c"