Package sym
Overview ▸
Index ▸
Constants
const ( SymVerABI0 = 0 SymVerABIInternal = 1 SymVerABICount = 2 // Number of internal ABIs SymVerStatic = 10 // Minimum version used by static (file-local) syms )
Variables
AbiSymKindToSymKind maps values read from object files (which are of type cmd/internal/objabi.SymKind) to values of type SymKind.
var AbiSymKindToSymKind = [...]SymKind{
objabi.Sxxx: Sxxx,
objabi.STEXT: STEXT,
objabi.SRODATA: SRODATA,
objabi.SNOPTRDATA: SNOPTRDATA,
objabi.SDATA: SDATA,
objabi.SBSS: SBSS,
objabi.SNOPTRBSS: SNOPTRBSS,
objabi.STLSBSS: STLSBSS,
objabi.SDWARFCUINFO: SDWARFCUINFO,
objabi.SDWARFCONST: SDWARFCONST,
objabi.SDWARFFCN: SDWARFFCN,
objabi.SDWARFABSFCN: SDWARFABSFCN,
objabi.SDWARFTYPE: SDWARFTYPE,
objabi.SDWARFVAR: SDWARFVAR,
objabi.SDWARFRANGE: SDWARFRANGE,
objabi.SDWARFLOC: SDWARFLOC,
objabi.SDWARFLINES: SDWARFLINES,
objabi.SLIBFUZZER_8BIT_COUNTER: SLIBFUZZER_8BIT_COUNTER,
objabi.SCOVERAGE_COUNTER: SCOVERAGE_COUNTER,
objabi.SCOVERAGE_AUXVAR: SCOVERAGE_AUXVAR,
objabi.SSEHUNWINDINFO: SSEHUNWINDINFO,
}
ReadOnly are the symbol kinds that form read-only sections. In some cases, if they will require relocations, they are transformed into rel-ro sections using relROMap.
var ReadOnly = []SymKind{
STYPE,
SSTRING,
SGOSTRING,
SGOFUNC,
SGCBITS,
SRODATA,
SFUNCTAB,
}
RelROMap describes the transformation of read-only symbols to rel-ro symbols.
var RelROMap = map[SymKind]SymKind{
STYPE: STYPERELRO,
SSTRING: SSTRINGRELRO,
SGOSTRING: SGOSTRINGRELRO,
SGOFUNC: SGOFUNCRELRO,
SGCBITS: SGCBITSRELRO,
SRODATA: SRODATARELRO,
SFUNCTAB: SFUNCTABRELRO,
}
func ABIToVersion ¶
func ABIToVersion(abi obj.ABI) int
func RelocName ¶
func RelocName(arch *sys.Arch, r objabi.RelocType) string
func VersionToABI ¶
func VersionToABI(v int) (obj.ABI, bool)
type CompilationUnit ¶
A CompilationUnit represents a set of source files that are compiled together. Since all Go sources in a Go package are compiled together, there's one CompilationUnit per package that represents all Go sources in that package, plus one for each assembly file.
Equivalently, there's one CompilationUnit per object file in each Library loaded by the linker.
These are used for both DWARF and pclntab generation.
type CompilationUnit struct { Lib *Library // Our library PclnIndex int // Index of this CU in pclntab PCs []dwarf.Range // PC ranges, relative to Textp[0] DWInfo *dwarf.DWDie // CU root DIE FileTable []string // The file table used in this compilation unit. Consts LoaderSym // Package constants DIEs FuncDIEs []LoaderSym // Function DIE subtrees VarDIEs []LoaderSym // Global variable DIEs AbsFnDIEs []LoaderSym // Abstract function DIE subtrees RangeSyms []LoaderSym // Symbols for debug_range Textp []LoaderSym // Text symbols in this CU }
type Library ¶
type Library struct { Objref string Srcref string File string Pkg string Shlib string Fingerprint goobj.FingerprintType Autolib []goobj.ImportedPkg Imports []*Library Main bool Units []*CompilationUnit Textp []LoaderSym // text syms defined in this library DupTextSyms []LoaderSym // dupok text syms defined in this library }
func (Library) String ¶
func (l Library) String() string
type LoaderSym ¶
LoaderSym holds a loader.Sym value. We can't refer to this type from the sym package since loader imports sym.
type LoaderSym uint32
type RelocVariant ¶
RelocVariant is a linker-internal variation on a relocation.
type RelocVariant uint8
const ( RV_NONE RelocVariant = iota RV_POWER_LO RV_POWER_HI RV_POWER_HA RV_POWER_DS // RV_390_DBL is a s390x-specific relocation variant that indicates that // the value to be placed into the relocatable field should first be // divided by 2. RV_390_DBL RV_CHECK_OVERFLOW RelocVariant = 1 << 7 RV_TYPE_MASK RelocVariant = RV_CHECK_OVERFLOW - 1 )
type Section ¶
type Section struct { Rwx uint8 Extnum int16 Align int32 Name string Vaddr uint64 Length uint64 Seg *Segment Elfsect interface{} // an *ld.ElfShdr Reloff uint64 Rellen uint64 // Relcount is the number of *host* relocations applied to this section // (when external linking). // Incremented atomically on multiple goroutines. // Note: this may differ from number of Go relocations, as one Go relocation // may turn into multiple host relocations. Relcount uint32 Sym LoaderSym // symbol for the section, if any Index uint16 // each section has a unique index, used internally Compressed bool }
type Segment ¶
type Segment struct { Rwx uint8 // permission as usual unix bits (5 = r-x etc) Vaddr uint64 // virtual address Length uint64 // length in memory Fileoff uint64 // file offset Filelen uint64 // length on disk Sections []*Section }
type SymKind ¶
A SymKind describes the kind of memory represented by a symbol.
type SymKind uint8
Defined SymKind values.
TODO(rsc): Give idiomatic Go names.
const ( Sxxx SymKind = iota STEXT SELFRXSECT SMACHOPLT // Read-only sections. STYPE SSTRING SGOSTRING SGOFUNC SGCBITS SRODATA SFUNCTAB SELFROSECT // Read-only sections with relocations. // // Types STYPE-SFUNCTAB above are written to the .rodata section by default. // When linking a shared object, some conceptually "read only" types need to // be written to by relocations and putting them in a section called // ".rodata" interacts poorly with the system linkers. The GNU linkers // support this situation by arranging for sections of the name // ".data.rel.ro.XXX" to be mprotected read only by the dynamic linker after // relocations have applied, so when the Go linker is creating a shared // object it checks all objects of the above types and bumps any object that // has a relocation to it to the corresponding type below, which are then // written to sections with appropriate magic names. STYPERELRO SSTRINGRELRO SGOSTRINGRELRO SGOFUNCRELRO SGCBITSRELRO SRODATARELRO SFUNCTABRELRO SELFRELROSECT // Part of .data.rel.ro if it exists, otherwise part of .rodata. STYPELINK SITABLINK SSYMTAB SPCLNTAB // Writable sections. SFirstWritable SBUILDINFO SELFSECT SMACHO SMACHOGOT SWINDOWS SELFGOT SNOPTRDATA SINITARR SDATA SXCOFFTOC SBSS SNOPTRBSS SLIBFUZZER_8BIT_COUNTER SCOVERAGE_COUNTER SCOVERAGE_AUXVAR STLSBSS SXREF SMACHOSYMSTR SMACHOSYMTAB SMACHOINDIRECTPLT SMACHOINDIRECTGOT SFILEPATH SDYNIMPORT SHOSTOBJ SUNDEFEXT // Undefined symbol for resolution by external linker // Sections for debugging information SDWARFSECT // DWARF symbol types SDWARFCUINFO SDWARFCONST SDWARFFCN SDWARFABSFCN SDWARFTYPE SDWARFVAR SDWARFRANGE SDWARFLOC SDWARFLINES // SEH symbol types SSEHUNWINDINFO SSEHSECT )
func (SymKind) IsDWARF ¶
func (t SymKind) IsDWARF() bool
func (SymKind) IsData ¶
func (t SymKind) IsData() bool
IsData returns true if the type is a data type.
func (SymKind) String ¶
func (i SymKind) String() string