public inbox for gnu-gabi@sourceware.org
 help / color / mirror / Atom feed
From: Suprateeka R Hegde <hegdesmailbox@gmail.com>
To: generic-abi@googlegroups.com, "H.J. Lu" <hjl.tools@gmail.com>
Cc: gnu-gabi@sourceware.org
Subject: Re: Alignment and sizes of note sections in 64-bit ELF objects
Date: Sun, 01 Jan 2017 00:00:00 -0000	[thread overview]
Message-ID: <d5442b97-be53-b2b6-ad3f-e44bc69dbd61@gmail.com> (raw)
In-Reply-To: <CAMe9rOp4tDf619hCJUMMjd=MGFobSEtNgddrczWR9trb6JishQ@mail.gmail.com>

(I took a while to recollect the discussion)

On 16-Nov-2017 10:11 PM, H.J. Lu wrote:
> On Mon, Apr 3, 2017 at 11:48 AM, Suprateeka R Hegde
> <hegdesmailbox@gmail.com> wrote:
>> On 03-Apr-2017 08:49 PM, Ian Lance Taylor wrote:
>>> On Mon, Apr 3, 2017 at 8:16 AM, H.J. Lu <hjl.tools@gmail.com> wrote:
>>>> According to gABI, in 64-bit objects, each note entry is an array of 8-bye
>>>> words in the format of the target processor.  But I got
>>>>
>>>>   [ 2] .note.ABI-tag     NOTE            0000000000000254 000254
>>>> 000020 00   A  0   0  4
>>>>   [ 3] .note.gnu.build-id NOTE            0000000000000274 000274
>>>> 000024 00   A  0   0  4
>>>>
>>>> on Linux/x86-64.  .note.ABI-tag size is 32, but it isn't aligned at 8 bytes.
>>>> .note.gnu.build-id size is 36, which isn't multiple of 8 bytes.  Should
>>>> note sections in 64-bit ELF objects be multiple of 8 bytes as well as
>>>> aligned to 8 bytes?
>>
>> On HP-UX, it is 8 byte alignment. And the size becomes multiple of 8
>> bytes automatically, as we ensure 8 byte alignment for the next note
>> entry. This is as per the gABI.
>>
>>> This is the comment I wrote in gold when I looked into this:
>>>
>>>   // Authorities all agree that the values in a .note field should
>>>   // be aligned on 4-byte boundaries for 32-bit binaries.  However,
>>>   // they differ on what the alignment is for 64-bit binaries.
>>>   // The GABI says unambiguously they take 8-byte alignment:
>>>   //    http://sco.com/developers/gabi/latest/ch5.pheader.html#note_section
>>>   // Other documentation says alignment should always be 4 bytes:
>>>   //    http://www.netbsd.org/docs/kernel/elf-notes.html#note-format
>>
>> Thats interesting. But why should it differ from GABI?
>>
>> May be because: In both ILP32 and LP64 model, integer is 4 bytes. And
>> the documentation says "integer" in parenthesis for the fields.
>>
>> For example:
>> Name Size
>>         4 bytes (integer)
>> Desc Size
>>         4 bytes (integer)
>>
>> In contrast to GABI, NetBSD seems to have attributed these fields with
>> "integer".
>>
> 
> Linux has been using 4 byte alignment for .note.ABI-tag note and
> .note.gnu.build-id note in 64-bit objects.  We can't change their
> alignment to 8 bytes.   Can we add a footnote in gABI to address it?

It should be more clear than that. See below.

> In reality, this isn't a real issue since all notes in one PT_LOAD segment
> must have the same alignment which equals to p_align.

p_align of PT_LOAD or PT_NOTE?

>  Note parser
> can use p_align of PT_LOAD segment for note alignment,

Why not p_align of PT_NOTE? p_align of PT_LOAD seems to be (on my
Ubuntu) set to the 2MiB pagesize value.

> instead of
> assuming alignment based on ELF file class.

The gABI description of ELF class based alignment may be because gABI
does not talk anything about PT_NOTE actually being part of PT_LOAD.
PT_NOTE could be a separate segment on its own outside PT_LOAD, though
almost all implementations make it part of PT_LOAD.

> BTW, should we document that all notes in one PT_LOAD segment
> must have the same alignment which equals to p_align?

Why not p_align of PT_NOTE? 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.

--
Supra

       reply	other threads:[~2017-11-20 15:27 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <CAMe9rOoWPk84b9HoeiJdF4B_X090jfQQXCyNUm1_R22uNSHOkw@mail.gmail.com>
     [not found] ` <CAOganjUx7N4qTEEM0DDdn0izhO_UPv9miB7w4O0abU=p4GmT0w@mail.gmail.com>
     [not found]   ` <6de4d8f7-a08e-7aac-64d0-3e41795c9143@gmail.com>
     [not found]     ` <CAMe9rOp4tDf619hCJUMMjd=MGFobSEtNgddrczWR9trb6JishQ@mail.gmail.com>
2017-01-01  0:00       ` Suprateeka R Hegde [this message]
2017-01-01  0:00         ` H.J. Lu

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=d5442b97-be53-b2b6-ad3f-e44bc69dbd61@gmail.com \
    --to=hegdesmailbox@gmail.com \
    --cc=generic-abi@googlegroups.com \
    --cc=gnu-gabi@sourceware.org \
    --cc=hjl.tools@gmail.com \
    /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).