]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
2005-03-03 Jakub Jelinek <jakub@redhat.com>
authorRoland McGrath <roland@gnu.org>
Wed, 6 Apr 2005 01:42:58 +0000 (01:42 +0000)
committerRoland McGrath <roland@gnu.org>
Wed, 6 Apr 2005 01:42:58 +0000 (01:42 +0000)
[BZ #821]
* elf/Makefile: Add rules to build and run unload3 test.
* elf/unload3.c: New test.
* elf/unload3mod1.c: New file.
* elf/unload3mod2.c: New file.
* elf/unload3mod3.c: New file.
* elf/unload3mod4.c: New file.

elf/unload3.c [new file with mode: 0644]
elf/unload3mod1.c [new file with mode: 0644]
elf/unload3mod2.c [new file with mode: 0644]
elf/unload3mod3.c [new file with mode: 0644]
elf/unload3mod4.c [new file with mode: 0644]

diff --git a/elf/unload3.c b/elf/unload3.c
new file mode 100644 (file)
index 0000000..6f1af70
--- /dev/null
@@ -0,0 +1,41 @@
+#include <dlfcn.h>
+#include <stdio.h>
+
+int
+main (void)
+{
+  void *g = dlopen ("unload3mod1.so", RTLD_GLOBAL | RTLD_NOW);
+  void *h = dlopen ("unload3mod2.so", RTLD_GLOBAL | RTLD_NOW);
+  if (g == NULL || h == NULL)
+    {
+      printf ("dlopen unload3mod{1,2}.so failed: %p %p\n", g, h);
+      return 1;
+    }
+  dlclose (h);
+  dlclose (g);
+
+  g = dlopen ("unload3mod3.so", RTLD_GLOBAL | RTLD_NOW);
+  h = dlopen ("unload3mod4.so", RTLD_GLOBAL | RTLD_NOW);
+  if (g == NULL || h == NULL)
+    {
+      printf ("dlopen unload3mod{3,4}.so failed: %p %p\n", g, h);
+      return 1;
+    }
+
+  int (*fn) (int);
+  fn = dlsym (h, "bar");
+  if (fn == NULL)
+    {
+      puts ("dlsym failed");
+      return 1;
+    }
+
+  int val = fn (16);
+  if (val != 24)
+    {
+      printf ("bar returned %d != 24\n", val);
+      return 1;
+    }
+
+  return 0;
+}
diff --git a/elf/unload3mod1.c b/elf/unload3mod1.c
new file mode 100644 (file)
index 0000000..e886b11
--- /dev/null
@@ -0,0 +1 @@
+int dummy1;
diff --git a/elf/unload3mod2.c b/elf/unload3mod2.c
new file mode 100644 (file)
index 0000000..03252a5
--- /dev/null
@@ -0,0 +1 @@
+int dummy2;
diff --git a/elf/unload3mod3.c b/elf/unload3mod3.c
new file mode 100644 (file)
index 0000000..046022c
--- /dev/null
@@ -0,0 +1,8 @@
+#include <stdio.h>
+
+int
+foo (int x)
+{
+  puts ("foo");
+  return x * 2;
+}
diff --git a/elf/unload3mod4.c b/elf/unload3mod4.c
new file mode 100644 (file)
index 0000000..4586ff7
--- /dev/null
@@ -0,0 +1,11 @@
+#include <stdio.h>
+
+int
+bar (int x)
+{
+  puts ("bar");
+  fflush (stdout);
+  x = foo (x - 4);
+  puts ("bar after foo");
+  return x;
+}