goobj

package standard library
go1.17.1 Latest Latest
Warning

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

Go to latest
Published: Sep 9, 2021 License: BSD-3-Clause Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PkgIdxNone     = (1<<31 - 1) - iota // Non-package symbols
	PkgIdxHashed64                      // Short hashed (content-addressable) symbols
	PkgIdxHashed                        // Hashed (content-addressable) symbols
	PkgIdxBuiltin                       // Predefined runtime symbols (ex: runtime.newobject)
	PkgIdxSelf                          // Symbols defined in the current package
	PkgIdxInvalid  = 0
)

Package Index.

View Source
const (
	BlkAutolib = iota
	BlkPkgIdx
	BlkFile
	BlkSymdef
	BlkHashed64def
	BlkHasheddef
	BlkNonpkgdef
	BlkNonpkgref
	BlkRefFlags
	BlkHash64
	BlkHash
	BlkRelocIdx
	BlkAuxIdx
	BlkDataIdx
	BlkReloc
	BlkAux
	BlkData
	BlkPcdata
	BlkRefName
	BlkEnd
	NBlk
)

Blocks

View Source
const (
	ObjFlagShared            = 1 << iota // this object is built with -shared
	ObjFlagNeedNameExpansion             // the linker needs to expand `"".` to package path in symbol names
	ObjFlagFromAssembly                  // object is from asm src, not go
)
View Source
const (
	SymFlagDupok = 1 << iota
	SymFlagLocal
	SymFlagTypelink
	SymFlagLeaf
	SymFlagNoSplit
	SymFlagReflectMethod
	SymFlagGoType
)

Sym.Flag

View Source
const (
	SymFlagUsedInIface = 1 << iota
	SymFlagItab
)

Sym.Flag2

View Source
const (
	AuxGotype = iota
	AuxFuncInfo
	AuxFuncdata
	AuxDwarfInfo
	AuxDwarfLoc
	AuxDwarfRanges
	AuxDwarfLines
	AuxPcsp
	AuxPcfile
	AuxPcline
	AuxPcinline
	AuxPcdata
)

Aux Type

View Source
const AuxSize = 1 + 8
View Source
const Hash64Size = 8
View Source
const HashSize = sha1.Size
View Source
const Magic = "\x00go117ld"
View Source
const RefFlagsSize = 8 + 1 + 1
View Source
const RefNameSize = 8 + stringRefSize
View Source
const RelocSize = 4 + 1 + 2 + 8 + 8
View Source
const SymABIstatic = ^uint16(0)
View Source
const SymSize = stringRefSize + 2 + 1 + 1 + 1 + 4 + 4

Variables

This section is empty.

Functions

func BuiltinIdx added in go1.16

func BuiltinIdx(name string, abi int) int

BuiltinIdx returns the index of the builtin with the given name and abi, or -1 if it is not a builtin.

func BuiltinName added in go1.16

func BuiltinName(i int) (string, int)

BuiltinName returns the name and ABI of the i-th builtin symbol.

func NBuiltin added in go1.16

func NBuiltin() int

NBuiltin returns the number of listed builtin symbols.

Types

type Aux added in go1.16

type Aux [AuxSize]byte

Aux symbol info.

Serialized format:

Aux struct {
   Type uint8
   Sym  SymRef
}

func (*Aux) SetSym added in go1.16

func (a *Aux) SetSym(x SymRef)

func (*Aux) SetType added in go1.16

func (a *Aux) SetType(x uint8)

func (*Aux) Sym added in go1.16

func (a *Aux) Sym() SymRef

func (*Aux) Type added in go1.16

func (a *Aux) Type() uint8

func (*Aux) Write added in go1.16

func (a *Aux) Write(w *Writer)

type CUFileIndex added in go1.16

type CUFileIndex uint32

CUFileIndex is used to index the filenames that are stored in the per-package/per-CU FileList.

type FingerprintType added in go1.16

type FingerprintType [8]byte

func (FingerprintType) IsZero added in go1.16

func (fp FingerprintType) IsZero() bool

type FuncInfo added in go1.16

