loader

package standard library
go1.23.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 3, 2024 License: BSD-3-Clause Imports: 16 Imported by: 0

Documentation

Index

Constants

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

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 Aux added in go1.16

type Aux struct {
	*goobj.Aux
	// contains filtered or unexported fields
}

Aux holds a "handle" to access an aux symbol record from an object file.

func (Aux) Sym added in go1.16

func (a Aux) Sym() Sym

type Bitmap added in go1.15

type Bitmap []uint32

func MakeBitmap added in go1.15

func MakeBitmap(n int) Bitmap

func (Bitmap) Count added in go1.15

func (bm Bitmap) Count() int

return the number of bits set.

func (Bitmap) Has added in go1.15

func (bm Bitmap) Has(i Sym) bool

whether the i-th bit is set.

func (Bitmap) Len added in go1.15

func (bm Bitmap) Len() int

return current length of bitmap in bits.

func (Bitmap) Set added in go1.15

func (bm Bitmap) Set(i Sym)

set the i-th bit.

func (Bitmap) Unset added in go1.15

func (bm Bitmap) Unset(i Sym)

unset the i-th bit.

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 ExtReloc added in go1.15

type ExtReloc struct {
	Xsym Sym
	Xadd int64
	Type objabi.RelocType
	Size uint8
}

ExtReloc contains the payload for an external relocation.

type FuncInfo added in go1.15

type FuncInfo struct {
	// contains filtered or unexported fields
}

FuncInfo provides hooks to access goobj.FuncInfo in the objects.

func (*FuncInfo) Args added in go1.15

func (fi *FuncInfo) Args() int

func (*FuncInfo) File added in go1.15

func (fi *FuncInfo) File(k int) goobj.CUFileIndex

func (*FuncInfo) FuncFlag added in go1.17

func (fi *FuncInfo) FuncFlag() abi.FuncFlag

func (*FuncInfo) FuncID added in go1.16

func (fi *FuncInfo) FuncID() abi.FuncID

func (*FuncInfo) InlTree added in go1.15

func (fi *FuncInfo) InlTree(k int) InlTreeNode

func (*FuncInfo) Locals added in go1.15

func (fi *FuncInfo) Locals() int

func (*FuncInfo) NumFile added in go1.15

func (fi *FuncInfo) NumFile() uint32

func (*FuncInfo) NumInlTree added in go1.15

func (fi *FuncInfo) NumInlTree() uint32

func (*FuncInfo) Preload added in go1.15

func (fi *FuncInfo) Preload()

Preload has to be called prior to invoking the various methods below related to pcdata, funcdataoff, files, and inltree nodes.

func (*FuncInfo) StartLine added in go1.20

func (fi *FuncInfo) StartLine() int32

func (*FuncInfo) TopFrame added in go1.17

func (fi *FuncInfo) TopFrame() bool

TopFrame returns true if the function associated with this FuncInfo is an entry point, meaning that unwinders should stop when they hit this function.

func (*FuncInfo) Valid added in go1.15

func (fi *FuncInfo) Valid() bool

type InlTreeNode added in go1.15

type InlTreeNode struct {
	Parent   int32
	File     goobj.CUFileIndex
	Line     int32
	Func     Sym
	ParentPC int32
}

type Loader

type Loader struct {

	// 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

	// CgoExports records cgo-exported symbols by SymName.
	CgoExports map[string]Sym
	// 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.

  • 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, reporter *ErrorReporter) *Loader

func (*Loader) AddCgoExport added in go1.17

func (l *Loader) AddCgoExport(s Sym)

