[RFC,v4,10/15] Use the new DSO finder helper function since we have it

Message ID 54183062dec1235cbf6d30c1129044686949d707.1585588166.git.vivek@collabora.com
State New
Headers show
Series
  • Proof-of-Concept implementation of RTLD_SHARED for dlmopen
Related show

Commit Message

Sergei Trofimovich via Libc-alpha March 30, 2020, 5:43 p.m.
---
 elf/dl-load.c | 31 +++----------------------------
 1 file changed, 3 insertions(+), 28 deletions(-)

-- 
2.11.0

Patch

diff --git a/elf/dl-load.c b/elf/dl-load.c
index 76970f79de..62820167d5 100644
--- a/elf/dl-load.c
+++ b/elf/dl-load.c
@@ -2031,34 +2031,9 @@  _dl_map_object (struct link_map *loader, const char *name,
 #endif
 
   /* Look for this name among those already loaded.  */
-  for (l = GL(dl_ns)[nsid]._ns_loaded; l; l = l->l_next)
-    {
-      /* If the requested name matches the soname of a loaded object,
-	 use that object.  Elide this check for names that have not
-	 yet been opened.  */
-      if (__glibc_unlikely ((l->l_faked | l->l_removed) != 0))
-	continue;
-      if (!_dl_name_match_p (name, l))
-	{
-	  const char *soname;
-
-	  if (__glibc_likely (l->l_soname_added)
-	      || l->l_info[DT_SONAME] == NULL)
-	    continue;
-
-	  soname = ((const char *) D_PTR (l, l_info[DT_STRTAB])
-		    + l->l_info[DT_SONAME]->d_un.d_val);
-	  if (strcmp (name, soname) != 0)
-	    continue;
-
-	  /* We have a match on a new name -- cache it.  */
-	  add_name_to_object (l, soname);
-	  l->l_soname_added = 1;
-	}
-
-      /* We have a match.  */
-      return l;
-    }
+  l = _dl_find_dso (name, nsid);
+  if (l != NULL)
+    return l;
 
   /* Display information if we are debugging.  */
   if (__glibc_unlikely (GLRO(dl_debug_mask) & DL_DEBUG_FILES)