about summary refs log tree commit diff
path: root/elf/rtld.c
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>2000-10-24 07:36:55 +0000
committerUlrich Drepper <drepper@redhat.com>2000-10-24 07:36:55 +0000
commit42c4f32a44c76d1f4e2b744bf80f495dc36caa87 (patch)
tree475224614ae3e30c27dc1889e86468080c48cf9c /elf/rtld.c
parent69c3325490f56db660b349d7c04daab6aaea1bf1 (diff)
downloadglibc-42c4f32a44c76d1f4e2b744bf80f495dc36caa87.tar.gz
glibc-42c4f32a44c76d1f4e2b744bf80f495dc36caa87.tar.xz
glibc-42c4f32a44c76d1f4e2b744bf80f495dc36caa87.zip
Update.
2000-10-24  Ulrich Drepper  <drepper@redhat.com>

	Complete revamp of the reference counter handling.
	* include/link.h (struct link_map): Add l_idx field.
	* elf/dl-close.c: Handle decrementing of reference counters more
	correctly. If necessary decrement reference counters of dependencies
	of dependencies.
	* elf/dl-lookup.c (add_dependency): Only increment reference counter
	of the object itself and not also its dependencies.
	* elf/dl-open.c: Increment reference counters here.
	* elf/dl-deps.c: Remove reference counter handling here.
	* elf/dl-load.c: Likewise.
	* elf/rtld.c: Adjust for _dl_map_deps not handling reference counters.

	* elf/loadtest.c: Print loaded objects at the beginning.
Diffstat (limited to 'elf/rtld.c')
-rw-r--r--elf/rtld.c16
1 files changed, 10 insertions, 6 deletions
diff --git a/elf/rtld.c b/elf/rtld.c
index ea5d7b5a3d..c44506acc4 100644
--- a/elf/rtld.c
+++ b/elf/rtld.c
@@ -550,7 +550,6 @@ of this helper program; chances are you did not intend to run this program.\n\
       _dl_loaded->l_phdr = phdr;
       _dl_loaded->l_phnum = phent;
       _dl_loaded->l_entry = *user_entry;
-      _dl_loaded->l_opencount = 1;
 
       /* At this point we are in a bit of trouble.  We would have to
 	 fill in the values for l_dev and l_ino.  But in general we
@@ -707,7 +706,7 @@ of this helper program; chances are you did not intend to run this program.\n\
 	  {
 	    struct link_map *new_map = _dl_map_object (_dl_loaded, p, 1,
 						       lt_library, 0, 0);
-	    if (new_map->l_opencount == 1)
+	    if (++new_map->l_opencount == 1)
 	      /* It is no duplicate.  */
 	      ++npreloads;
 	  }
@@ -775,7 +774,7 @@ of this helper program; chances are you did not intend to run this program.\n\
 	      {
 		struct link_map *new_map = _dl_map_object (_dl_loaded, p, 1,
 							   lt_library, 0, 0);
-		if (new_map->l_opencount == 1)
+		if (++new_map->l_opencount == 1)
 		  /* It is no duplicate.  */
 		  ++npreloads;
 	      }
@@ -786,7 +785,7 @@ of this helper program; chances are you did not intend to run this program.\n\
 	  char *p = strndupa (problem, file_size - (problem - file));
 	  struct link_map *new_map = _dl_map_object (_dl_loaded, p, 1,
 						     lt_library, 0, 0);
-	  if (new_map->l_opencount == 1)
+	  if (++new_map->l_opencount == 1)
 	    /* It is no duplicate.  */
 	    ++npreloads;
 	}
@@ -823,9 +822,14 @@ of this helper program; chances are you did not intend to run this program.\n\
   HP_TIMING_DIFF (diff, start, stop);
   HP_TIMING_ACCUM_NT (load_time, diff);
 
-  /* Mark all objects as being in the global scope.  */
+  /* Mark all objects as being in the global scope and set the open
+     counter.  */
   for (i = _dl_loaded->l_searchlist.r_nlist; i > 0; )
-    _dl_loaded->l_searchlist.r_list[--i]->l_global = 1;
+    {
+      --i;
+      _dl_loaded->l_searchlist.r_list[i]->l_global = 1;
+      ++_dl_loaded->l_searchlist.r_list[i]->l_opencount;
+    }
 
 #ifndef MAP_ANON
   /* We are done mapping things, so close the zero-fill descriptor.  */