about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog5
-rw-r--r--elf/dl-load.c35
2 files changed, 27 insertions, 13 deletions
diff --git a/ChangeLog b/ChangeLog
index e1e2c4820e..c300780d7f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2006-06-27  Ulrich Drepper  <drepper@redhat.com>
+
+	* elf/dl-load.c (_dl_map_object): Try harder to avoid looking at
+	RPATH of main map twice.
+
 2006-06-22  Ulrich Drepper  <drepper@redhat.com>
 
 	* intl/dcigettext.c (DCIGETTEXT): If _nl_find_msg returns -1 don't
diff --git a/elf/dl-load.c b/elf/dl-load.c
index 01e1572f51..ae99ffdcbc 100644
--- a/elf/dl-load.c
+++ b/elf/dl-load.c
@@ -2030,25 +2030,34 @@ _dl_map_object (struct link_map *loader, const char *name, int preloaded,
          RPATHs.  */
       if (loader == NULL || loader->l_info[DT_RUNPATH] == NULL)
 	{
+	  /* This is the executable's map (if there is one).  Make sure that
+	     we do not look at it twice.  */
+	  struct link_map *main_map = GL(dl_ns)[LM_ID_BASE]._ns_loaded;
+	  bool did_main_map = false;
+
 	  /* First try the DT_RPATH of the dependent object that caused NAME
 	     to be loaded.  Then that object's dependent, and on up.  */
-	  for (l = loader; fd == -1 && l; l = l->l_loader)
+	  for (l = loader; l; l = l->l_loader)
 	    if (cache_rpath (l, &l->l_rpath_dirs, DT_RPATH, "RPATH"))
-	      fd = open_path (name, namelen, preloaded, &l->l_rpath_dirs,
-			      &realname, &fb, loader, LA_SER_RUNPATH,
-			      &found_other_class);
+	      {
+		fd = open_path (name, namelen, preloaded, &l->l_rpath_dirs,
+				&realname, &fb, loader, LA_SER_RUNPATH,
+				&found_other_class);
+		if (fd != -1)
+		  break;
+
+		did_main_map |= l == main_map;
+	      }
 
 	  /* If dynamically linked, try the DT_RPATH of the executable
              itself.  NB: we do this for lookups in any namespace.  */
-	  if (fd == -1)
-	    {
-	      l = GL(dl_ns)[LM_ID_BASE]._ns_loaded;
-	      if (l && l->l_type != lt_loaded && l != loader
-		  && cache_rpath (l, &l->l_rpath_dirs, DT_RPATH, "RPATH"))
-		fd = open_path (name, namelen, preloaded, &l->l_rpath_dirs,
-				&realname, &fb, loader ?: l, LA_SER_RUNPATH,
-				&found_other_class);
-	    }
+	  if (fd == -1 && !did_main_map
+	      && main_map != NULL && main_map->l_type != lt_loaded
+	      && cache_rpath (main_map, &main_map->l_rpath_dirs, DT_RPATH,
+			      "RPATH"))
+	    fd = open_path (name, namelen, preloaded, &main_map->l_rpath_dirs,
+			    &realname, &fb, loader ?: main_map, LA_SER_RUNPATH,
+			    &found_other_class);
 	}
 
       /* Try the LD_LIBRARY_PATH environment variable.  */