1 | #include <dlfcn.h> |
2 | #include <stdio.h> |
3 | |
4 | int |
5 | main (void) |
6 | { |
7 | void *h = dlopen (file: "$ORIGIN/unload7mod1.so" , RTLD_LAZY); |
8 | if (h == NULL) |
9 | { |
10 | puts (s: "dlopen unload7mod1.so failed" ); |
11 | return 1; |
12 | } |
13 | |
14 | int (*fn) (void); |
15 | fn = dlsym (handle: h, name: "foo" ); |
16 | if (fn == NULL) |
17 | { |
18 | puts (s: "dlsym failed" ); |
19 | return 1; |
20 | } |
21 | |
22 | int ret = 0; |
23 | if (fn () == 0) |
24 | ++ret; |
25 | |
26 | void *h2 = dlopen (file: "$ORIGIN/unload7mod2.so" , RTLD_LAZY); |
27 | if (h2 == NULL) |
28 | { |
29 | puts (s: "dlopen unload7mod2.so failed" ); |
30 | return 1; |
31 | } |
32 | dlclose (handle: h2); |
33 | |
34 | if (fn () == 0) |
35 | ++ret; |
36 | |
37 | dlclose (handle: h); |
38 | return ret; |
39 | } |
40 | |