This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
[PATCH 1/3] dl-load: extract _dl_find_object_from_name() from _dl_map_object()
- From: Nicolas Viennot <Nicolas dot Viennot at twosigma dot com>
- To: "libc-alpha at sourceware dot org" <libc-alpha at sourceware dot org>
- Date: Mon, 6 Jan 2020 15:42:29 +0000
- Subject: [PATCH 1/3] dl-load: extract _dl_find_object_from_name() from _dl_map_object()
---
elf/dl-load.c | 36 ++++++++++++++++++++++++------------
1 file changed, 24 insertions(+), 12 deletions(-)
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)
--
2.19.1