wide function pointer type
Martin Uecker
ma.uecker@gmail.com
Tue Oct 19 09:43:52 GMT 2021
Am Dienstag, den 19.10.2021, 11:22 +0200 schrieb Florian Weimer:
> * Martin Uecker:
>
> > Am Montag, den 18.10.2021, 09:36 +0200 schrieb Florian Weimer:
> > > * Martin Uecker via Libffi-discuss:
> > >
> > > > In particular, I would be good to know whether
> > > > implementing a perfectly forwarding stub for
> > > > a variadic functions that loads the static
> > > > is possible on all architectures. I assume so,
> > > > but I am not entirely sure.
> > >
> > > Are you asking if it is possible to consume an argument in a variadic
> > > wrapper and forward the remaining arguments to a variadic function? The
> > > answer to that is no.
> >
> > Yes, I assumed this does not work. The question
> > is more whether architectures exist where the
> > existing ABI states that the static chain has to be
> > passed as a first argument (which would then need to be
> > removed when calling a regular function).
> >
> > The implementation most architectures
> > would use is that 1) the static chain is loaded from
> > the wide pointer 2) stored in the designated register
> > or stack slot and then 3) a call is performed
> > using the same calling convention as used for
> > regular functions.
>
> Many ABIs do not actually specify a register for the chain pointer.
Ok. The ones I looked at do, but I looked only at a few.
> For
> GCC's nested function extension, there are no ABI concerns because the
> nested function definition and the thunk generation are always built
> from the same translation unit. So GCC can just pick a custom calling
> convention, similar to what it does for other local, non-escaping
> functions.
Yes, but there are many other languages that make use of the
static chain. So it would be good to have a standardized ABI
for this.
> For obvious reasons, the proposal does not achieve interoperability with
> std::function from C++, so there is no ABI concern, either.
Not directly, but you could automatically create a wide
pointer that points to a compile-time stub that calls
a std::function.
Martin
More information about the Libffi-discuss
mailing list