goobj2

package
v0.0.0-...-26db732 Latest Latest
Warning

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

Go to latest
Published: May 8, 2023 License: BSD-3-Clause Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CompilerObjName = "__.PKGDEF"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type ArchiveHeader

type ArchiveHeader struct {
	Name string
	Date string
	UID  string
	GID  string
	Mode string
	Size int64
	Data []byte
}

type ArchiveMember

type ArchiveMember struct {
	ArchiveHeader ArchiveHeader
	ObjHeader     goobj2.Header
	Imports       []goobj2.ImportedPkg
	Packages      []string
	DWARFFileList []string
	SymDefs       []*Sym
	NonPkgSymDefs []*Sym
	NonPkgSymRefs []*Sym
	SymRefs       []SymRef

	IsDataObj bool
	// contains filtered or unexported fields
}

func (ArchiveMember) IsCompilerObj

func (a ArchiveMember) IsCompilerObj() bool

type ExportInfo

type ExportInfo struct {
	Path        string
	IsSharedLib bool
}

type Func

type Func struct {
	Args     int64      // size in bytes of argument frame: inputs and outputs
	Frame    int64      // size in bytes of local variable frame
	PCSP     []byte     // PC → SP offset map
	PCFile   []byte     // PC → file number map (index into File)
	PCLine   []byte     // PC → line number map
	PCInline []byte     // PC → inline tree index map
	PCData   [][]byte   // PC → runtime support data map
	FuncData []FuncData // non-PC-specific runtime support data
	File     []SymRef   // paths indexed by PCFile
	InlTree  []*InlinedCall

	FuncInfo        *SymRef
	DwarfInfo       *SymRef
	DwarfLoc        *SymRef
	DwarfRanges     *SymRef
	DwarfDebugLines *SymRef
	// contains filtered or unexported fields
}

Func contains additional per-symbol information specific to functions.

type FuncData

type FuncData struct {
	Sym    *SymRef // symbol holding data
	Offset uint32  // offset into symbol for funcdata pointer
}

A FuncData is a single function-specific data value.

type ImportCfg

type ImportCfg struct {
	ImportMap map[string]string
	Packages  map[string]ExportInfo
}

func ParseImportCfg

func ParseImportCfg(path string) (importCfg ImportCfg, err error)

type ImportMap

type ImportMap = func(importPath string) (objectPath string)

ImportMap is a function that returns the path of a Go object from a given import path. If the import path is not known, an empty string should be returned.

type InlinedCall

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

An InlinedCall is a node in an InlTree. See cmd/internal/obj.InlTree for details.

type Package

type Package struct {
	ArchiveMembers []ArchiveMember
	ImportPath     string
	// contains filtered or unexported fields
}

A Package is a parsed Go object file or archive defining a Go package.

func Parse

func Parse(objPath, pkgPath string, importMap ImportMap) (*Package, error)

Parse parses an object file or archive from objPath, assuming that its import path is pkgpath. A function that returns paths of object files from import paths can optionally be passed in as importMap to optimize looking up paths to dependencies' object files.

func (Package) Arch

func (p Package) Arch() string

func (Package) OS

func (p Package) OS() string

func (*Package) Write

func (pkg *Package) Write(path string) (err error)

Write writes the contents of the parsed archive to disk.

type Reloc

type Reloc struct {
	Name string
	// The bytes at [Offset, Offset+Size) within the containing Sym
	// should be updated to refer to the address Add bytes after the start
	// of the symbol Sym.
	Offset int64
	Size   int64
	Sym    goobj2.SymRef
	Add    int64

	// The Type records the form of address expected in the bytes
	// described by the previous fields: absolute, PC-relative, and so on.
	// TODO(rsc): The interpretation of Type is not exposed by this package.
	Type objabi.RelocType
}

A Reloc describes a relocation applied to a memory image to refer to an address within a particular symbol.

type Sym

type Sym struct {
	Name  string
	ABI   uint16
	Kind  SymKind // kind of symbol
	Flag  uint8
	Size  uint32 // size of corresponding data
	Align uint32
	Type  *SymRef // symbol for Go type information
	Data  []byte  // memory image of symbol
	Reloc []Reloc // relocations to apply to Data
	Func  *Func   // additional data for functions
}

A Sym is a named symbol in an object file.

type SymKind

type SymKind uint8

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

const (
	// An otherwise invalid zero value for the type
	Sxxx SymKind = iota
	// Executable instructions
	STEXT
	// Read only static data
	SRODATA
	// Static data that does not contain any pointers
	SNOPTRDATA
	// Static data
	SDATA
	// Statically data that is initially all 0s
	SBSS
	// Statically data that is initially all 0s and does not contain pointers
	SNOPTRBSS
	// Thread-local data that is initially all 0s
	STLSBSS
	// Debugging data
	SDWARFINFO
	SDWARFRANGE
	SDWARFLOC
	SDWARFLINES
	// ABI alias. An ABI alias symbol is an empty symbol with a
	// single relocation with 0 size that references the native
	// function implementation symbol.
	//
	// TODO(austin): Remove this and all uses once the compiler
	// generates real ABI wrappers rather than symbol aliases.
	SABIALIAS
	// Coverage instrumentation counter for libfuzzer.
	SLIBFUZZER_EXTRA_COUNTER
)

Defined SymKind values. Copied from cmd/internal/objabi

type SymRef

type SymRef struct {
	Name string
	goobj2.SymRef
}

Directories

Path Synopsis
internal
bio
Package bio implements common I/O abstractions used within the Go toolchain.
Package bio implements common I/O abstractions used within the Go toolchain.

Jump to

Keyboard shortcuts

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