about summary refs log tree commit diff
path: root/elf/multiload.c
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>1999-02-19 00:00:05 +0000
committerUlrich Drepper <drepper@redhat.com>1999-02-19 00:00:05 +0000
commit61e0617ac34c4daaeb2f07f89a05c9f9353b8879 (patch)
tree8dc1f2e00b67c6661892258bf2d479e793854c54 /elf/multiload.c
parent1a989e004c00955e60cd315666ebd450d6fa9732 (diff)
downloadglibc-61e0617ac34c4daaeb2f07f89a05c9f9353b8879.tar.gz
glibc-61e0617ac34c4daaeb2f07f89a05c9f9353b8879.tar.xz
glibc-61e0617ac34c4daaeb2f07f89a05c9f9353b8879.zip
Update.
	* elf/link.h (link_map): Add l_dev and l_ino.
	* elf/dl-load.c (_dl_map_object_from_fd): Test dev/ino of newly
	loaded shared object with all laoded objects.  Initialize l_ino
	and l_dev in case it's new.
	* elf/rtld.c (dl_main): Explain situation is l_dev/l_ino with main
	object.
	* elf/Makefile: Compile and run new test.
	* elf/multiload.c: New file.
Diffstat (limited to 'elf/multiload.c')
-rw-r--r--elf/multiload.c78
1 files changed, 78 insertions, 0 deletions
diff --git a/elf/multiload.c b/elf/multiload.c
new file mode 100644
index 0000000000..724c1ed562
--- /dev/null
+++ b/elf/multiload.c
@@ -0,0 +1,78 @@
+#include <dlfcn.h>
+#include <errno.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+
+int
+main (void)
+{
+  void *a;
+  void *b;
+  void *c;
+  void *d;
+  char *wd;
+  char *base;
+  char *buf;
+
+  /* Change to the binary directory.  */
+  if (chdir (OBJDIR) != 0)
+    {
+      printf ("cannot change to `%s': %m", OBJDIR);
+      exit (EXIT_FAILURE);
+    }
+
+  wd = getcwd (NULL, 0);
+  base = basename (wd);
+  buf = alloca (strlen (wd) + strlen (base) + 5 + sizeof "testobj1.so");
+
+  printf ("loading `%s'\n", "./testobj1.so");
+  a = dlopen ("./testobj1.so", RTLD_NOW);
+  if (a == NULL)
+    {
+      printf ("cannot load `./testobj1.so': %s\n", dlerror ());
+      exit (EXIT_FAILURE);
+    }
+
+  stpcpy (stpcpy (stpcpy (buf, "../"), base), "/testobj1.so");
+  printf ("loading `%s'\n", buf);
+  b = dlopen (buf, RTLD_NOW);
+  if (b == NULL)
+    {
+      printf ("cannot load `%s': %s\n", buf, dlerror ());
+      exit (EXIT_FAILURE);
+    }
+
+  stpcpy (stpcpy (buf, wd), "/testobj1.so");
+  printf ("loading `%s'\n", buf);
+  c = dlopen (buf, RTLD_NOW);
+  if (c == NULL)
+    {
+      printf ("cannot load `%s': %s\n", buf, dlerror ());
+      exit (EXIT_FAILURE);
+    }
+
+  stpcpy (stpcpy (stpcpy (stpcpy (buf, wd), "/../"), base), "/testobj1.so");
+  printf ("loading `%s'\n", buf);
+  d = dlopen (buf, RTLD_NOW);
+  if (d == NULL)
+    {
+      printf ("cannot load `%s': %s\n", buf, dlerror ());
+      exit (EXIT_FAILURE);
+    }
+
+  if (a != b || b != c || c != d)
+    {
+      puts ("shared object loaded more than once");
+      exit (EXIT_FAILURE);
+    }
+
+  return 0;
+}
+
+int
+foo (int a)
+{
+  return a;
+}