]>
Commit | Line | Data |
---|---|---|
2b7238dd | 1 | #include <dlfcn.h> |
6a72ae21 | 2 | #include <stdio.h> |
2b7238dd UD |
3 | #include <stdlib.h> |
4 | ||
5c80f57c AJ |
5 | extern int call_me (void); |
6 | ||
2b7238dd UD |
7 | int |
8 | call_me (void) | |
9 | { | |
10 | void *h; | |
11 | int (*fp) (void); | |
12 | int res; | |
13 | ||
14 | h = dlopen ("reldepmod1.so", RTLD_LAZY); | |
15 | if (h == NULL) | |
16 | { | |
17 | printf ("cannot open reldepmod1.so in %s: %s\n", __FILE__, dlerror ()); | |
18 | exit (1); | |
19 | } | |
20 | ||
21 | fp = dlsym (h, "foo"); | |
22 | if (fp == NULL) | |
23 | { | |
24 | printf ("cannot get address of foo in global scope: %s\n", dlerror ()); | |
25 | exit (1); | |
26 | } | |
27 | ||
28 | res = fp () - 42; | |
29 | ||
30 | if (dlclose (h) != 0) | |
31 | { | |
32 | printf ("failure when closing h in %s: %s\n", __FILE__, dlerror ()); | |
33 | exit (1); | |
34 | } | |
35 | ||
36 | return res; | |
37 | } |