AddCgoExport records a cgo-exported symbol in l.CgoExports. This table is used to identify the correct Go symbol ABI to use to resolve references from host objects (which don't have ABIs).

func (*Loader) AddInteriorSym added in go1.16

func (l *Loader) AddInteriorSym(container Sym, interior Sym)

AddInteriorSym sets up 'interior' as an interior symbol of container/payload symbol 'container'. An interior symbol does not itself have data, but gives a name to a subrange of the data in its container symbol. The container itself may or may not have a name. This method is intended primarily for use in the host object loaders, to capture the semantics of symbols and sections in an object file. When reading a host object file, we'll typically encounter a static section symbol (ex: ".text") containing content for a collection of functions, then a series of ELF (or macho, etc) symbol table entries each of which points into a sub-section (offset and length) of its corresponding container symbol. Within the go linker we create a loader.Sym for the container (which is expected to have the actual content/payload) and then a set of interior loader.Sym's that point into a portion of the container.

func (*Loader) AddToSymValue added in go1.15

func (l *Loader) AddToSymValue(i Sym, val int64)

AddToSymValue adds to the value of the i-th symbol. i is the global index.

func (*Loader) AssignTextSymbolOrder added in go1.15

func (l *Loader) AssignTextSymbolOrder(libs []*sym.Library, intlibs []bool, extsyms []Sym) []Sym

AssignTextSymbolOrder populates the Textp 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 (l *Loader) AttrCgoExport(i Sym) bool

func (*Loader) AttrCgoExportDynamic added in go1.15

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

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

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

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

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

AttrDuplicateOK returns true for a symbol that can be present in multiple object files.

func (*Loader) AttrExternal added in go1.15

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

AttrExternal returns true for function symbols loaded from host object files.

func (*Loader) AttrLocal added in go1.15

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

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

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

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

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

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

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

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

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

AttrReadOnly returns true for a symbol whose underlying data is stored via a read-only mmap.

func (*Loader) AttrShared added in go1.15

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

AttrShared returns true for symbols compiled with the -shared option.

func (*Loader) AttrSpecial added in go1.15

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

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 (l *Loader) AttrSubSymbol(i Sym) bool

func (*Loader) AttrUsedInIface added in go1.16

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

AttrUsedInIface returns true for a type symbol that is used in an interface.

func (*Loader) AttrVisibilityHidden added in go1.15

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

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) Aux added in go1.16

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

Returns the "handle" to the j-th aux symbol of the i-th symbol.

func (*Loader) CopySym added in go1.15

func (l *Loader) CopySym(src, dst Sym)

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

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

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

func (l *Loader) CreateStaticSym(name string) Sym

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) Data

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

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

func (*Loader) DataString added in go1.21.0

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

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

func (*Loader) Dump

func (l *Loader) Dump()

For debugging.

func (*Loader) DynidSyms added in go1.15

func (l *Loader) DynidSyms() []Sym

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

func (l *Loader) Errorf(s Sym, format string, args ...interface{})

Errorf method logs an error message. See ErrorReporter.Errorf for details.

func (*Loader) ForAllCgoExportDynamic added in go1.21.0

func (l *Loader) ForAllCgoExportDynamic(f func(Sym))

ForAllCgoExportDynamic calls f for every symbol that has been marked with the "cgo_export_dynamic" compiler directive.

func (*Loader) FreeData added in go1.16

func (l *Loader) FreeData(i Sym)

FreeData clears the symbol data of an external symbol, allowing the memory to be freed earlier. No-op for non-external symbols. i is global index.

func (*Loader) FreeSym added in go1.15

func (l *Loader) FreeSym(i Sym)

func (*Loader) FuncInfo added in go1.15

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

func (*Loader) Funcdata added in go1.18

func (l *Loader) Funcdata(i Sym, tmp []Sym) []Sym

Returns all funcdata symbols of symbol i. tmp is a scratch space.

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.

func (*Loader) GetVarDwarfAuxSym added in go1.21.0

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

func (*Loader) InitReachable

func (l *Loader) InitReachable()

Initialize Reachable bitmap and its siblings for running deadcode pass.

func (*Loader) IsDeferReturnTramp added in go1.15

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

Return whether this is a trampoline of a deferreturn call.

func (*Loader) IsDict added in go1.18

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

Returns whether this symbol is a dictionary symbol.

func (*Loader) IsExternal

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

func (*Loader) IsFileLocal added in go1.16

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

func (*Loader) IsFromAssembly added in go1.16

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

IsFromAssembly returns true if this symbol is derived from an object file generated by the Go assembler.

func (*Loader) IsGeneratedSym added in go1.16

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

IsGeneratedSym returns true if a symbol's been previously marked as a generator symbol through the SetIsGeneratedSym. The functions for generator symbols are kept in the Link context.

func (*Loader) IsGoType

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

Returns whether this is a Go type symbol.

func (*Loader) IsItab added in go1.16

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

Returns whether this symbol is an itab symbol.

func (*Loader) IsNoSplit added in go1.15

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

Returns whether the i-th symbol is nosplit.

func (*Loader) IsPkgInit added in go1.21.0

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

Returns whether this symbol is a compiler-generated package init func.

