This is the mail archive of the libc-help@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Undefined behaviour code used in sysdeps/unix/sysv/linux/x86_64/makecontext.c


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]