Documentation

Index

Constants

View Source
const (
	// Loader.flags
	FlagStrictDups = 1 << iota
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Loader

type Loader struct {
	Syms []*sym.Symbol // indexed symbols. XXX we still make sym.Symbol for now.

	Reachable bitmap // bitmap of reachable symbols, indexed by global index

	// Used to implement field tracking; created during deadcode if
	// field tracking is enabled. Reachparent[K] contains the index of
	// the symbol that triggered the marking of symbol K as live.
	Reachparent []Sym

	// contains filtered or unexported fields

}

A Loader loads new object files and resolves indexed symbol references.

func NewLoader

func NewLoader(flags uint32) *Loader

func (*Loader) AddExtSym

func (l *Loader) AddExtSym(name string, ver int) Sym

Add an external symbol (without index). Return the index of newly added symbol, or 0 if not added.

func (*Loader) AddSym

func (l *Loader) AddSym(name string, ver int, i Sym, r *oReader, dupok bool, typ sym.SymKind) bool

Add a symbol with a given index, return if it is added.

func (*Loader) AuxSym

func (l *Loader) AuxSym(i Sym, j int) Sym

Returns the referred symbol of the j-th aux symbol of the i-th symbol.

func (*Loader) Create

func (l *Loader) Create(name string, syms *sym.Symbols) *sym.Symbol

Create creates a symbol with the specified name, returning a sym.Symbol object for it. This method is intended for static/hidden symbols discovered while loading host objects. We can see more than one instance of a given static symbol with the same name/version, so we can't add them to the lookup tables "as is". Instead assign them fictitious (unique) versions, starting at -1 and decreasing by one for each newly created symbol, and record them in the extStaticSyms hash.

func (*Loader) Data

func (l *Loader) Data(i Sym) []byte

Returns the symbol content of the i-th symbol. i is global index.

func (*Loader) Dump

func (l *Loader) Dump()

For debugging.

func (*Loader) ExtractSymbols

func (l *Loader) ExtractSymbols(syms *sym.Symbols)

ExtractSymbols grabs the symbols out of the loader for work that hasn't been ported to the new symbol type.

func (*Loader) InitReachable

func (l *Loader) InitReachable()

Initialize Reachable bitmap for running deadcode pass.

func (*Loader) IsDup

func (l *Loader) IsDup(i Sym) bool

Returns whether i is a dup of another symbol, and i is not "primary", i.e. Lookup i by name will not return i.

func (*Loader) IsExternal

func (l *Loader) IsExternal(i Sym) bool

func (*Loader) IsGoType

func (l *Loader) IsGoType(i Sym) bool

Returns whether this is a Go type symbol.

func (l *Loader) IsItabLink(i Sym) bool

Returns whether this is a "go.itablink.*" symbol.

func (*Loader) IsReflectMethod

func (l *Loader) IsReflectMethod(i Sym) bool

Returns whether the i-th symbol has ReflectMethod attribute set.

func (*Loader) LoadFull

func (l *Loader) LoadFull(arch *sys.Arch, syms *sym.Symbols)

Load full contents.

func (*Loader) LoadRefs

func (l *Loader) LoadRefs(arch *sys.Arch, syms *sym.Symbols)

Make sure referenced symbols are added. Most of them should already be added. This should only be needed for referenced external symbols.

func (*Loader) LoadSymbol

func (l *Loader) LoadSymbol(name string, version int, syms *sym.Symbols) *sym.Symbol

LoadSymbol loads a single symbol by name. This function should only be used by the host object loaders. NB: This function does NOT set the symbol as reachable.

func (*Loader) Lookup

func (l *Loader) Lookup(name string, ver int) Sym

Look up a symbol by name, return global index, or 0 if not found. This is more like Syms.ROLookup than Lookup -- it doesn't create new symbol.

func (*Loader) LookupOrCreate

func (l *Loader) LookupOrCreate(name string, version int, syms *sym.Symbols) *sym.Symbol

LookupOrCreate looks up a symbol by name, and creates one if not found. Either way, it will also create a sym.Symbol for it, if not already. This should only be called when interacting with parts of the linker that still works on sym.Symbols (i.e. internal cgo linking, for now).

func (*Loader) NAux

func (l *Loader) NAux(i Sym) int

Returns the number of aux symbols given a global index.

func (*Loader) NDef

func (l *Loader) NDef() int

Number of defined Go symbols.

func (*Loader) NStrictDupMsgs

func (l *Loader) NStrictDupMsgs() int

func (*Loader) NSym

func (l *Loader) NSym() int

Number of total symbols.

func (*Loader) OuterSym

func (l *Loader) OuterSym(i Sym) Sym

OuterSym gets the outer symbol for host object loaded symbols.

func (*Loader) Preload

func (l *Loader) Preload(arch *sys.Arch, syms *sym.Symbols, f *bio.Reader, lib *sym.Library, unit *sym.CompilationUnit, length int64, pn string, flags int)

Preload a package: add autolibs, add symbols to the symbol table. Does not read symbol data yet.

func (*Loader) RawSymName

func (l *Loader) RawSymName(i Sym) string

Returns the raw (unpatched) name of the i-th symbol.

func (*Loader) ReadAuxSyms

func (l *Loader) ReadAuxSyms(symIdx Sym, dst []Sym) []Sym

ReadAuxSyms reads the aux symbol ids for the specified symbol into the slice passed as a parameter. If the slice capacity is not large enough, a new larger slice will be allocated. Final slice is returned.

func (*Loader) Relocs

func (l *Loader) Relocs(i Sym) Relocs

Relocs returns a Relocs object for the given global sym.

func (*Loader) SubSym

func (l *Loader) SubSym(i Sym) Sym

SubSym gets the subsymbol for host object loaded symbols.

func (*Loader) SymAttr

func (l *Loader) SymAttr(i Sym) uint8

Returns the attributes of the i-th symbol.

func (*Loader) SymName

func (l *Loader) SymName(i Sym) string

Returns the (patched) name of the i-th symbol.

func (*Loader) SymType

func (l *Loader) SymType(i Sym) sym.SymKind

Returns the type of the i-th symbol.

type Reloc

type Reloc struct {
	Off  int32            // offset to rewrite
	Size uint8            // number of bytes to rewrite: 0, 1, 2, or 4
	Type objabi.RelocType // the relocation type
	Add  int64            // addend
	Sym  Sym              // global index of symbol the reloc addresses
}

Reloc contains the payload for a specific relocation. TODO: replace this with sym.Reloc, once we change the relocation target from "*sym.Symbol" to "loader.Sym" in sym.Reloc.

type Relocs

type Relocs struct {
	Count int // number of relocs

	// contains filtered or unexported fields

}

Relocs encapsulates the set of relocations on a given symbol; an instance of this type is returned by the Loader Relocs() method.

func (*Relocs) At

func (relocs *Relocs) At(j int) Reloc

At method returns the j-th reloc for a global symbol.

func (*Relocs) ReadAll

func (relocs *Relocs) ReadAll(dst []Reloc) []Reloc

ReadAll method reads all relocations for a symbol into the specified slice. If the slice capacity is not large enough, a new larger slice will be allocated. Final slice is returned.

type Sym

type Sym int

Sym encapsulates a global symbol index, used to identify a specific Go symbol. The 0-valued Sym is corresponds to an invalid symbol.

Source Files