about summary refs log tree commit diff
path: root/REORG.TODO/elf/ltglobmod2.c
diff options
context:
space:
mode:
Diffstat (limited to 'REORG.TODO/elf/ltglobmod2.c')
-rw-r--r--REORG.TODO/elf/ltglobmod2.c33
1 files changed, 33 insertions, 0 deletions
diff --git a/REORG.TODO/elf/ltglobmod2.c b/REORG.TODO/elf/ltglobmod2.c
new file mode 100644
index 0000000000..33f14cc980
--- /dev/null
+++ b/REORG.TODO/elf/ltglobmod2.c
@@ -0,0 +1,33 @@
+#include <dlfcn.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+extern int bar (void);
+extern int foo (void);
+
+int
+foo (void)
+{
+  void *h;
+  int res;
+
+  /* Load ltglobalmod1 in the global namespace.  */
+  h = dlopen ("ltglobmod1.so", RTLD_GLOBAL | RTLD_LAZY);
+  if (h == NULL)
+    {
+      printf ("%s: cannot open %s: %s",
+	      __FUNCTION__, "ltglobmod1.so", dlerror ());
+      exit (EXIT_FAILURE);
+    }
+
+  /* Call bar.  This is undefined in the DSO.  */
+  puts ("about to call `bar'");
+  fflush (stdout);
+  res = bar ();
+
+  printf ("bar returned %d\n", res);
+
+  dlclose (h);
+
+  return res != 42;
+}