summarylogtreecommitdiffstats
path: root/dlopen.c
diff options
context:
space:
mode:
authorBoohbah2015-07-06 21:22:03 +0000
committerBoohbah2015-07-06 21:22:03 +0000
commit141ea963b585534eae0fd6cd151dc03c6c238712 (patch)
tree8111a3a5fa68317d0ca35325d061b5a5631f9aa3 /dlopen.c
downloadaur-141ea963b585534eae0fd6cd151dc03c6c238712.tar.gz
Initial import
Diffstat (limited to 'dlopen.c')
-rw-r--r--dlopen.c28
1 files changed, 28 insertions, 0 deletions
diff --git a/dlopen.c b/dlopen.c
new file mode 100644
index 000000000000..0a96da8ae24b
--- /dev/null
+++ b/dlopen.c
@@ -0,0 +1,28 @@
+#include <dlfcn.h>
+#include <stdio.h>
+#include <limits.h>
+#include <sys/stat.h>
+/* Simple program to see if dlopen() would succeed. */
+int main(int argc, char **argv)
+{
+ int i;
+ struct stat st;
+ char buf[PATH_MAX];
+ for (i = 1; i < argc; i++) {
+ if (dlopen(argv[i], RTLD_NOW)) {
+ fprintf(stdout, "dlopen() of \"%s\" succeeded.\n",
+ argv[i]);
+ } else {
+ snprintf(buf, sizeof(buf), "./%s", argv[i]);
+ if ((stat(buf, &st) == 0) && dlopen(buf, RTLD_NOW)) {
+ fprintf(stdout, "dlopen() of \"./%s\" "
+ "succeeded.\n", argv[i]);
+ } else {
+ fprintf(stdout, "dlopen() of \"%s\" failed: "
+ "%s\n", argv[i], dlerror());
+ return 1;
+ }
+ }
+ }
+ return 0;
+}