From: Adhemerval Zanella Netto <adhemerval.zanella@linaro.org>
To: Florian Weimer <fweimer@redhat.com>
Cc: John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de>,
"debian-alpha@lists.debian.org" <debian-alpha@lists.debian.org>,
gentoo-alpha@lists.gentoo.org,
GNU C Library <libc-alpha@sourceware.org>
Subject: Re: Update on the glibc segfault issue on Alpha
Date: Tue, 3 Jan 2023 10:47:02 -0300 [thread overview]
Message-ID: <4da93027-2dc2-95a0-8ec4-313af91dbc75@linaro.org> (raw)
In-Reply-To: <874jt7wxt7.fsf@oldenburg.str.redhat.com>
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]
> <https://sourceware.org/pipermail/libc-alpha/2022-December/143874.html>
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
next prev parent reply other threads:[~2023-01-03 13:47 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-01-02 11:44 John Paul Adrian Glaubitz
2023-01-02 17:37 ` John Paul Adrian Glaubitz
2023-01-03 12:09 ` Adhemerval Zanella Netto
2023-01-03 13:29 ` Florian Weimer
2023-01-03 13:47 ` Adhemerval Zanella Netto [this message]
2023-01-04 9:25 ` John Paul Adrian Glaubitz
2023-01-04 12:00 ` Adhemerval Zanella Netto
2023-01-05 11:25 ` John Paul Adrian Glaubitz
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4da93027-2dc2-95a0-8ec4-313af91dbc75@linaro.org \
--to=adhemerval.zanella@linaro.org \
--cc=debian-alpha@lists.debian.org \
--cc=fweimer@redhat.com \
--cc=gentoo-alpha@lists.gentoo.org \
--cc=glaubitz@physik.fu-berlin.de \
--cc=libc-alpha@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).