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

Re: What integer type should ELF note header have?



On Thu, 2017-12-14 at 08:39 -0800, H.J. Lu wrote:
> > > > BTW. What is the reason you need 8 byte aligned notes?
> > > 
> > > NT_GNU_PROPERTY_TYPE_0 can have 64-bit integer properties
> > > in 64-bit objects.  They should be aligned to 8 bytes.
> > 
> > Not necessarily. You can have not naturally aligned data in files.
> > ELF
> > files are cross architectures, so you have to account for different
> 
> 64-bit integers in NT_GNU_PROPERTY_TYPE_0 note are naturally aligned
> by design so that int64 can be used to access 64-bit integers in
> NT_GNU_PROPERTY_TYPE_0 note on all architectures.
> 
> > alignments and endian issues anyway. Is there a specific property
> > of
> > these 64-bit integers that require them to be 8 byte aligned in the
> > note descriptor data?
> 
> Currently it has GNU_PROPERTY_STACK_SIZE as 64-bit integer
> in 64-bit objects.  We may add more in the future.

So is it just convenience, so you don't have to write a
read_8byte_unaligned_value macro to read the data in the note?

I sympathize that reading note data can be a bit of a pain because you
cannot rely on the data being naturally aligned. But I am unsure that
is such a big trouble that it needs new alignment/layout rules.

Cheers,

Mark