sym

package standard library
Version: go1.17.3 Latest Latest
Warning

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

Go to latest
Published: Nov 4, 2021 License: BSD-3-Clause Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SymVerABI0        = 0
	SymVerABIInternal = 1
	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.

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.

RelROMap describes the transformation of read-only symbols to rel-ro symbols.

Functions

func ABIToVersion added in go1.12

func ABIToVersion(abi obj.ABI) int

func RelocName

func RelocName(arch *sys.Arch, r objabi.RelocType) string

func VersionToABI added in go1.12

func VersionToABI(v int) (obj.ABI, bool)

Types

type CompilationUnit added in go1.14

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
}

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

type LoaderSym int

LoaderSym holds a loader.Sym value. We can't refer to this type from the sym package since loader imports sym.

type RelocVariant

type RelocVariant uint8

RelocVariant is a linker-internal variation on a relocation.

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
}

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

type SymKind uint8

A SymKind describes the kind of memory represented by a symbol.

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

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

	// ABI aliases (these never appear in the output)
	SABIALIAS
)

Defined SymKind values.

TODO(rsc): Give idiomatic Go names.

func (SymKind) IsData added in go1.14

func (t SymKind) IsData() bool

IsData returns true if the type is a data type.

func (SymKind) String

func (i SymKind) String() string

Jump to

Keyboard shortcuts

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