type FuncInfo struct {
	Args     uint32
	Locals   uint32
	FuncID   objabi.FuncID
	FuncFlag objabi.FuncFlag

	Pcsp        SymRef
	Pcfile      SymRef
	Pcline      SymRef
	Pcinline    SymRef
	Pcdata      []SymRef
	Funcdataoff []uint32
	File        []CUFileIndex

	InlTree []InlTreeNode
}

FuncInfo is serialized as a symbol (aux symbol). The symbol data is the binary encoding of the struct below.

TODO: make each pcdata a separate symbol?

func (*FuncInfo) ReadArgs added in go1.16

func (*FuncInfo) ReadArgs(b []byte) uint32

func (*FuncInfo) ReadFile added in go1.16

func (*FuncInfo) ReadFile(b []byte, filesoff uint32, k uint32) CUFileIndex

func (*FuncInfo) ReadFuncFlag added in go1.17

func (*FuncInfo) ReadFuncFlag(b []byte) objabi.FuncFlag

func (*FuncInfo) ReadFuncID added in go1.16

func (*FuncInfo) ReadFuncID(b []byte) objabi.FuncID

func (*FuncInfo) ReadFuncInfoLengths added in go1.16

func (*FuncInfo) ReadFuncInfoLengths(b []byte) FuncInfoLengths

func (*FuncInfo) ReadFuncdataoff added in go1.16

func (*FuncInfo) ReadFuncdataoff(b []byte, funcdataofffoff uint32, k uint32) int64

func (*FuncInfo) ReadInlTree added in go1.16

func (*FuncInfo) ReadInlTree(b []byte, inltreeoff uint32, k uint32) InlTreeNode

func (*FuncInfo) ReadLocals added in go1.16

func (*FuncInfo) ReadLocals(b []byte) uint32

func (*FuncInfo) ReadPcdata added in go1.16

func (*FuncInfo) ReadPcdata(b []byte) []SymRef

func (*FuncInfo) ReadPcfile added in go1.16

func (*FuncInfo) ReadPcfile(b []byte) SymRef

func (*FuncInfo) ReadPcinline added in go1.16

func (*FuncInfo) ReadPcinline(b []byte) SymRef

func (*FuncInfo) ReadPcline added in go1.16

func (*FuncInfo) ReadPcline(b []byte) SymRef

func (*FuncInfo) ReadPcsp added in go1.16

func (*FuncInfo) ReadPcsp(b []byte) SymRef

func (*FuncInfo) Write added in go1.16

func (a *FuncInfo) Write(w *bytes.Buffer)

type FuncInfoLengths added in go1.16

type FuncInfoLengths struct {
	NumPcdata      uint32
	PcdataOff      uint32
	NumFuncdataoff uint32
	FuncdataoffOff uint32
	NumFile        uint32
	FileOff        uint32
	NumInlTree     uint32
	InlTreeOff     uint32
	Initialized    bool
}

FuncInfoLengths is a cache containing a roadmap of offsets and lengths for things within a serialized FuncInfo. Each length field stores the number of items (e.g. files, inltree nodes, etc), and the corresponding "off" field stores the byte offset of the start of the items in question.

type Hash64Type added in go1.16

type Hash64Type [Hash64Size]byte

Hash64

type HashType added in go1.16

type HashType [HashSize]byte

Hash

type Header struct {
	Magic       string
	Fingerprint FingerprintType
	Flags       uint32
	Offsets     [NBlk]uint32
}

File header. TODO: probably no need to export this.

func (*Header) Read added in go1.16

func (h *Header) Read(r *Reader) error

func (*Header) Size added in go1.16

func (h *Header) Size() int

func (*Header) Write added in go1.16

func (h *Header) Write(w *Writer)

type ImportedPkg added in go1.16

type ImportedPkg struct {
	Pkg         string
	Fingerprint FingerprintType
}

Autolib

func (*ImportedPkg) Write added in go1.16

func (p *ImportedPkg) Write(w *Writer)

type InlTreeNode added in go1.16

type InlTreeNode struct {
	Parent   int32
	File     CUFileIndex
	Line     int32
	Func     SymRef
	ParentPC int32
}

