Documentation ¶
Index ¶
- Constants
- func GenAddAddrPlusFunc(internalExec bool) func(s *SymbolBuilder, arch *sys.Arch, tgt Sym, add int64) int64
- type Aux2
- type Bitmap
- type ErrorReporter
- type ExtReloc
- type ExtRelocView
- type ExtRelocs
- type FuncInfo
- func (fi *FuncInfo) Args() int
- func (fi *FuncInfo) File(k int) Sym
- func (fi *FuncInfo) Funcdata(syms []Sym) []Sym
- func (fi *FuncInfo) Funcdataoff(k int) int64
- func (fi *FuncInfo) InlTree(k int) InlTreeNode
- func (fi *FuncInfo) Locals() int
- func (fi *FuncInfo) NumFile() uint32
- func (fi *FuncInfo) NumFuncdataoff() uint32
- func (fi *FuncInfo) NumInlTree() uint32
- func (fi *FuncInfo) NumPcdata() uint32
- func (fi *FuncInfo) Pcdata(k int) []byte
- func (fi *FuncInfo) Pcfile() []byte
- func (fi *FuncInfo) Pcinline() []byte
- func (fi *FuncInfo) Pcline() []byte
- func (fi *FuncInfo) Pcsp() []byte
- func (fi *FuncInfo) Preload()
- func (fi *FuncInfo) Valid() bool
- type InlTreeNode
- type Loader
- func (l *Loader) AddSym(name string, ver int, r *oReader, li int, kind int, dupok bool, ...) (Sym, bool)
- func (l *Loader) AddToSymValue(i Sym, val int64)
- func (l *Loader) AssignTextSymbolOrder(libs []*sym.Library, intlibs []bool, extsyms []Sym) []Sym
- func (l *Loader) AttrCgoExport(i Sym) bool
- func (l *Loader) AttrCgoExportDynamic(i Sym) bool
- func (l *Loader) AttrCgoExportStatic(i Sym) bool
- func (l *Loader) AttrDuplicateOK(i Sym) bool
- func (l *Loader) AttrExternal(i Sym) bool
- func (l *Loader) AttrLocal(i Sym) bool
- func (l *Loader) AttrNotInSymbolTable(i Sym) bool
- func (l *Loader) AttrOnList(i Sym) bool
- func (l *Loader) AttrReachable(i Sym) bool
- func (l *Loader) AttrReadOnly(i Sym) bool
- func (l *Loader) AttrShared(i Sym) bool
- func (l *Loader) AttrSpecial(i Sym) bool
- func (l *Loader) AttrSubSymbol(i Sym) bool
- func (l *Loader) AttrTopFrame(i Sym) bool
- func (l *Loader) AttrVisibilityHidden(i Sym) bool
- func (l *Loader) Aux2(i Sym, j int) Aux2
- func (l *Loader) CopyAttributes(src Sym, dst Sym)
- func (l *Loader) CopySym(src, dst Sym)
- func (l *Loader) CreateExtSym(name string, ver int) Sym
- func (l *Loader) CreateStaticSym(name string) Sym
- func (l *Loader) CreateSymForUpdate(name string, version int) *SymbolBuilder
- func (l *Loader) Data(i Sym) []byte
- func (l *Loader) Dump()
- func (l *Loader) DynidSyms() []Sym
- func (l *Loader) Errorf(s Sym, format string, args ...interface{})
- func (l *Loader) ExtRelocs(i Sym) ExtRelocs
- func (l *Loader) ExtractSymbols(syms *sym.Symbols)
- func (l *Loader) FreeSym(i Sym)
- func (l *Loader) FuncInfo(i Sym) FuncInfo
- func (l *Loader) GetErrorReporter() *ErrorReporter
- func (l *Loader) GetFuncDwarfAuxSyms(fnSymIdx Sym) (auxDwarfInfo, auxDwarfLoc, auxDwarfRanges, auxDwarfLines Sym)
- func (l *Loader) InitExtRelocs()
- func (l *Loader) InitOutData()
- func (l *Loader) InitReachable()
- func (l *Loader) IsDeferReturnTramp(i Sym) bool
- func (l *Loader) IsExternal(i Sym) bool
- func (l *Loader) IsGoType(i Sym) bool
- func (l *Loader) IsItabLink(i Sym) bool
- func (l *Loader) IsNoSplit(i Sym) bool
- func (l *Loader) IsReflectMethod(i Sym) bool
- func (l *Loader) IsTypelink(i Sym) bool
- func (l *Loader) LoadFull(arch *sys.Arch, syms *sym.Symbols, needReloc, needExtReloc bool)
- func (l *Loader) LoadNonpkgSyms(arch *sys.Arch)
- func (l *Loader) Lookup(name string, ver int) Sym
- func (l *Loader) LookupOrCreateSym(name string, ver int) Sym
- func (l *Loader) MakeSymbolBuilder(name string) *SymbolBuilder
- func (l *Loader) MakeSymbolUpdater(symIdx Sym) *SymbolBuilder
- func (l *Loader) NAux(i Sym) int
- func (l *Loader) NDef() int
- func (l *Loader) NReachableSym() int
- func (l *Loader) NStrictDupMsgs() int
- func (l *Loader) NSym() int
- func (l *Loader) NewSection() *sym.Section
- func (l *Loader) OutData(i Sym) []byte
- func (l *Loader) OuterSym(i Sym) Sym
- func (l *Loader) Preload(syms *sym.Symbols, f *bio.Reader, lib *sym.Library, unit *sym.CompilationUnit, ...) goobj2.FingerprintType
- func (l *Loader) PrependSub(outer Sym, sub Sym)
- func (l *Loader) PropagateLoaderChangesToSymbols(toconvert []Sym, anonVerReplacement int) []*sym.Symbol
- func (l *Loader) PropagateSymbolChangesBackToLoader()
- func (l *Loader) RawSymName(i Sym) string
- func (l *Loader) RelocVariant(s Sym, ri int) sym.RelocVariant
- func (l *Loader) Relocs(i Sym) Relocs
- func (l *Loader) ResolveABIAlias(s Sym) Sym
- func (l *Loader) SetAttrCgoExportDynamic(i Sym, v bool)
- func (l *Loader) SetAttrCgoExportStatic(i Sym, v bool)
- func (l *Loader) SetAttrDuplicateOK(i Sym, v bool)
- func (l *Loader) SetAttrExternal(i Sym, v bool)
- func (l *Loader) SetAttrLocal(i Sym, v bool)
- func (l *Loader) SetAttrNotInSymbolTable(i Sym, v bool)
- func (l *Loader) SetAttrOnList(i Sym, v bool)
- func (l *Loader) SetAttrReachable(i Sym, v bool)
- func (l *Loader) SetAttrReadOnly(i Sym, v bool)
- func (l *Loader) SetAttrShared(i Sym, v bool)
- func (l *Loader) SetAttrSpecial(i Sym, v bool)
- func (l *Loader) SetAttrTopFrame(i Sym, v bool)
- func (l *Loader) SetAttrVisibilityHidden(i Sym, v bool)
- func (l *Loader) SetExtRelocs(i Sym, relocs []ExtReloc)
- func (l *Loader) SetGot(i Sym, v int32)
- func (l *Loader) SetIsDeferReturnTramp(i Sym, v bool)
- func (l *Loader) SetOutData(i Sym, data []byte)
- func (l *Loader) SetOuterSym(i Sym, o Sym)
- func (l *Loader) SetPlt(i Sym, v int32)
- func (l *Loader) SetRelocVariant(s Sym, ri int, v sym.RelocVariant)
- func (l *Loader) SetSymAlign(i Sym, align int32)
- func (l *Loader) SetSymDynid(i Sym, val int32)
- func (l *Loader) SetSymDynimplib(i Sym, value string)
- func (l *Loader) SetSymDynimpvers(i Sym, value string)
- func (l *Loader) SetSymElfSym(i Sym, es int32)
- func (l *Loader) SetSymElfType(i Sym, et elf.SymType)
- func (l *Loader) SetSymExtname(i Sym, value string)
- func (l *Loader) SetSymLocalElfSym(i Sym, es int32)
- func (l *Loader) SetSymLocalentry(i Sym, value uint8)
- func (l *Loader) SetSymPkg(i Sym, pkg string)
- func (l *Loader) SetSymSect(i Sym, sect *sym.Section)
- func (l *Loader) SetSymValue(i Sym, val int64)
- func (l *Loader) SortSub(s Sym) Sym
- func (l *Loader) SubSym(i Sym) Sym
- func (l *Loader) SymAddr(i Sym) int64
- func (l *Loader) SymAlign(i Sym) int32
- func (l *Loader) SymAttr(i Sym) uint8
- func (l *Loader) SymDynid(i Sym) int32
- func (l *Loader) SymDynimplib(i Sym) string
- func (l *Loader) SymDynimpvers(i Sym) string
- func (l *Loader) SymElfSym(i Sym) int32
- func (l *Loader) SymElfType(i Sym) elf.SymType
- func (l *Loader) SymExtname(i Sym) string
- func (l *Loader) SymGoType(i Sym) Sym
- func (l *Loader) SymGot(s Sym) int32
- func (l *Loader) SymLocalElfSym(i Sym) int32
- func (l *Loader) SymLocalentry(i Sym) uint8
- func (l *Loader) SymName(i Sym) string
- func (l *Loader) SymPkg(i Sym) string
- func (l *Loader) SymPlt(s Sym) int32
- func (l *Loader) SymSect(i Sym) *sym.Section
- func (l *Loader) SymSize(i Sym) int64
- func (l *Loader) SymType(i Sym) sym.SymKind
- func (l *Loader) SymUnit(i Sym) *sym.CompilationUnit
- func (l *Loader) SymValue(i Sym) int64
- func (l *Loader) SymVersion(i Sym) int
- func (l *Loader) TopLevelSym(s Sym) bool
- func (l *Loader) UndefinedRelocTargets(limit int) []Sym
- type Reloc
- type Reloc2
- type RelocByOff
- type Relocs
- type Sym
- type SymbolBuilder
- func (sb *SymbolBuilder) AddAddr(arch *sys.Arch, tgt Sym) int64
- func (sb *SymbolBuilder) AddAddrPlus(arch *sys.Arch, tgt Sym, add int64) int64
- func (sb *SymbolBuilder) AddAddrPlus4(arch *sys.Arch, tgt Sym, add int64) int64
- func (sb *SymbolBuilder) AddBytes(data []byte)
- func (sb *SymbolBuilder) AddCURelativeAddrPlus(arch *sys.Arch, tgt Sym, add int64) int64
- func (sb *SymbolBuilder) AddPCRelPlus(arch *sys.Arch, tgt Sym, add int64) int64
- func (sb *SymbolBuilder) AddRel(typ objabi.RelocType) (Reloc2, int)
- func (sb *SymbolBuilder) AddReloc(r Reloc) uint32
- func (sb *SymbolBuilder) AddRelocs(n int) Relocs
- func (sb *SymbolBuilder) AddSize(arch *sys.Arch, tgt Sym) int64
- func (sb *SymbolBuilder) AddSymRef(arch *sys.Arch, tgt Sym, add int64, typ objabi.RelocType, rsize int) int64
- func (sb *SymbolBuilder) AddUint(arch *sys.Arch, v uint64) int64
- func (sb *SymbolBuilder) AddUint16(arch *sys.Arch, v uint16) int64
- func (sb *SymbolBuilder) AddUint32(arch *sys.Arch, v uint32) int64
- func (sb *SymbolBuilder) AddUint64(arch *sys.Arch, v uint64) int64
- func (sb *SymbolBuilder) AddUint8(v uint8) int64
- func (sb *SymbolBuilder) AddUintXX(arch *sys.Arch, v uint64, wid int) int64
- func (sb *SymbolBuilder) Addstring(str string) int64
- func (sb *SymbolBuilder) Align() int32
- func (sb *SymbolBuilder) CgoExportDynamic() bool
- func (sb *SymbolBuilder) Data() []byte
- func (sb *SymbolBuilder) DuplicateOK() bool
- func (sb *SymbolBuilder) Dynimplib() string
- func (sb *SymbolBuilder) Dynimpvers() string
- func (sb *SymbolBuilder) External() bool
- func (sb *SymbolBuilder) Extname() string
- func (sb *SymbolBuilder) GoType() Sym
- func (ms SymbolBuilder) Grow(siz int64)
- func (sb *SymbolBuilder) Localentry() uint8
- func (sb *SymbolBuilder) MakeWritable()
- func (sb *SymbolBuilder) Name() string
- func (sb *SymbolBuilder) OnList() bool
- func (sb *SymbolBuilder) Outer() Sym
- func (sb *SymbolBuilder) PrependSub(sub Sym)
- func (sb *SymbolBuilder) Reachable() bool
- func (sb *SymbolBuilder) ReadOnly() bool
- func (sb *SymbolBuilder) Relocs() Relocs
- func (sb *SymbolBuilder) Sect() *sym.Section
- func (sb *SymbolBuilder) SetAddr(arch *sys.Arch, off int64, tgt Sym) int64
- func (sb *SymbolBuilder) SetAddrPlus(arch *sys.Arch, off int64, tgt Sym, add int64) int64
- func (sb *SymbolBuilder) SetAlign(align int32)
- func (sb *SymbolBuilder) SetData(data []byte)
- func (sb *SymbolBuilder) SetDuplicateOK(v bool)
- func (sb *SymbolBuilder) SetDynimplib(value string)
- func (sb *SymbolBuilder) SetDynimpvers(value string)
- func (sb *SymbolBuilder) SetExternal(v bool)
- func (sb *SymbolBuilder) SetExtname(value string)
- func (sb *SymbolBuilder) SetGot(value int32)
- func (sb *SymbolBuilder) SetLocal(value bool)
- func (sb *SymbolBuilder) SetLocalentry(value uint8)
- func (sb *SymbolBuilder) SetNotInSymbolTable(value bool)
- func (sb *SymbolBuilder) SetOnList(v bool)
- func (sb *SymbolBuilder) SetPlt(value int32)
- func (sb *SymbolBuilder) SetReachable(v bool)
- func (sb *SymbolBuilder) SetReadOnly(v bool)
- func (sb *SymbolBuilder) SetReloc(j int, r Reloc)
- func (sb *SymbolBuilder) SetRelocAdd(i int, a int64)
- func (sb *SymbolBuilder) SetRelocSym(i int, tgt Sym)
- func (sb *SymbolBuilder) SetRelocType(i int, t objabi.RelocType)
- func (sb *SymbolBuilder) SetRelocs(rslice []Reloc)
- func (sb *SymbolBuilder) SetSect(sect *sym.Section)
- func (sb *SymbolBuilder) SetSize(size int64)
- func (sb *SymbolBuilder) SetSpecial(value bool)
- func (sb *SymbolBuilder) SetType(kind sym.SymKind)
- func (sb *SymbolBuilder) SetUint(arch *sys.Arch, r int64, v uint64) int64
- func (sb *SymbolBuilder) SetUint16(arch *sys.Arch, r int64, v uint16) int64
- func (sb *SymbolBuilder) SetUint32(arch *sys.Arch, r int64, v uint32) int64
- func (sb *SymbolBuilder) SetUint8(arch *sys.Arch, r int64, v uint8) int64
- func (sb *SymbolBuilder) SetValue(v int64)
- func (sb *SymbolBuilder) SetVisibilityHidden(value bool)
- func (sb *SymbolBuilder) Size() int64
- func (sb *SymbolBuilder) SortRelocs()
- func (sb *SymbolBuilder) SortSub()
- func (sb *SymbolBuilder) Sub() Sym
- func (sb *SymbolBuilder) SubSym() Sym
- func (sb *SymbolBuilder) Sym() Sym
- func (sb *SymbolBuilder) Type() sym.SymKind
- func (sb *SymbolBuilder) Value() int64
- func (sb *SymbolBuilder) Version() int
- func (sb *SymbolBuilder) VisibilityHidden() bool
Constants ¶
const ( // Loader.flags FlagStrictDups = 1 << iota )
Variables ¶
This section is empty.
Functions ¶
func GenAddAddrPlusFunc ¶ added in go1.15
func GenAddAddrPlusFunc(internalExec bool) func(s *SymbolBuilder, arch *sys.Arch, tgt Sym, add int64) int64
GenAddAddrPlusFunc returns a function to be called when capturing a function symbol's address. In later stages of the link (when address assignment is done) when doing internal linking and targeting an executable, we can just emit the address of a function directly instead of generating a relocation. Clients can call this function (setting 'internalExec' based on build mode and target) and then invoke the returned function in roughly the same way that loader.*SymbolBuilder.AddAddrPlus would be used.
Types ¶
type Aux2 ¶ added in go1.15
Aux2 holds a "handle" to access an aux symbol record from an object file.
type Bitmap ¶ added in go1.15
type Bitmap []uint32
func MakeBitmap ¶ added in go1.15
type ErrorReporter ¶ added in go1.15
type ErrorReporter struct { AfterErrorAction func() // contains filtered or unexported fields }
ErrorReporter is a helper class for reporting errors.
func (*ErrorReporter) Errorf ¶ added in go1.15
func (reporter *ErrorReporter) Errorf(s Sym, format string, args ...interface{})
Errorf method logs an error message.
After each error, the error actions function will be invoked; this will either terminate the link immediately (if -h option given) or it will keep a count and exit if more than 20 errors have been printed.
Logging an error means that on exit cmd/link will delete any output file and return a non-zero error code.
type ExtRelocView ¶ added in go1.15
ExtRelocView is a view of an external relocation. It is intended to be constructed on the fly, such as ExtRelocs.At. It is not the data structure used to store the payload internally.
type ExtRelocs ¶ added in go1.15
type ExtRelocs struct {
// contains filtered or unexported fields
}
ExtRelocs represents the set of external relocations of a symbol.
func (ExtRelocs) At ¶ added in go1.15
func (ers ExtRelocs) At(j int) ExtRelocView
type FuncInfo ¶ added in go1.15
type FuncInfo struct {
// contains filtered or unexported fields
}
FuncInfo provides hooks to access goobj2.FuncInfo in the objects.
func (*FuncInfo) Funcdataoff ¶ added in go1.15
func (*FuncInfo) InlTree ¶ added in go1.15
func (fi *FuncInfo) InlTree(k int) InlTreeNode
func (*FuncInfo) NumFuncdataoff ¶ added in go1.15
func (*FuncInfo) NumInlTree ¶ added in go1.15
type InlTreeNode ¶ added in go1.15
type Loader ¶
type Loader struct { Syms []*sym.Symbol // indexed symbols. XXX we still make sym.Symbol for now. // 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 SymLookup func(name string, ver int) *sym.Symbol // contains filtered or unexported fields }
A Loader loads new object files and resolves indexed symbol references.
Notes on the layout of global symbol index space:
- Go object files are read before host object files; each Go object read adds its defined package symbols to the global index space. Nonpackage symbols are not yet added.
- In loader.LoadNonpkgSyms, add non-package defined symbols and references in all object files to the global index space.
- Host object file loading happens; the host object loader does a name/version lookup for each symbol it finds; this can wind up extending the external symbol index space range. The host object loader stores symbol payloads in loader.payloads using SymbolBuilder.
- For now, in loader.LoadFull we convert all symbols (Go + external) to sym.Symbols.
- At some point (when the wayfront is pushed through all of the linker), all external symbols will be payload-based, and we can get rid of the loader.Syms array.
- Each symbol gets a unique global index. For duplicated and overwriting/overwritten symbols, the second (or later) appearance of the symbol gets the same global index as the first appearance.
func NewLoader ¶
func NewLoader(flags uint32, elfsetstring elfsetstringFunc, reporter *ErrorReporter) *Loader
func (*Loader) AddSym ¶
func (l *Loader) AddSym(name string, ver int, r *oReader, li int, kind int, dupok bool, typ sym.SymKind) (Sym, bool)
Add a symbol from an object file, return the global index and whether it is added. If the symbol already exist, it returns the index of that symbol.
func (*Loader) AddToSymValue ¶ added in go1.15
AddToSymValue adds to the value of the i-th symbol. i is the global index.
func (*Loader) AssignTextSymbolOrder ¶ added in go1.15
AssignTextSymbolOrder populates the Textp2 slices within each library and compilation unit, insuring that packages are laid down in dependency order (internal first, then everything else). Return value is a slice of all text syms.
func (*Loader) AttrCgoExport ¶ added in go1.15
func (*Loader) AttrCgoExportDynamic ¶ added in go1.15
AttrCgoExportDynamic returns true for a symbol that has been specially marked via the "cgo_export_dynamic" compiler directive written by cgo (in response to //export directives in the source).
func (*Loader) AttrCgoExportStatic ¶ added in go1.15
AttrCgoExportStatic returns true for a symbol that has been specially marked via the "cgo_export_static" directive written by cgo.
func (*Loader) AttrDuplicateOK ¶ added in go1.15
AttrDuplicateOK returns true for a symbol that can be present in multiple object files.
func (*Loader) AttrExternal ¶ added in go1.15
AttrExternal returns true for function symbols loaded from host object files.
func (*Loader) AttrLocal ¶ added in go1.15
AttrLocal returns true for symbols that are only visible within the module (executable or shared library) being linked. This attribute is applied to thunks and certain other linker-generated symbols.
func (*Loader) AttrNotInSymbolTable ¶ added in go1.15
AttrNotInSymbolTable returns true for symbols that should not be added to the symbol table of the final generated load module.
func (*Loader) AttrOnList ¶ added in go1.15
AttrOnList returns true for symbols that are on some list (such as the list of all text symbols, or one of the lists of data symbols) and is consulted to avoid bugs where a symbol is put on a list twice.
func (*Loader) AttrReachable ¶ added in go1.15
AttrReachable returns true for symbols that are transitively referenced from the entry points. Unreachable symbols are not written to the output.
func (*Loader) AttrReadOnly ¶ added in go1.15
AttrReadOnly returns true for a symbol whose underlying data is stored via a read-only mmap.
func (*Loader) AttrShared ¶ added in go1.15
AttrShared returns true for symbols compiled with the -shared option.
func (*Loader) AttrSpecial ¶ added in go1.15
AttrSpecial returns true for a symbols that do not have their address (i.e. Value) computed by the usual mechanism of data.go:dodata() & data.go:address().
func (*Loader) AttrSubSymbol ¶ added in go1.15
func (*Loader) AttrTopFrame ¶ added in go1.15
AttrTopFrame returns true for a function symbol that is an entry point, meaning that unwinders should stop when they hit this function.
func (*Loader) AttrVisibilityHidden ¶ added in go1.15
AttrVisibilityHidden symbols returns true for ELF symbols with visibility set to STV_HIDDEN. They become local symbols in the final executable. Only relevant when internally linking on an ELF platform.
func (*Loader) Aux2 ¶ added in go1.15
Returns the "handle" to the j-th aux symbol of the i-th symbol.
func (*Loader) CopyAttributes ¶ added in go1.15
CopyAttributes copies over all of the attributes of symbol 'src' to symbol 'dst'.
func (*Loader) CopySym ¶ added in go1.15
Copy the payload of symbol src to dst. Both src and dst must be external symbols. The intended use case is that when building/linking against a shared library, where we do symbol name mangling, the Go object file may have reference to the original symbol name whereas the shared library provides a symbol with the mangled name. When we do mangling, we copy payload of mangled to original.
func (*Loader) CreateExtSym ¶ added in go1.15
CreateExtSym creates a new external symbol with the specified name without adding it to any lookup tables, returning a Sym index for it.
func (*Loader) CreateStaticSym ¶ added in go1.15
CreateStaticSym creates a new static symbol with the specified name without adding it to any lookup tables, returning a Sym index for it.
func (*Loader) CreateSymForUpdate ¶ added in go1.15
func (l *Loader) CreateSymForUpdate(name string, version int) *SymbolBuilder
CreateSymForUpdate creates a symbol with given name and version, returns a CreateSymForUpdate for update. If the symbol already exists, it will update in-place.
func (*Loader) DynidSyms ¶ added in go1.15
DynIdSyms returns the set of symbols for which dynID is set to an interesting (non-default) value. This is expected to be a fairly small set.
func (*Loader) Errorf ¶ added in go1.15
Errorf method logs an error message. See ErrorReporter.Errorf for details.
func (*Loader) ExtRelocs ¶ added in go1.15
ExtRelocs returns the external relocations of the i-th symbol.
func (*Loader) ExtractSymbols ¶
ExtractSymbols grabs the symbols out of the loader for work that hasn't been ported to the new symbol type.
func (*Loader) GetErrorReporter ¶ added in go1.15
func (l *Loader) GetErrorReporter() *ErrorReporter
GetErrorReporter returns the loader's associated error reporter.
func (*Loader) GetFuncDwarfAuxSyms ¶ added in go1.15
func (l *Loader) GetFuncDwarfAuxSyms(fnSymIdx Sym) (auxDwarfInfo, auxDwarfLoc, auxDwarfRanges, auxDwarfLines Sym)
GetFuncDwarfAuxSyms collects and returns the auxiliary DWARF symbols associated with a given function symbol. Prior to the introduction of the loader, this was done purely using name lookups, e.f. for function with name XYZ we would then look up go.info.XYZ, etc. FIXME: once all of dwarfgen is converted over to the loader, it would save some space to make these aux symbols nameless.
func (*Loader) InitExtRelocs ¶ added in go1.15
func (l *Loader) InitExtRelocs()
InitExtRelocs initialize the slice used to store external relocations.
func (*Loader) InitOutData ¶ added in go1.15
func (l *Loader) InitOutData()
InitOutData initializes the slice used to store symbol output data.
func (*Loader) InitReachable ¶
func (l *Loader) InitReachable()
Initialize Reachable bitmap and its siblings for running deadcode pass.
func (*Loader) IsDeferReturnTramp ¶ added in go1.15
Return whether this is a trampoline of a deferreturn call.
func (*Loader) IsExternal ¶
func (*Loader) IsItabLink ¶
Returns whether this is a "go.itablink.*" symbol.
func (*Loader) IsReflectMethod ¶
Returns whether the i-th symbol has ReflectMethod attribute set.
func (*Loader) IsTypelink ¶ added in go1.15
Returns whether this symbol should be included in typelink.
func (*Loader) LoadNonpkgSyms ¶ added in go1.15
Add non-package symbols and references to external symbols (which are always named).
func (*Loader) Lookup ¶
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) LookupOrCreateSym ¶ added in go1.15
LookupOrCreateSym looks up the symbol with the specified name/version, returning its Sym index if found. If the lookup fails, a new external Sym will be created, entered into the lookup tables, and returned.
func (*Loader) MakeSymbolBuilder ¶ added in go1.15
func (l *Loader) MakeSymbolBuilder(name string) *SymbolBuilder
MakeSymbolBuilder creates a symbol builder for use in constructing an entirely new symbol.
func (*Loader) MakeSymbolUpdater ¶ added in go1.15
func (l *Loader) MakeSymbolUpdater(symIdx Sym) *SymbolBuilder
MakeSymbolUpdater creates a symbol builder helper for an existing symbol 'symIdx'. If 'symIdx' is not an external symbol, then create a clone of it (copy name, properties, etc) fix things up so that the lookup tables and caches point to the new version, not the old version.
func (*Loader) NReachableSym ¶ added in go1.15
Number of reachable symbols.
func (*Loader) NStrictDupMsgs ¶
func (*Loader) NewSection ¶ added in go1.15
NewSection creates a new (output) section.
func (*Loader) Preload ¶
func (l *Loader) Preload(syms *sym.Symbols, f *bio.Reader, lib *sym.Library, unit *sym.CompilationUnit, length int64) goobj2.FingerprintType
Preload a package: add autolibs, add defined package symbols to the symbol table. Does not add non-package symbols yet, which will be done in LoadNonpkgSyms. Does not read symbol data. Returns the fingerprint of the object.
func (*Loader) PrependSub ¶ added in go1.15
PrependSub prepends 'sub' onto the sub list for outer symbol 'outer'. Will panic if 'sub' already has an outer sym or sub sym. FIXME: should this be instead a method on SymbolBuilder?
func (*Loader) PropagateLoaderChangesToSymbols ¶ added in go1.15
func (*Loader) PropagateSymbolChangesBackToLoader ¶ added in go1.15
func (l *Loader) PropagateSymbolChangesBackToLoader()
PropagateSymbolChangesBackToLoader is a temporary shim function that copies over a given sym.Symbol into the equivalent representation in the loader world. The intent is to enable converting a given linker phase/pass from dealing with sym.Symbol's to a modernized pass that works with loader.Sym, in cases where the "loader.Sym wavefront" has not yet reached the pass in question. For such work the recipe is to first call PropagateSymbolChangesBackToLoader(), then exexute the pass working with the loader, then call PropagateLoaderChangesToSymbols to copy the changes made by the pass back to the sym.Symbol world.
func (*Loader) RawSymName ¶
Returns the raw (unpatched) name of the i-th symbol.
func (*Loader) RelocVariant ¶ added in go1.15
func (l *Loader) RelocVariant(s Sym, ri int) sym.RelocVariant
RelocVariant returns the 'variant' property of a relocation on some specific symbol.
func (*Loader) ResolveABIAlias ¶ added in go1.15
ResolveABIAlias given a symbol returns the ABI alias target of that symbol. If the sym in question is not an alias, the sym itself is returned.
func (*Loader) SetAttrCgoExportDynamic ¶ added in go1.15
SetAttrCgoExportDynamic sets the "cgo_export_dynamic" for a symbol (see AttrCgoExportDynamic).
func (*Loader) SetAttrCgoExportStatic ¶ added in go1.15
SetAttrCgoExportStatic sets the "cgo_export_static" for a symbol (see AttrCgoExportStatic).
func (*Loader) SetAttrDuplicateOK ¶ added in go1.15
SetAttrDuplicateOK sets the "duplicate OK" property for an external symbol (see AttrDuplicateOK).
func (*Loader) SetAttrExternal ¶ added in go1.15
SetAttrExternal sets the "external" property for an host object symbol (see AttrExternal).
func (*Loader) SetAttrLocal ¶ added in go1.15
SetAttrLocal the "local" property for a symbol (see AttrLocal above).
func (*Loader) SetAttrNotInSymbolTable ¶ added in go1.15
SetAttrNotInSymbolTable the "not in symtab" property for a symbol (see AttrNotInSymbolTable above).
func (*Loader) SetAttrOnList ¶ added in go1.15
SetAttrOnList sets the "on list" property for a symbol (see AttrOnList).
func (*Loader) SetAttrReachable ¶ added in go1.15
SetAttrReachable sets the reachability property for a symbol (see AttrReachable).
func (*Loader) SetAttrReadOnly ¶ added in go1.15
SetAttrReadOnly sets the "data is read only" property for a symbol (see AttrReadOnly).
func (*Loader) SetAttrShared ¶ added in go1.15
SetAttrShared sets the "shared" property for an external symbol (see AttrShared).
func (*Loader) SetAttrSpecial ¶ added in go1.15
SetAttrSpecial sets the "special" property for a symbol (see AttrSpecial).
func (*Loader) SetAttrTopFrame ¶ added in go1.15
SetAttrTopFrame sets the "top frame" property for a symbol (see AttrTopFrame).
func (*Loader) SetAttrVisibilityHidden ¶ added in go1.15
SetAttrVisibilityHidden sets the "hidden visibility" property for a symbol (see AttrVisibilityHidden).
func (*Loader) SetExtRelocs ¶ added in go1.15
SetExtRelocs sets the external relocations of the i-th symbol. i is global index.
func (*Loader) SetIsDeferReturnTramp ¶ added in go1.15
Set that i is a trampoline of a deferreturn call.
func (*Loader) SetOutData ¶ added in go1.15
SetOutData sets the position of the data of the i-th symbol in the output buffer. i is global index.
func (*Loader) SetOuterSym ¶ added in go1.15
SetOuterSym sets the outer symbol of i to o (without setting sub symbols).
func (*Loader) SetRelocVariant ¶ added in go1.15
func (l *Loader) SetRelocVariant(s Sym, ri int, v sym.RelocVariant)
SetRelocVariant sets the 'variant' property of a relocation on some specific symbol.
func (*Loader) SetSymAlign ¶ added in go1.15
SetSymAlign sets the alignment for a symbol.
func (*Loader) SetSymDynid ¶ added in go1.15
SetSymDynid sets the "dynid" property for a symbol.
func (*Loader) SetSymDynimplib ¶ added in go1.15
SetSymDynimplib sets the "dynimplib" attribute for a symbol.
func (*Loader) SetSymDynimpvers ¶ added in go1.15
SetSymDynimpvers sets the "dynimpvers" attribute for a symbol.
func (*Loader) SetSymElfSym ¶ added in go1.15
SetSymElfSym sets the elf symbol index for a symbol.
func (*Loader) SetSymElfType ¶ added in go1.15
SetSymElfType sets the elf type attribute for a symbol.
func (*Loader) SetSymExtname ¶ added in go1.15
SetSymExtname sets the "extname" attribute for a symbol.
func (*Loader) SetSymLocalElfSym ¶ added in go1.15
SetSymLocalElfSym sets the "local" elf symbol index for a symbol.
func (*Loader) SetSymLocalentry ¶ added in go1.15
SetSymLocalentry sets the "local entry" attribute for a symbol.
func (*Loader) SetSymPkg ¶ added in go1.15
SetSymPkg sets the package/library for a symbol. This is needed mainly for external symbols, specifically those imported from shared libraries.
func (*Loader) SetSymSect ¶ added in go1.15
SetSymValue sets the section of the i-th symbol. i is global index.
func (*Loader) SetSymValue ¶ added in go1.15
SetSymValue sets the value of the i-th symbol. i is global index.
func (*Loader) SortSub ¶ added in go1.15
SortSub walks through the sub-symbols for 's' and sorts them in place by increasing value. Return value is the new sub symbol for the specified outer symbol.
func (*Loader) SymAddr ¶ added in go1.15
SymAddr checks that a symbol is reachable, and returns its value.
func (*Loader) SymDynid ¶ added in go1.15
SymDynid returns the "dynid" property for the specified symbol.
func (*Loader) SymDynimplib ¶ added in go1.15
SymDynImplib returns the "dynimplib" attribute for the specified symbol, making up a portion of the info for a symbol specified on a "cgo_import_dynamic" compiler directive.
func (*Loader) SymDynimpvers ¶ added in go1.15
SymDynimpvers returns the "dynimpvers" attribute for the specified symbol, making up a portion of the info for a symbol specified on a "cgo_import_dynamic" compiler directive.
func (*Loader) SymElfSym ¶ added in go1.15
SymElfSym returns the ELF symbol index for a given loader symbol, assigned during ELF symtab generation.
func (*Loader) SymElfType ¶ added in go1.15
SymElfType returns the previously recorded ELF type for a symbol (used only for symbols read from shared libraries by ldshlibsyms). It is not set for symbols defined by the packages being linked or by symbols read by ldelf (and so is left as elf.STT_NOTYPE).
func (*Loader) SymExtname ¶ added in go1.15
SymExtname returns the "extname" value for the specified symbol.
func (*Loader) SymGoType ¶ added in go1.15
SymGoType returns the 'Gotype' property for a given symbol (set by the Go compiler for variable symbols). This version relies on reading aux symbols for the target sym -- it could be that a faster approach would be to check for gotype during preload and copy the results in to a map (might want to try this at some point and see if it helps speed things up).
func (*Loader) SymLocalElfSym ¶ added in go1.15
SymLocalElfSym returns the "local" ELF symbol index for a given loader symbol, assigned during ELF symtab generation.
func (*Loader) SymLocalentry ¶ added in go1.15
SymLocalentry returns the "local entry" value for the specified symbol.
func (*Loader) SymPkg ¶ added in go1.15
SymPkg returns the package where the symbol came from (for regular compiler-generated Go symbols), but in the case of building with "-linkshared" (when a symbol is read from a shared library), will hold the library name. NOTE: this correspondes to sym.Symbol.File field.
func (*Loader) SymSect ¶ added in go1.15
SymValue returns the section of the i-th symbol. i is global index.
func (*Loader) SymUnit ¶ added in go1.15
func (l *Loader) SymUnit(i Sym) *sym.CompilationUnit
SymUnit returns the compilation unit for a given symbol (which will typically be nil for external or linker-manufactured symbols).
func (*Loader) SymValue ¶ added in go1.15
SymValue returns the value of the i-th symbol. i is global index.
func (*Loader) SymVersion ¶ added in go1.15
Returns the version of the i-th symbol.
func (*Loader) TopLevelSym ¶ added in go1.15
TopLevelSym tests a symbol (by name and kind) to determine whether the symbol first class sym (participating in the link) or is an anonymous aux or sub-symbol containing some sub-part or payload of another symbol.
func (*Loader) UndefinedRelocTargets ¶ added in go1.15
UndefinedRelocTargets iterates through the global symbol index space, looking for symbols with relocations targeting undefined references. The linker's loadlib method uses this to determine if there are unresolved references to functions in system libraries (for example, libgcc.a), presumably due to CGO code. Return value is a list of loader.Sym's corresponding to the undefined cross-refs. The "limit" param controls the maximum number of results returned; if "limit" is -1, then all undefs are returned.
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 Reloc2 ¶ added in go1.15
Reloc2 holds a "handle" to access a relocation record from an object file.
type RelocByOff ¶ added in go1.15
type RelocByOff []Reloc
func (RelocByOff) Len ¶ added in go1.15
func (x RelocByOff) Len() int
func (RelocByOff) Less ¶ added in go1.15
func (x RelocByOff) Less(i, j int) bool
func (RelocByOff) Swap ¶ added in go1.15
func (x RelocByOff) Swap(i, j int)
type Relocs ¶
type Relocs struct {
// 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.
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.
type SymbolBuilder ¶ added in go1.15
type SymbolBuilder struct {
// contains filtered or unexported fields
}
SymbolBuilder is a helper designed to help with the construction of new symbol contents.
func (*SymbolBuilder) AddAddr ¶ added in go1.15
func (sb *SymbolBuilder) AddAddr(arch *sys.Arch, tgt Sym) int64
func (*SymbolBuilder) AddAddrPlus ¶ added in go1.15
func (*SymbolBuilder) AddAddrPlus4 ¶ added in go1.15
func (*SymbolBuilder) AddBytes ¶ added in go1.15
func (sb *SymbolBuilder) AddBytes(data []byte)
func (*SymbolBuilder) AddCURelativeAddrPlus ¶ added in go1.15
func (*SymbolBuilder) AddPCRelPlus ¶ added in go1.15
func (*SymbolBuilder) AddRel ¶ added in go1.15
func (sb *SymbolBuilder) AddRel(typ objabi.RelocType) (Reloc2, int)
Add a relocation with given type, return its handle and index (to set other fields).
func (*SymbolBuilder) AddReloc ¶ added in go1.15
func (sb *SymbolBuilder) AddReloc(r Reloc) uint32
AddReloc appends the specified reloc to the symbols list of relocations. Return value is the index of the newly created reloc.
func (*SymbolBuilder) AddRelocs ¶ added in go1.15
func (sb *SymbolBuilder) AddRelocs(n int) Relocs
Add n relocations, return a handle to the relocations.
func (*SymbolBuilder) AddSize ¶ added in go1.15
func (sb *SymbolBuilder) AddSize(arch *sys.Arch, tgt Sym) int64
func (*SymbolBuilder) AddSymRef ¶ added in go1.15
func (sb *SymbolBuilder) AddSymRef(arch *sys.Arch, tgt Sym, add int64, typ objabi.RelocType, rsize int) int64
Add a symbol reference (relocation) with given type, addend, and size (the most generic form).
func (*SymbolBuilder) AddUint ¶ added in go1.15
func (sb *SymbolBuilder) AddUint(arch *sys.Arch, v uint64) int64
func (*SymbolBuilder) AddUint16 ¶ added in go1.15
func (sb *SymbolBuilder) AddUint16(arch *sys.Arch, v uint16) int64
func (*SymbolBuilder) AddUint32 ¶ added in go1.15
func (sb *SymbolBuilder) AddUint32(arch *sys.Arch, v uint32) int64
func (*SymbolBuilder) AddUint64 ¶ added in go1.15
func (sb *SymbolBuilder) AddUint64(arch *sys.Arch, v uint64) int64
func (*SymbolBuilder) AddUint8 ¶ added in go1.15
func (sb *SymbolBuilder) AddUint8(v uint8) int64
func (*SymbolBuilder) Addstring ¶ added in go1.15
func (sb *SymbolBuilder) Addstring(str string) int64
func (*SymbolBuilder) Align ¶ added in go1.15
func (sb *SymbolBuilder) Align() int32
func (*SymbolBuilder) CgoExportDynamic ¶ added in go1.15
func (sb *SymbolBuilder) CgoExportDynamic() bool
func (*SymbolBuilder) Data ¶ added in go1.15
func (sb *SymbolBuilder) Data() []byte
func (*SymbolBuilder) DuplicateOK ¶ added in go1.15
func (sb *SymbolBuilder) DuplicateOK() bool
func (*SymbolBuilder) Dynimplib ¶ added in go1.15
func (sb *SymbolBuilder) Dynimplib() string
func (*SymbolBuilder) Dynimpvers ¶ added in go1.15
func (sb *SymbolBuilder) Dynimpvers() string
func (*SymbolBuilder) External ¶ added in go1.15
func (sb *SymbolBuilder) External() bool
func (*SymbolBuilder) Extname ¶ added in go1.15
func (sb *SymbolBuilder) Extname() string
func (*SymbolBuilder) GoType ¶ added in go1.15
func (sb *SymbolBuilder) GoType() Sym
func (*SymbolBuilder) Localentry ¶ added in go1.15
func (sb *SymbolBuilder) Localentry() uint8
func (*SymbolBuilder) MakeWritable ¶ added in go1.15
func (sb *SymbolBuilder) MakeWritable()
func (*SymbolBuilder) Name ¶ added in go1.15
func (sb *SymbolBuilder) Name() string
func (*SymbolBuilder) OnList ¶ added in go1.15
func (sb *SymbolBuilder) OnList() bool
func (*SymbolBuilder) Outer ¶ added in go1.15
func (sb *SymbolBuilder) Outer() Sym
func (*SymbolBuilder) PrependSub ¶ added in go1.15
func (sb *SymbolBuilder) PrependSub(sub Sym)
func (*SymbolBuilder) Reachable ¶ added in go1.15
func (sb *SymbolBuilder) Reachable() bool
func (*SymbolBuilder) ReadOnly ¶ added in go1.15
func (sb *SymbolBuilder) ReadOnly() bool
func (*SymbolBuilder) Relocs ¶ added in go1.15
func (sb *SymbolBuilder) Relocs() Relocs
func (*SymbolBuilder) Sect ¶ added in go1.15
func (sb *SymbolBuilder) Sect() *sym.Section
func (*SymbolBuilder) SetAddrPlus ¶ added in go1.15
func (*SymbolBuilder) SetAlign ¶ added in go1.15
func (sb *SymbolBuilder) SetAlign(align int32)
func (*SymbolBuilder) SetData ¶ added in go1.15
func (sb *SymbolBuilder) SetData(data []byte)
func (*SymbolBuilder) SetDuplicateOK ¶ added in go1.15
func (sb *SymbolBuilder) SetDuplicateOK(v bool)
func (*SymbolBuilder) SetDynimplib ¶ added in go1.15
func (sb *SymbolBuilder) SetDynimplib(value string)
func (*SymbolBuilder) SetDynimpvers ¶ added in go1.15
func (sb *SymbolBuilder) SetDynimpvers(value string)
func (*SymbolBuilder) SetExternal ¶ added in go1.15
func (sb *SymbolBuilder) SetExternal(v bool)
func (*SymbolBuilder) SetExtname ¶ added in go1.15
func (sb *SymbolBuilder) SetExtname(value string)
func (*SymbolBuilder) SetGot ¶ added in go1.15
func (sb *SymbolBuilder) SetGot(value int32)
func (*SymbolBuilder) SetLocal ¶ added in go1.15
func (sb *SymbolBuilder) SetLocal(value bool)
func (*SymbolBuilder) SetLocalentry ¶ added in go1.15
func (sb *SymbolBuilder) SetLocalentry(value uint8)
func (*SymbolBuilder) SetNotInSymbolTable ¶ added in go1.15
func (sb *SymbolBuilder) SetNotInSymbolTable(value bool)
func (*SymbolBuilder) SetOnList ¶ added in go1.15
func (sb *SymbolBuilder) SetOnList(v bool)
func (*SymbolBuilder) SetPlt ¶ added in go1.15
func (sb *SymbolBuilder) SetPlt(value int32)
func (*SymbolBuilder) SetReachable ¶ added in go1.15
func (sb *SymbolBuilder) SetReachable(v bool)
func (*SymbolBuilder) SetReadOnly ¶ added in go1.15
func (sb *SymbolBuilder) SetReadOnly(v bool)
func (*SymbolBuilder) SetReloc ¶ added in go1.15
func (sb *SymbolBuilder) SetReloc(j int, r Reloc)
Update the j-th relocation in place.
func (*SymbolBuilder) SetRelocAdd ¶ added in go1.15
func (sb *SymbolBuilder) SetRelocAdd(i int, a int64)
SetRelocAdd sets the addend of the 'i'-th relocation on this sym to 'a'
func (*SymbolBuilder) SetRelocSym ¶ added in go1.15
func (sb *SymbolBuilder) SetRelocSym(i int, tgt Sym)
SetRelocSym sets the target sym of the 'i'-th relocation on this sym to 's'
func (*SymbolBuilder) SetRelocType ¶ added in go1.15
func (sb *SymbolBuilder) SetRelocType(i int, t objabi.RelocType)
SetRelocType sets the type of the 'i'-th relocation on this sym to 't'
func (*SymbolBuilder) SetRelocs ¶ added in go1.15
func (sb *SymbolBuilder) SetRelocs(rslice []Reloc)
func (*SymbolBuilder) SetSect ¶ added in go1.15
func (sb *SymbolBuilder) SetSect(sect *sym.Section)
func (*SymbolBuilder) SetSize ¶ added in go1.15
func (sb *SymbolBuilder) SetSize(size int64)
func (*SymbolBuilder) SetSpecial ¶ added in go1.15
func (sb *SymbolBuilder) SetSpecial(value bool)
func (*SymbolBuilder) SetType ¶ added in go1.15
func (sb *SymbolBuilder) SetType(kind sym.SymKind)
func (*SymbolBuilder) SetValue ¶ added in go1.15
func (sb *SymbolBuilder) SetValue(v int64)
func (*SymbolBuilder) SetVisibilityHidden ¶ added in go1.15
func (sb *SymbolBuilder) SetVisibilityHidden(value bool)
func (*SymbolBuilder) Size ¶ added in go1.15
func (sb *SymbolBuilder) Size() int64
func (*SymbolBuilder) SortRelocs ¶ added in go1.15
func (sb *SymbolBuilder) SortRelocs()
Sort relocations by offset.
func (*SymbolBuilder) SortSub ¶ added in go1.15
func (sb *SymbolBuilder) SortSub()
func (*SymbolBuilder) Sub ¶ added in go1.15
func (sb *SymbolBuilder) Sub() Sym
func (*SymbolBuilder) SubSym ¶ added in go1.15
func (sb *SymbolBuilder) SubSym() Sym
func (*SymbolBuilder) Sym ¶ added in go1.15
func (sb *SymbolBuilder) Sym() Sym
func (*SymbolBuilder) Type ¶ added in go1.15
func (sb *SymbolBuilder) Type() sym.SymKind
func (*SymbolBuilder) Value ¶ added in go1.15
func (sb *SymbolBuilder) Value() int64
func (*SymbolBuilder) Version ¶ added in go1.15
func (sb *SymbolBuilder) Version() int
func (*SymbolBuilder) VisibilityHidden ¶ added in go1.15
func (sb *SymbolBuilder) VisibilityHidden() bool