From patchwork Thu Dec 7 10:32:47 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Florian Weimer X-Patchwork-Id: 1873148 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=Qoy6yU7E; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=sourceware.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=server2.sourceware.org; envelope-from=libc-alpha-bounces+incoming=patchwork.ozlabs.org@sourceware.org; receiver=patchwork.ozlabs.org) Received: from server2.sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Sm9dH3zrRz23nD for ; Thu, 7 Dec 2023 21:34:59 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id A3AEB3857BAD for ; Thu, 7 Dec 2023 10:34:55 +0000 (GMT) X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTPS id 195743860778 for ; Thu, 7 Dec 2023 10:32:52 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 195743860778 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 195743860778 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1701945173; cv=none; b=PzwJJlvj1XGAZK2E8tXYDeUXGDT9K6uvu4q04DJArjGjfppjrBIpsC12zEZVjXHVrvJH4ju6LfFjh/zyBIgJODZ97ZdtPVQ1sAJUjrr7fKAgUM40G50ANECUUJuoyoMSY6CZeTG4fcex6hHJMlYyIlIbucELwEGE6tv1sKPkSK0= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1701945173; c=relaxed/simple; bh=Sofr+NYUDaGVOoJbva/v3m4JjT+SC+L9L5qnEwbkOh0=; h=DKIM-Signature:From:To:Subject:Message-ID:Date:MIME-Version; b=UallfLmKgVDj9/ohMJPxT3kD5EcSusGjIzUFm38d9yzFfLGE8N9uC10KThz2gWLEiNRYHR+T0YWbD4QDmY6555PFb5+vJsS/LamPzLDytg+bx1H2rmnXyyzMjchrNT5fgGEbzClhzHYE/kMZHPGEa//4E/PljseAGGGzRNfWuTU= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1701945171; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=28v1NEiC/Eh/phSO4LmyAitBGWGdV/l3A3uJPEigWu8=; b=Qoy6yU7EHiqfMU1YM9CBxJE3BLYMEavrECmeuDBphcPEqLSTJzUEAZTLqwxJSdNq1y0L4e stVd/JvcUKc+8C3ZCkyf/dfVsCOP2rp1df4Oy/QfFFTgC7OWEIjqBKQc4HDuMR1+Vmp95Z oLLgYQF+tZX97MOuL3dBINwjJ+LFfgQ= Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-282-0nffo1SHO5-wv1zPp_MiXg-1; Thu, 07 Dec 2023 05:32:49 -0500 X-MC-Unique: 0nffo1SHO5-wv1zPp_MiXg-1 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 738DA38130BE for ; Thu, 7 Dec 2023 10:32:49 +0000 (UTC) Received: from oldenburg.str.redhat.com (unknown [10.39.192.131]) by smtp.corp.redhat.com (Postfix) with ESMTPS id CEC0A492C29 for ; Thu, 7 Dec 2023 10:32:48 +0000 (UTC) From: Florian Weimer To: libc-alpha@sourceware.org Subject: [PATCH v3 29/32] elf: Use _dl_find_object instead of _dl_find_dso_for_object in dlopen In-Reply-To: Message-ID: <46bd211cba668b2b5cda6ccb5f7a1e3cfdc33a4f.1701944612.git.fweimer@redhat.com> References: X-From-Line: 46bd211cba668b2b5cda6ccb5f7a1e3cfdc33a4f Mon Sep 17 00:00:00 2001 Date: Thu, 07 Dec 2023 11:32:47 +0100 User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.3 (gnu/linux) MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.10 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-10.9 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NONE, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libc-alpha-bounces+incoming=patchwork.ozlabs.org@sourceware.org The _dl_find_object uses a binary search and is faster if there are many objects. --- elf/dl-open.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/elf/dl-open.c b/elf/dl-open.c index a8c9945f2b..47638128dc 100644 --- a/elf/dl-open.c +++ b/elf/dl-open.c @@ -913,8 +913,10 @@ no more namespaces available for dlmopen()")); if (nsid == __LM_ID_CALLER || strchr (file, '$') != NULL || strchr (file, '/') == NULL) { - args.caller_map = _dl_find_dso_for_object ((ElfW(Addr)) caller_dlopen); - if (args.caller_map == NULL) + struct dl_find_object dlfo; + if (_dl_find_object ((void *) caller_dlopen, &dlfo) == 0) + args.caller_map = l_private (dlfo.dlfo_link_map); + else /* By default we assume this is the main application. */ args.caller_map = GL(dl_ns)[LM_ID_BASE]._ns_loaded; if (args.nsid == __LM_ID_CALLER)