asm

package
v0.0.0-...-f342860 Latest Latest
Warning

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

Go to latest
Published: Apr 9, 2024 License: BSD-3-Clause Imports: 4 Imported by: 1

Documentation

Overview

Package asm abstracts disassembling machine code from various architectures.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Arg

type Arg interface {
}

Arg is an argument to an instruction.

type Control

type Control struct {
	Type        ControlType
	Conditional bool
	TargetPC    uint64 // ^0 if unknown
	Target      Arg
}

Control captures control-flow effects of an instruction.

type ControlType

type ControlType uint8
const (
	ControlNone ControlType = iota
	ControlJump
	ControlCall
	ControlRet

	// ControlJumpUnknown is a jump with an unknown target. This
	// means the control analysis could be incomplete, since this
	// could jump to an instruction in the analyzed function.
	ControlJumpUnknown

	// ControlExit is like a call that never returns.
	ControlExit
)

func (ControlType) String

func (i ControlType) String() string

type Inst

type Inst interface {
	// GoSyntax returns the Go assembler syntax representation of
	// this instruction. symname, if non-nil, must return the name
	// and base of the symbol containing address addr, or "" if
	// symbol lookup fails.
	GoSyntax(symName func(addr uint64) (string, uint64)) string

	// PC returns the address of this instruction.
	PC() uint64

	// Len returns the length of this instruction in bytes.
	Len() int

	// Control returns the control-flow effects of this
	// instruction.
	Control() Control
}

Inst is a single machine instruction.

type Seq

type Seq interface {
	Len() int
	Get(i int) Inst
}

Seq is a sequence of instructions.

func Disasm

func Disasm(arch *arch.Arch, text []byte, pc uint64) (Seq, error)

Disasm disassembles machine code for the given architecture. pc is the program counter at which text begins.

Jump to

Keyboard shortcuts

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