public inbox for gnu-gabi@sourceware.org
 help / color / mirror / Atom feed
From: "H.J. Lu" <hjl.tools@gmail.com>
To: Michael Matz <matz@suse.de>
Cc: Rich Felker <dalias@libc.org>, Cary Coutant <ccoutant@gmail.com>,
		"Carlos O'Donell" <carlos@redhat.com>,
	Florian Weimer <fweimer@redhat.com>,
	Szabolcs Nagy <nsz@port70.net>, 	Jan Beulich <JBeulich@suse.com>,
	Binutils <binutils@sourceware.org>,
	gnu-gabi@sourceware.org
Subject: Re: RFC: Add GNU_PROPERTY_NEED_PHDRS
Date: Mon, 01 Jan 2018 00:00:00 -0000	[thread overview]
Message-ID: <CAMe9rOqfXXtUF=3H-TtcPaB5_emjbzV7gQ7MsXDj4iiJr1wC-Q@mail.gmail.com> (raw)
In-Reply-To: <alpine.LSU.2.21.1810021546590.7867@wotan.suse.de>

On Tue, Oct 2, 2018 at 8:48 AM Michael Matz <matz@suse.de> wrote:
>
> Hi,
>
> On Tue, 2 Oct 2018, H.J. Lu wrote:
>
> > > > If linker script discards a section, all bets are off.  Anything can
> > > > happen.
> > >
> > > I disagree, but even if I'd agree your solution still is more
> > > accidental than by design.  You want to guarantee something about
> > > program headers, so any solution that doesn't do anything specific
> > > about/with program headers is similarly accidental.
> >
> > Nothing is guaranteed when linker script is used since anything can
> > happen with linker script.
>
> Ignore the parts about the linker script, I disagree with you, but that's
> immaterial to my main point.  Your solution still is only an accidental
> one as you don't do anything about program headers but instead just add
> magic sections to magic places that happens to do what you want currently.
> That's not by design.

The problem is

1. Linker kernel passes AT_PHDR to main and assumes that AT_PHDR
is in a PT_LOAD segment.
2. gABI doesn't require phdrs in a PT_LOAD segment.
3. Ld won't create a PT_LOAD segment just to hold phdrs.
4. With -z separate-code, linker won't put any non-code in a PF_X PT_LOAD
segment.

When there are only PF_X PT_LOAD segments, phdrs isn't in any PT_LOAD
segment.

You are looking for a solution to create a PT_LOAD segment just to hold phdrs.
I have investigated it.  It is very intrusive.  My solution, which you
called a hack,
is to add a read-only SHF_ALLOC section so that a PT_LOAD segment will
be created by ld to hold phdrs when there is only PF_X PT_LOAD segments
otherwise.

-- 
H.J.

  reply	other threads:[~2018-10-02 16:23 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-01-01  0:00 H.J. Lu
2018-01-01  0:00 ` Michael Matz
2018-01-01  0:00   ` H.J. Lu
2018-01-01  0:00     ` Michael Matz
2018-01-01  0:00       ` H.J. Lu
2018-01-01  0:00         ` Michael Matz
2018-01-01  0:00           ` H.J. Lu
2018-01-01  0:00             ` Michael Matz
2018-01-01  0:00               ` H.J. Lu [this message]
2018-01-01  0:00                 ` Cary Coutant
2018-01-01  0:00                   ` Alan Modra
2018-01-01  0:00                     ` Cary Coutant
2018-01-01  0:00                       ` Alan Modra
2018-01-01  0:00                         ` Cary Coutant
2018-01-01  0:00                           ` H.J. Lu
2018-01-01  0:00                             ` Rich Felker
2018-01-01  0:00                               ` H.J. Lu
2018-01-01  0:00                                 ` Alan Modra

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='CAMe9rOqfXXtUF=3H-TtcPaB5_emjbzV7gQ7MsXDj4iiJr1wC-Q@mail.gmail.com' \
    --to=hjl.tools@gmail.com \
    --cc=JBeulich@suse.com \
    --cc=binutils@sourceware.org \
    --cc=carlos@redhat.com \
    --cc=ccoutant@gmail.com \
    --cc=dalias@libc.org \
    --cc=fweimer@redhat.com \
    --cc=gnu-gabi@sourceware.org \
    --cc=matz@suse.de \
    --cc=nsz@port70.net \
    /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).