chiark / gitweb /
fishdescriptor: Utility for RTLD_NOW
authorIan Jackson <ian.jackson@eu.citrix.com>
Fri, 6 Oct 2017 18:04:03 +0000 (19:04 +0100)
committerIan Jackson <Ian.Jackson@eu.citrix.com>
Fri, 6 Oct 2017 18:04:09 +0000 (19:04 +0100)
Actually we don't want to do this.  It is better to use the python dl
or os modules, so we will do that in a moment.

Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
fishdescriptor/Makefile
fishdescriptor/fishdescriptor.c [new file with mode: 0644]

index e6b493a..5b63931 100644 (file)
@@ -9,7 +9,7 @@ MINOR=0
 LIBCANON=       libfishdescriptor-donate.so.$(MAJOR)
 LIBTARGET=      $(LIBCANON).$(MINOR)
 
-all:   $(LIBTARGET)
+all:   $(LIBTARGET) fishdescriptor
 
 $(LIBTARGET):  donate.o
        $(CC) -shared -Wl,-soname -Wl,$(LIBCANON) -o $@ $< $(LIBS)
diff --git a/fishdescriptor/fishdescriptor.c b/fishdescriptor/fishdescriptor.c
new file mode 100644 (file)
index 0000000..b86831f
--- /dev/null
@@ -0,0 +1,42 @@
+/*
+ *
+ * utility
+ *
+ */
+
+#define _GNU_SOURCE
+
+#include <unistd.h>
+#include <getopt.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <dlfcn.h>
+
+static const struct option longopts[] = {
+  { "print-rtld-now", 0, 0, '\1' },
+  { }
+};
+
+static void printusage(FILE *f) {
+  fputs("usage: fishdescriptor --print-rtld-now\n",f);
+}
+
+int main(int argc, char **argv) {
+  int o;
+
+  while ((o = getopt_long(argc, argv, "", longopts, 0)) != -1) {
+    switch (o) {
+    case '\1' /* --print-rtld-now */:
+      printf("%d\n", RTLD_NOW);
+      exit (0);
+    default:
+      fputs("bad usage: unknown option\n",stderr);
+      printusage(stderr);
+      exit(-1);
+    }
+  }
+
+  fputs("bad usage: XXX\n",stderr);
+  printusage(stderr);
+  exit(-1);
+}