]>
Commit | Line | Data |
---|---|---|
3fac0001 UD |
1 | #include <dlfcn.h> |
2 | #include <mcheck.h> | |
3 | #include <stdio.h> | |
4 | #include <stdlib.h> | |
5 | ||
6 | ||
7 | int | |
8 | main (void) | |
9 | { | |
10 | void *p1; | |
11 | void *p2; | |
12 | int (*fp) (void); | |
13 | int result; | |
14 | ||
15 | mtrace (); | |
16 | ||
17 | p1 = dlopen ("dblloadmod1.so", RTLD_LAZY); | |
18 | if (p1 == NULL) | |
19 | { | |
20 | printf ("cannot open dblloadmod1.so: %s\n", dlerror ()); | |
21 | exit (EXIT_FAILURE); | |
22 | } | |
23 | ||
24 | p2 = dlopen ("dblloadmod2.so", RTLD_LAZY); | |
25 | if (p1 == NULL) | |
26 | { | |
27 | printf ("cannot open dblloadmod2.so: %s\n", dlerror ()); | |
28 | exit (EXIT_FAILURE); | |
29 | } | |
30 | ||
31 | fp = dlsym (p1, "foo"); | |
32 | if (fp == NULL) | |
33 | { | |
34 | printf ("cannot get function \"foo\": %s\n", dlerror ()); | |
35 | exit (EXIT_FAILURE); | |
36 | } | |
37 | ||
38 | result = fp (); | |
39 | ||
40 | if (dlclose (p1) != 0) | |
41 | { | |
42 | printf ("error while closing dblloadmod1.so: %s\n", dlerror ()); | |
43 | exit (EXIT_FAILURE); | |
44 | } | |
45 | ||
46 | if (dlclose (p2) != 0) | |
47 | { | |
48 | printf ("error while closing dblloadmod2.so: %s\n", dlerror ()); | |
49 | exit (EXIT_FAILURE); | |
50 | } | |
51 | ||
52 | return result; | |
53 | } |