gort

package module
v0.0.0-...-7a7794b Latest Latest
Warning

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

Go to latest
Published: May 15, 2022 License: MIT Imports: 13 Imported by: 2

README

gort

  • go runtime type: get reflect.Type by name

Usage

  • lets you call functions in your binary with just the string of their name
	rt, err := gort.NewDwarfRT("")
	fmt.Printf("test call fmt.Printf\n")

	rets, err = rt.CallFunc("fmt.Printf", true, []reflect.Value{
		reflect.ValueOf("test call fmt.Printf:%d %s\n"),
		reflect.ValueOf(1234),
		reflect.ValueOf("hello"),
	})
  • lets you get access to globals in your binary with just the string of their name
	rt, err := gort.NewDwarfRT("")
	rGlobal, err := rt.FindGlobal("main.testGlobal")
  • lets you get access to all of the reflect.Types in your binary of their name
    • Caveat: the types must be possible outputs to reflect.TypeOf(val) in your binary
	rt, err := gort.NewDwarfRT("")
	typ, err := rt.FindType("main.testStruct")

Examples

  • go build -gcflags=all=-l examples/hello/hello.go
  • ./hello

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNeedInit         = errors.New("need init")
	ErrNotFound         = errors.New("not found")
	ErrNotSupport       = errors.New("not support")
	ErrTooManyLibraries = errors.New("number of loaded libraries exceeds maximum")
)

Functions

Types

type DwarfRT

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

func NewDwarfRT

func NewDwarfRT(path string) (*DwarfRT, error)

func (*DwarfRT) AddImage

func (d *DwarfRT) AddImage(path string, addr uint64) error

func (*DwarfRT) BI

func (d *DwarfRT) BI() *proc.BinaryInfo

func (*DwarfRT) CallFunc

func (d *DwarfRT) CallFunc(name string, variadic bool, args []reflect.Value) ([]reflect.Value, error)

func (*DwarfRT) FindFunc

func (d *DwarfRT) FindFunc(name string, variadic bool) (reflect.Value, error)

func (*DwarfRT) FindFuncEntry

func (d *DwarfRT) FindFuncEntry(name string) (*proc.Function, error)

func (*DwarfRT) FindFuncPc

func (d *DwarfRT) FindFuncPc(name string) (uint64, error)

func (*DwarfRT) FindFuncType

func (d *DwarfRT) FindFuncType(name string, variadic bool) (reflect.Type, error)

func (*DwarfRT) FindGlobal

func (d *DwarfRT) FindGlobal(name string) (reflect.Value, error)

func (*DwarfRT) FindType

func (d *DwarfRT) FindType(name string) (reflect.Type, error)

func (*DwarfRT) ForeachFunc

func (d *DwarfRT) ForeachFunc(f func(name string, pc uint64)) error

func (*DwarfRT) ForeachGlobal

func (d *DwarfRT) ForeachGlobal(f func(name string, v reflect.Value)) error

func (*DwarfRT) ForeachType

func (d *DwarfRT) ForeachType(f func(name string)) error

func (*DwarfRT) SearchPluginByName

func (d *DwarfRT) SearchPluginByName(name string) (string, uint64, error)

func (*DwarfRT) SearchPlugins

func (d *DwarfRT) SearchPlugins() ([]string, []uint64, error)

type Func

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

Directories

Path Synopsis
examples

Jump to

Keyboard shortcuts

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