binary

package
v0.0.0-...-c356460 Latest Latest
Warning

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

Go to latest
Published: Jul 20, 2026 License: AGPL-3.0 Imports: 5 Imported by: 0

Documentation

Overview

Package binary defines types and the interface for parsed executable files. Format-specific packages (elf, pe, macho) implement this interface and register themselves via RegisterFormat.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RegisterFormat

func RegisterFormat(format Format, opener Opener)

Types

type Binary

type Binary interface {
	Format() Format
	Architecture() types.Arch
	EntryPoint() uint64
	Sections() []Section
	Section(name string) (Section, bool)
	Symbols() ([]Symbol, error)
	DynamicSymbols() ([]Symbol, error)
	IsPIE() bool
	IsStripped() bool
	ByteOrder() binary.ByteOrder
	GoBuildInfo() (*GoBuildInfo, bool)
	Pclntab() ([]byte, uint64, bool)
	Close() error
}

func Open

func Open(path string) (Binary, error)

Open detects the binary format from magic bytes and returns a parsed Binary.

type Format

type Format int
const (
	FormatUnknown Format = iota
	FormatELF
	FormatPE
	FormatMachO
)

func (Format) String

func (f Format) String() string

type GoBuildInfo

type GoBuildInfo struct {
	Version  string
	Path     string
	Main     string
	Deps     []GoModuleDep
	Settings map[string]string
}

type GoModuleDep

type GoModuleDep struct {
	Path    string
	Version string
	Sum     string
}

type Opener

type Opener func(path string) (Binary, error)

type Section

type Section struct {
	Name    string
	Address uint64
	Size    uint64
	Offset  uint64
	Data    []byte
	Flags   SectionFlag
	EntSize uint64
	Link    uint32
	Info    uint32
	Align   uint64
}

type SectionFlag

type SectionFlag int
const (
	SectionExecutable SectionFlag = 1 << iota
	SectionWritable
	SectionReadable
)

type Symbol

type Symbol struct {
	Name    string
	Address uint64
	Size    uint64
	Type    SymbolType
	Section string
	Version string
	Binding SymbolBinding
}

type SymbolBinding

type SymbolBinding int
const (
	SymbolLocal SymbolBinding = iota
	SymbolGlobal
	SymbolWeak
)

type SymbolType

type SymbolType int
const (
	SymbolUnknown SymbolType = iota
	SymbolFunction
	SymbolObject
	SymbolSection
	SymbolFile
)

Directories

Path Synopsis
Package macho provides a Mach-O binary parser implementing the binary.Binary interface.
Package macho provides a Mach-O binary parser implementing the binary.Binary interface.

Jump to

Keyboard shortcuts

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