Documentation
¶
Index ¶
- Constants
- func BareFunc(f *Func) ([]byte, error)
- func Main(pkgs map[string]*Pkg, funcs []*PkgSym) ([]*image.Section, error)
- func SinglePkg(pkg *Pkg, start string) ([]*image.Section, error)
- type Func
- type FuncMeta
- type Job
- type Pkg
- func (p *Pkg) DeclareFunc(name string)
- func (p *Pkg) DeclareVar(name string)
- func (p *Pkg) DefineFunc(name string, f *Func)
- func (p *Pkg) DefineVar(name string, v *Var)
- func (p *Pkg) Func(name string) *Func
- func (p *Pkg) HasFunc(name string) bool
- func (p *Pkg) Path() string
- func (p *Pkg) PrintSymbols(out io.Writer)
- func (p *Pkg) SymbolByName(name string) *Symbol
- func (p *Pkg) Var(name string) *Var
- type PkgSym
- type Symbol
- type Var
Constants ¶
const ( FillNone = iota // no fill FillLink // fill as linking offset for jump instructions FillLow // fill with the lower 16 bits FillHigh // fill with the higher 16 bits )
Constant fill-later methods.
const ( SymNone = iota // for default return value SymFunc SymVar )
Linking symbol types
Variables ¶
This section is empty.
Functions ¶
func BareFunc ¶
BareFunc produces a image of a single function that has no links.
func Main ¶
Main is a short hand for NewJob(pkgs, path, start).Link(out)
Types ¶
type Func ¶
type Func struct {
// contains filtered or unexported fields
}
Func is a relocatable code section
func (*Func) AddInst ¶
AddInst appends an instruction at the end of the function.
func (*Func) AddLink ¶
AddLink links the last instruction in inst to the symbol pkg.sym, where pkg and sym are using the indexing of the object file. fill field must be less than 4 so that it fits in the lowest 2 bits in the offset field. The other bits of the offset fields will be automatically calculated based on the number of instructions in insts.
type FuncMeta ¶
FuncMeta stores the meta data of a function for generating debug symbol.
type Job ¶
type Job struct { Pkgs map[string]*Pkg Funcs []*PkgSym InitPC uint32 FuncDebug func(pkg, name string, addr, size uint32) }
Job is a linking job.
func NewJob ¶
NewJob creates a new linking job which init pc is the default one.
type Pkg ¶
type Pkg struct {
// contains filtered or unexported fields
}
Pkg is the compiling object of a package. It is the linking unit for programs.
func (*Pkg) DeclareFunc ¶
DeclareFunc declares a function (code block).
func (*Pkg) DeclareVar ¶
DeclareVar declares a variable (data block)
func (*Pkg) DefineFunc ¶
DefineFunc instantiates a function object.
func (*Pkg) DefineVar ¶
DefineVar instantiates a variable object.
func (*Pkg) HasFunc ¶
HasFunc checks if the package has a function of a particular name.
func (*Pkg) PrintSymbols ¶
PrintSymbols prints all symbols out to a writer.
func (*Pkg) SymbolByName ¶
SymbolByName returns the symbol with the particular name.
type PkgSym ¶
PkgSym is a link to a symbol in a particular package
type Symbol ¶
Symbol is a linking symbol in an object file
type Var ¶
type Var struct {
// contains filtered or unexported fields
}
Var reprsents a variable object
func (*Var) IsZeros ¶
IsZeros checks if the variable section is a BSS section.
func (*Var) Write ¶
Write appends bytes to this data section.
func (*Var) WriteLink ¶
WriteLink writes a symbol link into the data section.