func (*Loader) IsReflectMethod

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

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

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

Returns whether this symbol should be included in typelink.

func (*Loader) LoadSyms added in go1.16

func (l *Loader) LoadSyms(arch *sys.Arch)

Add syms, hashed (content-addressable) symbols, non-package symbols, and references to external symbols (which are always named).

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) LookupOrCreateCgoExport added in go1.17

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

LookupOrCreateCgoExport is like LookupOrCreateSym, but if ver indicates a global symbol, it uses the CgoExport table to determine the appropriate symbol version (ABI) to use. ver must be either 0 or a static symbol version.

func (*Loader) LookupOrCreateSym added in go1.15

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

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) 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) NReachableSym added in go1.15

func (l *Loader) NReachableSym() int

Number of reachable symbols.

func (*Loader) NStrictDupMsgs

func (l *Loader) NStrictDupMsgs() int

func (*Loader) NSym

func (l *Loader) NSym() int

Number of total symbols.

func (*Loader) NewSection added in go1.15

func (l *Loader) NewSection() *sym.Section

NewSection creates a new (output) section.

func (*Loader) NumFuncdata added in go1.18

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

Returns the number of funcdata for symbol i.

func (*Loader) NumPcdata added in go1.18

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

Returns the number of pcdata for symbol i.

func (*Loader) OuterSym

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

OuterSym gets the outer/container symbol.

func (*Loader) PcdataAuxs added in go1.18

func (l *Loader) PcdataAuxs(i Sym, tmp []Sym) (pcsp, pcfile, pcline, pcinline Sym, pcdata []Sym)

Returns all aux symbols of per-PC data for symbol i. tmp is a scratch space for the pcdata slice.

func (*Loader) Pcsp added in go1.18

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

func (*Loader) Preload

func (l *Loader) Preload(localSymVersion int, f *bio.Reader, lib *sym.Library, unit *sym.CompilationUnit, length int64) goobj.FingerprintType

Preload a package: adds autolib. Does not add defined package or non-packaged symbols to the symbol table. These are done in LoadSyms. Does not read symbol data. Returns the fingerprint of the object.

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) Relocs

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

Relocs returns a Relocs object for the given global sym.

func (*Loader) SEHUnwindSym added in go1.21.0

func (l *Loader) SEHUnwindSym(fnSymIdx Sym) Sym

SEHUnwindSym returns the auxiliary SEH unwind symbol associated with a given function symbol.

func (*Loader) SetAttrCgoExportDynamic added in go1.15

func (l *Loader) SetAttrCgoExportDynamic(i Sym, v bool)

SetAttrCgoExportDynamic sets the "cgo_export_dynamic" for a symbol (see AttrCgoExportDynamic).

func (*Loader) SetAttrCgoExportStatic added in go1.15

func (l *Loader) SetAttrCgoExportStatic(i Sym, v bool)

SetAttrCgoExportStatic sets the "cgo_export_static" for a symbol (see AttrCgoExportStatic).

func (*Loader) SetAttrDuplicateOK added in go1.15

func (l *Loader) SetAttrDuplicateOK(i Sym, v bool)

SetAttrDuplicateOK sets the "duplicate OK" property for an external symbol (see AttrDuplicateOK).

func (*Loader) SetAttrExternal added in go1.15

func (l *Loader) SetAttrExternal(i Sym, v bool)

SetAttrExternal sets the "external" property for a host object symbol (see AttrExternal).

func (*Loader) SetAttrLocal added in go1.15

func (l *Loader) SetAttrLocal(i Sym, v bool)

SetAttrLocal the "local" property for a symbol (see AttrLocal above).

func (*Loader) SetAttrNotInSymbolTable added in go1.15

func (l *Loader) SetAttrNotInSymbolTable(i Sym, v bool)

SetAttrNotInSymbolTable the "not in symtab" property for a symbol (see AttrNotInSymbolTable above).

func (*Loader) SetAttrOnList added in go1.15

func (l *Loader) SetAttrOnList(i Sym, v bool)

SetAttrOnList sets the "on list" property for a symbol (see AttrOnList).

func (*Loader) SetAttrReachable added in go1.15

func (l *Loader) SetAttrReachable(i Sym, v bool)

SetAttrReachable sets the reachability property for a symbol (see AttrReachable).

func (*Loader) SetAttrReadOnly added in go1.15

