about summary refs log tree commit diff
path: root/REORG.TODO/dlfcn/default.c
diff options
context:
space:
mode:
authorZack Weinberg <zackw@panix.com>2017-06-08 15:39:03 -0400
committerZack Weinberg <zackw@panix.com>2017-06-08 15:39:03 -0400
commit5046dbb4a7eba5eccfd258f92f4735c9ffc8d069 (patch)
tree4470480d904b65cf14ca524f96f79eca818c3eaf /REORG.TODO/dlfcn/default.c
parent199fc19d3aaaf57944ef036e15904febe877fc93 (diff)
downloadglibc-5046dbb4a7eba5eccfd258f92f4735c9ffc8d069.tar.gz
glibc-5046dbb4a7eba5eccfd258f92f4735c9ffc8d069.tar.xz
glibc-5046dbb4a7eba5eccfd258f92f4735c9ffc8d069.zip
Prepare for radical source tree reorganization. zack/build-layout-experiment
All top-level files and directories are moved into a temporary storage
directory, REORG.TODO, except for files that will certainly still
exist in their current form at top level when we're done (COPYING,
COPYING.LIB, LICENSES, NEWS, README), all old ChangeLog files (which
are moved to the new directory OldChangeLogs, instead), and the
generated file INSTALL (which is just deleted; in the new order, there
will be no generated files checked into version control).
Diffstat (limited to 'REORG.TODO/dlfcn/default.c')
-rw-r--r--REORG.TODO/dlfcn/default.c80
1 files changed, 80 insertions, 0 deletions
diff --git a/REORG.TODO/dlfcn/default.c b/REORG.TODO/dlfcn/default.c
new file mode 100644
index 0000000000..612ab79b12
--- /dev/null
+++ b/REORG.TODO/dlfcn/default.c
@@ -0,0 +1,80 @@
+#include <dlfcn.h>
+#include <stdio.h>
+#include <string.h>
+
+
+extern int test_in_mod1 (void *);
+extern int test_in_mod2 (void *);
+
+
+int
+main (int argc, char *argv[])
+{
+  int (*ifp) (void);
+  void *p;
+  int result = 0;
+  Dl_info info;
+
+  dladdr(main, &info);
+  if (info.dli_fname == NULL)
+    {
+      printf ("%s: dladdr returns NULL dli_fname\n", __FILE__);
+      result = 1;
+    }
+  else if (strcmp (info.dli_fname, argv[0]))
+    {
+      printf ("%s: dladdr returned '%s' as dli_fname\n", __FILE__, info.dli_fname);
+      result = 1;
+    }
+  else
+    printf ("%s: dladdr returned correct dli_fname\n", __FILE__);
+
+  /* Find function `main'.  */
+  p = dlsym (RTLD_DEFAULT, "main");
+  if (p == NULL)
+    {
+      printf ("%s: main not found\n", __FILE__);
+      result = 1;
+    }
+  else if ((int (*)(int, char **))p != main)
+    {
+      printf ("%s: wrong address returned for main\n", __FILE__);
+      result = 1;
+    }
+  else
+    printf ("%s: main correctly found\n", __FILE__);
+
+  ifp = dlsym (RTLD_DEFAULT, "found_in_mod1");
+  if ((void *) ifp == NULL)
+    {
+      printf ("%s: found_in_mod1 not found\n", __FILE__);
+      result = 1;
+    }
+  else if (ifp () != 1)
+    {
+      printf ("%s: wrong address returned for found_in_mod1\n", __FILE__);
+      result = 1;
+    }
+  else
+    printf ("%s: found_in_mod1 correctly found\n", __FILE__);
+
+  ifp = dlsym (RTLD_DEFAULT, "found_in_mod2");
+  if ((void *) ifp == NULL)
+    {
+      printf ("%s: found_in_mod2 not found\n", __FILE__);
+      result = 1;
+    }
+  else if (ifp () != 2)
+    {
+      printf ("%s: wrong address returned for found_in_mod2\n", __FILE__);
+      result = 1;
+    }
+  else
+    printf ("%s: found_in_mod2 correctly found\n", __FILE__);
+
+  result |= test_in_mod1 (main);
+
+  result |= test_in_mod2 (main);
+
+  return result;
+}