From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pl1-x62a.google.com (mail-pl1-x62a.google.com [IPv6:2607:f8b0:4864:20::62a]) by sourceware.org (Postfix) with ESMTPS id B8AAD3858D1E for ; Fri, 11 Feb 2022 14:43:25 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org B8AAD3858D1E Received: by mail-pl1-x62a.google.com with SMTP id c3so4866022pls.5 for ; Fri, 11 Feb 2022 06:43:25 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=yvPgRBU5DgpPvPGHmkOS5tjBiWU6hLr3zzlikFR3mRk=; b=esL9/sQmEvps/WO4xxNXKbZCIx0Q5lQhmseGqP5aroCPM/JVuHRLUt9OcQhwj/QS5L aqr7rpcfJ7hhuHreR8qcv/GeRJHJ/tee9ddHQ4GsdDrQnbpzzFDLGJ9L63UepQB768cr Vk8w/G5OpuYTBFgtFWjd2X0CIPq49RiLM+O3lL0PeauJt2MEkmTLWC8TVvkzhfvq9Hbq lP5Fz/frVwaONTikL/5rkVUf7r0qyUNZd/hw2dtFr73wNEHE6plCUteny2rmPia2JnZk XtsbNOP6d9M7kMUGnPXAnGKtXtPIKNOsecrkJ2z2LC69XZKWM0auCoG9ujxFLNxT03w4 2FoQ== X-Gm-Message-State: AOAM532/dUKvb0FuaQCLHrzayMwgvUg9Qe89aOQ1ArGgDa4XaZQ5ym90 wUOnxGeWGl1u9RKYvwi9mdDxtqoKmiAaenPMGiM= X-Google-Smtp-Source: ABdhPJwk09+toRbZ0v7nXHVMYVZ/ADnmGEYD4iql2o2BASLhKaTndC/c1J7pxxUH4HFpBJps8Q/9Xa/VDFUWrxhkiSs= X-Received: by 2002:a17:90b:33d0:: with SMTP id lk16mr722368pjb.120.1644590604644; Fri, 11 Feb 2022 06:43:24 -0800 (PST) MIME-Version: 1.0 References: <151c5398adbbe538a275ea5ac77705b0abd0d748.1643886336.git.fweimer@redhat.com> <20220211123110.GB2692478@arm.com> <0dea5e89-25fb-3e17-8142-878482f171dd@linaro.org> <20220211132419.GC2692478@arm.com> <4d632b0d-191e-064b-d316-7614173561b7@linaro.org> In-Reply-To: <4d632b0d-191e-064b-d316-7614173561b7@linaro.org> From: "H.J. Lu" Date: Fri, 11 Feb 2022 06:42:48 -0800 Message-ID: Subject: Re: [PATCH v2 5/5] Linux: Consolidate auxiliary vector parsing To: Adhemerval Zanella Cc: Szabolcs Nagy , Florian Weimer , GNU C Library Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-3027.3 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) 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: Fri, 11 Feb 2022 14:43:27 -0000 On Fri, Feb 11, 2022 at 5:49 AM Adhemerval Zanella via Libc-alpha wrote: > > > > On 11/02/2022 10:24, Szabolcs Nagy wrote: > > The 02/11/2022 09:47, Adhemerval Zanella wrote: > >> On 11/02/2022 09:31, Szabolcs Nagy via Libc-alpha wrote: > >>> The 02/03/2022 12:08, Florian Weimer via Libc-alpha wrote > >>>> + dl_parse_auxv_t auxv_values = { 0, }; > >>>> + _dl_parse_auxv (av, auxv_values); > >>> > >>> this seems to use memset now on aarch64 before irelative > >>> relocs are resolved in static binaries. > >>> > >>> which causes infinite loops in the iplt (i've also seen > >>> segfaults in the build log). > >>> > >>> i wonder what is a clean fix... > >>> > >> > >> Maybe add inhibit_loop_to_libcall to avoid the memset call. > > > > does not work for me.. > > happens at -O0 too > > https://godbolt.org/z/W9r3nffYd > > Yeah, this won't help much this situation. Unless we can make gcc *not* > emit this memset call, we will need something like: > > diff --git a/elf/dl-support.c b/elf/dl-support.c > index 1977a2be76..49f3fd2a61 100644 > --- a/elf/dl-support.c > +++ b/elf/dl-support.c > @@ -19,6 +19,10 @@ > /* This file defines some things that for the dynamic linker are defined in > rtld.c and dl-sysdep.c in ways appropriate to bootstrap dynamic linking. */ > > +#ifndef SHARED > +asm ("memset = __memset_generic"); > +#endif > + > #include > /* Mark symbols hidden in static PIE for early self relocation to work. > Note: string.h may have ifuncs which cannot be hidden on i686. */ > > > $ make -j24 && make test t=elf/tst-tls1-static-non-pie > [...] > PASS: elf/tst-tls1-static-non-pie > original exit status 0 > set bar to 1 (LE) > get sum of foo and bar (IE) = 1 > get sum of foo and bar (LD or TLSDESC) = 1 > get sum of foo and bar (GD or TLSDESC) = 1 > > > I think the best approach would to add a __memset_generic, __memcpy_generic, > and __memmove_generic on all targets and add a header similar to > sysdeps/generic/symbol-hacks.h to activate the redirection when required > (to not pessimize code that would work with the IPTL generated by the > iFUNC). I ran into a similar problem on my CET branch. In my case, it is memcmp. I added a new header file, , to define functions which can be safely used during ld.so startup: https://gitlab.com/x86-glibc/glibc/-/commit/2bfa258b114e556ab0be68d6465b5e4fa5504e2e -- H.J.