Re: trampolines

Mike Meissner (
Wed, 16 Apr 1997 15:02:02 -0400

Stefan Monnier writes:
| I'd (personally) prefer to have functgion-pointers be actually represented by a
| structure containing the address of the code and the address of the
| corresponding environment (in which "limit" will be found) and I believe that
| the PowerPC standard API uses such a scheme, but it's a pain to change such a
| thing (just like changing the size of "long" tends to break many things)

The trouble is the System V x86 ABI that Linux uses was designed
around C, and function pointers are mandated to be one 'word' long and
point to the function in question. As was the PowerPC System V ABI
that PowerPC Linux uses. The PowerOpen ABI on the other hand that AIX
and the MAC uses was designed for other languages, and the function
pointer is a pointer to a 3 word structure. The first word is the
actual function address, the second word is the TOC address that needs
to be loaded into r2 before the call, and the third word is the static
chain that needs to be loaded into r11 before the call.

Michael Meissner, Cygnus Solutions (East Coast)
4th floor, 955 Massachusetts Avenue, Cambridge, MA 02139, USA,	617-354-5416 (office),	617-354-7161 (fax)