This is the mail archive of the
mailing list for the glibc project.
Re: Undefined behaviour code used in sysdeps/unix/sysv/linux/x86_64/makecontext.c
- From: Florian Weimer <fweimer at redhat dot com>
- To: Remus Clearwater <remus dot clearwater at gmail dot com>, libc-help at sourceware dot org
- Date: Tue, 22 May 2018 13:21:38 +0200
- Subject: Re: Undefined behaviour code used in sysdeps/unix/sysv/linux/x86_64/makecontext.c
- References: <CAMjELSscx-WZdBTrhhi_jzunQb+cU9_4d3-XBeN17RW1x8XyWg@mail.gmail.com>
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.