public inbox for gnu-gabi@sourceware.org
 help / color / mirror / Atom feed
From: Mark Mentovai <mark@chromium.org>
To: hjl.tools@gmail.com, gnu-gabi@sourceware.org
Subject: Re: GNU-gABI: Alignment of .note.ABI-tag and .note.gnu.build-id sections
Date: Sun, 01 Jan 2017 00:00:00 -0000	[thread overview]
Message-ID: <CAHk1GDxprWfsAYRJ05UUSLdq5-qncpeNAoGNn01pTTS0kkMF8Q@mail.gmail.com> (raw)
In-Reply-To: <CAHk1GDy79gf3YpzPt83WEXP-OLOKW+UH=aYUqvEjLfC=_ZHwew@mail.gmail.com>

I think that this recent change (commit 9a7bc47bf065) misses the
larger point. The alignment isn’t the only thing at issue here, the
very definition of the ELF note section is.

Quoting http://www.sco.com/developers/gabi/latest/ch5.pheader.html#note_section:

> In 64-bit objects (files with e_ident[EI_CLASS] equal to ELFCLASS64), each
> entry is an array of 8-byte words in the format of the target processor. In
> 32-bit objects (files with e_ident[EI_CLASS] equal to ELFCLASS32), each entry
> is an array of 4-byte words in the format of the target processor.

This is not followed by ELF on Linux (or, in fact, most other
systems), which define the note structure for 32-bit and 64-bit ELF
objects identically, as arrays of 4-byte words:

typedef uint32_t Elf32_Word;
typedef uint32_t Elf64_Word;
typedef struct {
  Elf32_Word n_namesz;
  Elf32_Word n_descsz;
  Elf32_Word n_type;
} Elf32_Nhdr;
typedef struct {
  Elf64_Word n_namesz;
  Elf64_Word n_descsz;
  Elf64_Word n_type;
} Elf64_Nhdr;

The requirement to use different note structures for 32-bit and 64-bit
objects is present in the 1998-04-29 gABI draft at earliest
(http://www.sco.com/developers/gabi/1998-04-29/ch5.pheader.html#note_section),
but is absent from Edition 4.1
(http://www.sco.com/developers/devspecs/gabi41.pdf#page=81), prior to
the standardization of the 64-bit format.

This structure’s alignment naturally follows its definition, and
specifically the sizes of the types involved.

As Linux deviates from the gABI in this not-insignificant way, the
Linux Extensions document ought to codify the distinction. The ELF
note structure definitions have been baked into too many places for
too much time to reasonably expect them to change.

Because Linux isn’t the only system to define the note structure in
this way even for 64-bit objects, it may be worth a mention in the
gABI as well, although I don’t know how to communicate this to its
maintainers.

       reply	other threads:[~2017-12-04 21:41 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <CAHk1GDxbS6Pgm3a3K9pkorzEg9cm8bWU+=LaRK_yGTrrQ57A-A@mail.gmail.com>
     [not found] ` <CAHk1GDy79gf3YpzPt83WEXP-OLOKW+UH=aYUqvEjLfC=_ZHwew@mail.gmail.com>
2017-01-01  0:00   ` Mark Mentovai [this message]
2017-01-01  0:00 H.J. Lu
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=CAHk1GDxprWfsAYRJ05UUSLdq5-qncpeNAoGNn01pTTS0kkMF8Q@mail.gmail.com \
    --to=mark@chromium.org \
    --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).