summaryrefslogtreecommitdiff
path: root/test/dlopen/testscope.c
diff options
context:
space:
mode:
Diffstat (limited to 'test/dlopen/testscope.c')
-rw-r--r--test/dlopen/testscope.c29
1 files changed, 29 insertions, 0 deletions
diff --git a/test/dlopen/testscope.c b/test/dlopen/testscope.c
new file mode 100644
index 0000000..90e0798
--- /dev/null
+++ b/test/dlopen/testscope.c
@@ -0,0 +1,29 @@
+#include <dlfcn.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+#define LIBNAME "libA.so"
+int main(int argc, char **argv)
+{
+ void *libA;
+ void (*libAfn)(void);
+ char *error;
+
+ libA = dlopen(LIBNAME, RTLD_LAZY);
+ if (!libA) {
+ fprintf(stderr, "Could not open ./%s: %s\n", LIBNAME, dlerror());
+ exit(1);
+ }
+
+ libAfn = dlsym(libA, "libA_func");
+ if ((error = dlerror()) != NULL) {
+ fprintf(stderr, "Could not locate symbol 'libA_func': %s\n", error);
+ exit(1);
+ }
+
+ libAfn();
+
+ dlclose(libA);
+
+ return EXIT_SUCCESS;
+}