From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-oa1-x33.google.com (mail-oa1-x33.google.com [IPv6:2001:4860:4864:20::33]) by sourceware.org (Postfix) with ESMTPS id 5CB6D3858D1E for ; Tue, 3 Jan 2023 13:47:06 +0000 (GMT) Received: by mail-oa1-x33.google.com with SMTP id 586e51a60fabf-150debe2b7cso1018832fac.0 for ; Tue, 03 Jan 2023 05:47:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:in-reply-to:organization:from:references :cc:to:content-language:subject:user-agent:mime-version:date :message-id:from:to:cc:subject:date:message-id:reply-to; bh=amPpVZaN/DEcxJVn2P8qVvIaVukDbYYKDAYhlPf67M0=; b=iSgoZIKAmpzo6rcwlCe1UvPlg8j3WG+3YKVSxSdolIfnwp+Kj4cAY4R1ITbkMU78tU eEgRh0sT7aHu4UqyYFIy4H3qwngy88d5BK9HzUjidPYfLsHT0jwBqCO52c/YuGuiDREZ Ea50gzNjwpq7YUj+SvmQX7dObjBOumeAL1qwMptHgZnqGtBmUR54Jsfx9lbSWPSX1DZx P4KYeULQYFPsaAimtXjZxGFu5qCUdtm1apvTrj0GGTpvTyGcm62urFGbyohRW/8G39Xp YCCNA88k+JPXEdyQHPTwBe4eqNZXlL2gstAVm/T22FPS7VIkzCgKLN5GiCVT7uA/Ah3g 9ZgQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:in-reply-to:organization:from:references :cc: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=amPpVZaN/DEcxJVn2P8qVvIaVukDbYYKDAYhlPf67M0=; b=cROq8DgYY+OT/P1UcrBXKus8dt4iZWuOzUC+pQqft/aTcugCNsYn/i2mYGnzC0RzwN d10nyIvwKxkTFTFDxyIHB7cR+9ByWiQXEEwZkfOsRJmjua+va7ECEqPypRYCVE8LMARq 86DVlk50vNXh/8WipuGjhWUwSG6nKgBDXfEVWESJ9fxL5FdRcX5qTNsyj1ESQVfCdzGe ChtPoMa7L4VawPU1tI2r3Cx7Ofc7RxY6dM/lHoCegmHs7bXjcvFuXuUWyp6Mn0jGvgnS JZ0sygSzscn3Ynh2pWrhx3t8spqF0AjORjicwOz8xYHwmQRIyoqmR/GHT7nR7FHvSs3z tpkQ== X-Gm-Message-State: AFqh2kpuwVfoEsr84yoxDPYTdjC8mw0/RLR9C6dyqbQTf5RjFxm9DTa3 Q22panXLTcCElcB4kdxcGVIZEGQZCk30KQE5JIU= X-Google-Smtp-Source: AMrXdXsZBpVkFbqJ8hnzmjdkfPlH9RKFVeddaqb2Jq1J/PHlwF1ysv5yCnaj6doMMDCgRh71FerBcw== X-Received: by 2002:a05:6870:3b8f:b0:13b:ad3a:f7c9 with SMTP id gi15-20020a0568703b8f00b0013bad3af7c9mr22283876oab.28.1672753625383; Tue, 03 Jan 2023 05:47:05 -0800 (PST) Received: from ?IPV6:2804:1b3:a7c0:1729:54db:2a30:ff9e:ffaa? ([2804:1b3:a7c0:1729:54db:2a30:ff9e:ffaa]) by smtp.gmail.com with ESMTPSA id bu2-20020a0568300d0200b0066dae8cf9a0sm6975246otb.50.2023.01.03.05.47.03 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 03 Jan 2023 05:47:04 -0800 (PST) Message-ID: <4da93027-2dc2-95a0-8ec4-313af91dbc75@linaro.org> Date: Tue, 3 Jan 2023 10:47:02 -0300 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:102.0) Gecko/20100101 Thunderbird/102.6.1 Subject: Re: Update on the glibc segfault issue on Alpha Content-Language: en-US To: Florian Weimer Cc: John Paul Adrian Glaubitz , "debian-alpha@lists.debian.org" , gentoo-alpha@lists.gentoo.org, GNU C Library References: <999879fc-9cb3-1efa-165b-36a5418f2e41@physik.fu-berlin.de> <86f86d4e-b9d5-1caf-a5ac-018bb95b38bc@linaro.org> <874jt7wxt7.fsf@oldenburg.str.redhat.com> From: Adhemerval Zanella Netto Organization: Linaro In-Reply-To: <874jt7wxt7.fsf@oldenburg.str.redhat.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-14.9 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 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 03/01/23 10:29, Florian Weimer wrote: > * Adhemerval Zanella Netto: > >> diff --git a/csu/libc-start.c b/csu/libc-start.c >> index 543560f36c..63a3eceaea 100644 >> --- a/csu/libc-start.c >> +++ b/csu/libc-start.c >> @@ -271,18 +271,10 @@ LIBC_START_MAIN (int (*main) (int, char **, char ** MAIN_AUXVEC_DECL), >> So we can set up _dl_phdr and _dl_phnum even without any >> information from auxv. */ >> >> - extern const ElfW(Ehdr) __ehdr_start >> -# if BUILD_PIE_DEFAULT >> - __attribute__ ((visibility ("hidden"))); >> -# else >> - __attribute__ ((weak, visibility ("hidden"))); >> - if (&__ehdr_start != NULL) >> -# endif >> - { >> - assert (__ehdr_start.e_phentsize == sizeof *GL(dl_phdr)); >> - GL(dl_phdr) = (const void *) &__ehdr_start + __ehdr_start.e_phoff; >> - GL(dl_phnum) = __ehdr_start.e_phnum; >> - } >> + extern const ElfW(Ehdr) __ehdr_start attribute_hidden; >> + assert (__ehdr_start.e_phentsize == sizeof *GL(dl_phdr)); >> + GL(dl_phdr) = (const void *) &__ehdr_start + __ehdr_start.e_phoff; >> + GL(dl_phnum) = __ehdr_start.e_phnum; > > There's a separate thread that e.ph_off is not actually correct in this > context because it's a file offset that doesn't necessarily match the > virtual memory offset:> > [PATCH 0/1] __libc_start_main() now uses auxv to obtain phdr's address > [BZ #29864] > Yes, but this is a fallback case where the kernel does not provide AT_PHDR and AT_PHNUM. As I added on the thread, I think it is better to use the kernel provided value since they will always present and it leverages a kernel fix for a similar issue [1]. > > I think this needs to be cleaned up so that the static and dynamic cases > are aligned. That is, we probably want to do the equivalent of > > GL(dl_phdr) = (const void *) &__ehdr_start + __ehdr_start.e_phoff; > GL(dl_phnum) = __ehdr_start.e_phnum; > I think we should use the __ehdr_start only as fallback. > in common code. Ideally, we don't use global variables for that because > in both cases, we only briefly need these variables. Right, this make sense. > > Thanks, > Florian > [1] https://sourceware.org/pipermail/libc-alpha/2022-December/143942.html