From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-oi1-x234.google.com (mail-oi1-x234.google.com [IPv6:2607:f8b0:4864:20::234]) by sourceware.org (Postfix) with ESMTPS id 52EFB385841D for ; Thu, 30 Mar 2023 20:46:58 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 52EFB385841D Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=linaro.org Received: by mail-oi1-x234.google.com with SMTP id w133so15213742oib.1 for ; Thu, 30 Mar 2023 13:46:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1680209217; h=content-transfer-encoding:in-reply-to:organization:from:references :to:content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=6klDbs2uvgRGUyTcJkSJ+rTh4cizkqMfxnGsPfy8ezU=; b=VYcUIfQ8wsaV6ZF8GVORAtYICCjk+v0FXT4dEkOw3KaN3Jg7by5nOclvMX53tvwtq6 ZWPv0TVYSZHHMJNp0zwFQiIeS5INQTyh22noUBCssF7+QflgBW3RhosgP7/N0Kc/GEZ6 ReIxQGBsQ35B+kLWaYlUXXrOpZ3NkC8adpRP+r/9Fzb2vfRsuIeF6NAArEVfFqbGOUOx feGcLbwmpsGwFg8yJROnPEaYZiVh7fVh0g0DHlytHQE3W842GahXwg6hxKd/goMs3Dob 13lA3Zc7lkUTYAfxjenqQMkSn2pV9DQ7DE5JTDeQYPz1iS4uGo8WleFkV1fDLmRGgcpA 3bgw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680209217; h=content-transfer-encoding:in-reply-to:organization:from:references :to:content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=6klDbs2uvgRGUyTcJkSJ+rTh4cizkqMfxnGsPfy8ezU=; b=Fb/cGVPhxPyP588w0Y05mKD7msprIy1wQpnDsaiQKMDkspx7SxA96Ru+c/5c/Afpza BThYMNV127p0b7whhb2Dob3Ljf4X/i7kAmONI0A8P1al8G9UQmBLrlva3wwWrI+X1Iid 6wAvxvKR14IPecfsHwx5pGszY412aDswZVTBsXKhaOnmA+YEoZz+9/6AF0LX0k5rEUCo Bdvnv/wwtk72skFMhUXLCGcaRma3E8mlMGdqQX2QIQQwOr87/B/TazJaAjOPrL+xGyRt z1JY0Kv89V60A3OSAfh+EC+geaPct27/c4Bkr0G6c/8HTcyKyQfb41kjim2XQBCDT/fk trXQ== X-Gm-Message-State: AO0yUKVwrLUTuGAvifNiYOjVIYH6W7bw7TFuHtqKWDfhP+hiYwZmg6/8 ss/zS+IPQMXoNfZQ4GaBjkrHUw== X-Google-Smtp-Source: AK7set++X/zumLb0vOgo7D6k7MVIv0gI2Ov1T8Bb+eUEfiOweFiXaymxVbmLT2vBYChWw/oeWsRq3g== X-Received: by 2002:a05:6808:6384:b0:386:9c8a:e729 with SMTP id ec4-20020a056808638400b003869c8ae729mr9582634oib.17.1680209217500; Thu, 30 Mar 2023 13:46:57 -0700 (PDT) Received: from ?IPV6:2804:1b3:a7c1:60f9:4ca7:df5c:ca4c:27b4? ([2804:1b3:a7c1:60f9:4ca7:df5c:ca4c:27b4]) by smtp.gmail.com with ESMTPSA id v15-20020a056808004f00b003898ebb8be0sm271587oic.48.2023.03.30.13.46.56 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 30 Mar 2023 13:46:57 -0700 (PDT) Message-ID: Date: Thu, 30 Mar 2023 17:46:54 -0300 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:102.0) Gecko/20100101 Thunderbird/102.9.0 Subject: Re: [PATCH 03/13] elf: dont pass fd to _dl_process_pt_xx Content-Language: en-US To: stsp , libc-alpha@sourceware.org, Szabolcs Nagy References: <20230318165110.3672749-1-stsp2@yandex.ru> <20230318165110.3672749-4-stsp2@yandex.ru> <77329e53-bb96-dc39-1f3d-6a5dfa0e7263@linaro.org> From: Adhemerval Zanella Netto Organization: Linaro In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-10.5 required=5.0 tests=BAYES_00,BODY_8BITS,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 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: On 30/03/23 13:08, stsp wrote: > > 29.03.2023 22:10, Adhemerval Zanella Netto пишет: >> >> On 18/03/23 13:51, Stas Sergeev via Libc-alpha wrote: >>> It is not used in these functions. >>> rtld.c:rtld_setup_main_map() does the same. >>> >>> The test-suite was run on x86_64/64 and showed no regressions. >>> >>> Signed-off-by: Stas Sergeev >>> --- >>>   elf/dl-load.c | 4 ++-- >>>   1 file changed, 2 insertions(+), 2 deletions(-) >>> >>> diff --git a/elf/dl-load.c b/elf/dl-load.c >>> index fcb39a78d4..ab8b648687 100644 >>> --- a/elf/dl-load.c >>> +++ b/elf/dl-load.c >>> @@ -1379,10 +1379,10 @@ cannot enable executable stack as shared object requires"); >>>       switch (ph[-1].p_type) >>>         { >>>         case PT_NOTE: >>> -    _dl_process_pt_note (l, fd, &ph[-1]); >>> +    _dl_process_pt_note (l, -1, &ph[-1]); >>>       break; >>>         case PT_GNU_PROPERTY: >>> -    _dl_process_pt_gnu_property (l, fd, &ph[-1]); >>> +    _dl_process_pt_gnu_property (l, -1, &ph[-1]); >>>       break; >>>         } >>>   >> >> It allows both _dl_process_pt_note and _dl_process_pt_gnu_property to know >> if the called where rtld code during statup code or dlopen.  But you are >> right that it is not used. >> >> However this does not accomplish anything, a better refactor would to just >> remove the argument altogether.  It at least would simplify the interface >> and allow slight better code generation. > > I tried to do that, but there is also that > _dl_process_gnu_property() called from > _dl_process_pt_gnu_property(). > For aarch64 it has this: >       unsigned int feature_1 = *(unsigned int *) data; >       if (feature_1 & GNU_PROPERTY_AARCH64_FEATURE_1_BTI) >         _dl_bti_protect (l, fd); > > What should I do here to remove that fd? > In fact aarch64 _dl_bti_protect requires to know whether the map was done by the kernel or not. Szabolcs, shouldn't the code: 1257 for (const ElfW(Phdr) *ph = &phdr[phnum]; ph != phdr; --ph) 1258 switch (ph[-1].p_type) 1259 { 1260 case PT_NOTE: 1261 _dl_process_pt_note (main_map, -1, &ph[-1]); 1262 break; 1263 case PT_GNU_PROPERTY: 1264 _dl_process_pt_gnu_property (main_map, -1, &ph[-1]); 1265 break; 1266 } Take in consideration whether the main_map was allocated by the kernel or by loader to pass the correct value on 'fd'?