From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-oi1-x22b.google.com (mail-oi1-x22b.google.com [IPv6:2607:f8b0:4864:20::22b]) by sourceware.org (Postfix) with ESMTPS id B3F08384242A for ; Tue, 19 Jan 2021 14:49:21 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org B3F08384242A Received: by mail-oi1-x22b.google.com with SMTP id w124so21403321oia.6 for ; Tue, 19 Jan 2021 06:49:21 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=ClJQl5BN7yA+QgMdECNEklPyiKdKn5QxjSBzF7ynoYk=; b=jx43iFleBdflmxqOmvi/XXpiOV2fzPTHeVJuAZap4d2hlEa42XS4GX29FbWeOYXl4g 1DlN3r5dikzCSbe/o/Ex0c8D/tu3wkdNt6XraZ0IzfQGG6QwA7jUNIaMlJIub/QDrJhv slWtlCwbEIF4SBFqzuLGV0XCFMVVkBs135KR/3d5gYbBASz8Qj3/DISZv5aoO0VNHiaW ukE3koUN3MgeVcIaGjwxDpwtoZWxdLVgkyMAl7PzNyYn4srAZkuxijYoN1ByF/z34O11 J/bTLBp95szr2LPABVKYjuClFucWWFagA1BKmZtaBapAsImEWHqjstojBXWXOAHOD2HX HfEw== X-Gm-Message-State: AOAM533XKnX5JepoTkb3NMtx1RApgxq8awgtFSMk0ZIAEeqVpBo83ju+ EHKF39BySocQFv+nFF44hu7CB6mjAeNV0KZNmQqGKCmbLgE= X-Google-Smtp-Source: ABdhPJwkqxt/cdVX1WeOKc/fNghPOvs8tBaacELtKZ2apXjpDiZUA+3mBsaSndJ+MpKI2wlEanOlf8atRvMt6XZEu0s= X-Received: by 2002:aca:4d8b:: with SMTP id a133mr2779135oib.79.1611067761218; Tue, 19 Jan 2021 06:49:21 -0800 (PST) MIME-Version: 1.0 References: <4224b7c0428492696fe6d6c01739adcf69fc677d.1610986541.git.szabolcs.nagy@arm.com> <1ba70d1b-08f8-6a5d-ecf4-45200744c9d8@linaro.org> <20210119143500.GA3445@arm.com> In-Reply-To: From: "H.J. Lu" Date: Tue, 19 Jan 2021 06:48:45 -0800 Message-ID: Subject: Re: [PATCH v4 08/10] csu: Move static pie self relocation later [BZ #27072] To: Adhemerval Zanella Cc: Szabolcs Nagy , GNU C Library Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-3030.3 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 19 Jan 2021 14:49:25 -0000 On Tue, Jan 19, 2021 at 6:37 AM Adhemerval Zanella via Libc-alpha wrote: > > > > On 19/01/2021 11:35, Szabolcs Nagy wrote: > > The 01/19/2021 11:07, Adhemerval Zanella wrote: > >> On 18/01/2021 13:25, Szabolcs Nagy via Libc-alpha wrote: > >>> IFUNC resolvers may depend on tunables and cpu feature setup so > >>> move static pie self relocation after those. > >>> > >>> It is hard to guarantee that the ealy startup code does not rely > >>> on relocations so this is a bit fragile. It would be more robust > >>> to handle RELATIVE relocs early and only IRELATIVE relocs later, > >>> but the current relocation processing code cannot do that. > >>> > >>> The early startup code before relocation processing includes > >>> > >>> _dl_aux_init (auxvec); > >>> __libc_init_secure (); > >>> __tunables_init (__environ); > >>> ARCH_INIT_CPU_FEATURES (); > >>> > >>> These are simple enough that RELATIVE relocs can be avoided. > >>> > >>> __ehdr_start may require RELATIVE relocation so it was moved > >>> later, fortunately ehdr and phdr are not used in the early code. > >>> > >>> Fixes bug 27072. > >> > >> LGTM, thanks. > >> > >> Reviewed-by: Adhemerval Zanella > > > > > > sigh, this is an old version of this patch, i made a > > mistake putting the series together. > > > > the problem is that _dl_phdr is used in ARCH_SETUP_TLS > > (to get the tls program headers) so the __ehdr_start > > magic should be before that (this only matters if auxv > > lacks AT_PHDR for some reason, which should not happen > > normally on linux, so testing won't show the problem) > > By normally do you mean it might happen on a specific kernel version > or is it architecture specific? I think we can leave __ehdr_start ASIS since it doesn't need RELATIVE relocation. I verified it by adding -Wl,-z,report-relative-reloc when building elf/sln on x86. -- H.J.