InlTreeNode is the serialized form of FileInfo.InlTree.

func (*InlTreeNode) Read added in go1.16

func (inl *InlTreeNode) Read(b []byte) []byte

Read an InlTreeNode from b, return the remaining bytes.

func (*InlTreeNode) Write added in go1.16

func (inl *InlTreeNode) Write(w *bytes.Buffer)

type Reader added in go1.16

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

func NewReaderFromBytes added in go1.16

func NewReaderFromBytes(b []byte, readonly bool) *Reader

func (*Reader) Autolib added in go1.16

func (r *Reader) Autolib() []ImportedPkg

func (*Reader) Aux added in go1.16

func (r *Reader) Aux(i uint32, j int) *Aux

Aux returns a pointer to the j-th aux symbol of the i-th symbol.

func (*Reader) AuxOff added in go1.16

func (r *Reader) AuxOff(i uint32, j int) uint32

AuxOff returns the offset of the j-th aux symbol of the i-th symbol.

func (*Reader) Auxs added in go1.16

func (r *Reader) Auxs(i uint32) []Aux

Auxs returns the aux symbols of the i-th symbol.

func (*Reader) BytesAt added in go1.16

func (r *Reader) BytesAt(off uint32, len int) []byte

func (*Reader) Data added in go1.16

func (r *Reader) Data(i uint32) []byte

Data returns the i-th symbol's data.

func (*Reader) DataOff added in go1.16

func (r *Reader) DataOff(i uint32) uint32

DataOff returns the offset of the i-th symbol's data.

func (*Reader) DataSize added in go1.16

func (r *Reader) DataSize(i uint32) int

DataSize returns the size of the i-th symbol's data.

func (*Reader) File added in go1.16

func (r *Reader) File(i int) string

func (*Reader) Fingerprint added in go1.16

func (r *Reader) Fingerprint() FingerprintType

func (*Reader) Flags added in go1.16

func (r *Reader) Flags() uint32

Flags returns the flag bits read from the object file header.

func (*Reader) FromAssembly added in go1.16

func (r *Reader) FromAssembly() bool

func (*Reader) Hash added in go1.16

func (r *Reader) Hash(i uint32) *HashType

Hash returns a pointer to the i-th hashed symbol's hash. Note: here i is the index of hashed symbols, not all symbols (unlike other accessors).

func (*Reader) Hash64 added in go1.16

func (r *Reader) Hash64(i uint32) uint64

Hash64 returns the i-th short hashed symbol's hash. Note: here i is the index of short hashed symbols, not all symbols (unlike other accessors).

func (*Reader) NAux added in go1.16

func (r *Reader) NAux(i uint32) int

NAux returns the number of aux symbols of the i-th symbol.

func (*Reader) NFile added in go1.16

func (r *Reader) NFile() int

func (*Reader) NHashed64def added in go1.16

func (r *Reader) NHashed64def() int

func (*Reader) NHasheddef added in go1.16

func (r *Reader) NHasheddef() int

func (*Reader) NNonpkgdef added in go1.16

func (r *Reader) NNonpkgdef() int

func (*Reader) NNonpkgref added in go1.16

func (r *Reader) NNonpkgref() int

func (*Reader) NPkg added in go1.16

func (r *Reader) NPkg() int

func (*Reader) NRefFlags added in go1.16

func (r *Reader) NRefFlags() int

NRefFlags returns the number of referenced symbol flags.

func (*Reader) NRefName added in go1.16

func (r *Reader) NRefName() int

NRefName returns the number of referenced symbol names.

func (*Reader) NReloc added in go1.16

func (r *Reader) NReloc(i uint32) int

NReloc returns the number of relocations of the i-th symbol.

func (*Reader) NSym added in go1.16

func (r *Reader) NSym() int

func (*Reader) NeedNameExpansion added in go1.16

func (r *Reader) NeedNameExpansion() bool

func (*Reader) Pkg added in go1.16

func (r *Reader) Pkg(i int) string

func (*Reader) Pkglist added in go1.16

func (r *Reader) Pkglist() []string

