obj

package
v0.0.23 Latest Latest
Warning

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

Go to latest
Published: Dec 24, 2025 License: Apache-2.0 Imports: 15 Imported by: 1

Documentation

Index

Constants

View Source
const (
	InvalidIndex             = uint32(0xFFFFFFFF)
	InlinedCallSize          = int(unsafe.Sizeof(InlinedCall{}))
	UNRESOLVED_SYMREF_PREFIX = "unresolvedSymRef#"
	UNRESOLVED_SYMREF_FMT    = UNRESOLVED_SYMREF_PREFIX + "%d#%d"
)

Variables

This section is empty.

Functions

func Dummy added in v0.0.21

func Dummy()

func DumpCode added in v0.0.21

func DumpCode(text []byte, archName string)

func FindFileTab added in v0.0.18

func FindFileTab(fileName string, nameMap map[string]int, fileTab []uint32) int32

func GetOpName added in v0.0.21

func GetOpName(op uint) string

func Grow added in v0.0.19

func Grow(bytes *[]byte, size int)

func IsExtraRegister added in v0.0.21

func IsExtraRegister(regName string) bool

func MarkReloc added in v0.0.21

func MarkReloc(text []byte, relocs []Reloc, offset int, archName string)

func OpString added in v0.0.21

func OpString(op Op) string

func PathToPrefix added in v0.0.19

func PathToPrefix(s string) string

func ReplacePkgPath added in v0.0.19

func ReplacePkgPath(name, pkgpath string) string

Types

type Archive added in v0.0.20

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

func (Archive) MarshalBinary added in v0.0.20

func (v Archive) MarshalBinary() ([]byte, error)

func (*Archive) UnmarshalBinary added in v0.0.20

func (v *Archive) UnmarshalBinary(data []byte) error

type Arg added in v0.0.21

type Arg interface {
	String() string
	// contains filtered or unexported methods
}

An Arg is a single instruction argument, one of these types: Reg, Mem, Imm, Rel.

type Args added in v0.0.21

type Args [4]Arg

An Args holds the instruction arguments. If an instruction has fewer than 4 arguments, the final elements in the array are nil.

type CgoImport added in v0.0.20

type CgoImport struct {
	GoSymName string
	CSymName  string
	SoName    string
}

type Epilogue added in v0.0.17

type Epilogue struct {
	Offset int
	Size   int
}

type Func

type Func struct {
	PCData   []uint32
	FuncData []uintptr
}

type FuncInfo

type FuncInfo struct {
	Args      uint32
	Locals    uint32
	FuncID    uint8
	FuncFlag  uint8
	StartLine int32
	PCSP      []byte
	PCFile    []byte
	PCLine    []byte
	PCInline  []byte
	PCData    [][]byte
	File      []string
	FuncData  []string
	InlTree   []InlTreeNode
	CUOffset  int32
}

type InlTreeNode

type InlTreeNode struct {
	Parent   int64
	File     string
	Line     int64
	Func     string
	ParentPC int64
}

type InlinedCall added in v0.0.19

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

inlinedCall is the encoding of entries in the FUNCDATA_InlTree table.

func InitInlinedCall added in v0.0.19

func InitInlinedCall(inl InlTreeNode, funcid uint8, namemap map[string]int, filetab []uint32) InlinedCall

type Inst added in v0.0.21

type Inst struct {
	Prefix   Prefixes // Prefixes applied to the instruction.
	Op       Op       // Opcode mnemonic
	Opcode   uint32   // Encoded opcode bits, left aligned (first byte is Opcode>>24, etc)
	Args     Args     // Instruction arguments, in Intel order
	Mode     int      // processor mode in bits: 16, 32, or 64
	AddrSize int      // address size in bits: 16, 32, or 64
	DataSize int      // operand size in bits: 16, 32, or 64
	MemBytes int      // size of memory argument in bytes: 1, 2, 4, 8, 16, and so on.
	Len      int      // length of encoded instruction in bytes
	PCRel    int      // length of PC-relative address in instruction encoding
	PCRelOff int      // index of start of PC-relative address in instruction encoding
}

An Inst is a single instruction.

func Decode added in v0.0.21

func Decode(src []byte, mode int) (inst Inst, err error)

type Instruction added in v0.0.21

type Instruction struct {
	Op    uint
	Start int
	End   int
	Text  []byte
	Args  []string
}

type Name added in v0.0.21

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

func (Name) Name added in v0.0.21

func (n Name) Name() string

type ObjSymbol

type ObjSymbol struct {
	Name  string
	Kind  int    // kind of symbol
	DupOK bool   // are duplicate definitions okay?
	Size  int64  // size of corresponding data
	Data  []byte // memory image of symbol
	Type  string
	Reloc []Reloc
	Func  *FuncInfo // additional data for functions
	ABI   uint
}

type Op added in v0.0.21

type Op uint32

func (Op) String added in v0.0.21

func (op Op) String() string

type Pkg

type Pkg struct {
	Syms       map[string]*ObjSymbol
	CgoImports map[string]*CgoImport
	GoArchive  *Archive
	SymIndex   []string
	Arch       string
	PkgPath    string
	File       string
	ImportPkgs []string
	CUFiles    []string
	CUOffset   int32
}

func (*Pkg) AddCgoFuncs added in v0.0.20

func (pkg *Pkg) AddCgoFuncs(cgoFuncs map[string]int)

func (*Pkg) AddSymIndex added in v0.0.20

func (pkg *Pkg) AddSymIndex(cgoFuncs map[string]int)

func (*Pkg) ResolveSymbols added in v0.0.20

func (pkg *Pkg) ResolveSymbols(packages map[string]*Pkg, ObjSymbolMap map[string]*ObjSymbol, CUOffset int32)

func (*Pkg) Symbols added in v0.0.19

func (pkg *Pkg) Symbols() error

type Prefix added in v0.0.21

type Prefix uint16

A Prefix represents an Intel instruction prefix. The low 8 bits are the actual prefix byte encoding, and the top 8 bits contain distinguishing bits and metadata.

type Prefixes added in v0.0.21

type Prefixes [14]Prefix

Prefixes is an array of prefixes associated with a single instruction. The prefixes are listed in the same order as found in the instruction: each prefix byte corresponds to one slot in the array. The first zero in the array marks the end of the prefixes.

type Reloc

type Reloc struct {
	Offset  int
	SymName string
	Size    int
	Type    int
	Add     int
	Instruction
	Epilogue
}

copy from $GOROOT/src/cmd/internal/goobj/read.go type Reloc struct

func (*Reloc) GetEnd added in v0.0.21

func (r *Reloc) GetEnd() int

func (*Reloc) GetStart added in v0.0.21

func (r *Reloc) GetStart() int

type Sym

type Sym struct {
	Name   string
	Type   string
	Kind   int
	Offset int
	Func   *Func
	Reloc  []Reloc
}

copy from $GOROOT/src/cmd/internal/goobj/read.go type Sym struct

Jump to

Keyboard shortcuts

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