aboutsummaryrefslogtreecommitdiff
path: root/elf/dl-load.c
diff options
context:
space:
mode:
authorFlorian Weimer <fweimer@redhat.com>2025-02-02 20:10:08 +0100
committerFlorian Weimer <fweimer@redhat.com>2025-02-02 20:10:08 +0100
commitaa1bf8903992cc0d26cacb9e5930a9fed8f50548 (patch)
tree598d102d7d8a2687ccc3981c3150764440a8faf0 /elf/dl-load.c
parenta7aad6e2b774f24934d8925d3169ee6bf9d7538c (diff)
downloadglibc-aa1bf8903992cc0d26cacb9e5930a9fed8f50548.zip
glibc-aa1bf8903992cc0d26cacb9e5930a9fed8f50548.tar.gz
glibc-aa1bf8903992cc0d26cacb9e5930a9fed8f50548.tar.bz2
elf: Split _dl_lookup_map, _dl_map_new_object from _dl_map_object
So that they can eventually be called separately from dlopen.
Diffstat (limited to 'elf/dl-load.c')
-rw-r--r--elf/dl-load.c41
1 files changed, 29 insertions, 12 deletions
diff --git a/elf/dl-load.c b/elf/dl-load.c
index f905578..deb1b32 100644
--- a/elf/dl-load.c
+++ b/elf/dl-load.c
@@ -1887,24 +1887,14 @@ open_path (const char *name, size_t namelen, int mode,
return -1;
}
-/* 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)
+_dl_lookup_map (Lmid_t nsid, const char *name)
{
- 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)
+ for (struct link_map *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
@@ -1933,6 +1923,22 @@ _dl_map_object (struct link_map *loader, const char *name,
return l;
}
+ return NULL;
+}
+
+/* Map in the shared object file NAME. */
+
+struct link_map *
+_dl_map_new_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;
+
/* Display information if we are debugging. */
if (__glibc_unlikely (GLRO(dl_debug_mask) & DL_DEBUG_FILES)
&& loader != NULL)
@@ -2183,6 +2189,17 @@ _dl_map_object (struct link_map *loader, const char *name,
type, mode, &stack_end, nsid);
}
+struct link_map *
+_dl_map_object (struct link_map *loader, const char *name,
+ int type, int trace_mode, int mode, Lmid_t nsid)
+{
+ struct link_map *l = _dl_lookup_map (nsid, name);
+ if (l != NULL)
+ return l;
+ return _dl_map_new_object (loader, name, type, trace_mode, mode, nsid);
+}
+
+
struct add_path_state
{
bool counting;