binutils

package
v0.0.6 Latest Latest
Warning

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

Go to latest
Published: Jan 8, 2026 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MaxGadgetLen = 20 // max count bytes in gadget
)

Variables

View Source
var (
	ErrUnknownArch    = errors.New("unknown arch")
	ErrUnknownOS      = errors.New("unknown os")
	ErrUnknownBinary  = errors.New("binary type is unknown")
	ErrStringNotFound = errors.New("string not found")
	ErrGadgetNotFound = errors.New("gadget not found")
	ErrSymbolNotFound = errors.New("symbol not found")
)
View Source
var (
	ArchAmd64   = Arch{Name: "amd64", Bitness: 64}
	ArchI386    = Arch{Name: "i386", Bitness: 32}
	ArchArm64   = Arch{Name: "arm64", Bitness: 64}
	ArchArm32   = Arch{Name: "arm", Bitness: 32}
	ArchUnknown = Arch{Name: "unknown"}
)
View Source
var (
	ErrNasmNotFoundInPATH = fmt.Errorf("nasm not found in PATH")
)
View Source
var ErrNoDynamicSection = errors.New("no .dynamic section")

Functions

This section is empty.

Types

type Addr

type Addr uint64

func (Addr) String

func (a Addr) String() string

type Arch

type Arch struct {
	Name    string
	Bitness uint8
}

func (*Arch) String

func (a *Arch) String() string

type Binary

type Binary interface {
	// Info returns binary info like arch, os, compiler, security mitigations, etc
	Info() *BinaryInfo

	// GetSymbolAddr returns the address of the symbol with the given name.
	// If the symbol is not found, an error is returned.
	GetSymbolAddr(symbolName string) (Addr, error)

	// GetStringAddr returns the address of the given string in the binary's .data or .rodata
	// sections. If the string is not found, an error of type ErrStringNotFound
	// is returned.
	GetStringAddr(s string) (Addr, error)

	GetGadgetAddr(instructions []string) ([]Addr, error)
}

func AnalyzeBinary

func AnalyzeBinary(path string) (Binary, error)

AnalyzeBinary analyzes the given binary and returns information about it.

The path must be a valid ELF, PE or Mach-O file. If the file is not recognized, an error of type ErrUnknownBinary is returned.

The returned ELF contains information about the binary's architecture, operating system, compiler, linking, and security.

The returned error is nil if the analysis is successful, or an error describing the problem if the analysis fails.

type BinaryInfo added in v0.0.6

type BinaryInfo struct {
	Arch          Arch
	OS            OS
	Compiler      string
	Linking       string
	Security      *SecurityInfo
	StaticLinking bool
	ByteOrder     binary.ByteOrder
}

func (*BinaryInfo) String added in v0.0.6

func (bi *BinaryInfo) String() string

type OS

type OS string
var (
	OSLinux   OS = "Linux"
	OSWindows OS = "Windows"
	OSMac     OS = "macOS"
	OSUnknown OS = "Unknown"
)

func (*OS) String

func (o *OS) String() string

type RelRo

type RelRo uint8
const (
	RelRoEnable RelRo = iota
	RelRoPartial
	RelRoDisable
	RelRoUnknown
)

func (RelRo) String

func (r RelRo) String() string

type SecurityInfo

type SecurityInfo struct {
	RelRo        RelRo
	CanaryEnable bool
	NXEnable     bool
	PIEEnable    bool
}

Jump to

Keyboard shortcuts

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