asm

package
v0.9.2 Latest Latest
Warning

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

Go to latest
Published: May 21, 2024 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Generate

func Generate(arch *config.Arch, srcPath string, clangVersion string, functions []Function) ([]byte, error)

Generate generates the Go PLAN9 assembly

func GenerateFile

func GenerateFile(arch *config.Arch, path string, srcPath string, clangVersion string, functions []Function) error

GenerateFile generates the Go PLAN9 assembly file

func GenerateGoStubs

func GenerateGoStubs(arch *config.Arch, pkg, output string, functions []Function) error

GenerateGoStubs generates Go stubs for the functions.

func ParseClangObjectDump

func ParseClangObjectDump(arch *config.Arch, dump string, functions []Function, dec Plan9Decoder) error

ParseClangObjectDump parses the output of objdump file and returns a list of functions

func ParseGoObjectDump

func ParseGoObjectDump(arch *config.Arch, dump string, functions []Function) error

ParseGoObjectDump parses the output of objdump file and returns a list of functions

Types

type Const

type Const struct {
	Label string      `json:"label"` // Label of the constant
	Lines []ConstLine `json:"lines"` // LInes of the constant
}

func (*Const) Compile

func (c *Const) Compile(arch *config.Arch) string

Compile returns the string representation of a line in PLAN9 assembly

type ConstLine

type ConstLine struct {
	Size  int    `json:"size"`  // Size of the constant
	Value uint64 `json:"value"` // Value of the constant
}

type Function

type Function struct {
	Name       string  `json:"name"`
	SourcePath string  `json:"sourcePath"`
	Position   int     `json:"position"`
	Params     []Param `json:"params"`
	Consts     []Const `json:"consts,omitempty"`
	Lines      []Line  `json:"lines"`
	LocalsSize int     `json:"localsSize,omitempty"`
	Ret        *Param  `json:"return,omitempty"`
	GoFunc     GoFunction
}

func ApplyTransforms

func ApplyTransforms(arch *config.Arch, functions []Function) []Function

func ParseAssembly

func ParseAssembly(arch *config.Arch, path string) ([]Function, error)

ParseAssembly parses the assembly file and returns a list of functions

func (*Function) ParamsSize

func (f *Function) ParamsSize(arch *config.Arch) (int, []int)

func (*Function) String

func (f *Function) String() string

String returns the function signature for a Go stub

type GoFunction

type GoFunction struct {
	Name string
	Expr *ast.FuncType
}

func (*GoFunction) ForEachParam

func (f *GoFunction) ForEachParam(fn func(name, typ string))

func (*GoFunction) ForEachResult

func (f *GoFunction) ForEachResult(fn func(name, typ string))

func (*GoFunction) NumResults

func (f *GoFunction) NumResults() int

type Line

type Line struct {
	Labels       []string `json:"labels,omitempty"`       // Labels for the line
	Binary       []string `json:"binary"`                 // Binary representation of the line
	Assembly     string   `json:"assembly"`               // Assembly representation of the line
	Disassembled string   `json:"disassembled,omitempty"` // Disassembled representation of the line
}

Line represents a line of assembly code

func (*Line) Compile

func (line *Line) Compile(arch *config.Arch) string

Compile returns the string representation of a line in PLAN9 assembly

type Param

type Param struct {
	Type      string `json:"type"`                // Type of the parameter (C type)
	Name      string `json:"name"`                // Name of the parameter
	IsPointer bool   `json:"isPointer,omitempty"` // Whether the parameter is a pointer
}

Param represents a function parameter

func (*Param) CString

func (p *Param) CString() string

func (*Param) CTypeStr

func (p *Param) CTypeStr() string

func (*Param) EquivalentType

func (p *Param) EquivalentType() types.Type

func (*Param) IsFloatingPoint

func (p *Param) IsFloatingPoint() bool

func (*Param) Size

func (p *Param) Size() int

func (*Param) String

func (p *Param) String() string

String returns the Go string representation of a parameter

type Plan9Decoder

type Plan9Decoder interface {
	DecodeInstruction(symName string, binary []string) (string, error)
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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