func (*Reader) ReadOnly added in go1.16

func (r *Reader) ReadOnly() bool

ReadOnly returns whether r.BytesAt returns read-only bytes.

func (*Reader) RefFlags added in go1.16

func (r *Reader) RefFlags(i int) *RefFlags

RefFlags returns a pointer to the i-th referenced symbol flags. Note: here i is not a local symbol index, just a counter.

func (*Reader) RefName added in go1.16

func (r *Reader) RefName(i int) *RefName

RefName returns a pointer to the i-th referenced symbol name. Note: here i is not a local symbol index, just a counter.

func (*Reader) Reloc added in go1.16

func (r *Reader) Reloc(i uint32, j int) *Reloc

Reloc returns a pointer to the j-th relocation of the i-th symbol.

func (*Reader) RelocOff added in go1.16

func (r *Reader) RelocOff(i uint32, j int) uint32

RelocOff returns the offset of the j-th relocation of the i-th symbol.

func (*Reader) Relocs added in go1.16

func (r *Reader) Relocs(i uint32) []Reloc

Relocs returns a pointer to the relocations of the i-th symbol.

func (*Reader) Shared added in go1.16

func (r *Reader) Shared() bool

func (*Reader) StringAt added in go1.16

func (r *Reader) StringAt(off uint32, len uint32) string

func (*Reader) StringRef added in go1.16

func (r *Reader) StringRef(off uint32) string

func (*Reader) Sym added in go1.16

func (r *Reader) Sym(i uint32) *Sym

Sym returns a pointer to the i-th symbol.

func (*Reader) SymOff added in go1.16

func (r *Reader) SymOff(i uint32) uint32

SymOff returns the offset of the i-th symbol.

type RefFlags added in go1.16

type RefFlags [RefFlagsSize]byte

Referenced symbol flags.

Serialized format:

RefFlags struct {
   Sym   symRef
   Flag  uint8
   Flag2 uint8
}

func (*RefFlags) Flag added in go1.16

func (r *RefFlags) Flag() uint8

func (*RefFlags) Flag2 added in go1.16

func (r *RefFlags) Flag2() uint8

func (*RefFlags) SetFlag added in go1.16

func (r *RefFlags) SetFlag(x uint8)

func (*RefFlags) SetFlag2 added in go1.16

func (r *RefFlags) SetFlag2(x uint8)

func (*RefFlags) SetSym added in go1.16

func (r *RefFlags) SetSym(x SymRef)

func (*RefFlags) Sym added in go1.16

func (r *RefFlags) Sym() SymRef

func (*RefFlags) Write added in go1.16

func (r *RefFlags) Write(w *Writer)

type RefName added in go1.16

type RefName [RefNameSize]byte

Referenced symbol name.

Serialized format:

RefName struct {
   Sym  symRef
   Name string
}

func (*RefName) Name added in go1.16

func (n *RefName) Name(r *Reader) string

func (*RefName) SetName added in go1.16

func (n *RefName) SetName(x string, w *Writer)

func (*RefName) SetSym added in go1.16

func (n *RefName) SetSym(x SymRef)

func (*RefName) Sym added in go1.16

func (n *RefName) Sym() SymRef

func (*RefName) Write added in go1.16

func (n *RefName) Write(w *Writer)

type Reloc

type Reloc [RelocSize]byte

Relocation.

Serialized format:

Reloc struct {
   Off  int32
   Siz  uint8
   Type uint16
   Add  int64
   Sym  SymRef
}

func (*Reloc) Add

func (r *Reloc) Add() int64

func (*Reloc) Off added in go1.16

func (r *Reloc) Off() int32

func (*Reloc) Set added in go1.16

func (r *Reloc) Set(off int32, size uint8, typ uint16, add int64, sym SymRef)

func (*Reloc) SetAdd added in go1.16

func (r *Reloc) SetAdd(x int64)

func (*Reloc) SetOff added in go1.16

func (r *Reloc) SetOff(x int32)

func (*Reloc) SetSiz added in go1.16

func (r *Reloc) SetSiz(x uint8)

