public inbox for glibc-cvs@sourceware.org help / color / mirror / Atom feed
From: Adhemerval Zanella <azanella@sourceware.org> To: glibc-cvs@sourceware.org Subject: [glibc/azanella/rtld-shared] elf: Abstract loaded-DSO search code into a helper function Date: Mon, 9 Aug 2021 20:17:49 +0000 (GMT) [thread overview] Message-ID: <20210809201749.AF2533938C0C@sourceware.org> (raw) https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=22b419be4e23df6fead108b7a40ea7b019aa9f13 commit 22b419be4e23df6fead108b7a40ea7b019aa9f13 Author: Vivek Das Mohapatra <vivek@collabora.com> Date: Thu Jul 8 17:32:49 2021 +0100 elf: Abstract loaded-DSO search code into a helper function Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org> Diff: --- elf/dl-load.c | 44 ++++++++++++++++++++++++++++++-------------- sysdeps/generic/ldsodefs.h | 4 ++++ 2 files changed, 34 insertions(+), 14 deletions(-) diff --git a/elf/dl-load.c b/elf/dl-load.c index 650e4edc35..fb23ba632b 100644 --- a/elf/dl-load.c +++ b/elf/dl-load.c @@ -2027,24 +2027,13 @@ open_path (const char *name, size_t namelen, int mode, return -1; } -/* Map in the shared object file NAME. */ - +/* Search for a shared object in a given namespace. */ struct link_map * -_dl_map_object (struct link_map *loader, const char *name, - int type, int trace_mode, int mode, Lmid_t nsid) +_dl_find_dso (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) + for (l = GL(dl_ns)[nsid]._ns_loaded; l != NULL; 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 @@ -2073,6 +2062,33 @@ _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_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_dso (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) diff --git a/sysdeps/generic/ldsodefs.h b/sysdeps/generic/ldsodefs.h index 9c15259236..22f3fea436 100644 --- a/sysdeps/generic/ldsodefs.h +++ b/sysdeps/generic/ldsodefs.h @@ -1287,6 +1287,10 @@ extern void _dl_show_scope (struct link_map *new, int from) extern struct link_map *_dl_find_dso_for_object (const ElfW(Addr) addr); rtld_hidden_proto (_dl_find_dso_for_object) +extern struct link_map *_dl_find_dso (const char *name, Lmid_t nsid); +rtld_hidden_proto (_dl_find_dso) + + /* Initialization which is normally done by the dynamic linker. */ extern void _dl_non_dynamic_init (void) attribute_hidden;
next reply other threads:[~2021-08-09 20:17 UTC|newest] Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top 2021-08-09 20:17 Adhemerval Zanella [this message] 2021-08-09 20:25 Adhemerval Zanella 2021-08-09 20:31 Adhemerval Zanella 2021-08-10 12:43 Adhemerval Zanella 2021-08-10 13:42 Adhemerval Zanella 2021-09-27 18:54 Adhemerval Zanella
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20210809201749.AF2533938C0C@sourceware.org \ --to=azanella@sourceware.org \ --cc=glibc-cvs@sourceware.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).