func (l *Loader) SetAttrReadOnly(i Sym, v bool)

SetAttrReadOnly sets the "data is read only" property for a symbol (see AttrReadOnly).

func (*Loader) SetAttrShared added in go1.15

func (l *Loader) SetAttrShared(i Sym, v bool)

SetAttrShared sets the "shared" property for an external symbol (see AttrShared).

func (*Loader) SetAttrSpecial added in go1.15

func (l *Loader) SetAttrSpecial(i Sym, v bool)

SetAttrSpecial sets the "special" property for a symbol (see AttrSpecial).

func (*Loader) SetAttrUsedInIface added in go1.16

func (l *Loader) SetAttrUsedInIface(i Sym, v bool)

func (*Loader) SetAttrVisibilityHidden added in go1.15

func (l *Loader) SetAttrVisibilityHidden(i Sym, v bool)

SetAttrVisibilityHidden sets the "hidden visibility" property for a symbol (see AttrVisibilityHidden).

func (*Loader) SetCarrierSym added in go1.16

func (l *Loader) SetCarrierSym(s Sym, c Sym)

SetCarrierSym declares that 'c' is the carrier or container symbol for 's'. Carrier symbols are used in the linker to as a container for a collection of sub-symbols where the content of the sub-symbols is effectively concatenated to form the content of the carrier. The carrier is given a name in the output symbol table while the sub-symbol names are not. For example, the Go compiler emits named string symbols (type SGOSTRING) when compiling a package; after being deduplicated, these symbols are collected into a single unit by assigning them a new carrier symbol named "go:string.*" (which appears in the final symbol table for the output load module).

func (*Loader) SetGot added in go1.15

func (l *Loader) SetGot(i Sym, v int32)

SetGot sets the GOT offset of symbol i.

func (*Loader) SetIsDeferReturnTramp added in go1.15

func (l *Loader) SetIsDeferReturnTramp(i Sym, v bool)

Set that i is a trampoline of a deferreturn call.

func (*Loader) SetIsGeneratedSym added in go1.16

func (l *Loader) SetIsGeneratedSym(i Sym, v bool)

SetIsGeneratedSym marks symbols as generated symbols. Data shouldn't be stored in generated symbols, and a function is registered and called for each of these symbols.

func (*Loader) SetPlt added in go1.15

func (l *Loader) SetPlt(i Sym, v int32)

SetPlt sets the PLT offset of symbol i.

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

func (l *Loader) SetSymAlign(i Sym, align int32)

SetSymAlign sets the alignment for a symbol.

func (*Loader) SetSymDynid added in go1.15

func (l *Loader) SetSymDynid(i Sym, val int32)

SetSymDynid sets the "dynid" property for a symbol.

func (*Loader) SetSymDynimplib added in go1.15

func (l *Loader) SetSymDynimplib(i Sym, value string)

SetSymDynimplib sets the "dynimplib" attribute for a symbol.

func (*Loader) SetSymDynimpvers added in go1.15

func (l *Loader) SetSymDynimpvers(i Sym, value string)

SetSymDynimpvers sets the "dynimpvers" attribute for a symbol.

func (*Loader) SetSymElfSym added in go1.15

func (l *Loader) SetSymElfSym(i Sym, es int32)

SetSymElfSym sets the elf symbol index for a symbol.

func (*Loader) SetSymElfType added in go1.15

func (l *Loader) SetSymElfType(i Sym, et elf.SymType)

SetSymElfType sets the elf type attribute for a symbol.

func (*Loader) SetSymExtname added in go1.15

func (l *Loader) SetSymExtname(i Sym, value string)

SetSymExtname sets the "extname" attribute for a symbol.

func (*Loader) SetSymLocalElfSym added in go1.15

func (l *Loader) SetSymLocalElfSym(i Sym, es int32)

SetSymLocalElfSym sets the "local" elf symbol index for a symbol.

func (*Loader) SetSymLocalentry added in go1.15

func (l *Loader) SetSymLocalentry(i Sym, value uint8)

SetSymLocalentry sets the "local entry" offset attribute for a symbol.

func (*Loader) SetSymPkg added in go1.15

func (l *Loader) SetSymPkg(i Sym, pkg string)

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

func (l *Loader) SetSymSect(i Sym, sect *sym.Section)

SetSymSect sets the section of the i-th symbol. i is global index.

func (*Loader) SetSymValue added in go1.15

