binary

package
v0.0.2 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrUnknownArch   = errors.New("unknown arch")
	ErrUnknownOS     = errors.New("unknown os")
	ErrUnknownBinary = errors.New("binary type is unknown")
)
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 string
var (
	ArchAmd64   Arch = "amd64"
	ArchI386    Arch = "i386"
	ArchArm64   Arch = "arm64"
	ArchArm32   Arch = "arm"
	ArchUnknown Arch = "Unknown"
)

func (*Arch) String

func (a *Arch) String() string

type Info

type Info struct {
	Arch          Arch
	OS            OS
	Compiler      string
	StaticLinking bool
	ByteOrder     binary.ByteOrder
	Security      *SecurityInfo
	// contains filtered or unexported fields
}

func AnalyzeBinary

func AnalyzeBinary(path string) (*Info, 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 Info 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.

func (*Info) GetSymbolAddr

func (bi *Info) GetSymbolAddr(symbolName string) (Addr, error)

GetSymbolAddr returns the address of the symbol with the given name. If the symbol is not found, an error is returned.

func (*Info) String

func (bi *Info) 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