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 link_map
*)((struct dyn_elf
*)h1
)->dyn
)->l_tls_modid
;
45 else if (((struct link_map
*)((struct dyn_elf
*)h1
)->dyn
)->l_tls_modid
48 printf ("round %d: modid now %zd, initially %zd\n",
50 ((struct link_map
*)((struct dyn_elf
*)h1
)->dyn
)->l_tls_modid
,
55 if (modid1
== (size_t) -1)
56 modid1
= ((struct link_map
*) h1
)->l_tls_modid
;
57 else if (((struct link_map
*) h1
)->l_tls_modid
!= modid1
)
59 printf ("round %d: modid now %zd, initially %zd\n",
60 i
, ((struct link_map
*) h1
)->l_tls_modid
, modid1
);
65 fp1
= dlsym (h1
, "in_dso2");
68 printf ("cannot get symbol 'in_dso2' in %s\n", modname1
);
76 h2
= dlopen (modname2
, RTLD_LAZY
);
79 printf ("cannot open '%s': %s\n", modname2
, dlerror ());
83 /* Dirty test code here: we peek into a private data structure.
84 We make sure that the module gets assigned the same ID every
85 time. The value of the first round is used. */
87 if (modid2
== (size_t) -1)
88 modid2
= ((struct link_map
*)((struct dyn_elf
*)h1
)->dyn
)->l_tls_modid
;
89 else if (((struct link_map
*)((struct dyn_elf
*)h1
)->dyn
)->l_tls_modid
92 printf ("round %d: modid now %zd, initially %zd\n",
94 ((struct link_map
*)((struct dyn_elf
*)h1
)->dyn
)->l_tls_modid
,
99 if (modid2
== (size_t) -1)
100 modid2
= ((struct link_map
*) h1
)->l_tls_modid
;
101 else if (((struct link_map
*) h1
)->l_tls_modid
!= modid2
)
103 printf ("round %d: modid now %zd, initially %zd\n",
104 i
, ((struct link_map
*) h1
)->l_tls_modid
, modid2
);
109 bazp
= dlsym (h2
, "baz");
112 printf ("cannot get symbol 'baz' in %s\n", modname2
);
118 fp2
= dlsym (h2
, "in_dso");
121 printf ("cannot get symbol 'in_dso' in %s\n", modname2
);
125 result
|= fp2 (42 + i
, bazp
);
131 h1
= dlopen (modname1
, RTLD_LAZY
);
134 printf ("cannot open '%s': %s\n", modname1
, dlerror ());
138 /* Dirty test code here: we peek into a private data structure.
139 We make sure that the module gets assigned the same ID every
140 time. The value of the first round is used. */
142 if (((struct link_map
*)((struct dyn_elf
*)h1
)->dyn
)->l_tls_modid
145 printf ("round %d: modid now %zd, initially %zd\n",
147 ((struct link_map
*)((struct dyn_elf
*)h1
)->dyn
)->l_tls_modid
,
152 if (((struct link_map
*) h1
)->l_tls_modid
!= modid1
)
154 printf ("round %d: modid now %zd, initially %zd\n",
155 i
, ((struct link_map
*) h1
)->l_tls_modid
, modid1
);
160 fp1
= dlsym (h1
, "in_dso2");
163 printf ("cannot get symbol 'in_dso2' in %s\n", modname1
);
171 h2
= dlopen (modname2
, RTLD_LAZY
);
174 printf ("cannot open '%s': %s\n", modname2
, dlerror ());
178 /* Dirty test code here: we peek into a private data structure.
179 We make sure that the module gets assigned the same ID every
180 time. The value of the first round is used. */
182 if (((struct link_map
*)((struct dyn_elf
*)h1
)->dyn
)->l_tls_modid
185 printf ("round %d: modid now %zd, initially %zd\n",
187 ((struct link_map
*)((struct dyn_elf
*)h1
)->dyn
)->l_tls_modid
,
192 if (((struct link_map
*) h1
)->l_tls_modid
!= modid2
)
194 printf ("round %d: modid now %zd, initially %zd\n",
195 i
, ((struct link_map
*) h1
)->l_tls_modid
, modid2
);
200 bazp
= dlsym (h2
, "baz");
203 printf ("cannot get symbol 'baz' in %s\n", modname2
);
209 fp2
= dlsym (h2
, "in_dso");
212 printf ("cannot get symbol 'in_dso' in %s\n", modname2
);
216 result
|= fp2 (62 + i
, bazp
);
218 /* This time the dlclose calls are in reverse order. */
230 #include "../test-skeleton.c"