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 61706385841B for ; Fri, 11 Feb 2022 18:15:57 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 61706385841B Received: by mail-oi1-x22b.google.com with SMTP id m10so10491576oie.2 for ; Fri, 11 Feb 2022 10:15:57 -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=IkCZASAw/L7SgbDikM512ew18V205VLzf9HUb7ODM54=; b=8LtsRaWZMScvGOd1OM+YdK8qLkQtCdUbyEvaZKanyraHvTNTzRNwkaIg6SjyVJP4gK LNM3rif3STTAONr66K5bn8ruwWgMsy3ReSLW43pgdNhSMA22kWWx8LwsLKw6CmkEYGU8 OT1Hoz7dKHEduwS+4r2LGy8bF2xFv1JevLZhcPnnWjCflfjxBrDfyt2Ws/WPt50dAcoq 6x7iP+bEvKtA7Q+ol906Y1pTJDylFcraAcso1IXUsNTVBf2LQBW0UEVyaKW1NG4l1ufC da37aahX5zmvKy2BNXpZqRgHNqdD7Em63cywpaAl7n97pdhChukeUeQ7rZULt2yeqdbE pgKg== X-Gm-Message-State: AOAM531EdOEmdZBFY0MYvcYob3b8hPUvVQC6NYt7GTjQtJrbORmtTpaP rq8yDybGNnEIWnUjn1TnCbW5HA== X-Google-Smtp-Source: ABdhPJzq7tRCkThRL6PGMn7Zd+PfhhBJDbw2B1svUmv5Xr8INAu+yOiq9O5bQxLnTru1VTUjejOocA== X-Received: by 2002:a05:6808:1899:: with SMTP id bi25mr819364oib.338.1644603356654; Fri, 11 Feb 2022 10:15:56 -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 t21sm9231937otq.81.2022.02.11.10.15.55 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 11 Feb 2022 10:15:56 -0800 (PST) Message-ID: <1d499713-3215-4298-982c-73898045a973@linaro.org> Date: Fri, 11 Feb 2022 15:15:54 -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> <87a6exv7gd.fsf@oldenburg.str.redhat.com> <6cc1d2ae-f399-10d2-833b-4c17bd774892@linaro.org> <20220211142941.GD2692478@arm.com> From: Adhemerval Zanella In-Reply-To: <20220211142941.GD2692478@arm.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-5.8 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, 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 18:15:59 -0000 On 11/02/2022 11:29, Szabolcs Nagy wrote: > The 02/11/2022 11:17, Adhemerval Zanella wrote: >> On 11/02/2022 10:49, Florian Weimer wrote: >>> * Szabolcs Nagy: >>>> 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 >>> >>> Seems to happen with -fno-builtin or -ffreestanding as well. It's a GCC >>> bug, but I'll investigating working around it. >> >> I don't think it is gcc bug, even for -ffreestanding compiler can assume >> the C environment will always provide memset/memcpy. The problem is we >> need a gcc option to avoid such optimization, which afaik there is none. >> >> And without such option I think we will need to either revert this change >> or use the symbol alias strategy to avoid using IFUNC on loader code. > > if we can rewrite the code not to depend on zeroing a large array > (where large is about >200bytes) that should work too. > > i dont see a clean way, but e.g. a > > char seen_auxval[AT_MINSIGSTKSZ+1] = {0}; > > would not trigger memset (on aarch64). > > as a bonus with such an array we can distinguish auxv unset and auxv 0. I think this kind of solution is fragile, if compiler decides to change the optimization threshold we will see a regression.