blob: d8428f7f9da7d3e2f4fc3073803e1761a802f4e6 [file] [log] [blame]
lh9ed821d2023-04-07 01:36:19 -07001#include <fcntl.h>
2#include <stdlib.h>
3#include <stdio.h>
4#include <dlfcn.h>
5
6#ifdef __UCLIBC__
7extern void _dlinfo(void);
8#endif
9
10int main(int argc, char **argv) {
11 void *handle;
12 int (*mydltest)(const char *s);
13 char *error;
14
15 handle = dlopen ("./libtest2.so", RTLD_LAZY);
16 if (!handle) {
17 fprintf(stderr, "Could not open ./libtest2.so: %s\n", dlerror());
18 exit(1);
19 }
20
21 handle = dlopen ("./libtest1.so", RTLD_LAZY);
22 if (!handle) {
23 fprintf(stderr, "Could not open ./libtest1.so: %s\n", dlerror());
24 exit(1);
25 }
26
27 mydltest = dlsym(handle, "dltest");
28 if ((error = dlerror()) != NULL) {
29 fprintf(stderr, "Could not locate symbol 'dltest': %s\n", error);
30 exit(1);
31 }
32
33 mydltest("hello world!");
34
35 dlclose(handle);
36
37 return EXIT_SUCCESS;
38}
39