]>
Commit | Line | Data |
---|---|---|
19cf43be | 1 | #include <dlfcn.h> |
805d2e7d UD |
2 | #include <stdio.h> |
3 | #include <stdlib.h> | |
19cf43be UD |
4 | |
5 | extern int bar (void); | |
1a511d31 AJ |
6 | extern int baz (void); |
7 | extern int foo (void); | |
59b139cb | 8 | extern void __attribute__ ((__constructor__)) init (void); |
19cf43be UD |
9 | |
10 | void *h; | |
11 | ||
12 | int | |
13 | foo (void) | |
14 | { | |
15 | return 42 + bar (); | |
16 | } | |
17 | ||
18 | int | |
19 | baz (void) | |
20 | { | |
21 | return -21; | |
22 | } | |
23 | ||
59b139cb | 24 | |
19cf43be UD |
25 | void |
26 | __attribute__ ((__constructor__)) | |
27 | init (void) | |
28 | { | |
29 | h = dlopen ("constload3.so", RTLD_GLOBAL | RTLD_LAZY); | |
805d2e7d UD |
30 | if (h == NULL) |
31 | { | |
32 | puts ("failed to load constload3"); | |
33 | exit (1); | |
34 | } | |
35 | else | |
36 | puts ("succeeded loading constload3"); | |
37 | } | |
38 | ||
39 | static void | |
40 | __attribute__ ((__destructor__)) | |
41 | fini (void) | |
42 | { | |
43 | if (dlclose (h) != 0) | |
44 | { | |
45 | puts ("failed to unload constload3"); | |
46 | exit (1); | |
47 | } | |
48 | else | |
49 | puts ("succeeded unloading constload3"); | |
19cf43be | 50 | } |