about summary refs log tree commit diff
path: root/elf/dl-close.c
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>2001-09-08 16:27:08 +0000
committerUlrich Drepper <drepper@redhat.com>2001-09-08 16:27:08 +0000
commitc4bb124a75b23d1a82cee232005dc7e8c43a4276 (patch)
tree070153ee7d895708e4e1b8c69b0d05093c19f17d /elf/dl-close.c
parent5a21d307c518c911f81848b6c0056fcc39e3ddcd (diff)
downloadglibc-c4bb124a75b23d1a82cee232005dc7e8c43a4276.tar.gz
glibc-c4bb124a75b23d1a82cee232005dc7e8c43a4276.tar.xz
glibc-c4bb124a75b23d1a82cee232005dc7e8c43a4276.zip
Update.
2001-09-08  Ulrich Drepper  <drepper@redhat.com>

	* elf/dl-close.c (_dl_close): If object has no r_list (i.e., wasn't
	loaded directly) determine length if l_initfini list by iterating
	over its elements.  Minor optimizations.
	* elf/dl-deps.c (_dl_map_object_deps): Always add own map to l_initfini
	for dependency objects.
	If object was already loaded check whether any of the dependencies
	is already on the relocation dependency list.  If yes, remove the
	latter.  Minor optimizations.
	* elf/dl-lookup.c (add_dependency): Add check for self reference of
	maps here.  Search l_initfini list only if the object was loaded
	directly and not only as a dependency.
	(_dl_lookup_symbol): Add relocation dependency also if object
	is not in global scope.  Remove test for self-reference here.
	(_dl_lookup_versioned_symbol): Likewise.
	* elf/dl-object (_dl_new_object): Cleanup.  Initialize dont_free
	element of first name record.
	* elf/loadtest.c: Add some more test to recognize early if an object
	wasn't unloaded.
	* elf/Makefile: Add rules to build and run reldep5.
	* elf/reldep5.c: New file.
	* elf/reldepmod5.c: New file.
	* elf/reldepmod6.c: New file.

	* elf/reldep2.c: Fix typo.

	* elf/dl-object.c (_dl_new_object): Initialize l_scope and l_scope_max.
Diffstat (limited to 'elf/dl-close.c')
-rw-r--r--elf/dl-close.c24
1 files changed, 13 insertions, 11 deletions
diff --git a/elf/dl-close.c b/elf/dl-close.c
index dfc204d478..31b4863afe 100644
--- a/elf/dl-close.c
+++ b/elf/dl-close.c
@@ -48,7 +48,8 @@ _dl_close (void *_map)
   unsigned int *new_opencount;
 
   /* First see whether we can remove the object at all.  */
-  if ((map->l_flags_1 & DF_1_NODELETE) && map->l_init_called)
+  if (__builtin_expect (map->l_flags_1 & DF_1_NODELETE, 0)
+      && map->l_init_called)
     /* Nope.  Do nothing.  */
     return;
 
@@ -63,14 +64,8 @@ _dl_close (void *_map)
     {
       /* There are still references to this object.  Do nothing more.  */
       if (__builtin_expect (_dl_debug_mask & DL_DEBUG_FILES, 0))
-	{
-	  char buf[20];
-
-	  buf[sizeof buf - 1] = '\0';
-
-	  _dl_debug_printf ("\nclosing file=%s; opencount == %u\n",
-			    map->l_name, map->l_opencount);
-	}
+	_dl_debug_printf ("\nclosing file=%s; opencount == %u\n",
+			  map->l_name, map->l_opencount);
 
       /* One decrement the object itself, not the dependencies.  */
       --map->l_opencount;
@@ -82,8 +77,15 @@ _dl_close (void *_map)
   list = map->l_initfini;
 
   /* Compute the new l_opencount values.  */
-  new_opencount = (unsigned int *) alloca (map->l_searchlist.r_nlist
-					   * sizeof (unsigned int));
+  i = map->l_searchlist.r_nlist;
+  if (__builtin_expect (i == 0, 0))
+    /* This can happen if we handle relocation dependencies for an
+       object which wasn't loaded directly.  */
+    for (i = 1; list[i] != NULL; ++i)
+      ;
+
+  new_opencount = (unsigned int *) alloca (i * sizeof (unsigned int));
+
   for (i = 0; list[i] != NULL; ++i)
     {
       list[i]->l_idx = i;