Documentation ¶
Overview ¶
Package bininfo provides functions for reading elf binary files and converting file/line pairs or functions to addresses.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var (
ErrInvalidElfType = errors.New("invalid elf type")
)
Functions ¶
This section is empty.
Types ¶
type BinFile ¶
type BinFile struct {
// contains filtered or unexported fields
}
A BinFile provides functions for converting source code structures such as functions and line numbers into addresses. The BinFile also tracks if the executable is position-independent and if so provides a function to compute the PIE offset for a running instance.
func (*BinFile) FuncToPC ¶
FuncToPC converts a function name to a PC. It does a "fuzzy" search so if the given name is a substring of a real function name, and the substring uniquely identifies it, that function is used. If there are multiple matches it returns a multiple match error describing all the matches.
func (*BinFile) InlinedFuncToPCs ¶
func (b *BinFile) InlinedFuncToPCs(name string) ([]InlinedFunc, error)
InlinedFuncToPCs is the same as FuncToPCs but works for inlined functions and returns all start addresses and end addresses of the various inlinings of the specified function.
func (*BinFile) LineToPC ¶
LineToPC converts a file/line location to a PC. It performs a "fuzzy" search on the filename similar to FuncToPC.
func (*BinFile) PieOffset ¶
PieOffset returns the PIE/ASLR offset for a running instance of this binary file. It reads /proc/pid/maps to determine the right location, so the caller must have ptrace permissions. If possible, you should cache the result of this function instead of calling it multiple times.
type ErrMultipleMatches ¶
type ErrMultipleMatches struct {
Matches []string
}
ErrMultipleMatches is an error that describes a filename or function name matching multiple known files/functions.
func (*ErrMultipleMatches) Error ¶
func (e *ErrMultipleMatches) Error() string
type InlinedFunc ¶
An InlinedFunc is a range of addresses representing the beginning and end of the inlined function.