about summary refs log tree commit diff
path: root/REORG.TODO/elf/reldep6.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/elf/reldep6.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/elf/reldep6.c')
-rw-r--r--REORG.TODO/elf/reldep6.c109
1 files changed, 109 insertions, 0 deletions
diff --git a/REORG.TODO/elf/reldep6.c b/REORG.TODO/elf/reldep6.c
new file mode 100644
index 0000000000..1eeec6c862
--- /dev/null
+++ b/REORG.TODO/elf/reldep6.c
@@ -0,0 +1,109 @@
+#include <dlfcn.h>
+#include <mcheck.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+typedef int (*fn)(void);
+#define CHUNKS 1024
+#define REPEAT 64
+
+int
+main (void)
+{
+  void *h1;
+  void *h2;
+  fn **foopp;
+  fn bar, baz;
+  int i, j;
+  int n;
+  void *allocs[REPEAT][CHUNKS];
+
+  mtrace ();
+
+  /* Open the two objects.  */
+  h1 = dlopen ("reldep6mod3.so", RTLD_LAZY);
+  if (h1 == NULL)
+    {
+      printf ("cannot open reldep6mod3.so: %s\n", dlerror ());
+      exit (1);
+    }
+
+  foopp = dlsym (h1, "foopp");
+  if (foopp == NULL)
+    {
+      printf ("cannot get address of \"foopp\": %s\n", dlerror ());
+      exit (1);
+    }
+  n = (**foopp) ();
+  if (n != 20)
+    {
+      printf ("(**foopp)() return %d, not return 20\n", n);
+      exit (1);
+    }
+
+  h2 = dlopen ("reldep6mod4.so", RTLD_LAZY);
+  if (h2 == NULL)
+    {
+      printf ("cannot open reldep6mod4.so: %s\n", dlerror ());
+      exit (1);
+    }
+
+  baz = dlsym (h2, "baz");
+  if (baz == NULL)
+    {
+      printf ("cannot get address of \"baz\": %s\n", dlerror ());
+      exit (1);
+    }
+  if (baz () != 31)
+    {
+      printf ("baz() did not return 31\n");
+      exit (1);
+    }
+
+  if (dlclose (h1) != 0)
+    {
+      printf ("closing h1 failed: %s\n", dlerror ());
+      exit (1);
+    }
+
+  /* Clobber memory.  */
+  for (i = 0; i < REPEAT; ++i)
+    for (j = 0; j < CHUNKS; ++j)
+      allocs[i][j] = calloc (1, j + 1);
+
+  bar = dlsym (h2, "bar");
+  if (bar == NULL)
+    {
+      printf ("cannot get address of \"bar\": %s\n", dlerror ());
+      exit (1);
+    }
+  if (bar () != 40)
+    {
+      printf ("bar() did not return 40\n");
+      exit (1);
+    }
+
+  baz = dlsym (h2, "baz");
+  if (baz == NULL)
+    {
+      printf ("cannot get address of \"baz\": %s\n", dlerror ());
+      exit (1);
+    }
+  if (baz () != 31)
+    {
+      printf ("baz() did not return 31\n");
+      exit (1);
+    }
+
+  for (i = 0; i < REPEAT; ++i)
+    for (j = 0; j < CHUNKS; ++j)
+      free (allocs[i][j]);
+
+  if (dlclose (h2) != 0)
+    {
+      printf ("closing h2 failed: %s\n", dlerror ());
+      exit (1);
+    }
+
+  return 0;
+}