From: Josh Stone <jistone@redhat.com>
To: elfutils-devel@lists.fedorahosted.org
Subject: Re: libelf gelf_newehdr and gelf_newphdr return types
Date: Fri, 02 Dec 2016 11:00:22 -0800 [thread overview]
Message-ID: <629f7d14-5bca-3ce6-a11e-2c7a2533458d@redhat.com> (raw)
In-Reply-To: 1480671752.3728.253.camel@klomp.org
[-- Attachment #1: Type: text/plain, Size: 2215 bytes --]
On 12/02/2016 01:42 AM, Mark Wielaard wrote:
> Hi,
>
> Someone was porting elfutils libelf to Windows64 and noticed that the
> return types of gelf_newehdr and gelf_newphdr (unsigned long int) is not
> appropriate on that platform. It uses the LLP64 data model where int and
> long are both 32bits, while pointers are 64bits. Instead of the more
> common LP64 model where both long and pointer are 64bits. This obviously
> breaks that interface.
>
> I couldn't find the history behind this return type. Both elfutils and
> solaris libelf share the same return type, but some other libelf
> implementations, like the freebsd one, return a void *. Which does make
> more sense IMHO. Does someone remember the background?
>
> I have been pondering just changing the return type to void *, which
> should be abi compatible on any platform that elfutils currently
> supports. But it might cause some compiler warnings about needed or
> unneeded casts when existing code relies on the the return type being an
> integral type. So an alternative would be to make the functions return
> an uintptr_t, which should work in all data models.
I'd favor uintptr_t to keep better compatibility with current elfutils.
That's not perfect either, since glibc uses "unsigned int" on 32-bit
platforms, so that could still cause warnings for things that strictly
expect long, like printf "%lx". But directly printing a newehdr return
value (without saving it somewhere) is a weird thing to do, so I think
we can dismiss that case, at least. Off the top of my head, I can't
think of anything else that's so strict about long vs. int.
Another option is to make the change conditional on __LP64__, so
existing platforms are totally unaffected. I'd still lean toward
uintptr_t for the new case, so existing libelf code can port easily.
> Any opinions if this is something to clarify/fix across
> implementations/platforms supporting an libelf implementation?
>
> Thanks,
>
> Mark
> _______________________________________________
> elfutils-devel mailing list -- elfutils-devel@lists.fedorahosted.org
> To unsubscribe send an email to elfutils-devel-leave@lists.fedorahosted.org
>
next reply other threads:[~2016-12-02 19:00 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-12-02 19:00 Josh Stone [this message]
-- strict thread matches above, loose matches on Subject: below --
2016-12-06 23:41 Ali Bahrami
2016-12-06 23:09 Mark Wielaard
2016-12-06 16:45 Ali Bahrami
2016-12-06 14:31 Mark Wielaard
2016-12-06 13:47 Mark Wielaard
2016-12-03 22:02 Kurt Roeckx
2016-12-03 21:05 Ali Bahrami
2016-12-02 20:39 Ali Bahrami
2016-12-02 20:25 Ali Bahrami
2016-12-02 9:42 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=629f7d14-5bca-3ce6-a11e-2c7a2533458d@redhat.com \
--to=jistone@redhat.com \
--cc=elfutils-devel@lists.fedorahosted.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).