public inbox for gnu-gabi@sourceware.org
 help / color / mirror / Atom feed
From: Mark Wielaard <mark@klomp.org>
To: "H.J. Lu" <hjl.tools@gmail.com>
Cc: Generic System V Application Binary Interface
	<generic-abi@googlegroups.com>,
	Suprateeka R Hegde <hegdesmailbox@gmail.com>,
	 Cary Coutant <ccoutant@gmail.com>,
	Mark Mentovai <mark@chromium.org>,
	gnu-gabi@sourceware.org
Subject: Re: What integer type should ELF note header have?
Date: Sun, 01 Jan 2017 00:00:00 -0000	[thread overview]
Message-ID: <1513173445.15696.62.camel@klomp.org> (raw)
In-Reply-To: <CAMe9rOp2Ps90xxVr4qER=QCXhsYJnaLLoJFdOP7WWJKqA9_dFA@mail.gmail.com>

On Mon, 2017-12-11 at 04:11 -0800, H.J. Lu wrote:
> Changing ELF64_Nhdr is going to be hard, but not impossible.  In
> theory, an 64-bit object may have a note entry which is bigger than 4
> GB.  We can add a new note header:
> 
> typedef struct
> {
>   Elf64_Xword n_namesz;                  /* Length of the note's name.  */
>   Elf64_Xword n_descsz;                  /* Length of the note's descriptor.  */
>   Elf64_Xword n_type;                    /* Type of the note.  */
> } Elf64_Nhdr64;
> 
> Note segments/sections with 8 byte alignment should use Elf64_Nhdr64.
> If we want to do it, we should do it now before
> NT_GNU_PROPERTY_TYPE_0
> notes with the existing Elf64_Nhdr are generated by GCC 8 with
> -fcf-protection -mcet.

Yes, I think having a new note type is the way to go, if we want to
change the alignment requirements.

BTW. What is the reason you need 8 byte aligned notes?

One issue we had with ELF notes for systemtap (the stap sdt notes) was
that tools like prelink don't know about addresses inside notes. So we
did end up with (also) using a .stapsdt.base section so we had a
sh_addr that we could compare against in case tools like prelink needed
to adjust needed to do address adjustments.

Another thing about ELF notes is that they normally should be fairly
small because when generating separate .debug files they get copied. So
they take up space in both the main and debug file.

So maybe using a normal ELF section might be an alternative?

> I have updated glibc and binutils to support 4 byte and 8 byte alignments
> in 64-bit objects by checking p_align/sh_addralign, instead of assuming
> 4 byte alignment, like

I looked at those glibc and binutils patch proposals and I must say I
don't get the feeling you really got consensus on them. For both
reviewers said that on GNU/Linux note alignment doesn't follow gabi and
seemed to think it was a bad idea to change that now. I am somewhat
surprised you committed them anyway without more discussion to get
consensus.

> > You could play with the SHT_NOTE sh_align and PT_NOTE p_align
> > values, but I haven't actually found any code that pays attention
> > to it. So a lot of code would have to be rewritten.
> > 
> These can be easily fixed with [...]

But the issue is that the code is not wrong. ELF Notes on GNU/Linux
always have had a fixed 4 byte alignment. That might not be what gabi
intended, but it is what several code bases have been assuming for
decades. If we are going to change that, it really should require new 
ELF note types so consumers current code for existing notes isn't
broken.

Cheers,

Mark

  reply	other threads:[~2017-12-13 13:57 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <CAMe9rOoV5u263JotP=XpiYEzcnjCJOG3U-0X5bnK-WwZoOKTQA@mail.gmail.com>
     [not found] ` <99c8440b-54d8-41bc-6e4d-cd1894536bb7@Oracle.COM>
     [not found]   ` <CAJimCsHE8cMY8MY=BYyQ+o4b14LtQKa2u+SiXWi1o4zBQB9t9Q@mail.gmail.com>
2017-01-01  0:00     ` Suprateeka R Hegde
2017-01-01  0:00       ` Ali Bahrami
2017-01-01  0:00         ` Mark Wielaard
2017-01-01  0:00           ` H.J. Lu
2017-01-01  0:00             ` Mark Wielaard [this message]
2017-01-01  0:00               ` H.J. Lu
2017-01-01  0:00                 ` Mark Wielaard
     [not found]                   ` <3704867e-58b8-3da1-2b29-959ad67a540d@Oracle.COM>
     [not found]                     ` <1513355861.15696.95.camel@klomp.org>
     [not found]                       ` <CAMe9rOrAFX5gPCB355A=vP0VpWQT1x8V3Hrttxm5ZRsvG1FXXw@mail.gmail.com>
2017-01-01  0:00                         ` Mark Wielaard
     [not found]                           ` <CAMe9rOosYw=9kF8eTUnxwQXNguvCrcK5GSaM=vbUUSA6+J49Zw@mail.gmail.com>
2017-01-01  0:00                             ` Mark Wielaard
2017-01-01  0:00                   ` H.J. Lu
2017-01-01  0:00                     ` Mark Wielaard
2017-01-01  0:00                       ` H.J. Lu
2017-01-01  0:00       ` Ali Bahrami

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=1513173445.15696.62.camel@klomp.org \
    --to=mark@klomp.org \
    --cc=ccoutant@gmail.com \
    --cc=generic-abi@googlegroups.com \
    --cc=gnu-gabi@sourceware.org \
    --cc=hegdesmailbox@gmail.com \
    --cc=hjl.tools@gmail.com \
    --cc=mark@chromium.org \
    /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).