func (*Reloc) SetSym added in go1.16

func (r *Reloc) SetSym(x SymRef)

func (*Reloc) SetType added in go1.16

func (r *Reloc) SetType(x uint16)

func (*Reloc) Siz added in go1.16

func (r *Reloc) Siz() uint8

func (*Reloc) Sym

func (r *Reloc) Sym() SymRef

func (*Reloc) Type

func (r *Reloc) Type() uint16

func (*Reloc) Write added in go1.16

func (r *Reloc) Write(w *Writer)

type Sym

type Sym [SymSize]byte

Symbol definition.

Serialized format:

Sym struct {
   Name  string
   ABI   uint16
   Type  uint8
   Flag  uint8
   Flag2 uint8
   Siz   uint32
   Align uint32
}

func (*Sym) ABI added in go1.16

func (s *Sym) ABI() uint16

func (*Sym) Align added in go1.16

func (s *Sym) Align() uint32

func (*Sym) Dupok added in go1.16

func (s *Sym) Dupok() bool

func (*Sym) Flag added in go1.16

func (s *Sym) Flag() uint8

func (*Sym) Flag2 added in go1.16

func (s *Sym) Flag2() uint8

func (*Sym) IsGoType added in go1.16

func (s *Sym) IsGoType() bool

func (*Sym) IsItab added in go1.16

func (s *Sym) IsItab() bool

func (*Sym) Leaf added in go1.16

func (s *Sym) Leaf() bool

func (*Sym) Local added in go1.16

func (s *Sym) Local() bool

func (*Sym) Name added in go1.16

func (s *Sym) Name(r *Reader) string

func (*Sym) NameLen added in go1.16

func (s *Sym) NameLen(r *Reader) int

Returns the length of the name of the symbol.

func (*Sym) NoSplit added in go1.16

func (s *Sym) NoSplit() bool

func (*Sym) ReflectMethod added in go1.16

func (s *Sym) ReflectMethod() bool

func (*Sym) SetABI added in go1.16

func (s *Sym) SetABI(x uint16)

func (*Sym) SetAlign added in go1.16

func (s *Sym) SetAlign(x uint32)

func (*Sym) SetFlag added in go1.16

func (s *Sym) SetFlag(x uint8)

func (*Sym) SetFlag2 added in go1.16

func (s *Sym) SetFlag2(x uint8)

func (*Sym) SetName added in go1.16

func (s *Sym) SetName(x string, w *Writer)

func (*Sym) SetSiz added in go1.16

func (s *Sym) SetSiz(x uint32)

func (*Sym) SetType added in go1.16

func (s *Sym) SetType(x uint8)

func (*Sym) Siz added in go1.16

func (s *Sym) Siz() uint32

func (*Sym) Type

func (s *Sym) Type() uint8
func (s *Sym) Typelink() bool

func (*Sym) UsedInIface added in go1.16

func (s *Sym) UsedInIface() bool

func (*Sym) Write added in go1.16

func (s *Sym) Write(w *Writer)

type SymRef added in go1.16

type SymRef struct {
	PkgIdx uint32
	SymIdx uint32
}

Symbol reference.

type Writer added in go1.16

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

func NewWriter added in go1.16

func NewWriter(wr *bio.Writer) *Writer

func (*Writer) AddString added in go1.16

func (w *Writer) AddString(s string)

func (*Writer) Bytes added in go1.16

func (w *Writer) Bytes(s []byte)

func (*Writer) Offset added in go1.16

func (w *Writer) Offset() uint32

func (*Writer) RawString added in go1.16

func (w *Writer) RawString(s string)

func (*Writer) StringRef added in go1.16

func (w *Writer) StringRef(s string)

func (*Writer) Uint16 added in go1.16

func (w *Writer) Uint16(x uint16)

func (*Writer) Uint32 added in go1.16

func (w *Writer) Uint32(x uint32)

func (*Writer) Uint64 added in go1.16

func (w *Writer) Uint64(x uint64)

func (*Writer) Uint8 added in go1.16

func (w *Writer) Uint8(x uint8)

Jump to

Keyboard shortcuts

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