1 | #include <dlfcn.h> |
2 | #include <stdio.h> |
3 | |
4 | static const char obj[] = "testobj1.so" ; |
5 | |
6 | int |
7 | main (void) |
8 | { |
9 | void *d = dlopen (file: obj, RTLD_LAZY); |
10 | int n; |
11 | |
12 | if (d == NULL) |
13 | { |
14 | printf (format: "cannot load %s: %s\n" , obj, dlerror ()); |
15 | return 1; |
16 | } |
17 | |
18 | for (n = 0; n < 10000; ++n) |
19 | if (dlsym (handle: d, name: "does not exist" ) != NULL) |
20 | { |
21 | puts (s: "dlsym() did not fail" ); |
22 | return 1; |
23 | } |
24 | else if (dlerror () == NULL) |
25 | { |
26 | puts (s: "dlerror() didn't return a string" ); |
27 | return 1; |
28 | } |
29 | |
30 | return 0; |
31 | } |
32 | |