1: #include <dlfcn.h>
2: #include <errno.h>
3: #include <error.h>
4: #include <mcheck.h>
5: #include <stdio.h>
6: #include <stdlib.h>
7:
8: int
9: main (void)
10: {
11: int (*foo) (void);
12: void *h;
13: int ret;
14:
15: mtrace ();
16:
17: h = dlopen ("constload2.so", RTLD_LAZY | RTLD_GLOBAL);
18: if (h == NULL)
19: error (EXIT_FAILURE, errno, "cannot load module \"constload2.so\"");
20: foo = dlsym (h, "foo");
21: ret = foo ();
22:
23:
24:
25:
26: if (dlclose (h) != 0)
27: {
28: puts ("failed to close");
29: exit (EXIT_FAILURE);
30: }
31: return ret;
32: }