about summary refs log tree commit diff
path: root/elf/dl-load.c
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>1998-09-06 09:16:53 +0000
committerUlrich Drepper <drepper@redhat.com>1998-09-06 09:16:53 +0000
commitbe93561004695198611aa8707f10250f780988b2 (patch)
tree7b9a502d849b761d966114b855a1fa9de4022e90 /elf/dl-load.c
parent9eb71e60ef889158238c3066c75b65336d846684 (diff)
downloadglibc-be93561004695198611aa8707f10250f780988b2.tar.gz
glibc-be93561004695198611aa8707f10250f780988b2.tar.xz
glibc-be93561004695198611aa8707f10250f780988b2.zip
Update.
1998-09-06 09:00  Ulrich Drepper  <drepper@cygnus.com>

	* version.h (VERSION): Bump to 2.0.96.

	Rewrite runtime linker to be truly thread-safe.  There is now no
	global variable specifying the scope.  We create all needed
	scopes at the time the link maps are created.
	* elf/Versions [GLIBC_2.1]: Add _dl_loaded and _dl_main_searchlist.
	* elf/link.h: Add struct r_scope_elem and use this for l_searchlist,
	l_symbolic_searchlist, l_scope, and l_local_scope elements in
	struct link_map.
	* elf/dl-close.c: Rewritten accordingly.
	* elf/dl-deps.c: Likewise.
	* elf/dl-error.c: Likewise.
	* elf/dl-init.c: Likewise.
	* elf/dl-load.c: Likewise.
	* elf/dl-lookup.c: Likewise.
	* elf/dl-object.c: Likewise.
	* elf/dl-open.c: Likewise.
	* elf/dl-reloc.c: Likewise.
	* elf/dl-runtime.c: Likewise.
	* elf/dl-support.c: Likewise.
	* elf/dl-symbol.c: Likewise.
	* elf/dl-version.c: Likewise.
	* elf/dlfcn.h: Likewise.
	* elf/dlsym.c: Likewise.
	* elf/dlvsym.c: Likewise.
	* elf/ldsodefs.h: Likewise.
	* elf/rtld.c: Likewise.
	* iconv/gconv_dl.c: Likewise.
	* nss/nsswitch.c: Likewise.
	* sysdeps/i386/dl-machine.h: Likewise.
	* sysdeps/unix/sysv/linux/i386/dl-librecon.h: Likewise.
Diffstat (limited to 'elf/dl-load.c')
-rw-r--r--elf/dl-load.c41
1 files changed, 37 insertions, 4 deletions
diff --git a/elf/dl-load.c b/elf/dl-load.c
index c9a39c01a2..35c34e0305 100644
--- a/elf/dl-load.c
+++ b/elf/dl-load.c
@@ -529,7 +529,12 @@ _dl_init_paths (const char *llp)
   l = _dl_loaded;
   if (l != NULL)
     {
-      if (l->l_type != lt_loaded && l->l_info[DT_RPATH])
+      /* We should never get here when initializing in a static application.
+	 If this is a dynamically linked application _dl_loaded always
+	 points to the main map which is not dlopen()ed.  */
+      assert (l->l_type != lt_loaded);
+
+      if (l->l_info[DT_RPATH])
 	{
 	  /* Allocate room for the search path and fill in information
 	     from RPATH.  */
@@ -727,11 +732,10 @@ _dl_map_object_from_fd (const char *name, int fd, char *realname,
 #endif
 
   /* Enter the new object in the list of loaded objects.  */
-  l = _dl_new_object (realname, name, l_type);
+  l = _dl_new_object (realname, name, l_type, loader);
   if (! l)
     lose (ENOMEM, "cannot create shared object descriptor");
   l->l_opencount = 1;
-  l->l_loader = loader;
 
   /* Extract the remaining details we need from the ELF header
      and then read in the program header table.  */
@@ -973,6 +977,35 @@ _dl_map_object_from_fd (const char *name, int fd, char *realname,
   if (l->l_info[DT_HASH])
     _dl_setup_hash (l);
 
+  /* If this object has DT_SYMBOLIC set modify now its scope.  We don't
+     have to do this for the main map.  */
+  if (l->l_info[DT_SYMBOLIC] && &l->l_searchlist != l->l_scope[0])
+    {
+      /* Create an appropriate searchlist.  It contains only this map.
+
+	 XXX This is the definition of DT_SYMBOLIC in SysVr4.  The old
+	 GNU ld.so implementation had a different interpretation which
+	 is more reasonable.  We are prepared to add this possibility
+	 back as part of a GNU extension of the ELF format.  */
+      l->l_symbolic_searchlist.r_list =
+	(struct link_map **) malloc (sizeof (struct link_map *));
+
+      if (l->l_symbolic_searchlist.r_list == NULL)
+	lose (ENOMEM, "cannot create searchlist");
+
+      l->l_symbolic_searchlist.r_list[0] = l;
+      l->l_symbolic_searchlist.r_nlist = 1;
+      l->l_symbolic_searchlist.r_duplist = l->l_symbolic_searchlist.r_list;
+      l->l_symbolic_searchlist.r_nduplist = 1;
+
+      /* Now move the existing entries one back.  */
+      memmove (&l->l_scope[1], &l->l_scope[0],
+	       3 * sizeof (struct r_scope_elem *));
+
+      /* Now add the new entry.  */
+      l->l_scope[0] = &l->l_symbolic_searchlist;
+    }
+
   return l;
 }
 
@@ -1280,7 +1313,7 @@ _dl_map_object (struct link_map *loader, const char *name, int preloaded,
 
 	  /* Enter the new object in the list of loaded objects.  */
 	  if ((name_copy = local_strdup (name)) == NULL
-	      || (l = _dl_new_object (name_copy, name, type)) == NULL)
+	      || (l = _dl_new_object (name_copy, name, type, loader)) == NULL)
 	    _dl_signal_error (ENOMEM, name,
 			      "cannot create shared object descriptor");
 	  /* We use an opencount of 0 as a sign for the faked entry.  */