Structs
Addr
struct
#
type Addr struct {
Reg int16
Index int16
Scale int16
Type AddrType
Name AddrName
Class int8
Offset int64
Sym *LSym
Val interface{}
}
AddrPos
struct
#
AddrPos indicates whether the operand is the source or the destination.
type AddrPos struct {
Addr
Pos OperandPos
}
Auto
struct
#
type Auto struct {
Asym *LSym
Aoffset int32
Name AddrName
Gotype *LSym
}
DwarfFixupTable
struct
#
This table is designed to aid in the creation of references between
DWARF subprogram DIEs.
In most cases when one DWARF DIE has to refer to another DWARF DIE,
the target of the reference has an LSym, which makes it easy to use
the existing relocation mechanism. For DWARF inlined routine DIEs,
however, the subprogram DIE has to refer to a child
parameter/variable DIE of the abstract subprogram. This child DIE
doesn't have an LSym, and also of interest is the fact that when
DWARF generation is happening for inlined function F within caller
G, it's possible that DWARF generation hasn't happened yet for F,
so there is no way to know the offset of a child DIE within F's
abstract function. Making matters more complex, each inlined
instance of F may refer to a subset of the original F's variables
(depending on what happens with optimization, some vars may be
eliminated).
The fixup table below helps overcome this hurdle. At the point
where a parameter/variable reference is made (via a call to
"ReferenceChildDIE"), a fixup record is generate that records
the relocation that is targeting that child variable. At a later
point when the abstract function DIE is emitted, there will be
a call to "RegisterChildDIEOffsets", at which point the offsets
needed to apply fixups are captured. Finally, once the parallel
portion of the compilation is done, fixups can actually be applied
during the "Finalize" method (this can't be done during the
parallel portion of the compile due to the possibility of data
races).
This table is also used to record the "precursor" function node for
each function that is the target of an inline -- child DIE references
have to be made with respect to the original pre-optimization
version of the function (to allow for the fact that each inlined
body may be optimized differently).
type DwarfFixupTable struct {
ctxt *Link
mu sync.Mutex
symtab map[*LSym]int
svec []symFixups
precursor map[*LSym]fnState
}
FileInfo
struct
#
A FileInfo contains extra fields for SDATA symbols backed by files.
(If LSym.Extra is a *FileInfo, LSym.P == nil.)
type FileInfo struct {
Name string
Size int64
}
FuncInfo
struct
#
A FuncInfo contains extra fields for STEXT symbols.
type FuncInfo struct {
Args int32
Locals int32
Align int32
FuncID abi.FuncID
FuncFlag abi.FuncFlag
StartLine int32
Text *Prog
Autot map[*LSym]struct{...}
Pcln Pcln
InlMarks []InlMark
spills []RegSpill
dwarfInfoSym *LSym
dwarfLocSym *LSym
dwarfRangesSym *LSym
dwarfAbsFnSym *LSym
dwarfDebugLinesSym *LSym
GCArgs *LSym
GCLocals *LSym
StackObjects *LSym
OpenCodedDeferInfo *LSym
ArgInfo *LSym
ArgLiveInfo *LSym
WrapInfo *LSym
JumpTables []JumpTable
FuncInfoSym *LSym
WasmImport *WasmImport
WasmExport *WasmExport
sehUnwindInfoSym *LSym
}
InlMark
struct
#
type InlMark struct {
p *Prog
id int32
}
InlTree
struct
#
InlTree is a collection of inlined calls. The Parent field of an
InlinedCall is the index of another InlinedCall in InlTree.
The compiler maintains a global inlining tree and adds a node to it
every time a function is inlined. For example, suppose f() calls g()
and g has two calls to h(), and that f, g, and h are inlineable:
1 func main() {
2 f()
3 }
4 func f() {
5 g()
6 }
7 func g() {
8 h()
9 h()
10 }
11 func h() {
12 println("H")
13 }
Assuming the global tree starts empty, inlining will produce the
following tree:
[]InlinedCall{
{Parent: -1, Func: "f", Pos: },
{Parent: 0, Func: "g", Pos: },
{Parent: 1, Func: "h", Pos: },
{Parent: 1, Func: "h", Pos: },
}
The nodes of h inlined into main will have inlining indexes 2 and 3.
Eventually, the compiler extracts a per-function inlining tree from
the global inlining tree (see pcln.go).
type InlTree struct {
nodes []InlinedCall
}
InlinedCall
struct
#
InlinedCall is a node in an InlTree.
type InlinedCall struct {
Parent int
Pos src.XPos
Func *LSym
Name string
ParentPC int32
}
JumpTable
struct
#
JumpTable represents a table used for implementing multi-way
computed branching, used typically for implementing switches.
Sym is the table itself, and Targets is a list of target
instructions to go to for the computed branch index.
type JumpTable struct {
Sym *LSym
Targets []*Prog
}
LSym
struct
#
An LSym is the sort of symbol that is written to an object file.
It represents Go symbols in a flat pkg+"."+name namespace.
type LSym struct {
Name string
Type objabi.SymKind
Attribute
Size int64
Gotype *LSym
P []byte
R []Reloc
Extra *interface{}
Pkg string
PkgIdx int32
SymIdx int32
}
Link
struct
#
Link holds the context for writing object code from a compiler
to be linker input or for reading that input into the linker.
type Link struct {
Headtype objabi.HeadType
Arch *LinkArch
Debugasm int
Debugvlog bool
Debugpcln string
Flag_shared bool
Flag_dynlink bool
Flag_linkshared bool
Flag_optimize bool
Flag_locationlists bool
Flag_noRefName bool
Retpoline bool
Flag_maymorestack string
Bso *bufio.Writer
Pathname string
Pkgpath string
hashmu sync.Mutex
hash map[string]*LSym
funchash map[string]*LSym
statichash map[string]*LSym
PosTable src.PosTable
InlTree InlTree
DwFixups *DwarfFixupTable
Imports []goobj.ImportedPkg
DiagFunc func(string, ...interface{})
DiagFlush func()
DebugInfo func(ctxt *Link, fn *LSym, info *LSym, curfn Func) ([]dwarf.Scope, dwarf.InlCalls)
GenAbstractFunc func(fn *LSym)
Errors int
InParallel bool
UseBASEntries bool
IsAsm bool
Std bool
Text []*LSym
Data []*LSym
constSyms []*LSym
SEHSyms []*LSym
pkgIdx map[string]int32
defs []*LSym
hashed64defs []*LSym
hasheddefs []*LSym
nonpkgdefs []*LSym
nonpkgrefs []*LSym
Fingerprint goobj.FingerprintType
}
LinkArch
struct
#
LinkArch is the definition of a single architecture.
type LinkArch struct {
*sys.Arch
Init func(*Link)
ErrorCheck func(*Link, *LSym)
Preprocess func(*Link, *LSym, ProgAlloc)
Assemble func(*Link, *LSym, ProgAlloc)
Progedit func(*Link, *Prog, ProgAlloc)
SEH func(*Link, *LSym) *LSym
UnaryDst map[As]bool
DWARFRegisters map[int16]int16
}
PCIter
struct
#
PCIter iterates over encoded pcdata tables.
type PCIter struct {
p []byte
PC uint32
NextPC uint32
PCScale uint32
Value int32
start bool
Done bool
}
Pcln
struct
#
type Pcln struct {
Pcsp *LSym
Pcfile *LSym
Pcline *LSym
Pcinline *LSym
Pcdata []*LSym
Funcdata []*LSym
UsedFiles map[goobj.CUFileIndex]struct{...}
InlTree InlTree
}
Plist
struct
#
type Plist struct {
Firstpc *Prog
Curfn Func
}
Prog
struct
#
Prog describes a single machine instruction.
The general instruction form is:
(1) As.Scond From [, ...RestArgs], To
(2) As.Scond From, Reg [, ...RestArgs], To, RegTo2
where As is an opcode and the others are arguments:
From, Reg are sources, and To, RegTo2 are destinations.
RestArgs can hold additional sources and destinations.
Usually, not all arguments are present.
For example, MOVL R1, R2 encodes using only As=MOVL, From=R1, To=R2.
The Scond field holds additional condition bits for systems (like arm)
that have generalized conditional execution.
(2) form is present for compatibility with older code,
to avoid too much changes in a single swing.
(1) scheme is enough to express any kind of operand combination.
Jump instructions use the To.Val field to point to the target *Prog,
which must be in the same linked list as the jump instruction.
The Progs for a given function are arranged in a list linked through the Link field.
Each Prog is charged to a specific source line in the debug information,
specified by Pos.Line().
Every Prog has a Ctxt field that defines its context.
For performance reasons, Progs are usually bulk allocated, cached, and reused;
those bulk allocators should always be used, rather than new(Prog).
The other fields not yet mentioned are for use by the back ends and should
be left zeroed by creators of Prog lists.
type Prog struct {
Ctxt *Link
Link *Prog
From Addr
RestArgs []AddrPos
To Addr
Pool *Prog
Forwd *Prog
Rel *Prog
Pc int64
Pos src.XPos
Spadj int32
As As
Reg int16
RegTo2 int16
Mark uint16
Optab uint16
Scond uint8
Back uint8
Ft uint8
Tt uint8
Isize uint8
}
RegSpill
struct
#
RegSpill provides spill/fill information for a register-resident argument
to a function. These need spilling/filling in the safepoint/stackgrowth case.
At the time of fill/spill, the offset must be adjusted by the architecture-dependent
adjustment to hardware SP that occurs in a call instruction. E.g., for AMD64,
at Offset+8 because the return address was pushed.
type RegSpill struct {
Addr Addr
Reg int16
Reg2 int16
Spill As
Unspill As
}
Reloc
struct
#
type Reloc struct {
Off int32
Siz uint8
Type objabi.RelocType
Add int64
Sym *LSym
}
TypeInfo
struct
#
A TypeInfo contains information for a symbol
that contains a runtime._type.
type TypeInfo struct {
Type interface{}
}
VarInfo
struct
#
type VarInfo struct {
dwarfInfoSym *LSym
}
WasmExport
struct
#
WasmExport represents a WebAssembly (WASM) exported function with
parameters and results translated into WASM types based on the Go function
declaration.
type WasmExport struct {
WasmFuncType
WrappedSym *LSym
AuxSym *LSym
}
WasmField
struct
#
type WasmField struct {
Type WasmFieldType
Offset int64
}
WasmFuncType
struct
#
WasmFuncType represents a WebAssembly (WASM) function type with
parameters and results translated into WASM types based on the Go function
declaration.
type WasmFuncType struct {
Params []WasmField
Results []WasmField
}
WasmImport
struct
#
WasmImport represents a WebAssembly (WASM) imported function with
parameters and results translated into WASM types based on the Go function
declaration.
type WasmImport struct {
Module string
Name string
WasmFuncType
AuxSym *LSym
}
declOffset
struct
#
type declOffset struct {
dclIdx int32
offset int32
}
dwCtxt
struct
#
implement dwarf.Context
type dwCtxt struct {
*Link
}
fnState
struct
#
type fnState struct {
precursor Func
absfn *LSym
}
opSet
struct
#
type opSet struct {
lo As
names []string
}
opSuffixSet
struct
#
opSuffixSet is like regListSet, but for opcode suffixes.
Unlike some other similar structures, uint8 space is not
divided by its own values set (because there are only 256 of them).
Instead, every arch may interpret/format all 8 bits as they like,
as long as they register proper cconv function for it.
type opSuffixSet struct {
arch string
cconv func(suffix uint8) string
}
pcinlineState
struct
#
pcinlineState holds the state used to create a function's inlining
tree and the PC-value table that maps PCs to nodes in that tree.
type pcinlineState struct {
globalToLocal map[int]int
localTree InlTree
}
regListSet
struct
#
type regListSet struct {
lo int64
hi int64
RLconv func(int64) string
}
regSet
struct
#
type regSet struct {
lo int
hi int
Rconv func(int) string
}
relFixup
struct
#
type relFixup struct {
refsym *LSym
relidx int32
dclidx int32
}
spcSet
struct
#
Special operands
type spcSet struct {
lo int64
hi int64
SPCconv func(int64) string
}
symFixups
struct
#
type symFixups struct {
fixups []relFixup
doffsets []declOffset
inlIndex int32
defseen bool
}
writer
struct
#
type writer struct {
*goobj.Writer
filebuf []byte
ctxt *Link
pkgpath string
pkglist []string
tmpSym goobj.Sym
tmpReloc goobj.Reloc
tmpAux goobj.Aux
tmpHash64 goobj.Hash64Type
tmpHash goobj.HashType
tmpRefFlags goobj.RefFlags
tmpRefName goobj.RefName
}
Functions
ABI
method
#
func (a *Attribute) ABI() ABI
ABISetOf
function
#
func ABISetOf(abi ABI) ABISet
ABIWrapper
method
#
func (a *Attribute) ABIWrapper() bool
AbsFuncDwarfSym
method
#
return the LSym corresponding to the 'abstract subprogram' DWARF
info entry for a function.
func (ft *DwarfFixupTable) AbsFuncDwarfSym(fnsym *LSym) *LSym
Add
method
#
Add adds a new call to the tree, returning its index.
func (tree *InlTree) Add(parent int, pos src.XPos, func_ *LSym, name string) int
AddAddress
method
#
func (c dwCtxt) AddAddress(s dwarf.Sym, data interface{}, value int64)
AddBytes
method
#
func (c dwCtxt) AddBytes(s dwarf.Sym, b []byte)
AddCURelativeAddress
method
#
func (c dwCtxt) AddCURelativeAddress(s dwarf.Sym, data interface{}, value int64)
AddDWARFAddrSectionOffset
method
#
func (c dwCtxt) AddDWARFAddrSectionOffset(s dwarf.Sym, t interface{}, ofs int64)
AddImport
method
#
AddImport adds a package to the list of imported packages.
func (ctxt *Link) AddImport(pkg string, fingerprint goobj.FingerprintType)
AddInlMark
method
#
Mark p as the instruction to set as the pc when
"unwinding" the inlining global frame id. Usually it should be
instruction with a file:line at the callsite, and occur
just before the body of the inlined function.
func (fi *FuncInfo) AddInlMark(p *Prog, id int32)
AddInt
method
#
func (c dwCtxt) AddInt(s dwarf.Sym, size int, i int64)
AddRel
method
#
AddRel adds the relocation rel to s.
func (s *LSym) AddRel(ctxt *Link, rel Reloc)
AddRestDest
method
#
AddRestDest assigns []Args{{a, Destination}} to p.RestArgs when the second destination
operand does not fit into prog.RegTo2.
func (p *Prog) AddRestDest(a Addr)
AddRestSource
method
#
AddRestSource assigns []Args{{a, Source}} to p.RestArgs.
func (p *Prog) AddRestSource(a Addr)
AddRestSourceArgs
method
#
AddRestSourceArgs assigns more than one source operands to p.RestArgs.
func (p *Prog) AddRestSourceArgs(args []Addr)
AddRestSourceConst
method
#
AddRestSourceConst calls p.AddRestSource with a const Addr containing off.
func (p *Prog) AddRestSourceConst(off int64)
AddRestSourceReg
method
#
AddRestSourceReg calls p.AddRestSource with a register Addr containing reg.
func (p *Prog) AddRestSourceReg(reg int16)
AddSectionOffset
method
#
func (c dwCtxt) AddSectionOffset(s dwarf.Sym, size int, t interface{}, ofs int64)
AddSpill
method
#
AddSpill appends a spill record to the list for FuncInfo fi
func (fi *FuncInfo) AddSpill(s RegSpill)
AddString
method
#
func (c dwCtxt) AddString(s dwarf.Sym, v string)
AddUint16
method
#
func (c dwCtxt) AddUint16(s dwarf.Sym, i uint16)
AddUint8
method
#
func (c dwCtxt) AddUint8(s dwarf.Sym, i uint8)
AlignmentPadding
function
#
AlignmentPadding bytes to add to align code as requested.
Alignment is restricted to powers of 2 between 8 and 2048 inclusive.
pc_: current offset in function, in bytes
p: a PCALIGN or PCALIGNMAX prog
ctxt: the context, for current function
cursym: current function being assembled
returns number of bytes of padding needed,
updates minimum alignment for the function.
func AlignmentPadding(pc int32, p *Prog, ctxt *Link, cursym *LSym) int
AlignmentPaddingLength
function
#
AlignmentPaddingLength is the number of bytes to add to align code as requested.
Alignment is restricted to powers of 2 between 8 and 2048 inclusive.
This only computes the length and does not update the (missing parameter)
current function's own required alignment.
pc: current offset in function, in bytes
p: a PCALIGN or PCALIGNMAX prog
ctxt: the context, for current function
returns number of bytes of padding needed,
func AlignmentPaddingLength(pc int32, p *Prog, ctxt *Link) int
AllParents
method
#
AllParents invokes do on each InlinedCall in the inlining call
stack, from outermost to innermost.
That is, if inlIndex corresponds to f inlining g inlining h,
AllParents invokes do with the call for inlining g into f, and then
inlining h into g.
func (tree *InlTree) AllParents(inlIndex int, do func(InlinedCall))
AllPos
method
#
AllPos invokes do with every position in the inlining call stack for xpos,
from outermost to innermost. That is, xpos corresponds to f inlining g inlining h,
AllPos invokes do with the position in f, then the position in g, then the position in h.
func (ctxt *Link) AllPos(xpos src.XPos, do func(src.Pos))
Appendp
function
#
func Appendp(q *Prog, newprog ProgAlloc) *Prog
Aux
method
#
func (w *writer) Aux(s *LSym)
Bool2int
function
#
func Bool2int(b bool) int
CConv
function
#
CConv formats opcode suffix bits (Prog.Scond).
func CConv(s uint8) string
CConvARM
function
#
CConvARM formats ARM opcode suffix bits (mostly condition codes).
func CConvARM(s uint8) string
CFunc
method
#
func (a *Attribute) CFunc() bool
CallPos
method
#
func (tree *InlTree) CallPos(inlIndex int) src.XPos
CanBeAnSSAAux
method
#
func (*LSym) CanBeAnSSAAux()
CanBeAnSSASym
method
#
The compiler needs *LSym to be assignable to cmd/compile/internal/ssa.Sym.
func (*LSym) CanBeAnSSASym()
CanReuseProgs
method
#
func (ctxt *Link) CanReuseProgs() bool
ContentAddressable
method
#
func (a *Attribute) ContentAddressable() bool
CreateAuxSym
method
#
func (we *WasmExport) CreateAuxSym()
CreateAuxSym
method
#
func (wi *WasmImport) CreateAuxSym()
CurrentOffset
method
#
func (c dwCtxt) CurrentOffset(s dwarf.Sym) int64
Dconv
function
#
Dconv accepts an argument 'a' within a prog 'p' and returns a string
with a formatted version of the argument.
func Dconv(p *Prog, a *Addr) string
DconvWithABIDetail
function
#
DconvWithABIDetail accepts an argument 'a' within a prog 'p'
and returns a string with a formatted version of the argument, in
which text symbols are rendered with explicit ABI selectors.
func DconvWithABIDetail(p *Prog, a *Addr) string
Diag
method
#
func (ctxt *Link) Diag(format string, args ...interface{})
DuplicateOK
method
#
func (a *Attribute) DuplicateOK() bool
DwarfAbstractFunc
method
#
func (ctxt *Link) DwarfAbstractFunc(curfn Func, s *LSym)
DwarfGlobal
method
#
DwarfGlobal creates a link symbol containing a DWARF entry for
a global variable.
func (ctxt *Link) DwarfGlobal(typename string, varSym *LSym)
DwarfIntConst
method
#
DwarfIntConst creates a link symbol for an integer constant with the
given name, type and value.
func (ctxt *Link) DwarfIntConst(name string, typename string, val int64)
EmitEntryLiveness
method
#
EmitEntryLiveness generates PCDATA Progs after p to switch to the
liveness map active at the entry of function s. It returns the last
Prog generated.
func (ctxt *Link) EmitEntryLiveness(s *LSym, p *Prog, newprog ProgAlloc) *Prog
EmitEntryStackMap
method
#
Similar to EmitEntryLiveness, but just emit stack map.
func (ctxt *Link) EmitEntryStackMap(s *LSym, p *Prog, newprog ProgAlloc) *Prog
EmitEntryUnsafePoint
method
#
Similar to EmitEntryLiveness, but just emit unsafe point map.
func (ctxt *Link) EmitEntryUnsafePoint(s *LSym, p *Prog, newprog ProgAlloc) *Prog
EnableFIPS
function
#
EnableFIPS reports whether FIPS should be enabled at all
on the current buildcfg GOOS and GOARCH.
func EnableFIPS() bool
EndUnsafePoint
method
#
EndUnsafePoint generates PCDATA Progs after p to mark the end of an
unsafe point, restoring the register map index to oldval.
The unsafe point ends right after p.
It returns the last Prog generated.
func (ctxt *Link) EndUnsafePoint(p *Prog, newprog ProgAlloc, oldval int64) *Prog
File
method
#
File returns the *FileInfo associated with s, or else nil.
func (s *LSym) File() *FileInfo
Finalize
method
#
Called after all functions have been compiled; the main job of this
function is to identify cases where there are outstanding fixups.
This scenario crops up when we have references to variables of an
inlined routine, but that routine is defined in some other package.
This helper walks through and locate these fixups, then invokes a
helper to create an abstract subprogram DIE for each one.
func (ft *DwarfFixupTable) Finalize(myimportpath string, trace bool)
Float32Sym
method
#
func (ctxt *Link) Float32Sym(f float32) *LSym
Float64Sym
method
#
func (ctxt *Link) Float64Sym(f float64) *LSym
Flushplist
function
#
func Flushplist(ctxt *Link, plist *Plist, newprog ProgAlloc)
From3Type
method
#
From3Type returns p.GetFrom3().Type, or TYPE_NONE when
p.GetFrom3() returns nil.
func (p *Prog) From3Type() AddrType
Func
method
#
Func returns the *FuncInfo associated with s, or else nil.
func (s *LSym) Func() *FuncInfo
GCLocalsSym
method
#
GCLocalsSym generates a content-addressable sym containing data.
func (ctxt *Link) GCLocalsSym(data []byte) *LSym
Get
method
#
func (a *ABISet) Get(abi ABI) bool
GetFrom3
method
#
GetFrom3 returns second source operand (the first is Prog.From).
The same kinds of operands are saved in order so GetFrom3 actually
return the first source operand in p.RestArgs.
In combination with Prog.From and Prog.To it makes common 3 operand
case easier to use.
func (p *Prog) GetFrom3() *Addr
GetPrecursorFunc
method
#
func (ft *DwarfFixupTable) GetPrecursorFunc(s *LSym) Func
GetTo2
method
#
GetTo2 returns the second destination operand.
The same kinds of operands are saved in order so GetTo2 actually
return the first destination operand in Prog.RestArgs[]
func (p *Prog) GetTo2() *Addr
Globl
method
#
func (ctxt *Link) Globl(s *LSym, size int64, flag int)
GloblPos
method
#
func (ctxt *Link) GloblPos(s *LSym, size int64, flag int, pos src.XPos)
Grow
method
#
Grow increases the length of s.P to lsiz.
func (s *LSym) Grow(lsiz int64)
GrowCap
method
#
GrowCap increases the capacity of s.P to c.
func (s *LSym) GrowCap(c int64)
Hash
method
#
func (w *writer) Hash(s *LSym)
Hash64
method
#
func (w *writer) Hash64(s *LSym)
Indexed
method
#
func (a *Attribute) Indexed() bool
Init
method
#
init prepares it to iterate over p,
and advances it to the first pc.
func (it *PCIter) Init(p []byte)
InitTextSym
method
#
func (ctxt *Link) InitTextSym(s *LSym, flag int, start src.XPos)
InlinedFunction
method
#
func (tree *InlTree) InlinedFunction(inlIndex int) *LSym
InnermostFilename
method
#
InnermostFilename returns a string containing the innermost
(in inlining) filename at p's position
func (p *Prog) InnermostFilename() string
InnermostLine
method
#
func (p *Prog) InnermostLine(w io.Writer)
InnermostLineNumber
method
#
InnermostLineNumber returns a string containing the line number for the
innermost inlined function (if any inlining) at p's position
func (p *Prog) InnermostLineNumber() string
InnermostLineNumberHTML
method
#
InnermostLineNumberHTML returns a string containing the line number for the
innermost inlined function (if any inlining) at p's position
func (p *Prog) InnermostLineNumberHTML() string
InnermostPos
method
#
InnermostPos returns the innermost position corresponding to xpos,
that is, the code that is inlined and that inlines nothing else.
In the example for InlTree above, the code for println within h
would have an innermost position with line number 12, whether
h was not inlined, inlined into g, g-then-f, or g-then-f-then-main.
This corresponds to what someone debugging main, f, g, or h might
expect to see while single-stepping.
func (ctxt *Link) InnermostPos(xpos src.XPos) src.Pos
InnermostString
method
#
func (p *Prog) InnermostString(w io.Writer)
InstructionString
method
#
InstructionString returns a string representation of the instruction without preceding
program counter or file and line number.
func (p *Prog) InstructionString() string
Int128Sym
method
#
func (ctxt *Link) Int128Sym(hi int64, lo int64) *LSym
Int32Sym
method
#
func (ctxt *Link) Int32Sym(i int64) *LSym
Int64Sym
method
#
func (ctxt *Link) Int64Sym(i int64) *LSym
IsFIPS
method
#
IsFIPS reports whether we are compiling one of the crypto/internal/fips140/... packages.
func (ctxt *Link) IsFIPS() bool
IsLinkname
method
#
func (a *Attribute) IsLinkname() bool
IsPcdata
method
#
func (a *Attribute) IsPcdata() bool
IsPkgInit
method
#
func (a *Attribute) IsPkgInit() bool
Leaf
method
#
func (a *Attribute) Leaf() bool
Line
method
#
Line returns a string containing the filename and line number for p
func (p *Prog) Line() string
Linknew
function
#
func Linknew(arch *LinkArch) *Link
Local
method
#
func (a *Attribute) Local() bool
Logf
method
#
func (ctxt *Link) Logf(format string, args ...interface{})
Logf
method
#
func (c dwCtxt) Logf(format string, args ...interface{})
Lookup
method
#
Lookup looks up the symbol with name name.
If it does not exist, it creates it.
func (ctxt *Link) Lookup(name string) *LSym
LookupABI
method
#
LookupABI looks up a symbol with the given ABI.
If it does not exist, it creates it.
func (ctxt *Link) LookupABI(name string, abi ABI) *LSym
LookupABIInit
method
#
LookupABIInit looks up a symbol with the given ABI.
If it does not exist, it creates it and
passes it to init for one-time initialization.
func (ctxt *Link) LookupABIInit(name string, abi ABI, init func(s *LSym)) *LSym
LookupDerived
method
#
LookupDerived looks up or creates the symbol with name derived from symbol s.
The resulting symbol will be static iff s is.
func (ctxt *Link) LookupDerived(s *LSym, name string) *LSym
LookupInit
method
#
LookupInit looks up the symbol with name name.
If it does not exist, it creates it and
passes it to init for one-time initialization.
func (ctxt *Link) LookupInit(name string, init func(s *LSym)) *LSym
LookupStatic
method
#
LookupStatic looks up the static symbol with name name.
If it does not exist, it creates it.
func (ctxt *Link) LookupStatic(name string) *LSym
MakeTypelink
method
#
func (a *Attribute) MakeTypelink() bool
MarkUnsafePoints
function
#
MarkUnsafePoints inserts PCDATAs to mark nonpreemptible and restartable
instruction sequences, based on isUnsafePoint and isRestartable predicate.
p0 is the start of the instruction stream.
isUnsafePoint(p) returns true if p is not safe for async preemption.
isRestartable(p) returns true if we can restart at the start of p (this Prog)
upon async preemption. (Currently multi-Prog restartable sequence is not
supported.)
isRestartable can be nil. In this case it is treated as always returning false.
If isUnsafePoint(p) and isRestartable(p) are both true, it is treated as
an unsafe point.
func MarkUnsafePoints(ctxt *Link, p0 *Prog, newprog ProgAlloc, isUnsafePoint func(*Prog) bool, isRestartable func(*Prog) bool)
NeedCtxt
method
#
func (a *Attribute) NeedCtxt() bool
NewDwarfFixupTable
function
#
func NewDwarfFixupTable(ctxt *Link) *DwarfFixupTable
NewFileInfo
method
#
NewFileInfo allocates and returns a FileInfo for LSym.
func (s *LSym) NewFileInfo() *FileInfo
NewFuncInfo
method
#
NewFuncInfo allocates and returns a FuncInfo for LSym.
func (s *LSym) NewFuncInfo() *FuncInfo
NewPCIter
function
#
NewPCIter creates a PCIter with a scale factor for the PC step size.
func NewPCIter(pcScale uint32) *PCIter
NewProg
method
#
func (ctxt *Link) NewProg() *Prog
NewTypeInfo
method
#
func (s *LSym) NewTypeInfo() *TypeInfo
NewVarInfo
method
#
NewVarInfo allocates and returns a VarInfo for LSym.
func (s *LSym) NewVarInfo() *VarInfo
Next
method
#
Next advances it to the Next pc.
func (it *PCIter) Next()
NoFrame
method
#
func (a *Attribute) NoFrame() bool
NoSplit
method
#
func (a *Attribute) NoSplit() bool
Nopout
function
#
func Nopout(p *Prog)
NumberSyms
method
#
Assign index to symbols.
asm is set to true if this is called by the assembler (i.e. not the compiler),
in which case all the symbols are non-package (for now).
func (ctxt *Link) NumberSyms()
OnList
method
#
func (a *Attribute) OnList() bool
OutermostPos
method
#
OutermostPos returns the outermost position corresponding to xpos,
which is where xpos was ultimately inlined to. In the example for
InlTree, main() contains inlined AST nodes from h(), but the
outermost position for those nodes is line 2.
func (ctxt *Link) OutermostPos(xpos src.XPos) src.Pos
Parent
method
#
func (tree *InlTree) Parent(inlIndex int) int
ParseABI
function
#
ParseABI converts from a string representation in 'abistr' to the
corresponding ABI value. Second return value is TRUE if the
abi string is recognized, FALSE otherwise.
func ParseABI(abistr string) (ABI, bool)
PtrSize
method
#
func (c dwCtxt) PtrSize() int
RLconv
function
#
func RLconv(list int64) string
Rconv
function
#
func Rconv(reg int) string
Read
method
#
func (wi *WasmImport) Read(b []byte)
Read
method
#
func (ft *WasmFuncType) Read(b []byte)
RecordAutoType
method
#
Record the type symbol for an auto variable so that the linker
an emit DWARF type information for the type.
func (fi *FuncInfo) RecordAutoType(gotype *LSym)
RecordChildDieOffsets
method
#
func (c dwCtxt) RecordChildDieOffsets(s dwarf.Sym, vars []*dwarf.Var, offsets []int32)
RecordDclReference
method
#
Here "from" is a symbol corresponding to an inlined or concrete
function, "to" is the symbol for the corresponding abstract
function, and "dclIdx" is the index of the symbol of interest with
respect to the Dcl slice of the original pre-optimization version
of the inlined function.
func (c dwCtxt) RecordDclReference(from dwarf.Sym, to dwarf.Sym, dclIdx int, inlIndex int)
ReferenceChildDIE
method
#
Make a note of a child DIE reference: relocation 'ridx' within symbol 's'
is targeting child 'c' of DIE with symbol 'tgt'.
func (ft *DwarfFixupTable) ReferenceChildDIE(s *LSym, ridx int, tgt *LSym, dclidx int, inlIndex int)
ReflectMethod
method
#
func (a *Attribute) ReflectMethod() bool
RegisterChildDIEOffsets
method
#
Called once DWARF generation is complete for a given abstract function,
whose children might have been referenced via a call above. Stores
the offsets for any child DIEs (vars, params) so that they can be
consumed later in on DwarfFixupTable.Finalize, which applies any
outstanding fixups.
func (ft *DwarfFixupTable) RegisterChildDIEOffsets(s *LSym, vars []*dwarf.Var, coffsets []int32)
RegisterOpSuffix
function
#
RegisterOpSuffix assigns cconv function for formatting opcode suffixes
when compiling for GOARCH=arch.
cconv is never called with 0 argument.
func RegisterOpSuffix(arch string, cconv func(uint8) string)
RegisterOpcode
function
#
RegisterOpcode binds a list of instruction names
to a given instruction number range.
func RegisterOpcode(lo As, Anames []string)
RegisterRegister
function
#
RegisterRegister binds a pretty-printer (Rconv) for register
numbers to a given register number range. Lo is inclusive,
hi exclusive (valid registers are lo through hi-1).
func RegisterRegister(lo int, hi int, Rconv func(int) string)
RegisterRegisterList
function
#
RegisterRegisterList binds a pretty-printer (RLconv) for register list
numbers to a given register list number range. Lo is inclusive,
hi exclusive (valid register list are lo through hi-1).
func RegisterRegisterList(lo int64, hi int64, rlconv func(int64) string)
RegisterSpecialOperands
function
#
RegisterSpecialOperands binds a pretty-printer (SPCconv) for special
operand numbers to a given special operand number range. Lo is inclusive,
hi is exclusive (valid special operands are lo through hi-1).
func RegisterSpecialOperands(lo int64, hi int64, rlconv func(int64) string)
Reloc
method
#
func (w *writer) Reloc(r *Reloc)
SPCconv
function
#
SPCconv returns the string representation of the special operand spc.
func SPCconv(spc int64) string
Set
method
#
func (a *ABISet) Set(abi ABI, value bool)
Set
method
#
func (a *Attribute) Set(flag Attribute, value bool)
SetABI
method
#
func (a *Attribute) SetABI(abi ABI)
SetConst
method
#
func (a *Addr) SetConst(v int64)
SetFIPSDebugHash
function
#
SetFIPSDebugHash sets the bisect pattern for debugging FIPS changes.
The compiler calls this with the pattern set by -d=fipshash=pattern,
so that if FIPS symbol type conversions are causing problems,
you can use 'bisect -compile fips go test strings' to identify exactly
which symbol is not being handled correctly.
func SetFIPSDebugHash(pattern string)
SetPrecursorFunc
method
#
func (ft *DwarfFixupTable) SetPrecursorFunc(s *LSym, fn Func)
SetTarget
method
#
func (a *Addr) SetTarget(t *Prog)
Size
method
#
func (c dwCtxt) Size(s dwarf.Sym) int64
SpillRegisterArgs
method
#
SpillRegisterArgs emits the code to spill register args into whatever
locations the spill records specify.
func (fi *FuncInfo) SpillRegisterArgs(last *Prog, pa ProgAlloc) *Prog
StartUnsafePoint
method
#
StartUnsafePoint generates PCDATA Progs after p to mark the
beginning of an unsafe point. The unsafe point starts immediately
after p.
It returns the last Prog generated.
func (ctxt *Link) StartUnsafePoint(p *Prog, newprog ProgAlloc) *Prog
Static
method
#
func (a *Attribute) Static() bool
String
method
#
func (i ABI) String() string
String
method
#
func (s *LSym) String() string
String
method
#
func (a As) String() string
String
method
#
func (i AddrType) String() string
String
method
#
String formats a for printing in as part of a TEXT prog.
func (a Attribute) String() string
String
method
#
func (a ABISet) String() string
String
method
#
func (p *Prog) String() string
StringTable
method
#
func (w *writer) StringTable()
Sym
method
#
func (w *writer) Sym(s *LSym)
Target
method
#
func (a *Addr) Target() *Prog
TextAttrString
method
#
TextAttrString formats the symbol attributes for printing in as part of a TEXT prog.
func (s *LSym) TextAttrString() string
UnspillRegisterArgs
method
#
UnspillRegisterArgs emits the code to restore register args from whatever
locations the spill records specify.
func (fi *FuncInfo) UnspillRegisterArgs(last *Prog, pa ProgAlloc) *Prog
UsedInIface
method
#
func (a *Attribute) UsedInIface() bool
VarInfo
method
#
VarInfo returns the *VarInfo associated with s, or else nil.
func (s *LSym) VarInfo() *VarInfo
WasInlined
method
#
func (a *Attribute) WasInlined() bool
Wrapper
method
#
func (a *Attribute) Wrapper() bool
Write
method
#
func (ft *WasmFuncType) Write(w *bytes.Buffer)
Write
method
#
func (wi *WasmImport) Write(w *bytes.Buffer)
WriteAddr
method
#
WriteAddr writes an address of size siz into s at offset off.
rsym and roff specify the relocation for the address.
func (s *LSym) WriteAddr(ctxt *Link, off int64, siz int, rsym *LSym, roff int64)
WriteBytes
method
#
WriteBytes writes a slice of bytes into s at offset off.
func (s *LSym) WriteBytes(ctxt *Link, off int64, b []byte) int64
WriteCURelativeAddr
method
#
WriteCURelativeAddr writes a pointer-sized address into s at offset off.
rsym and roff specify the relocation for the address which will be
resolved by the linker to an offset from the DW_AT_low_pc attribute of
the DWARF Compile Unit of rsym.
func (s *LSym) WriteCURelativeAddr(ctxt *Link, off int64, rsym *LSym, roff int64)
WriteDconv
function
#
WriteDconv accepts an argument 'a' within a prog 'p'
and writes a formatted version of the arg to the writer.
func WriteDconv(w io.Writer, p *Prog, a *Addr)
WriteFloat32
method
#
WriteFloat32 writes f into s at offset off.
func (s *LSym) WriteFloat32(ctxt *Link, off int64, f float32)
WriteFloat64
method
#
WriteFloat64 writes f into s at offset off.
func (s *LSym) WriteFloat64(ctxt *Link, off int64, f float64)
WriteInstructionString
method
#
WriteInstructionString writes a string representation of the instruction without preceding
program counter or file and line number.
func (p *Prog) WriteInstructionString(w io.Writer)
WriteInt
method
#
WriteInt writes an integer i of size siz into s at offset off.
func (s *LSym) WriteInt(ctxt *Link, off int64, siz int, i int64)
WriteNameTo
method
#
func (a *Addr) WriteNameTo(w io.Writer)
WriteObjFile
function
#
Entry point of writing new object file.
func WriteObjFile(ctxt *Link, b *bio.Writer)
WriteOff
method
#
WriteOff writes a 4 byte offset to rsym+roff into s at offset off.
After linking the 4 bytes stored at s+off will be
rsym+roff-(start of section that s is in).
func (s *LSym) WriteOff(ctxt *Link, off int64, rsym *LSym, roff int64)
WriteString
method
#
WriteString writes a string of size siz into s at offset off.
func (s *LSym) WriteString(ctxt *Link, off int64, siz int, str string)
WriteWeakAddr
method
#
WriteWeakAddr writes an address of size siz into s at offset off.
rsym and roff specify the relocation for the address.
This is a weak reference.
func (s *LSym) WriteWeakAddr(ctxt *Link, off int64, siz int, rsym *LSym, roff int64)
WriteWeakOff
method
#
WriteWeakOff writes a weak 4 byte offset to rsym+roff into s at offset off.
After linking the 4 bytes stored at s+off will be
rsym+roff-(start of section that s is in).
func (s *LSym) WriteWeakOff(ctxt *Link, off int64, rsym *LSym, roff int64)
_
function
#
func _()
_
function
#
func _()
abiDecorate
function
#
func abiDecorate(a *Addr, abiDetail bool) string
addBranch
method
#
addBranch adds a branch from the global inlining tree in ctxt to
the function's local inlining tree, returning the index in the local tree.
func (s *pcinlineState) addBranch(ctxt *Link, globalIndex int) int
aux1
method
#
func (w *writer) aux1(typ uint8, rs *LSym)
brloop
function
#
brloop returns the ultimate destination of the series of unconditional jumps beginning at p.
In the case of an infinite loop, brloop returns nil.
func brloop(p *Prog) *Prog
checkFIPSReloc
method
#
checkFIPSReloc should be called for every relocation applied to s.
It rejects absolute (non-PC-relative) address relocations when building
with go build -buildmode=pie (which triggers the compiler's -shared flag),
because those relocations will be applied before crypto/internal/fips140/check
can hash-verify the FIPS code+data, which will make the verification fail.
func (s *LSym) checkFIPSReloc(ctxt *Link, rel Reloc)
checkaddr
function
#
checkaddr checks that a has an expected encoding, especially TYPE_CONST vs TYPE_ADDR.
func checkaddr(ctxt *Link, p *Prog, a *Addr)
contentHash
method
#
Compute the content hash for a content-addressable symbol.
We build a content hash based on its content and relocations.
Depending on the category of the referenced symbol, we choose
different hash algorithms such that the hash is globally
consistent.
- For referenced content-addressable symbol, its content hash
is globally consistent.
- For package symbol and builtin symbol, its local index is
globally consistent.
- For non-package symbol, its fully-expanded name is globally
consistent. For now, we require we know the current package
path so we can always expand symbol names. (Otherwise,
symbols with relocations are not considered hashable.)
For now, we assume there is no circular dependencies among
hashed symbols.
func (w *writer) contentHash(s *LSym) goobj.HashType
contentHash64
function
#
func contentHash64(s *LSym) goobj.Hash64Type
contentHashSection
function
#
contentHashSection returns a mnemonic for s's section.
The goal is to prevent content-addressability from moving symbols between sections.
contentHashSection only distinguishes between sets of sections for which this matters.
Allowing flexibility increases the effectiveness of content-addressability.
But in some cases, such as doing addressing based on a base symbol,
we need to ensure that a symbol is always in a particular section.
Some of these conditions are duplicated in cmd/link/internal/ld.(*Link).symtab.
TODO: instead of duplicating them, have the compiler decide where symbols go.
func contentHashSection(s *LSym) byte
debugAsmEmit
function
#
func debugAsmEmit(ctxt *Link)
dumpInlTree
function
#
func dumpInlTree(ctxt *Link, tree InlTree)
dwarfSym
method
#
func (ctxt *Link) dwarfSym(s *LSym) (dwarfInfoSym *LSym, dwarfLocSym *LSym, dwarfRangesSym *LSym, dwarfAbsFnSym *LSym, dwarfDebugLines *LSym)
funcpctab
function
#
funcpctab writes to dst a pc-value table mapping the code in func to the values
returned by valfunc parameterized by arg. The invocation of valfunc to update the
current value is, for each p,
sym = valfunc(func, p, 0, arg);
record sym.P as value at p->pc;
sym = valfunc(func, p, 1, arg);
where func is the function, val is the current value, p is the instruction being
considered, and arg can be used to further parameterize valfunc.
func funcpctab(ctxt *Link, func_ *LSym, desc string, valfunc func(*Link, *LSym, int32, *Prog, int32, interface{}) int32, arg interface{}) *LSym
genFuncInfoSyms
function
#
generate symbols for FuncInfo.
func genFuncInfoSyms(ctxt *Link)
generateDebugLinesSymbol
method
#
generateDebugLinesSymbol fills the debug lines symbol of a given function.
It's worth noting that this function doesn't generate the full debug_lines
DWARF section, saving that for the linker. This function just generates the
state machine part of debug_lines. The full table is generated by the
linker. Also, we use the file numbers from the full package (not just the
function in question) when generating the state machine. We do this so we
don't have to do a fixup on the indices when writing the full section.
func (ctxt *Link) generateDebugLinesSymbol(s *LSym, lines *LSym)
getFileIndexAndLine
method
#
getFileIndexAndLine returns the relative file index (local to the CU), and
the relative line number for a position (i.e., as adjusted by a //line
directive). This is the file/line visible in the final binary (pcfile, pcln,
etc).
func (ctxt *Link) getFileIndexAndLine(xpos src.XPos) (int, int32)
init
method
#
prepare package index list
func (w *writer) init()
isDwarf64
function
#
func isDwarf64(ctxt *Link) bool
isNonPkgSym
function
#
Returns whether s is a non-package symbol, which needs to be referenced
by name instead of by index.
func isNonPkgSym(ctxt *Link, s *LSym) bool
linkpatch
function
#
func linkpatch(ctxt *Link, sym *LSym, newprog ProgAlloc)
linkpcln
function
#
func linkpcln(ctxt *Link, cursym *LSym)
load
method
#
func (a *Attribute) load() Attribute
makeSymRef
function
#
func makeSymRef(s *LSym) goobj.SymRef
mkfwd
function
#
func mkfwd(sym *LSym)
nAuxSym
function
#
return the number of aux symbols s have.
func nAuxSym(s *LSym) int
offConv
function
#
func offConv(off int64) string
pctofileline
function
#
pctofileline computes either the file number (arg == 0)
or the line number (arg == 1) to use at p.
Because p.Pos applies to p, phase == 0 (before p)
takes care of the update.
func pctofileline(ctxt *Link, sym *LSym, oldval int32, p *Prog, phase int32, arg interface{}) int32
pctoinline
method
#
pctoinline computes the index into the local inlining tree to use at p.
If p is not the result of inlining, pctoinline returns -1. Because p.Pos
applies to p, phase == 0 (before p) takes care of the update.
func (s *pcinlineState) pctoinline(ctxt *Link, sym *LSym, oldval int32, p *Prog, phase int32, arg interface{}) int32
pctopcdata
function
#
pctopcdata computes the pcdata value in effect at p.
A PCDATA instruction sets the value in effect at future
non-PCDATA instructions.
Since PCDATA instructions have no width in the final code,
it does not matter which phase we use for the update.
func pctopcdata(ctxt *Link, sym *LSym, oldval int32, p *Prog, phase int32, arg interface{}) int32
pctospadj
function
#
pctospadj computes the sp adjustment in effect.
It is oldval plus any adjustment made by p itself.
The adjustment by p takes effect only after p, so we
apply the change during phase == 1.
func pctospadj(ctxt *Link, sym *LSym, oldval int32, p *Prog, phase int32, arg interface{}) int32
populateDWARF
method
#
populateDWARF fills in the DWARF Debugging Information Entries for
TEXT symbol 's'. The various DWARF symbols must already have been
initialized in InitTextSym.
func (ctxt *Link) populateDWARF(curfn Func, s *LSym)
prepwrite
method
#
prepwrite prepares to write data of size siz into s at offset off.
func (s *LSym) prepwrite(ctxt *Link, off int64, siz int)
processFixups
method
#
func (ft *DwarfFixupTable) processFixups(slot int, s *LSym)
putpclcdelta
function
#
func putpclcdelta(linkctxt *Link, dctxt dwCtxt, s *LSym, deltaPC uint64, deltaLC int64)
refFlags
method
#
Emits flags of referenced indexed symbols.
func (w *writer) refFlags()
refNames
method
#
Emits names of referenced indexed symbols, used by tools (objdump, nm)
only.
func (w *writer) refNames()
relocByOffCmp
function
#
relocByOffCmp compare relocations by their offsets.
func relocByOffCmp(x Reloc, y Reloc) int
requireAlignment
function
#
requireAlignment ensures that the function is aligned enough to support
the required code alignment
func requireAlignment(a int64, ctxt *Link, cursym *LSym)
rodataKind
method
#
func (ctxt *Link) rodataKind() (suffix string, typ objabi.SymKind)
setFIPSType
method
#
setFIPSType should be called every time s.Type is set or changed.
It changes the type to one of the FIPS type (for example, STEXT -> STEXTFIPS) if appropriate.
func (s *LSym) setFIPSType(ctxt *Link)
setParentPC
method
#
func (s *pcinlineState) setParentPC(ctxt *Link, globalIndex int, pc int32)
setParentPC
method
#
func (tree *InlTree) setParentPC(inlIndex int, pc int32)
textPos
function
#
textPos returns the source position of the first instruction (prog)
of the specified function.
func textPos(fn *LSym) src.XPos
toFuncFlag
method
#
func (ctxt *Link) toFuncFlag(flag int) abi.FuncFlag
traverseAuxSyms
method
#
Traverse aux symbols, calling fn for each sym/aux pair.
func (ctxt *Link) traverseAuxSyms(flag traverseFlag, fn func(parent *LSym, aux *LSym))
traverseFuncAux
method
#
func (ctxt *Link) traverseFuncAux(flag traverseFlag, fsym *LSym, fn func(parent *LSym, aux *LSym), files []string)
traverseSyms
method
#
Traverse symbols based on flag, call fn for each symbol.
func (ctxt *Link) traverseSyms(flag traverseFlag, fn func(*LSym))
writeAddr
method
#
func (s *LSym) writeAddr(ctxt *Link, off int64, siz int, rsym *LSym, roff int64, rtype objabi.RelocType)
writeAuxSymDebug
function
#
func writeAuxSymDebug(ctxt *Link, par *LSym, aux *LSym)
writeDconv
function
#
func writeDconv(w io.Writer, p *Prog, a *Addr, abiDetail bool)
writeFile
method
#
func (w *writer) writeFile(ctxt *Link, file *FileInfo)
writeNameTo
method
#
func (a *Addr) writeNameTo(w io.Writer, abiDetail bool)
writeSymDebug
method
#
func (ctxt *Link) writeSymDebug(s *LSym)
writeSymDebugNamed
method
#
func (ctxt *Link) writeSymDebugNamed(s *LSym, name string)