...

Package ppc64

import "cmd/link/internal/ppc64"
Overview
Index

Overview ▾

Constants

const (
    // For genstub, the type of stub required by the caller.
    STUB_TOC = iota
    STUB_PCREL
)
const (
    OP_TOCRESTORE    = 0xe8410018 // ld r2,24(r1)
    OP_TOCSAVE       = 0xf8410018 // std r2,24(r1)
    OP_NOP           = 0x60000000 // nop
    OP_BL            = 0x48000001 // bl 0
    OP_BCTR          = 0x4e800420 // bctr
    OP_BCTRL         = 0x4e800421 // bctrl
    OP_BCL           = 0x40000001 // bcl
    OP_ADDI          = 0x38000000 // addi
    OP_ADDIS         = 0x3c000000 // addis
    OP_LD            = 0xe8000000 // ld
    OP_PLA_PFX       = 0x06100000 // pla (prefix instruction word)
    OP_PLA_SFX       = 0x38000000 // pla (suffix instruction word)
    OP_PLD_PFX_PCREL = 0x04100000 // pld (prefix instruction word, R=1)
    OP_PLD_SFX       = 0xe4000000 // pld (suffix instruction word)
    OP_MFLR          = 0x7c0802a6 // mflr
    OP_MTLR          = 0x7c0803a6 // mtlr
    OP_MFCTR         = 0x7c0902a6 // mfctr
    OP_MTCTR         = 0x7c0903a6 // mtctr

    OP_ADDIS_R12_R2  = OP_ADDIS | 12<<21 | 2<<16  // addis r12,r2,0
    OP_ADDIS_R12_R12 = OP_ADDIS | 12<<21 | 12<<16 // addis  r12,r12,0
    OP_ADDI_R12_R12  = OP_ADDI | 12<<21 | 12<<16  // addi  r12,r12,0
    OP_PLD_SFX_R12   = OP_PLD_SFX | 12<<21        // pld   r12,0 (suffix instruction word)
    OP_PLA_SFX_R12   = OP_PLA_SFX | 12<<21        // pla   r12,0 (suffix instruction word)
    OP_LIS_R12       = OP_ADDIS | 12<<21          // lis r12,0
    OP_LD_R12_R12    = OP_LD | 12<<21 | 12<<16    // ld r12,0(r12)
    OP_MTCTR_R12     = OP_MTCTR | 12<<21          // mtctr r12
    OP_MFLR_R12      = OP_MFLR | 12<<21           // mflr r12
    OP_MFLR_R0       = OP_MFLR | 0<<21            // mflr r0
    OP_MTLR_R0       = OP_MTLR | 0<<21            // mtlr r0

    // This is a special, preferred form of bcl to obtain the next
    // instruction address (NIA, aka PC+4) in LR.
    OP_BCL_NIA = OP_BCL | 20<<21 | 31<<16 | 1<<2 // bcl 20,31,$+4

    // Masks to match opcodes
    MASK_PLD_PFX  = 0xfff70000
    MASK_PLD_SFX  = 0xfc1f0000 // Also checks RA = 0 if check value is OP_PLD_SFX.
    MASK_PLD_RT   = 0x03e00000 // Extract RT from the pld suffix.
    MASK_OP_LD    = 0xfc000003
    MASK_OP_ADDIS = 0xfc000000
)

func Init

func Init() (*sys.Arch, ld.Arch)