From patchwork Mon Jan 6 15:42:29 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicolas Viennot X-Patchwork-Id: 37213 Received: (qmail 37511 invoked by alias); 6 Jan 2020 15:42:33 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 37503 invoked by uid 89); 6 Jan 2020 15:42:33 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-9.0 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 spammy=Display X-HELO: mxo1.dft.dmz.twosigma.com From: Nicolas Viennot To: "libc-alpha@sourceware.org" Subject: [PATCH 1/3] dl-load: extract _dl_find_object_from_name() from _dl_map_object() Date: Mon, 6 Jan 2020 15:42:29 +0000 Message-ID: <61c0b49f4d7342a48743d0de82a5429d@EXMBDFT10.ad.twosigma.com> MIME-Version: 1.0 --- 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)