about summary refs log tree commit diff
path: root/test/test-dlopen.c
diff options
context:
space:
mode:
authorAndrea Fioraldi <andreafioraldi@gmail.com>2021-03-18 21:34:12 +0100
committerAndrea Fioraldi <andreafioraldi@gmail.com>2021-03-18 21:34:12 +0100
commit166c8f93b5166087255265f9a00fd8babbd432d7 (patch)
tree62ff5c970bac9c73982f75a96b0c52665ab3c349 /test/test-dlopen.c
parent9393452d1c390d9c8ba3fd045107e6bb7dc312b4 (diff)
downloadafl++-166c8f93b5166087255265f9a00fd8babbd432d7.tar.gz
test-dlopen llvm test
Diffstat (limited to 'test/test-dlopen.c')
-rw-r--r--test/test-dlopen.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/test/test-dlopen.c b/test/test-dlopen.c
new file mode 100644
index 00000000..e4524536
--- /dev/null
+++ b/test/test-dlopen.c
@@ -0,0 +1,19 @@
+#include <dlfcn.h>
+#include <stdlib.h>
+
+int main(int argc, char **argv) {
+
+  if (!getenv("TEST_DLOPEN_TARGET"))
+    return 1;
+  void* lib = dlopen(getenv("TEST_DLOPEN_TARGET"), RTLD_LAZY);
+  if (!lib) {
+    perror(dlerror());
+    return 2;
+  }
+  int (*func)(int, char**) = dlsym(lib, "main_exported");
+  if (!func)
+    return 3;
+  
+  return func(argc, argv);
+
+}