From: Mark Wielaard <mark@klomp.org>
To: generic-abi@googlegroups.com, hegdesmailbox@gmail.com,
Cary Coutant <ccoutant@gmail.com>,
"H.J. Lu" <hjl.tools@gmail.com>,
Mark Mentovai <mark@chromium.org>
Cc: 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: <1512985389.15696.45.camel@klomp.org> (raw)
In-Reply-To: <f9194708-5cc8-4924-0cf4-686c9abe1b47@Oracle.COM>
On Sun, 2017-12-10 at 22:22 -0700, Ali Bahrami wrote:
> To my reading, the words of the gABI support what HP-UX did, and the
> comment in the Solaris code makes me think our definition of
> ELF64_Nhdr
> was a mistake. And given that the rest of us don't have any installed
> base (yet) of 8 byte alignment notes, it seems that the most
> compatible
> thing that we could do would be to also use 8-byte words for these
> fields.
> triggered by an sh_addralign, or p_align, of 8. That seems to match
> the
> gABI words, and preserves interoperability with HP-UX.
>
> An open question to you and Mark, and any others in the GNU world:
> Would you consider making that change? If so, I think we (Solaris)
> would have no problem in doing likewise.
I am afraid changing ELF64_Nhdr/GElf_Nhdr now from 32bit Words, or
changing the alignment of the namesz or descsz from 4 byte alignment is
not going to work. It is too hardcoded in various GNU/Linux code bases
now to change. On GNU/Linux ELF notes have been used a lot already, if
only to parse the build-id embedded in every executable. So you will
find a lot of code that will simply do:
/*
* Align offset to 4 bytes as needed for note name and descriptor data.
*/
#define NOTE_ALIGN(n) (((n) + 3) & -4U)
GElf_Nhdr *nhdr = ptr;
size_t namesz = NOTE_ALIGN(nhdr->n_namesz),
descsz = NOTE_ALIGN(nhdr->n_descsz);
const char *name;
ptr += sizeof(*nhdr);
name = ptr;
ptr += namesz;
[...]
ptr += descsz;
The above is from the linux kernel perf tool (tools/perf/util/symbol-
elf.c), but I can easily find more examples of hard coded parsing of
ELF notes that simply assumes they are 32 bit Words, 4 byte aligned (it
is basically what elfutils libelf also does).
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.
Cheers,
Mark
next prev parent reply other threads:[~2017-12-11 9:43 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 ` Ali Bahrami
2017-01-01 0:00 ` Mark Wielaard [this message]
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 ` 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
[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
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=1512985389.15696.45.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).