[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: What integer type should ELF note header have?



On Fri, 2017-12-15 at 08:52 -0800, H.J. Lu wrote:
> > On Fri, Dec 15, 2017 at 8:37 AM, Mark Wielaard <mark@klomp.org> wrote:
> > But honestly it feels much cleaner to just leave this past mistake be.
> > And maybe just introduce new notes types if people really care about
> > having naturally aligned note data in 64-bit ELF files.
> 
> If NT_GNU_PROPERTY_TYPE_0 note is the only concern, I have
> updated all of its REAL consumers to handle it properly.  It is OK if a tool
> doesn't understand it.

It is not really OK. I have seen code that marks an ELF file as invalid
and/or gives up processing ELF notes if it contains notes that don't
follow the standard 4-byte alignment/layout rules. So this really
impacts any tool that processes any ELF note.

> However, if we want to add SHT_NOTE64/PT_NOTE64, please do it ASAP
> since NT_GNU_PROPERTY_TYPE_0 note is used for Intel CET.

Yes, I think that is the correct long term solution. But we might not
get consensus soon over the holiday season. So if you probably should
do something that doesn't require introducing new note layout/alignment
or new note section/phdr types.

The simplest really is to just use the normal note alignment/layout.
This seems to be what Fedora rawhide toolchain currently does for
NT_GNU_PROPERTY_TYPE_0. That way all tools can process the note and the
only thing you need to be careful for is that some values in the note
descriptor might not be naturally aligned. This really shouldn't be an
issue, especially not if this is x86-only anyway.

If you insist on having the data value be naturally aligned for this
one property then it might make sense to look if you can use an
existing ELF construct that does give those guarantees. e.g. Use a
special symbol, PT header or DT value to encode the property.

Cheers,

Mark