goobj2

package standard library
go1.14.6 Latest Latest
Warning

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

Go to latest
Published: Jul 16, 2020 License: BSD-3-Clause Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PkgIdxNone    = (1<<31 - 1) - iota // Non-package symbols
	PkgIdxBuiltin                      // Predefined symbols // TODO: not used for now, we could use it for compiler-generated symbols like runtime.newobject
	PkgIdxSelf                         // Symbols defined in the current package
	PkgIdxInvalid = 0
)

Package Index.

View Source
const (
	BlkAutolib = iota
	BlkPkgIdx
	BlkDwarfFile
	BlkSymdef
	BlkNonpkgdef
	BlkNonpkgref
	BlkRelocIdx
	BlkAuxIdx
	BlkDataIdx
	BlkReloc
	BlkAux
	BlkData
	BlkPcdata
	NBlk
)

Blocks

View Source
const (
	SymFlagDupok = 1 << iota
	SymFlagLocal
	SymFlagTypelink
	SymFlagLeaf
	SymFlagCFunc
	SymFlagReflectMethod
	SymFlagGoType
	SymFlagTopFrame
)
View Source
const (
	AuxGotype = iota
	AuxFuncInfo
	AuxFuncdata
	AuxDwarfInfo
	AuxDwarfLoc
	AuxDwarfRanges
	AuxDwarfLines
)

Aux Type

View Source
const Magic = "\x00go114LD"
View Source
const (
	ObjFlagShared = 1 << iota
)
View Source
const SymABIstatic = ^uint16(0)

Variables

This section is empty.

Functions

func BuiltinIdx

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

func BuiltinName(i int) (string, int)

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

func NBuiltin

func NBuiltin() int

NBuiltin returns the number of listed builtin symbols.

Types

type Aux

type Aux struct {
	Type uint8
	Sym  SymRef
}

Aux symbol info.

func (*Aux) Read

func (a *Aux) Read(r *Reader, off uint32)

func (*Aux) Size

func (a *Aux) Size() int

func (*Aux) Write

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

type FuncInfo

type FuncInfo struct {
	NoSplit uint8

	Args   uint32
	Locals uint32

	Pcsp        uint32
	Pcfile      uint32
	Pcline      uint32
	Pcinline    uint32
	Pcdata      []uint32
	PcdataEnd   uint32
	Funcdataoff []uint32
	File        []SymRef // TODO: just use string?

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

func (a *FuncInfo) Read(b []byte)

func (*FuncInfo) Write

func (a *FuncInfo) Write(w *bytes.Buffer)
type Header struct {
	Magic   string
	Flags   uint32
	Offsets [NBlk]uint32
}

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

func (*Header) Read

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

func (*Header) Size

func (h *Header) Size() int

func (*Header) Write

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

type InlTreeNode

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

InlTreeNode is the serialized form of FileInfo.InlTree.

func (*InlTreeNode) Read

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

Read an InlTreeNode from b, return the remaining bytes.

func (*InlTreeNode) Write

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

type Reader

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

func NewReaderFromBytes

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

func (*Reader) Autolib

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

func (*Reader) AuxOff

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

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

func (*Reader) BytesAt

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

func (*Reader) Data

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

Data returns the i-th symbol's data.

func (*Reader) DataOff

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

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

func (*Reader) DataSize

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

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

func (*Reader) DwarfFile

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

func (*Reader) Flags

func (r *Reader) Flags() uint32

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

func (*Reader) NAux

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

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

func (*Reader) NDwarfFile

func (r *Reader) NDwarfFile() int

func (*Reader) NNonpkgdef

func (r *Reader) NNonpkgdef() int

func (*Reader) NNonpkgref

func (r *Reader) NNonpkgref() int

func (*Reader) NPkg

func (r *Reader) NPkg() int

func (*Reader) NReloc

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

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

func (*Reader) NSym

func (r *Reader) NSym() int

func (*Reader) PcdataBase

func (r *Reader) PcdataBase() uint32

AuxDataBase returns the base offset of the aux data block.

func (*Reader) Pkg

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

func (*Reader) Pkglist

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

func (*Reader) ReadOnly

func (r *Reader) ReadOnly() bool

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

func (*Reader) RelocOff

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

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

func (*Reader) StringAt

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

func (*Reader) StringRef

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

func (*Reader) SymOff

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

SymOff returns the offset of the i-th symbol.

type Reloc

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

Relocation.

func (*Reloc) Read

func (o *Reloc) Read(r *Reader, off uint32)

func (*Reloc) Size

func (r *Reloc) Size() int

func (*Reloc) Write

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

type Sym

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

Symbol definition.

func (*Sym) CFunc

func (s *Sym) CFunc() bool

func (*Sym) Dupok

func (s *Sym) Dupok() bool

func (*Sym) IsGoType

func (s *Sym) IsGoType() bool

func (*Sym) Leaf

func (s *Sym) Leaf() bool

func (*Sym) Local

func (s *Sym) Local() bool

func (*Sym) Read

func (s *Sym) Read(r *Reader, off uint32)

func (*Sym) ReflectMethod

func (s *Sym) ReflectMethod() bool

func (*Sym) Size

func (s *Sym) Size() int

func (*Sym) TopFrame

func (s *Sym) TopFrame() bool
func (s *Sym) Typelink() bool

func (*Sym) Write

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

type SymRef

type SymRef struct {
	PkgIdx uint32
	SymIdx uint32
}

Symbol reference.

func (*SymRef) Read

func (s *SymRef) Read(r *Reader, off uint32)

func (*SymRef) Size

func (s *SymRef) Size() int

func (*SymRef) Write

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

type Writer

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

func NewWriter

func NewWriter(wr *bio.Writer) *Writer

func (*Writer) AddString

func (w *Writer) AddString(s string)

func (*Writer) Bytes

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

func (*Writer) Offset

func (w *Writer) Offset() uint32

func (*Writer) RawString

func (w *Writer) RawString(s string)

func (*Writer) StringRef

func (w *Writer) StringRef(s string)

func (*Writer) Uint16

func (w *Writer) Uint16(x uint16)

func (*Writer) Uint32

func (w *Writer) Uint32(x uint32)

func (*Writer) Uint64

func (w *Writer) Uint64(x uint64)

func (*Writer) Uint8

func (w *Writer) Uint8(x uint8)

Jump to

Keyboard shortcuts

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