From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-oi1-x229.google.com (mail-oi1-x229.google.com [IPv6:2607:f8b0:4864:20::229]) by sourceware.org (Postfix) with ESMTPS id ACF86385801C for ; Fri, 11 Feb 2022 13:48:44 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org ACF86385801C Received: by mail-oi1-x229.google.com with SMTP id m10so9613440oie.2 for ; Fri, 11 Feb 2022 05:48:44 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent:subject :content-language:to:cc:references:from:in-reply-to :content-transfer-encoding; bh=5JhlAaZicVpN3Ms7gnABPuv8jGHM8FEQdbWJqJ2DV98=; b=XarDggXV3gBdqSFLed03hybiN5SiKdLfdEljFjd+peL1QgzpU10dJVGlSSdpU06OG0 QAiqtmXvYY6aLUHiEQKVtvN7x0JtJvoo6x7aPZyomDBSHahJ/5Ro64JxvZLQTox9lqXV jtqhkh1EWJyHCRNFKpNgtwJ89XOlk6958+8SK+ZF/mJ9NTpwgLXxud0aJT3vIU7VKIyT u9wKHWDj9CiKSfVquTL5clRCF5MteSZoaoURT5i/hmCYRhARRyjWlStpFXftNZMf2wwq we62kx99Gq6bJfI3My9Ptqrsd5he6wrsbBgQbct+cEX31KtB+rgP1ezvGVnrZmp8Vwp3 k0mw== X-Gm-Message-State: AOAM531dCuHxbjc04FCHorrgf10Z50eHu6QQywe5QV4VFbxWcR9ReeDz OHuuckrIgousiuWen2YIVDkdHg== X-Google-Smtp-Source: ABdhPJyPUgmTTt079ESnoVYuzmEgGZo75ExGCvwo4ar4275kmPEVvrDRqP39G49T6UxqvFTtz8NfWA== X-Received: by 2002:aca:300f:: with SMTP id w15mr204300oiw.112.1644587324039; Fri, 11 Feb 2022 05:48:44 -0800 (PST) Received: from ?IPV6:2804:431:c7ca:733:82fc:6b41:692a:b9e0? ([2804:431:c7ca:733:82fc:6b41:692a:b9e0]) by smtp.gmail.com with ESMTPSA id s64sm9324352oos.0.2022.02.11.05.48.42 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 11 Feb 2022 05:48:43 -0800 (PST) Message-ID: <4d632b0d-191e-064b-d316-7614173561b7@linaro.org> Date: Fri, 11 Feb 2022 10:48:41 -0300 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.6.0 Subject: Re: [PATCH v2 5/5] Linux: Consolidate auxiliary vector parsing Content-Language: en-US To: Szabolcs Nagy Cc: Florian Weimer , libc-alpha@sourceware.org References: <151c5398adbbe538a275ea5ac77705b0abd0d748.1643886336.git.fweimer@redhat.com> <20220211123110.GB2692478@arm.com> <0dea5e89-25fb-3e17-8142-878482f171dd@linaro.org> <20220211132419.GC2692478@arm.com> From: Adhemerval Zanella In-Reply-To: <20220211132419.GC2692478@arm.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-12.1 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, NICE_REPLY_A, 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 13:48:46 -0000 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).