From patchwork Fri Nov 24 12:56:13 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Florian Weimer X-Patchwork-Id: 80718 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id C7C91385B526 for ; Fri, 24 Nov 2023 12:56:29 +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 3D095385843A for ; Fri, 24 Nov 2023 12:56:17 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 3D095385843A 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 3D095385843A 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=1700830578; cv=none; b=xxu6dcmVTI/EYoY1//MS+xBguOqOX570SZ5CnZKQeK22BJ2ZKUEhLvytID9GDTJg6xQ5CJNKyaGNU+hF4YsSaf/xSlWPFXDylkWV22txXl2WWQo4lwXOH2/e/4dOljqe+s7qLijRYC/UQBJOz8kR0XDNhHF3nj27ivmCmz7XItM= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1700830578; c=relaxed/simple; bh=HZx07PpQVg64pcLm9a6Q+TgRKvgUfxAL9/3VxU9Ycm8=; h=DKIM-Signature:From:To:Subject:Message-ID:Date:MIME-Version; b=G5piLRIIuf25v+uzexq4M7xO9GTM/n0fCz8+2sGlcgjANbT3kf2gKDIyaSWmMMMl4Wd/El2TnDYxLiXLcKqhVMS8MCYa503e4AS8b23g87jZ8u0gAzJ23c4jtKHBo+tFUf8sM/OrKHRULUJl+/ooD07zSTjcsq4/+pNJ7MS1+6E= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1700830576; 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=FOQJHv84IIICqo3dFNhGX/vsgRXiMq0mZZuiCIr1cmM=; b=LuxmzLLavGZpEPdrjHNL9gjAF+ePeeYQfT/VKFblsxo90m7xV8dtQ3ojqlaTPIBeLbbWoB c0aLR7FaikkOYvFNkY4yiYInCVzvx4uBXOUCb+SCx6eBvzG4BceMsCGWlU3r+HuColqEf8 XAOB/WSPAYozbi9JmPdThcM+FaIQZAE= 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-280-86iI1tJUM0K5SZSg8CKRIQ-1; Fri, 24 Nov 2023 07:56:15 -0500 X-MC-Unique: 86iI1tJUM0K5SZSg8CKRIQ-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (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 6A9C83C0C131 for ; Fri, 24 Nov 2023 12:56:15 +0000 (UTC) Received: from oldenburg.str.redhat.com (unknown [10.39.192.57]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 104962166B26 for ; Fri, 24 Nov 2023 12:56:14 +0000 (UTC) From: Florian Weimer To: libc-alpha@sourceware.org Subject: [PATCH 1/3] elf: In _dl_relocate_object, skip processing if object is relocated In-Reply-To: Message-ID: <765fa8fd1d282964cf158d425b7e2cba28f79cb8.1700829130.git.fweimer@redhat.com> References: X-From-Line: 765fa8fd1d282964cf158d425b7e2cba28f79cb8 Mon Sep 17 00:00:00 2001 Date: Fri, 24 Nov 2023 13:56:13 +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.6 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+patchwork=sourceware.org@sourceware.org This is just a minor optimization. It also makes it more obvious that _dl_relocate_object can be called multiple times. Reviewed-by: Carlos O'Donell --- elf/dl-reloc.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/elf/dl-reloc.c b/elf/dl-reloc.c index e5c555d82c..72c8586d29 100644 --- a/elf/dl-reloc.c +++ b/elf/dl-reloc.c @@ -205,6 +205,9 @@ void _dl_relocate_object (struct link_map *l, struct r_scope_elem *scope[], int reloc_mode, int consider_profiling) { + if (l->l_relocated) + return; + struct textrels { caddr_t start; @@ -242,9 +245,6 @@ _dl_relocate_object (struct link_map *l, struct r_scope_elem *scope[], # define consider_symbind 0 #endif - if (l->l_relocated) - return; - /* If DT_BIND_NOW is set relocate all references in this object. We do not do this if we are profiling, of course. */ // XXX Correct for auditing?