SPRAB89A September 2011 – March 2014
If the call target is defined in the same static link unit, but is unreachable with a 21-bit word offset, the static linker generates a trampoline, which is a stub function that uses an alternate form of addressing to reach the target. This example illustrates a trampoline using absolute addressing: (2)
$Tramp$$sym2:
MVKL sym,tmp ;reloc R_C6000_ABS_L16
MVKH sym,tmp ;reloc R_C6000_ABS_H16
B tmp
Alternatively, the trampoline may compute the address of the destination function using other forms of addressing as described in Section 5.2.
If the call target is not defined in the same static link unit, the static linker generates a PLT entry, which is similar to a trampoline. This case is covered in Section 6.6.
Depending on the addressing used, trampolines typically require either one or two scratch registers (e.g. tmp in the previous sequence).
For C64x and newer targets, B30 and B31 are available for use by any trampoline. Callers are prevented from assuming that B30 and B31 are preserved by calls, even when the called function is known not to modify them (see Section 3.8).
For the older C62 and C67 targets, trampolines must save and restore any registers they use.