This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [RFC] Change PCH "checksum"


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]