replacer

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Apr 3, 2022 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrFunctionNotFound returned when provided function was not found.
	ErrFunctionNotFound = fmt.Errorf("function was not found")

	// ErrUnsupportedArchitecture returned if cpu architecture currently unsupported.
	ErrUnsupportedArchitecture = fmt.Errorf("unsupported cpu architecture")

	// ErrShortFunction returned if function too short for trampoline.
	ErrShortFunction = fmt.Errorf("too short function")

	// ErrLongDistance returned if functions located too far for trampoline.
	ErrLongDistance = fmt.Errorf("long distance between functions")
)

Functions

This section is empty.

Types

type Executable

type Executable interface {
	io.WriterAt

	// GOARCH returns "GOARCH" string of executable.
	GOARCH() string

	// TextAddr returns 'text' (executable code) section address.
	TextAddr() uint64

	// GoSymTabData returns reader for 'gosymtab' section.
	GoSymTabData() io.Reader

	// GoPCLnTabData returns reader for 'gopclntab' section.
	GoPCLnTabData() io.Reader

	// Offset returns function offset from beginning of executable.
	Offset(p *gosym.Func) int64
}

Executable contains methods to fetch information required for patching.

type Replacer

type Replacer struct {
	// contains filtered or unexported fields
}

func NewReplacer

func NewReplacer(executable Executable) (*Replacer, error)

func (*Replacer) Replace

func (r *Replacer) Replace(sourceName, targetName string) error

Replace puts "trampoline code" to beginning of function with sourceName that redirects to function with targetName. Function names here are "raw" (no mangling, etc. performed before search). There is no checks about "cyclic replacement" (i.e. "a"->"b" than "b"->"a") so be careful to avoid infinite loops.

Jump to

Keyboard shortcuts

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