func (l *Loader) SetSymValue(i Sym, val int64)

SetSymValue sets the value of the i-th symbol. i is global index.

func (*Loader) SortSub added in go1.15

func (l *Loader) SortSub(s Sym) Sym

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) SortSyms added in go1.16

func (l *Loader) SortSyms(ss []Sym)

SortSyms sorts a list of symbols by their value.

func (*Loader) Stat added in go1.16

func (l *Loader) Stat() string

Symbol statistics.

func (*Loader) SubSym

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

SubSym gets the subsymbol for host object loaded symbols.

func (*Loader) SymAddr added in go1.15

func (l *Loader) SymAddr(i Sym) int64

SymAddr checks that a symbol is reachable, and returns its value.

func (*Loader) SymAlign added in go1.15

func (l *Loader) SymAlign(i Sym) int32

SymAlign returns the alignment for a symbol.

func (*Loader) SymAttr

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

Returns the attributes of the i-th symbol.

func (*Loader) SymDynid added in go1.15

func (l *Loader) SymDynid(i Sym) int32

SymDynid returns the "dynid" property for the specified symbol.

func (*Loader) SymDynimplib added in go1.15

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

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

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

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

func (l *Loader) SymElfSym(i Sym) int32

SymElfSym returns the ELF symbol index for a given loader symbol, assigned during ELF symtab generation.

func (*Loader) SymElfType added in go1.15

func (l *Loader) SymElfType(i Sym) elf.SymType

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

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

SymExtname returns the "extname" value for the specified symbol.

func (*Loader) SymGoType added in go1.15

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

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) SymGot added in go1.15

func (l *Loader) SymGot(s Sym) int32

SymGot returns the GOT offset of symbol s.

func (*Loader) SymLocalElfSym added in go1.15

func (l *Loader) SymLocalElfSym(i Sym) int32

SymLocalElfSym returns the "local" ELF symbol index for a given loader symbol, assigned during ELF symtab generation.

func (*Loader) SymLocalentry added in go1.15

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

SymLocalentry returns an offset in bytes of the "local entry" of a symbol.

On PPC64, a value of 1 indicates the symbol does not use or preserve a TOC pointer in R2, nor does it have a distinct local entry.

func (*Loader) SymName

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

Returns the name of the i-th symbol.

func (*Loader) SymPkg added in go1.15

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

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 corresponds to sym.Symbol.File field.

func (*Loader) SymPlt added in go1.15

func (l *Loader) SymPlt(s Sym) int32

SymPlt returns the PLT offset of symbol s.

func (*Loader) SymSect added in go1.15

func (l *Loader) SymSect(i Sym) *sym.Section

SymSect returns the section of the i-th symbol. i is global index.

func (*Loader) SymSize added in go1.15

func (l *Loader) SymSize(i Sym) int64

Returns the size of the i-th symbol.

func (*Loader) SymType

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

Returns the type of the i-th symbol.

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

func (l *Loader) SymValue(i Sym) int64

SymValue returns the value of the i-th symbol. i is global index.

func (*Loader) SymVersion added in go1.15

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

Returns the version of the i-th symbol.

func (*Loader) TopLevelSym added in go1.15

func (l *Loader) TopLevelSym(s Sym) bool

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

func (l *Loader) UndefinedRelocTargets(limit int) ([]Sym, []Sym)

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 pair of lists of loader.Sym's. First list corresponds to the corresponding to the undefined symbols themselves, the second list is the symbol that is making a reference to the undef. The "limit" param controls the maximum number of results returned; if "limit" is -1, then all undefs are returned.

func (*Loader) WasmImportSym added in go1.21.0

func (l *Loader) WasmImportSym(fnSymIdx Sym) (Sym, bool)

WasmImportSym returns the auxiliary WebAssembly import symbol associated with a given function symbol. The aux sym only exists for Go function stubs that have been annotated with the //go:wasmimport directive. The aux sym contains the information necessary for the linker to add a WebAssembly import statement. (https://webassembly.github.io/spec/core/syntax/modules.html#imports)

type Reloc

type Reloc struct {
	*goobj.Reloc
	// contains filtered or unexported fields
}

Reloc holds a "handle" to access a relocation record from an object file.

func (Reloc) IsMarker added in go1.16

func (rel Reloc) IsMarker() bool

func (Reloc) SetSym added in go1.16

func (rel Reloc) SetSym(s Sym)

