Patchwork [1/3] dl-load: extract _dl_find_object_from_name() from _dl_map_object()

login
register
mail settings
Submitter Nicolas Viennot
Date Jan. 6, 2020, 3:42 p.m.
Message ID <61c0b49f4d7342a48743d0de82a5429d@EXMBDFT10.ad.twosigma.com>
Download mbox | patch
Permalink /patch/37213/
State New
Headers show

Comments

Nicolas Viennot - Jan. 6, 2020, 3:42 p.m.
---
 elf/dl-load.c | 36 ++++++++++++++++++++++++------------
 1 file changed, 24 insertions(+), 12 deletions(-)

Patch

diff --git a/elf/dl-load.c b/elf/dl-load.c
index 6cdd11e6b0..c436a447af 100644
--- a/elf/dl-load.c
+++ b/elf/dl-load.c
@@ -1906,21 +1906,11 @@  open_path (const char *name, size_t namelen, int mode,
 
 /* Map in the shared object file NAME.  */
 
-struct link_map *
-_dl_map_object (struct link_map *loader, const char *name,
-		int type, int trace_mode, int mode, Lmid_t nsid)
+static struct link_map *
+_dl_find_object_from_name(const char *name, Lmid_t nsid)
 {
-  int fd;
-  const char *origname = NULL;
-  char *realname;
-  char *name_copy;
   struct link_map *l;
-  struct filebuf fb;
 
-  assert (nsid >= 0);
-  assert (nsid < GL(dl_nns));
-
-  /* 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,
@@ -1950,6 +1940,28 @@  _dl_map_object (struct link_map *loader, const char *name,
       return l;
     }
 
+  return NULL;
+}
+
+struct link_map *
+_dl_map_object (struct link_map *loader, const char *name,
+		int type, int trace_mode, int mode, Lmid_t nsid)
+{
+  int fd;
+  const char *origname = NULL;
+  char *realname;
+  char *name_copy;
+  struct link_map *l;
+  struct filebuf fb;
+
+  assert (nsid >= 0);
+  assert (nsid < GL(dl_nns));
+
+  /* Look for this name among those already loaded.  */
+  l = _dl_find_object_from_name(name, nsid);
+  if (l != NULL)
+    return l;
+
   /* Display information if we are debugging.  */
   if (__glibc_unlikely (GLRO(dl_debug_mask) & DL_DEBUG_FILES)
       && loader != NULL)