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

Re: What integer type should ELF note header have?



On 09-Dec-2017 08:11 PM, Cary Coutant wrote:
> I'm pretty sure that at HP, we implemented the 8-byte wording.

That might be in the initial days. I do not have any archive that says
so. The current implementation is extremely very clear. It follows gABI
completely. Its 4 byte word with 4 byte alignment for 32-bit and 8 byte
word with 8 byte alignment for 64-bit. Read below.

On 10-Dec-2017 12:18 AM, Ali Bahrami wrote:
> Would the following work, and be backward compatible on other platforms?

What you mentioned below is exactly what we have on HP-UX too.

> 
>     - The ELFCLASS of an object no longer dictates the wordsize of
>       note sections.
> 
>     - In SHT_NOTE section headers, valid values of sh_addralign are
>       4, or 8. This value specifies the required alignment, as well
>       as the note wordsize, and padding.

Thats precisely what I wrote a week back:

supra wrote:
> And p_align of PT_NOTE may be set to the
> maximum of all sh_addralign of all SHT_NOTE that make up the PT_NOTE.

Since it is unlikely that there could be SHT_NOTE of different
alignments (in the same data model), it boils down to precisely what you
said above.

>       - In PT_NOTE program headers, the p_align field must match the
>         sh_addralign value for the note(s) that it encapsulates, and is
>         expected to be 4 for 32-bit notes, and 8 for 64-bit notes. For
>         historical reasons, values of 0 or 1 are also allowed, and refer
>         to a 32-bit note. 

Looks perfect. I agree.

> I have several reasons for thinking these are intended to be 8 bytes in 64-bit
> notes, starting with the words in the gABI. As HP-UX already implemented this
> years ago, Cary and Supra can confirm or deny that.

> What do other platforms (again, thinking about HP-UX) do for 64-bit notes?

Thats right. Reiterating, its 4 byte word with 4 byte alignment for
32-bit, and 8 byte word with 8 byte alignment for 64-bit.

>     - If those three fields are always 32-bit, then it means that name is
>       aligned on 4 bytes. This complicates the padding of name,

Agree. See below.

On 05-Dec-2017 03:11 AM, Mark Mentovai wrote:
> typedef uint32_t Elf32_Word;
> typedef uint32_t Elf64_Word;

This is the reason why on HP-UX we do not even have that
Elf[64|32]_Nhdr. It would make the word size same for both 32-bit and
64-bit data models. I think even gABI does not define *_Nhdr. Or am I
mistaken?

We generate contents of SHT_NOTE sections using internal data structs
and ensure gABI compatibility in a very simple way.

--
Supra