1 | #include <dlfcn.h> |
---|---|
2 | #include <stdio.h> |
3 | #include <stdlib.h> |
4 | |
5 | extern int call_me (void); |
6 | |
7 | int |
8 | call_me (void) |
9 | { |
10 | int (*fp) (void); |
11 | |
12 | fp = dlsym (RTLD_DEFAULT, name: "foo"); |
13 | if (fp == NULL) |
14 | { |
15 | printf (format: "cannot get address of foo in global scope: %s\n", dlerror ()); |
16 | exit (status: 1); |
17 | } |
18 | |
19 | return fp () - 42; |
20 | } |
21 |