blob: 28f9cfb66835eac0812f68d640de199fc1ab7c21 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
|
#include <sys/param.h>
#include <err.h>
#include <dlfcn.h>
#ifdef __ELF__
#define C_LABEL(x) x
#else
#define C_LABEL(x) "_" ## x
#endif
int
main()
{
void *handle = dlopen("libtest.so", DL_LAZY);
void (*version)(void);
if (handle == NULL)
errx(1, "could not dynamically link libtest");
version = dlsym(handle, C_LABEL("version"));
if (version == NULL)
errx(2, "libtest did not define version()");
version();
dlclose(handle);
return 0;
}
|