From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: 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 479D83853D07 for ; Tue, 4 Jul 2023 20:03:16 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 479D83853D07 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1688500995; 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=YSIHpX7VxFemRxe+xVuQAg+NpbXeCXa6xuGLbwBQWNo=; b=Odkl/Xd+q1McdeeIHqODL3/adsEg+jhO+lspU16RpInbyQOG1qaRMGzXgNKsD/Mm7nJKEK 43HfGSsSovNQDnMEEiEL35iYKV//56az0ZuOpwdpNrMvlTNKpfglrRgB27dp7qNnbkd0c8 HiETEg9EulLqoC3PyN29c1eyJWdEUf0= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-149-OnqzXLrnPiucSFf2G9lv2g-1; Tue, 04 Jul 2023 16:03:14 -0400 X-MC-Unique: OnqzXLrnPiucSFf2G9lv2g-1 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 7A9EF101A528 for ; Tue, 4 Jul 2023 20:03:14 +0000 (UTC) Received: from oldenburg.str.redhat.com (unknown [10.2.16.19]) by smtp.corp.redhat.com (Postfix) with ESMTPS id E049A492C13 for ; Tue, 4 Jul 2023 20:03:13 +0000 (UTC) From: Florian Weimer To: libc-alpha@sourceware.org Subject: [PATCH 13/33] elf: Move __rtld_malloc_init_stubs call into _dl_start_final In-Reply-To: Message-ID: References: X-From-Line: c9fb46cfb1ae40b76b0cf31ee0481b004288da7f Mon Sep 17 00:00:00 2001 Date: Tue, 04 Jul 2023 22:03:12 +0200 User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.2 (gnu/linux) MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.10 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain X-Spam-Status: No, score=-10.5 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 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: Calling an extern function in a different translation unit before self-relocation is brittle. The compiler may load the address at an earlier point in _dl_start, before self-relocation. In _dl_start_final, the call is behidn a compiler barrier, so this cannot happen. --- elf/rtld.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/elf/rtld.c b/elf/rtld.c index 54a7ade886..4624d99570 100644 --- a/elf/rtld.c +++ b/elf/rtld.c @@ -452,6 +452,8 @@ _dl_start_final (void *arg, struct dl_start_final_info *info) { ElfW(Addr) start_addr; + __rtld_malloc_init_stubs (); + /* Do not use an initializer for these members because it would interfere with __rtld_static_init. */ GLRO (dl_find_object) = &_dl_find_object; @@ -575,8 +577,6 @@ _dl_start (void *arg) function, that way the compiler cannot put accesses to the GOT before ELF_DYNAMIC_RELOCATE. */ - __rtld_malloc_init_stubs (); - #ifdef DONT_USE_BOOTSTRAP_MAP return _dl_start_final (arg); #else -- 2.41.0