public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
From: Mark Wielaard <mark@klomp.org>
To: Richard Biener <rguenther@suse.de>
Cc: gcc@gcc.gnu.org
Subject: Re: [RFC] Change PCH "checksum"
Date: Tue, 26 Feb 2019 17:35:00 -0000	[thread overview]
Message-ID: <d7baab3ee4fdbe0dc5f2fed63d14f221826b0b23.camel@klomp.org> (raw)
In-Reply-To: <alpine.LSU.2.20.1902261807150.23386@zhemvz.fhfr.qr>

On Tue, 2019-02-26 at 18:13 +0100, Richard Biener wrote:
> > > That would mean when p_align == 8 the note name isn't 8-aligned
> > > but just 4-aligned?  That is, sizeof (Elf*_Nhdr) == 12, and the
> > > name starts right after that instead of being aligned according
> > > to p_align?  That sounds odd...  So p_align only applies to
> > > the descriptor?
> > 
> > Yes, it is that odd. There are 3 kinds of ELF notes.
> > 
> > The traditional ones as used by GNU and Solaris, which use 4 byte
> > words
> > for everything whether in ELFCLASS32 or ELFCLASS64 and which are 4
> > byte
> > aligned themselves.
> > 
> > The gabi ones, which are similar for ELFCLASS32 but for ELFCLASS64
> > all
> > words are 8 bytes and 8 bytes aligned themselves (as used by HPUX).
> > 
> > And the new style GNU Property notes, only used in ELFCLASS64,
> > which
> > use 4 byte words for the first 3 fields, immediately followed by
> > the
> > name bytes, padded so that desc is 8 bytes aligned and the note as
> > a
> > whole is 8 byte aligned.
> 
> I wonder how to distinguish the latter two - does one really need
> to test the size of ElfW(Nhdr).n_namesz for example?

I think the second one is only used on HPUX.
Everything else uses the 4 byte words variant.
I have only encountered the traditional note types and the new GNU
Properties notes (on Fedora, I don't believe any other distro has,
yet?, adopted them).

>   Why was the GNU Property one chosen this way?!

All I can do is point you at the "consensus" document:
https://sourceware.org/ml/binutils/2018-09/msg00282.html
and the replies to that.

>   Is the first case (traditional
> GNU note) with p_align == 8 invalid?

Yes, I believe so.

>   That is, is testing p_align
> really the correct way to determine how the individual parts are
> aligned?  I guess not.

I do think that is the only way. If the PT_NOTE segment or SHT_NOTE
segment has an alignment of 8 then it is a GNU Properties note with the
new layout (at least on GNU systems). Cary did propose some additional
constraints which might be helpful:
https://sourceware.org/ml/binutils/2018-09/msg00359.html

> So - how do I identify a GNU Property note vs. a traditional
> note vs. a gabi one?
> 
> Why was the third one added?! (I guess I asked that already...)

Yeah... See above.

Cheers,

Mark

  reply	other threads:[~2019-02-26 17:35 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-02-22 11:29 Richard Biener
2019-02-22 15:47 ` Jeff Law
2019-02-22 16:03   ` Jakub Jelinek
2019-02-22 17:12     ` Richard Biener
2019-02-25  8:42 ` Mark Wielaard
2019-02-26  8:33   ` Richard Biener
2019-02-26 11:40     ` Mark Wielaard
2019-02-26 14:36       ` Richard Biener
2019-02-26 14:49         ` Richard Biener
2019-02-26 16:18           ` Michael Matz
2019-02-26 17:02             ` Richard Biener
2019-02-27 16:56             ` Nathan Sidwell
2019-02-26 17:03         ` Mark Wielaard
2019-02-26 17:13           ` Richard Biener
2019-02-26 17:35             ` Mark Wielaard [this message]
2019-02-27 13:12     ` Florian Weimer

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=d7baab3ee4fdbe0dc5f2fed63d14f221826b0b23.camel@klomp.org \
    --to=mark@klomp.org \
    --cc=gcc@gcc.gnu.org \
    --cc=rguenther@suse.de \
    /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).