8 #define TEST_FUNCTION do_test ()
12 static const char modname1
[] = "$ORIGIN/tst-tlsmod3.so";
13 static const char modname2
[] = "$ORIGIN/tst-tlsmod4.so";
16 int (*fp2
) (int, int *);
20 size_t modid1
= (size_t) -1;
21 size_t modid2
= (size_t) -1;
24 for (i
= 0; i
< 10; ++i
)
26 h1
= dlopen (modname1
, RTLD_LAZY
);
29 printf ("cannot open '%s': %s\n", modname1
, dlerror ());
33 /* Dirty test code here: we peek into a private data structure.
34 We make sure that the module gets assigned the same ID every
35 time. The value of the first round is used. */
36 if (modid1
== (size_t) -1)
37 modid1
= ((struct link_map
*) h1
)->l_tls_modid
;
38 else if (((struct link_map
*) h1
)->l_tls_modid
!= modid1
)
40 printf ("round %d: modid now %zd, initially %zd\n",
41 i
, ((struct link_map
*) h1
)->l_tls_modid
, modid1
);
45 fp1
= dlsym (h1
, "in_dso2");
48 printf ("cannot get symbol 'in_dso2' in %s\n", modname1
);
56 h2
= dlopen (modname2
, RTLD_LAZY
);
59 printf ("cannot open '%s': %s\n", modname2
, dlerror ());
63 /* Dirty test code here: we peek into a private data structure.
64 We make sure that the module gets assigned the same ID every
65 time. The value of the first round is used. */
66 if (modid2
== (size_t) -1)
67 modid2
= ((struct link_map
*) h1
)->l_tls_modid
;
68 else if (((struct link_map
*) h1
)->l_tls_modid
!= modid2
)
70 printf ("round %d: modid now %zd, initially %zd\n",
71 i
, ((struct link_map
*) h1
)->l_tls_modid
, modid2
);
75 bazp
= dlsym (h2
, "baz");
78 printf ("cannot get symbol 'baz' in %s\n", modname2
);
84 fp2
= dlsym (h2
, "in_dso");
87 printf ("cannot get symbol 'in_dso' in %s\n", modname2
);
91 result
|= fp2 (42 + i
, bazp
);
97 h1
= dlopen (modname1
, RTLD_LAZY
);
100 printf ("cannot open '%s': %s\n", modname1
, dlerror ());
104 /* Dirty test code here: we peek into a private data structure.
105 We make sure that the module gets assigned the same ID every
106 time. The value of the first round is used. */
107 if (((struct link_map
*) h1
)->l_tls_modid
!= modid1
)
109 printf ("round %d: modid now %zd, initially %zd\n",
110 i
, ((struct link_map
*) h1
)->l_tls_modid
, modid1
);
114 fp1
= dlsym (h1
, "in_dso2");
117 printf ("cannot get symbol 'in_dso2' in %s\n", modname1
);
125 h2
= dlopen (modname2
, RTLD_LAZY
);
128 printf ("cannot open '%s': %s\n", modname2
, dlerror ());
132 /* Dirty test code here: we peek into a private data structure.
133 We make sure that the module gets assigned the same ID every
134 time. The value of the first round is used. */
135 if (((struct link_map
*) h1
)->l_tls_modid
!= modid2
)
137 printf ("round %d: modid now %zd, initially %zd\n",
138 i
, ((struct link_map
*) h1
)->l_tls_modid
, modid2
);
142 bazp
= dlsym (h2
, "baz");
145 printf ("cannot get symbol 'baz' in %s\n", modname2
);
151 fp2
= dlsym (h2
, "in_dso");
154 printf ("cannot get symbol 'in_dso' in %s\n", modname2
);
158 result
|= fp2 (62 + i
, bazp
);
160 /* This time the dlclose calls are in reverse order. */
169 #include "../test-skeleton.c"