Undefined behaviour code used in sysdeps/unix/sysv/linux/x86_64/makecontext.c
Florian Weimer
fweimer@redhat.com
Tue May 22 11:21:00 GMT 2018
On 05/21/2018 06:32 AM, Remus Clearwater wrote:
> As far as I know cast a function pointer to ordinary integer type or
> void*/char* is undefined behaviour in C specification.
ELF doesn't really work unless all your pointers are the same size, so
we assume this throughout the code base.
Conceptually, the ELFv1 ABI for POWER has function pointers which
consist of multiple words, and the way this is solved is that function
pointers point to a function descriptor, not the code address. This
pointer is again a single word, as expected. It works because there is
no run-time code generation and all the functions are known at static
link time, so the link editor can make sure that the required
descriptors exist somewhere.
Thanks,
Florian
More information about the Libc-help
mailing list