From patchwork Fri Dec 8 09:12:37 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Florian Weimer X-Patchwork-Id: 81735 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 71E353858412 for ; Fri, 8 Dec 2023 09:13:02 +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.129.124]) by sourceware.org (Postfix) with ESMTPS id 55D0D3858CD1 for ; Fri, 8 Dec 2023 09:12:42 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 55D0D3858CD1 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 55D0D3858CD1 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1702026763; cv=none; b=rI5v2Ji2vhd7DO2jfpR8KRGZ0vrCBNjaZ/7ktziW5MbQb72lXzx239rYuQYRQsV6aXNdCfb0vRHELPG5vVd84BPViBZu12DyF/JvmPntxitSTQiwmRmBTbK0YFTQ5sj9JkhARYH/rzUHypJjB6jE/7FysrttXdoJvH77H/HN34M= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1702026763; c=relaxed/simple; bh=WiQwYheeuDaDfyuyUH1Ls2scPepu24wT+11QPD420Hc=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=Tq+EYGijx1ABNlxd4BuNxzLONspanK0EUgb+1ZvBNU306cd5cpF2GDsidZfVJXpJAvUUx7DZvJCgXO09CmEZJN3VuJr6YjB0lzXJoC72hMwBkR2oo5fmaNcKXPxa0oljZPHDSF6SGR1TSm2p4W+IPb4jSwOICyNxnLoxOAmrxZE= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1702026761; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type; bh=RyNGM5JcoEGM+vjCVF0OS4IIkRQnwYlLQeYhgoD6jNg=; b=EWB3NeS3EjTV5/+a42U96Gth3oNXBVmb/9wIpTMaX/W70znt7dHdGEpn7B+YHwrCuQ+iiK Wi8dhoiCJAkN6cZ1Rws8i5IaOmlcrwVv5kHrzmhKv3nAjMilEfG3Jfcb0DZBtYGfBVeyow 1vcF3McpOfsHCHxn7pB2AxD3AiUVGJE= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-541-PFatINLdOg-FpGCNl6gJFA-1; Fri, 08 Dec 2023 04:12:40 -0500 X-MC-Unique: PFatINLdOg-FpGCNl6gJFA-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 E456288F2EA for ; Fri, 8 Dec 2023 09:12:39 +0000 (UTC) Received: from oldenburg.str.redhat.com (unknown [10.39.192.131]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 4A09C2166AE2 for ; Fri, 8 Dec 2023 09:12:39 +0000 (UTC) From: Florian Weimer To: libc-alpha@sourceware.org Subject: [PATCH] elf: Initialize GLRO(dl_lazy) before relocating libc in dynamic startup Date: Fri, 08 Dec 2023 10:12:37 +0100 Message-ID: <87a5qlgire.fsf@oldenburg.str.redhat.com> 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=-9.8 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_H4, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NONE, TXREP, T_SCC_BODY_TEXT_LINE, URIBL_BLACK 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 GLRO(dl_lazy) is used to set the parameters for the early _dl_relocate_object call, so the consider_profiling setting has to be applied before the call. Fixes commit 78ca44da0160a0b442f0ca1f253e3360f044b2ec ("elf: Relocate libc.so early during startup and dlmopen (bug 31083)"). Reviewed-by: Carlos O'Donell --- elf/rtld.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) base-commit: 958478889c6a7a12b35b857b9788b7ad8706a01e diff --git a/elf/rtld.c b/elf/rtld.c index f0b0f3328d..326286f3b2 100644 --- a/elf/rtld.c +++ b/elf/rtld.c @@ -2278,14 +2278,14 @@ dl_main (const ElfW(Phdr) *phdr, int consider_profiling = GLRO(dl_profile) != NULL; + /* If we are profiling we also must do lazy reloaction. */ + GLRO(dl_lazy) |= consider_profiling; + if (GL(dl_ns)[LM_ID_BASE].libc_map != NULL) _dl_relocate_object (GL(dl_ns)[LM_ID_BASE].libc_map, GL(dl_ns)[LM_ID_BASE].libc_map->l_scope, GLRO(dl_lazy) ? RTLD_LAZY : 0, consider_profiling); - /* If we are profiling we also must do lazy reloaction. */ - GLRO(dl_lazy) |= consider_profiling; - RTLD_TIMING_VAR (start); rtld_timer_start (&start); {