func (Reloc) SetType added in go1.16

func (rel Reloc) SetType(t objabi.RelocType)

func (Reloc) Sym

func (rel Reloc) Sym() Sym

func (Reloc) Type

func (rel Reloc) Type() objabi.RelocType

func (Reloc) Weak added in go1.17

func (rel Reloc) Weak() bool

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.

func (*Relocs) At

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

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

func (*Relocs) Count

func (relocs *Relocs) Count() int

type Sym

type Sym = sym.LoaderSym

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 (sb *SymbolBuilder) AddAddrPlus(arch *sys.Arch, tgt Sym, add int64) int64

func (*SymbolBuilder) AddAddrPlus4 added in go1.15

func (sb *SymbolBuilder) AddAddrPlus4(arch *sys.Arch, tgt Sym, add int64) int64

func (*SymbolBuilder) AddBytes added in go1.15

func (sb *SymbolBuilder) AddBytes(data []byte)

func (*SymbolBuilder) AddCStringAt added in go1.18

func (sb *SymbolBuilder) AddCStringAt(off int64, str string) int64

AddCStringAt adds str plus a null terminating byte.

func (*SymbolBuilder) AddCURelativeAddrPlus added in go1.15

func (sb *SymbolBuilder) AddCURelativeAddrPlus(arch *sys.Arch, tgt Sym, add int64) int64

func (*SymbolBuilder) AddInteriorSym added in go1.16

func (sb *SymbolBuilder) AddInteriorSym(sub Sym)

func (*SymbolBuilder) AddPCRelPlus added in go1.15

func (sb *SymbolBuilder) AddPCRelPlus(arch *sys.Arch, tgt Sym, add int64) int64

func (*SymbolBuilder) AddPEImageRelativeAddrPlus added in go1.21.0

func (sb *SymbolBuilder) AddPEImageRelativeAddrPlus(arch *sys.Arch, tgt Sym, add int64) int64

func (*SymbolBuilder) AddRel added in go1.15

func (sb *SymbolBuilder) AddRel(typ objabi.RelocType) (Reloc, int)

Add a relocation with given type, return its handle and index (to set other fields).

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) AddStringAt added in go1.16

func (sb *SymbolBuilder) AddStringAt(off int64, str string) 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) AddUintXX added in go1.15

func (sb *SymbolBuilder) AddUintXX(arch *sys.Arch, v uint64, wid int) int64

func (*SymbolBuilder) AddUleb added in go1.16

func (sb *SymbolBuilder) AddUleb(v uint64)

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) Grow added in go1.15

func (ms SymbolBuilder) Grow(siz int64)

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) 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) ResetRelocs added in go1.16

func (sb *SymbolBuilder) ResetRelocs()

ResetRelocs removes all relocations on this symbol.

func (*SymbolBuilder) Sect added in go1.15

func (sb *SymbolBuilder) Sect() *sym.Section

func (*SymbolBuilder) SetAddr added in go1.15

func (sb *SymbolBuilder) SetAddr(arch *sys.Arch, off int64, tgt Sym) int64

func (*SymbolBuilder) SetAddrPlus added in go1.15

func (sb *SymbolBuilder) SetAddrPlus(arch *sys.Arch, off int64, tgt Sym, add int64) int64

func (*SymbolBuilder) SetAlign added in go1.15

func (sb *SymbolBuilder) SetAlign(align int32)

func (*SymbolBuilder) SetBytesAt added in go1.16

func (sb *SymbolBuilder) SetBytesAt(off int64, b []byte) int64

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) 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) 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) SetUint added in go1.15

func (sb *SymbolBuilder) SetUint(arch *sys.Arch, r int64, v uint64) int64

func (*SymbolBuilder) SetUint16 added in go1.15

func (sb *SymbolBuilder) SetUint16(arch *sys.Arch, r int64, v uint16) int64

func (*SymbolBuilder) SetUint32 added in go1.15

func (sb *SymbolBuilder) SetUint32(arch *sys.Arch, r int64, v uint32) int64

func (*SymbolBuilder) SetUint8 added in go1.15

func (sb *SymbolBuilder) SetUint8(arch *sys.Arch, r int64, v uint8) int64

func (*SymbolBuilder) SetUintptr added in go1.16

func (sb *SymbolBuilder) SetUintptr(arch *sys.Arch, r int64, v uintptr) int64

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

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL