Documentation ¶
Index ¶
- Constants
- Variables
- func Access(name string, mode int) int
- func Aconv(a int) string
- func Adduint32(ctxt *Link, s *LSym, v uint32) int64
- func Adduint64(ctxt *Link, s *LSym, v uint64) int64
- func Atoi(s string) int
- func Bflush(b *Biobuf) error
- func Bgetc(b *Biobuf) int
- func Bgetrune(b *Biobuf) int
- func Blinelen(b *Biobuf) int
- func Boffset(b *Biobuf) int64
- func Bputc(b *Biobuf, c byte)
- func Brdline(b *Biobuf, delim int) string
- func Brdstr(b *Biobuf, delim int, cut int) string
- func Bread(b *Biobuf, p []byte) int
- func Bseek(b *Biobuf, offset int64, whence int) int64
- func Bterm(b *Biobuf) error
- func Bungetc(b *Biobuf)
- func Bungetrune(b *Biobuf)
- func Bwrite(b *Biobuf, p []byte) (int, error)
- func Bwritestring(b *Biobuf, p string) (int, error)
- func CConv(s uint8) string
- func Cputime() float64
- func Dconv(p *Prog, a *Addr) string
- func Expandpkg(t0 string, pkg string) string
- func Expstring() string
- func Flagcount(name, usage string, val *int)
- func Flagfn0(name, usage string, f func())
- func Flagfn1(name, usage string, f func(string))
- func Flagfn2(string, string, func(string, string))
- func Flagint32(name, usage string, val *int32)
- func Flagint64(name, usage string, val *int64)
- func Flagparse(usage func())
- func Flagprint(fd int)
- func Flagstr(name, usage string, val *string)
- func Getcallerpc(interface{}) uintptr
- func Getgo386() string
- func Getgoarch() string
- func Getgoarm() string
- func Getgoextlinkenabled() string
- func Getgoos() string
- func Getgoroot() string
- func Getgoversion() string
- func Headstr(v int) string
- func Linklinefmt(ctxt *Link, lineno int, showAll, showFullPath bool) string
- func Linklinehist(ctxt *Link, lineno int, f string, n int)
- func Linkprfile(ctxt *Link, line int)
- func Linksymfmt(s *LSym) string
- func Mconv(a *Addr) string
- func Nocache(p *Prog)
- func Nopout(p *Prog)
- func Rconv(reg int) string
- func RegisterOpcode(lo int, Anames []string)
- func RegisterRegister(lo, hi int, Rconv func(int) string)
- func Setuintxx(ctxt *Link, s *LSym, off int64, v uint64, wid int64) int64
- func Symgrow(ctxt *Link, s *LSym, lsiz int64)
- func Writeobjdirect(ctxt *Link, b *Biobuf)
- type Addr
- type Auto
- type Biobuf
- type LSym
- type Library
- type LineHist
- func (h *LineHist) AbsFileLine(lineno int) (file string, line int)
- func (h *LineHist) At(lineno int) *LineStack
- func (h *LineHist) FileLine(lineno int) (file string, line int)
- func (h *LineHist) LineString(lineno int) string
- func (h *LineHist) Pop(lineno int)
- func (h *LineHist) Push(lineno int, file string)
- func (h *LineHist) Update(lineno int, file string, line int)
- type LineRange
- type LineStack
- type Link
- type LinkArch
- type Pcdata
- type Pciter
- type Pcln
- type Plist
- type Prog
- type Reloc
- type SymVer
Constants ¶
const ( FmtWidth = 1 FmtLeft = FmtWidth << 1 FmtPrec = FmtLeft << 1 FmtSharp = FmtPrec << 1 FmtSpace = FmtSharp << 1 FmtSign = FmtSpace << 1 FmtApost = FmtSign << 1 FmtZero = FmtApost << 1 FmtUnsigned = FmtZero << 1 FmtShort = FmtUnsigned << 1 FmtLong = FmtShort << 1 FmtVLong = FmtLong << 1 FmtComma = FmtVLong << 1 FmtByte = FmtComma << 1 FmtLDouble = FmtByte << 1 FmtFlag = FmtLDouble << 1 )
const ( PCDATA_StackMapIndex = 0 FUNCDATA_ArgsPointerMaps = 0 FUNCDATA_LocalsPointerMaps = 1 FUNCDATA_DeadValueMaps = 2 ArgsSizeUnknown = -0x80000000 )
ArgsSizeUnknown is set in Func.argsize to mark all functions whose argument size is unknown (C vararg functions, and assembly code without an explicit specification). This value is generated by the compiler, assembler, or linker.
const ( OREAD = iota OWRITE ORDWR SIGBUS SIGSEGV NDFLT FPPDBL FPRNR HEADER_IO BOM = 0xFEFF )
const ( NAME_NONE = 0 + iota NAME_EXTERN NAME_STATIC NAME_AUTO NAME_PARAM )
const ( TYPE_BRANCH = 5 + iota TYPE_TEXTSIZE TYPE_MEM TYPE_CONST TYPE_FCONST TYPE_SCONST TYPE_REG TYPE_ADDR TYPE_SHIFT TYPE_REGREG TYPE_REGREG2 TYPE_INDIR TYPE_REGLIST )
const ( AXXX = 0 + iota ACALL ACHECKNIL ADATA ADUFFCOPY ADUFFZERO AEND AFUNCDATA AGLOBL AJMP ANOP APCDATA ARET ATEXT ATYPE AUNDEF AUSEFIELD AVARDEF AVARKILL A_ARCHSPECIFIC )
Prog.as opcodes. These are the portable opcodes, common to all architectures. Each architecture defines many more arch-specific opcodes, with values starting at A_ARCHSPECIFIC. Each architecture adds an offset to this so each machine has distinct space for its instructions. The offset is a power of two so it can be masked to return to origin zero. See the definitions of ABase386 etc.
const ( Sxxx = iota STEXT SELFRXSECT STYPE SSTRING SGOSTRING SGOFUNC SRODATA SFUNCTAB STYPELINK SSYMTAB SPCLNTAB SELFROSECT SMACHOPLT SELFSECT SMACHO SMACHOGOT SWINDOWS SELFGOT SNOPTRDATA SINITARR SDATA SBSS SNOPTRBSS STLSBSS SXREF SMACHOSYMSTR SMACHOSYMTAB SMACHOINDIRECTPLT SMACHOINDIRECTGOT SFILE SFILEPATH SCONST SDYNIMPORT SHOSTOBJ SSUB = 1 << 8 SMASK = SSUB - 1 SHIDDEN = 1 << 9 )
LSym.type
const ( R_ADDR = 1 + iota R_ADDRPOWER R_SIZE R_CALL R_CALLARM R_CALLARM64 R_CALLIND R_CALLPOWER R_CONST R_PCREL R_TLS R_TLS_LE R_TLS_IE R_GOTOFF R_PLT0 R_PLT1 R_PLT2 R_USEFIELD R_POWER_TOC )
Reloc.type
const ( RV_NONE = iota RV_POWER_LO RV_POWER_HI RV_POWER_HA RV_POWER_DS RV_CHECK_OVERFLOW = 1 << 8 RV_TYPE_MASK = RV_CHECK_OVERFLOW - 1 )
Reloc.variant
const ( A_AUTO = 1 + iota A_PARAM )
Auto.name
const ( Hunknown = 0 + iota Hdarwin Hdragonfly Helf Hfreebsd Hlinux Hnacl Hnetbsd Hopenbsd Hplan9 Hsolaris Hwindows )
executable header types
const ( LinkAuto = 0 + iota LinkInternal LinkExternal )
const ( GcBits = 4 BitsPerPointer = 2 BitsDead = 0 BitsScalar = 1 BitsPointer = 2 BitsMask = 3 PointersPerByte = 8 / BitsPerPointer )
const ( InsData = 1 + iota InsArray InsArrayEnd InsEnd MaxGCMask = 65536 )
const ( STACKSYSTEM = 0 StackSystem = STACKSYSTEM StackBig = 4096 StackGuard = 640 + StackSystem StackSmall = 128 StackLimit = StackGuard - StackSystem - StackSmall )
const ( // Don't profile the marked routine. This flag is deprecated. NOPROF = 1 // It is ok for the linker to get multiple of these symbols. It will // pick one of the duplicates to use. DUPOK = 2 // Don't insert stack check preamble. NOSPLIT = 4 // Put this data in a read-only section. RODATA = 8 // This data contains no pointers. NOPTR = 16 // This is a wrapper function and should not count as disabling 'recover'. WRAPPER = 32 // This function uses its incoming context register. NEEDCTXT = 64 )
const ( KindBool = 1 + iota KindInt KindInt8 KindInt16 KindInt32 KindInt64 KindUint KindUint8 KindUint16 KindUint32 KindUint64 KindUintptr KindFloat32 KindFloat64 KindComplex64 KindComplex128 KindArray KindChan KindFunc KindInterface KindMap KindPtr KindSlice KindString KindStruct KindUnsafePointer KindDirectIface = 1 << 5 KindGCProg = 1 << 6 KindNoPointers = 1 << 7 KindMask = (1 << 5) - 1 )
const ( C_SCOND = (1 << 4) - 1 C_SBIT = 1 << 4 C_PBIT = 1 << 5 C_WBIT = 1 << 6 C_FBIT = 1 << 7 C_UBIT = 1 << 7 C_SCOND_XOR = 14 )
ARM scond byte
const ( // Because of masking operations in the encodings, each register // space should start at 0 modulo some power of 2. RBase386 = 1 * 1024 RBaseAMD64 = 2 * 1024 RBaseARM = 3 * 1024 RBasePPC64 = 4 * 1024 // range [4k, 8k) RBaseARM64 = 8 * 1024 // range [8k, 12k) )
const ( ABase386 = (1 + iota) << 12 ABaseARM ABaseAMD64 ABasePPC64 ABaseARM64 AMask = 1<<12 - 1 // AND with this to use the opcode as an array index. )
const (
AEXIST = 0
)
const Beof = -1
const (
HistVersion = 1
)
symbol version, incremented each time a file is loaded. version==1 is reserved for savehist.
const (
LOG = 5
)
const REG_NONE = 0
const (
StackPreempt = -1314 // 0xfff...fade
)
const (
TYPE_NONE = 0
)
Variables ¶
var Anames = []string{
"XXX",
"CALL",
"CHECKNIL",
"DATA",
"DUFFCOPY",
"DUFFZERO",
"END",
"FUNCDATA",
"GLOBL",
"JMP",
"NOP",
"PCDATA",
"RET",
"TEXT",
"TYPE",
"UNDEF",
"USEFIELD",
"VARDEF",
"VARKILL",
}
var Fieldtrack_enabled int
var Framepointer_enabled int
var GOEXPERIMENT string
Functions ¶
func Bungetrune ¶
func Bungetrune(b *Biobuf)
func Getcallerpc ¶
func Getcallerpc(interface{}) uintptr
func Getgoextlinkenabled ¶
func Getgoextlinkenabled() string
func Getgoversion ¶
func Getgoversion() string
func Linklinefmt ¶
TODO(rsc): Replace call sites with use of ctxt.LineHist. Note that all call sites use showAll=false, showFullPath=false.
func Linklinehist ¶
Linklinehist pushes, amends, or pops an entry on the line history stack. If f != "<pop>" and n == 0, the call pushes the start of a new file named f at lineno. If f != "<pop>" and n > 0, the call amends the top of the stack to record that lineno now corresponds to f at line n. If f == "<pop>", the call pops the topmost entry from the stack, picking up the parent file at the line following the one where the corresponding push occurred.
If n < 0, linklinehist records f as a package required by the current compilation (nothing to do with line numbers).
TODO(rsc): Replace uses with direct calls to ctxt.Hist methods.
func Linkprfile ¶
func Linksymfmt ¶
func RegisterOpcode ¶
RegisterOpcode binds a list of instruction names to a given instruction number range.
func RegisterRegister ¶
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 Writeobjdirect ¶
The Go and C compilers, and the assembler, call writeobj to write out a Go object file. The linker does not call this; the linker does not write out object files.
Types ¶
type Addr ¶
type Addr struct { Type int16 Reg int16 Reg2 int16 // RHS of register pair. AX:DX (386) Index int16 Scale int16 // Sometimes holds a register. Name int8 Offset int64 Sym *LSym U struct { Sval string Dval float64 Branch *Prog Argsize int32 Bits uint64 } Gotype *LSym Class int8 Etype uint8 Node interface{} Width int64 }
type LSym ¶
type LSym struct { Name string Extname string Type int16 Version int16 Dupok uint8 Cfunc uint8 External uint8 Nosplit uint8 Reachable uint8 Cgoexport uint8 Special uint8 Stkcheck uint8 Hide uint8 Leaf uint8 Fnptr uint8 Localentry uint8 Seenglobl uint8 Onlist uint8 Printed uint8 Symid int16 Dynid int32 Plt int32 Got int32 Align int32 Elfsym int32 Args int32 Locals int32 Value int64 Size int64 Allsym *LSym Next *LSym Sub *LSym Outer *LSym Gotype *LSym Reachparent *LSym Queue *LSym File string Dynimplib string Dynimpvers string Sect *struct{} Autom *Auto Text *Prog Etext *Prog Pcln *Pcln P []byte R []Reloc }
type LineHist ¶
type LineHist struct { Top *LineStack // current top of stack Ranges []LineRange // ranges for lookup Dir string // directory to qualify relative paths TrimPathPrefix string // remove leading TrimPath from recorded file names GOROOT string // current GOROOT GOROOT_FINAL string // target GOROOT }
A LineHist records the history of the file input stack, which maps the virtual line number, an incrementing count of lines processed in any input file and typically named lineno, to a stack of file:line pairs showing the path of inclusions that led to that position. The first line directive (//line in Go, #line in assembly) is treated as pushing a new entry on the stack, so that errors can report both the actual and translated line number.
In typical use, the virtual lineno begins at 1, and file line numbers also begin at 1, but the only requirements placed upon the numbers by this code are:
- calls to Push, Update, and Pop must be monotonically increasing in lineno
- except as specified by those methods, virtual and file line number increase together, so that given (only) calls Push(10, "x.go", 1) and Pop(15), virtual line 12 corresponds to x.go line 3.
func (*LineHist) AbsFileLine ¶
AbsFileLine returns the absolute file name and line number at the top of the stack for the given lineno.
func (*LineHist) FileLine ¶
FileLine returns the file name and line number at the top of the stack for the given lineno.
func (*LineHist) LineString ¶
LineString returns a string giving the file and line number corresponding to lineno, for use in error messages.
type LineRange ¶
type LineRange struct { Start int // starting lineno Stack *LineStack // top of stack for this range }
The span of valid linenos in the recorded line history can be broken into a set of ranges, each with a particular stack. A LineRange records one such range.
type LineStack ¶
type LineStack struct { Parent *LineStack // parent in inclusion stack Lineno int // virtual line number where this entry takes effect File string // file name used to open source file, for error messages AbsFile string // absolute file name, for pcln tables FileLine int // line number in file at Lineno Directive bool Sym *LSym // for linkgetline - TODO(rsc): remove }
A LineStack is an entry in the recorded line history. Although the history at any given line number is a stack, the record for all line processed forms a tree, with common stack prefixes acting as parents.
type Link ¶
type Link struct { Thechar int32 Thestring string Goarm int32 Headtype int Arch *LinkArch Ignore func(string) int32 Debugasm int32 Debugline int32 Debughist int32 Debugread int32 Debugvlog int32 Debugstack int32 Debugzerostack int32 Debugdivmod int32 Debugfloat int32 Debugpcln int32 Iself int32 Bso *Biobuf Pathname string Windows int32 Trimpath string Goroot string Goroot_final string Enforce_data_order int32 Hash map[SymVer]*LSym Allsym *LSym Nsymbol int32 LineHist LineHist Imports []string Plist *Plist Plast *Plist Sym_div *LSym Sym_divu *LSym Sym_mod *LSym Sym_modu *LSym Symmorestack [2]*LSym Tlsg *LSym Plan9privates *LSym Curp *Prog Printp *Prog Blitrl *Prog Elitrl *Prog Rexflag int Rep int Repn int Lock int Asmode int Andptr []byte And [100]uint8 Instoffset int64 Autosize int32 Armsize int32 Pc int64 Libdir []string Library []Library Tlsoffset int Diag func(string, ...interface{}) Mode int Curauto *Auto Curhist *Auto Cursym *LSym Version int Textp *LSym Etextp *LSym Histdepth int32 Nhistfile int32 Filesyms *LSym }
type Prog ¶
type Prog struct { Ctxt *Link Pc int64 Lineno int32 Link *Prog As int16 Scond uint8 From Addr Reg int16 From3 Addr To Addr To2 Addr Opt interface{} Forwd *Prog Pcond *Prog Comefrom *Prog Pcrel *Prog Spadj int32 Mark uint16 Optab uint16 Back uint8 Ft uint8 F3t uint8 Tt uint8 Isize uint8 Printed uint8 Width int8 Mode int8 }