public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: Florian Weimer <fweimer@redhat.com>
To: Adhemerval Zanella Netto <adhemerval.zanella@linaro.org>
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, 03 Jan 2023 14:29:56 +0100	[thread overview]
Message-ID: <874jt7wxt7.fsf@oldenburg.str.redhat.com> (raw)
In-Reply-To: <86f86d4e-b9d5-1caf-a5ac-018bb95b38bc@linaro.org> (Adhemerval Zanella Netto's message of "Tue, 3 Jan 2023 09:09:04 -0300")

* 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>

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;

in common code.  Ideally, we don't use global variables for that because
in both cases, we only briefly need these variables.

Thanks,
Florian


  reply	other threads:[~2023-01-03 13:30 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 [this message]
2023-01-03 13:47       ` Adhemerval Zanella Netto
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=874jt7wxt7.fsf@oldenburg.str.redhat.com \
    --to=fweimer@redhat.com \
    --cc=adhemerval.zanella@linaro.org \
    --cc=debian-alpha@lists.debian.org \
    --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).