From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from forward204c.mail.yandex.net (forward204c.mail.yandex.net [IPv6:2a02:6b8:c03:500:1:45:d181:d204]) by sourceware.org (Postfix) with ESMTPS id 1C0BD3850218 for ; Mon, 3 Apr 2023 09:04:50 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 1C0BD3850218 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=yandex.ru Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=yandex.ru Received: from mail-nwsmtp-smtp-production-main-73.iva.yp-c.yandex.net (mail-nwsmtp-smtp-production-main-73.iva.yp-c.yandex.net [IPv6:2a02:6b8:c0c:a810:0:640:6b9b:0]) by forward204c.mail.yandex.net (Yandex) with ESMTP id D408360102 for ; Mon, 3 Apr 2023 12:04:48 +0300 (MSK) Received: by mail-nwsmtp-smtp-production-main-73.iva.yp-c.yandex.net (smtp/Yandex) with ESMTPSA id h4J5UKjDcmI0-JGuoInyj; Mon, 03 Apr 2023 12:04:48 +0300 X-Yandex-Fwd: 1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex.ru; s=mail; t=1680512688; bh=117cSdAW89ebS80ru56peSq5GRcbYMjuvkjReW4Hdm0=; h=Message-Id:Date:In-Reply-To:Cc:Subject:References:To:From; b=io3fVWoKHVQgfhIcPFetIDe4Te/w+tnc25fBkZ96IgGZop6xN1IRTxLLKetQAzk/m MJ7rtpzq5qDej10vHn1iAQE8/C9SgWgdLcWegxWRwUrMTfGM/k3BpwTGtB0AIFu1qc 5U7JvyrTnw1WIXv34UXCZWA9z1xGyIEM1tHHlYKM= Authentication-Results: mail-nwsmtp-smtp-production-main-73.iva.yp-c.yandex.net; dkim=pass header.i=@yandex.ru From: Stas Sergeev To: libc-alpha@sourceware.org Cc: Stas Sergeev Subject: [PATCH 03/12] elf: split _dl_check_loaded() from _dl_map_object Date: Mon, 3 Apr 2023 14:04:12 +0500 Message-Id: <20230403090421.560208-4-stsp2@yandex.ru> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20230403090421.560208-1-stsp2@yandex.ru> References: <20230403090421.560208-1-stsp2@yandex.ru> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-11.3 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_ENVFROM_END_DIGIT,FREEMAIL_FROM,GIT_PATCH_0,SPF_HELO_NONE,SPF_PASS,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: This is a purely mechanical split of a reusable code part. No functional changes. The test-suite was run on x86_64/64 and showed no regressions. Signed-off-by: Stas Sergeev --- elf/dl-load.c | 39 +++++++++++++++++++++++++-------------- 1 file changed, 25 insertions(+), 14 deletions(-) diff --git a/elf/dl-load.c b/elf/dl-load.c index 7a939cb8c1..e05a2a41de 100644 --- a/elf/dl-load.c +++ b/elf/dl-load.c @@ -1988,23 +1988,11 @@ 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) +static struct link_map * +_dl_check_loaded(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, @@ -2033,6 +2021,29 @@ _dl_map_object (struct link_map *loader, const char *name, /* We have a match. */ 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_check_loaded (name, nsid); + if (l) + return l; /* Display information if we are debugging. */ if (__glibc_unlikely (GLRO(dl_debug_mask) & DL_DEBUG_FILES) -- 2.37.2