assembly

package module
v0.0.0-...-4e68953 Latest Latest
Warning

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

Go to latest
Published: May 7, 2026 License: Apache-2.0 Imports: 14 Imported by: 1

README

Assembly

Go Reference license-Apache 2 Go Report Card Test

Provides DWARF-based binary analysis for Go programs, including symbol lookup, type inspection, function invocation, and plugin discovery. Supports Linux, macOS, and Windows platforms.

API Overview

// NewDwarfAssembly creates and initializes a new DwarfAssembly instance.
// It loads DWARF debug information from the current binary and prepares it
// for symbol lookup, type inspection, and function invocation.
func NewDwarfAssembly() (DwarfAssembly, error)

// DwarfAssembly provides an interface for analyzing binary programs using DWARF debug information.
type DwarfAssembly interface {
	// LoadImage dynamically loads a shared library image into the process address space.
	LoadImage(path string, entryPoint uint64) error
	// Close releases all associated resources.
	Close() error

	// Global variables
	FindGlobal(name string) (reflect.Value, error)
	Globals() iter.Seq2[string, reflect.Value]

	// Type definitions
	FindType(name string) (reflect.Type, error)
	Types() iter.Seq[string]

	// Functions
	FindFunc(name string) (*proc.Function, error)
	FindFuncType(name string, variadic bool) (reflect.Type, error)
	FindFuncValue(name string, variadic bool) (reflect.Value, error)
	Funcs() iter.Seq[string]
	CallFunc(name string, variadic bool, args []reflect.Value) ([]reflect.Value, error)

	// Plugins
	FindPlugin(name string) (lib string, addr uint64, err error)
	Plugins() iter.Seq[string]
}
Go Test
$ go test -gcflags "all=-N -l" -ldflags "-w=false -s=false" ./...
License

The repository released under version 2.0 of the Apache License.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNotFound   = errors.New("not found")
	ErrNotSupport = errors.New("not support")
)

Functions

Types

type DwarfAssembly

type DwarfAssembly interface {
	// LoadImage dynamically loads a shared library image into the process address space.
	LoadImage(path string, entryPoint uint64) error
	// Close releases all associated resources.
	Close() error

	// FindGlobal looks up a global variable by name.
	FindGlobal(name string) (reflect.Value, error)
	// Globals returns an iterator over all global variables.
	Globals() iter.Seq2[string, reflect.Value]

	// FindType looks up a type definition by name.
	FindType(name string) (reflect.Type, error)
	// Types returns an iterator over all type definition names.
	// Panics if the underlying type information cannot be loaded.
	Types() iter.Seq[string]

	// FindFunc looks up a function by name.
	// Returns the function object containing entry address details, or an error if not found.
	FindFunc(name string) (*proc.Function, error)
	// FindFuncType looks up a function's type signature by name.
	// variadic indicates whether to treat the function as a variadic function.
	FindFuncType(name string, variadic bool) (reflect.Type, error)
	// FindFuncValue looks up a function by name and creates a callable reflect.Value.
	// variadic indicates whether to treat the function as a variadic function.
	FindFuncValue(name string, variadic bool) (reflect.Value, error)
	// Funcs returns an iterator over all function names.
	Funcs() iter.Seq[string]
	// CallFunc invokes a function by name.
	// variadic indicates whether to treat the function as a variadic function.
	// args specifies the list of function arguments.
	CallFunc(name string, variadic bool, args []reflect.Value) ([]reflect.Value, error)

	// FindPlugin searches for a plugin by name.
	FindPlugin(name string) (lib string, addr uint64, err error)
	// Plugins returns an iterator over all plugin library names.
	Plugins() iter.Seq[string]
}

DwarfAssembly provides an interface for analyzing binary programs using DWARF debug information.

func NewDwarfAssembly

func NewDwarfAssembly() (DwarfAssembly, error)

NewDwarfAssembly creates and initializes a new DwarfAssembly instance.

type Func

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

type ModuleData

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

ModuleData counterpart to proc.moduleData

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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