9 #define TEST_FUNCTION do_test ()
13 static const char modname1
[] = "$ORIGIN/tst-tlsmod3.so";
14 static const char modname2
[] = "$ORIGIN/tst-tlsmod4.so";
17 int (*fp2
) (int, int *);
21 size_t modid1
= (size_t) -1;
22 size_t modid2
= (size_t) -1;
25 for (i
= 0; i
< 10; ++i
)
27 h1
= dlopen (modname1
, RTLD_LAZY
);
30 printf ("cannot open '%s': %s\n", modname1
, dlerror ());
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
);
46 fp1
= dlsym (h1
, "in_dso2");
49 printf ("cannot get symbol 'in_dso2' in %s\n", modname1
);
57 h2
= dlopen (modname2
, RTLD_LAZY
);
60 printf ("cannot open '%s': %s\n", modname2
, dlerror ());
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
);
76 bazp
= dlsym (h2
, "baz");
79 printf ("cannot get symbol 'baz' in %s\n", modname2
);
85 fp2
= dlsym (h2
, "in_dso");
88 printf ("cannot get symbol 'in_dso' in %s\n", modname2
);
92 result
|= fp2 (42 + i
, bazp
);
98 h1
= dlopen (modname1
, RTLD_LAZY
);
101 printf ("cannot open '%s': %s\n", modname1
, dlerror ());
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
);
115 fp1
= dlsym (h1
, "in_dso2");
118 printf ("cannot get symbol 'in_dso2' in %s\n", modname1
);
126 h2
= dlopen (modname2
, RTLD_LAZY
);
129 printf ("cannot open '%s': %s\n", modname2
, dlerror ());
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
);
143 bazp
= dlsym (h2
, "baz");
146 printf ("cannot get symbol 'baz' in %s\n", modname2
);
152 fp2
= dlsym (h2
, "in_dso");
155 printf ("cannot get symbol 'in_dso' in %s\n", modname2
);
159 result
|= fp2 (62 + i
, bazp
);
161 /* This time the dlclose calls are in reverse order. */
170 #include "../test-skeleton.c"