]>
Commit | Line | Data |
---|---|---|
fc093be1 UD |
1 | #include <dlfcn.h> |
2 | #include <stdio.h> | |
3 | #include <stdlib.h> | |
4 | ||
5 | #include <link.h> | |
fc093be1 UD |
6 | |
7 | ||
8 | #define TEST_FUNCTION do_test () | |
9 | static int | |
10 | do_test (void) | |
11 | { | |
fc093be1 UD |
12 | static const char modname[] = "tst-tlsmod3.so"; |
13 | int result = 0; | |
14 | int (*fp) (void); | |
15 | void *h; | |
16 | int i; | |
17 | int modid = -1; | |
18 | ||
19 | for (i = 0; i < 10; ++i) | |
20 | { | |
21 | h = dlopen (modname, RTLD_LAZY); | |
22 | if (h == NULL) | |
23 | { | |
24 | printf ("cannot open '%s': %s\n", modname, dlerror ()); | |
25 | exit (1); | |
26 | } | |
27 | ||
28 | /* Dirty test code here: we peek into a private data structure. | |
29 | We make sure that the module gets assigned the same ID every | |
30 | time. The value of the first round is used. */ | |
31 | if (modid == -1) | |
32 | modid = ((struct link_map *) h)->l_tls_modid; | |
9cfd8172 | 33 | else if (((struct link_map *) h)->l_tls_modid != (size_t) modid) |
fc093be1 | 34 | { |
9cfd8172 | 35 | printf ("round %d: modid now %zu, initially %d\n", |
fc093be1 UD |
36 | i, ((struct link_map *) h)->l_tls_modid, modid); |
37 | result = 1; | |
38 | } | |
39 | ||
40 | fp = dlsym (h, "in_dso2"); | |
41 | if (fp == NULL) | |
42 | { | |
43 | printf ("cannot get symbol 'in_dso2': %s\n", dlerror ()); | |
44 | exit (1); | |
45 | } | |
46 | ||
47 | result |= fp (); | |
48 | ||
49 | dlclose (h); | |
50 | } | |
51 | ||
52 | return result; | |
fc093be1 UD |
53 | } |
54 | ||
55 | ||
56 | #include "../test-skeleton.c" |