This is the mail archive of the
mailing list for the elfutils project.
libelf gelf_newehdr and gelf_newphdr return types
- From: Mark Wielaard <mark at klomp dot org>
- To: elfutils-devel at lists dot fedorahosted dot org
- Date: Fri, 02 Dec 2016 10:42:32 +0100
- Subject: libelf gelf_newehdr and gelf_newphdr return types
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.
Any opinions if this is something to clarify/fix across
implementations/platforms supporting an libelf implementation?