Documentation
¶
Index ¶
- Constants
- func GetStringType(t dwarf.Type) string
- func GetUnderlyingType(entry *dwarf.Entry, data *dwarf.Data) (dwarf.Type, error)
- func OpenElf(r io.ReaderAt) (rawFile, error)
- func ParseCallSites(d *dwarf.Data, callSites *[]CallSite, ...) map[string]DwarfEntry
- func ParseDwarf(dwf *dwarf.Data) map[string]map[string]DwarfEntry
- func PrintRelocationTable(relocs []Relocation)
- type CachedFile
- type CallSite
- type Component
- type Disasm
- func (d *Disasm) Decode(start, end uint64, relocs []Relocation, gnuAsm bool, ...)
- func (d *Disasm) DecodeGNUAssembly(start, end uint64, relocs []Relocation, ...) []Instruction
- func (d *Disasm) GetGNUAssembly() GNUAssemblyLookup
- func (d *Disasm) Lookup(addr uint64) (name string, base uint64)
- func (d *Disasm) Print(w io.Writer, filter *regexp.Regexp, start, end uint64, printCode bool, ...)
- type DwarfEntry
- type ElfFile
- func (f *ElfFile) Dwarf() (*dwarf.Data, error)
- func (f *ElfFile) DynamicSymbols() ([]Symbol, error)
- func (f *ElfFile) GetRelocations() []Relocation
- func (f *ElfFile) GoArch() string
- func (f *ElfFile) PCLineTable() (textStart uint64, symtab, pclntab []byte, err error)
- func (f *ElfFile) ParseDwarf() map[string]map[string]DwarfEntry
- func (f *ElfFile) Symbols() ([]Symbol, error)
- type ElfSymbol
- func (s *ElfSymbol) GetAddress() uint64
- func (s *ElfSymbol) GetBinding() string
- func (s *ElfSymbol) GetCode() rune
- func (s *ElfSymbol) GetDirection() string
- func (s *ElfSymbol) GetIntArch() int
- func (s *ElfSymbol) GetLibrary() string
- func (s *ElfSymbol) GetName() string
- func (s *ElfSymbol) GetOriginal() interface{}
- func (s *ElfSymbol) GetRelocations() []Relocation
- func (s *ElfSymbol) GetSize() int64
- func (s *ElfSymbol) GetType() string
- func (s *ElfSymbol) GetVersion() string
- type Entry
- func (e *Entry) Disasm() (*Disasm, error)
- func (e *Entry) Dwarf() (*dwarf.Data, error)
- func (e *Entry) DynamicSymbols() ([]Symbol, error)
- func (e *Entry) GOARCH() string
- func (e *Entry) GetRelocations() []Relocation
- func (e *Entry) LoadAddress() (uint64, error)
- func (e *Entry) PCLineTable() (Liner, error)
- func (e *Entry) Symbols() ([]Symbol, error)
- func (e *Entry) Text() (uint64, []byte, error)
- type File
- func (f *File) Close() error
- func (f *File) DWARF() (*dwarf.Data, error)
- func (f *File) Disasm() (*Disasm, error)
- func (f *File) DynamicSymbols() ([]Symbol, error)
- func (f *File) GetRelocations() []Relocation
- func (f *File) GoArch() string
- func (f *File) LoadAddress() (uint64, error)
- func (f *File) PCLineTable() (Liner, error)
- func (f *File) ParseDwarf() map[string]map[string]DwarfEntry
- func (f *File) Symbols() ([]Symbol, error)
- func (f *File) Text() (uint64, []byte, error)
- type FileCache
- type FormalParamEntry
- type FunctionEntry
- type GNUAssembly
- type GNUAssemblyLookup
- type Instruction
- type Liner
- type RelocStringer
- type Relocation
- type SortByAddress
- type Symbol
- type VariableEntry
Constants ¶
const FileSymPrefix = "gofile.."
Added from cmd/internal/src
Variables ¶
This section is empty.
Functions ¶
func GetStringType ¶
Given a type, return a string representation
func GetUnderlyingType ¶
GetUnderlyingType for a parameter or return value from AttrType
func ParseCallSites ¶
func ParseCallSites(d *dwarf.Data, callSites *[]CallSite, subprograms *map[dwarf.Offset]dwarf.Entry, functions map[string]DwarfEntry) map[string]DwarfEntry
Parse Call sites into a map of DwarfEntry
func ParseDwarf ¶
func ParseDwarf(dwf *dwarf.Data) map[string]map[string]DwarfEntry
ParseDwarf and populate a lookup of Dwarf entries
func PrintRelocationTable ¶
func PrintRelocationTable(relocs []Relocation)
Print the relocation table - currently not used
Types ¶
type CachedFile ¶
CachedFile contains the content of a file split into lines.
type Component ¶
type Component struct { Name string Class string Size int64 Type string Framebase string RawType interface{} // the original type }
A Component can be a Field or param
type Disasm ¶
type Disasm struct {
// contains filtered or unexported fields
}
Disasm is a disassembler for a given File.
func (*Disasm) Decode ¶
func (d *Disasm) Decode(start, end uint64, relocs []Relocation, gnuAsm bool, f func(pc, size uint64, file string, line int, text string))
Decode disassembles the text segment range [start, end), calling f for each instruction.
func (*Disasm) DecodeGNUAssembly ¶
func (d *Disasm) DecodeGNUAssembly(start, end uint64, relocs []Relocation, f func(pc, size uint64, file string, line int, text string) Instruction) []Instruction
DecodeGNUAssembly disassembles the text segment range [start, end), calling f for each instruction.
func (*Disasm) GetGNUAssembly ¶
func (d *Disasm) GetGNUAssembly() GNUAssemblyLookup
GetAssembly returns a full data structure of instructions to further parse
func (*Disasm) Print ¶
func (d *Disasm) Print(w io.Writer, filter *regexp.Regexp, start, end uint64, printCode bool, gnuAsm bool)
Print prints a disassembly of the file to w. If filter is non-nil, the disassembly only includes functions with names matching filter. If printCode is true, the disassembly includs corresponding source lines. The disassembly only includes functions that overlap the range [start, end).
type DwarfEntry ¶
type DwarfEntry interface { GetComponents() []Component // Can be fields, params, etc. Name() string GetData() *dwarf.Data GetEntry() *dwarf.Entry GetType() *dwarf.Type }
A common interface to represent a dwarf entry (what we need)
func ParseFunction ¶
func ParseFunction(d *dwarf.Data, entry *dwarf.Entry, params []FormalParamEntry) DwarfEntry
Populate a function entry
func ParseVariable ¶
func ParseVariable(d *dwarf.Data, entry *dwarf.Entry) DwarfEntry
Populate a variable entry
type ElfFile ¶
type ElfFile struct {
// contains filtered or unexported fields
}
func (*ElfFile) DynamicSymbols ¶
Get dynamic symbols for the elf file
func (*ElfFile) GetRelocations ¶
func (f *ElfFile) GetRelocations() []Relocation
GetRelocations from te entire elf file - yes this is ugly and redundant, please improve!
func (*ElfFile) PCLineTable ¶
PCLineTable is renamed from pcln
func (*ElfFile) ParseDwarf ¶
func (f *ElfFile) ParseDwarf() map[string]map[string]DwarfEntry
Parse dwarf into the file object
type ElfSymbol ¶
type ElfSymbol struct { Name string // symbol name Address uint64 // virtual address of symbol Size int64 // size in bytes Code rune // nm code (T for text, D for data, and so on) Type string // string of type calculated from s.Info Binding string // binding calculated from s.Info Library string // Library name Version string // Library name Relocations []Relocation // in increasing Addr order Original elf.Symbol // hold the original symbol ArchInt int }
An Elf Symbol found in a file (e.g., ELF?)
func (*ElfSymbol) GetAddress ¶
func (*ElfSymbol) GetBinding ¶
func (*ElfSymbol) GetDirection ¶
GetDirection determines if we have import/export based on definition
func (*ElfSymbol) GetIntArch ¶
func (*ElfSymbol) GetLibrary ¶
func (*ElfSymbol) GetOriginal ¶
func (s *ElfSymbol) GetOriginal() interface{}
func (*ElfSymbol) GetRelocations ¶
func (s *ElfSymbol) GetRelocations() []Relocation
func (*ElfSymbol) GetVersion ¶
type Entry ¶
type Entry struct { Name string // contains filtered or unexported fields }
A generic Entry in a file has a name and data
func (*Entry) DynamicSymbols ¶
func (*Entry) GetRelocations ¶
func (e *Entry) GetRelocations() []Relocation
func (*Entry) LoadAddress ¶
LoadAddress returns the EXPECTED (not actual) address of the file.
func (*Entry) PCLineTable ¶
type File ¶
type File struct { Entries []*Entry // contains filtered or unexported fields }
An opened File - can be multiple types
func (*File) DynamicSymbols ¶
func (*File) GetRelocations ¶
func (f *File) GetRelocations() []Relocation
func (*File) LoadAddress ¶
func (*File) PCLineTable ¶
func (*File) ParseDwarf ¶
func (f *File) ParseDwarf() map[string]map[string]DwarfEntry
type FileCache ¶
type FileCache struct {
// contains filtered or unexported fields
}
FileCache is a simple LRU cache of file contents.
func NewFileCache ¶
NewFileCache returns a FileCache which can contain up to maxLen cached file contents.
type FormalParamEntry ¶
func ParseFormalParameter ¶
func ParseFormalParameter(d *dwarf.Data, entry *dwarf.Entry) FormalParamEntry
Populate a formal parameter
type FunctionEntry ¶
type FunctionEntry struct { Entry *dwarf.Entry Type *dwarf.Type Params []FormalParamEntry Data *dwarf.Data FormalParamsLookup map[dwarf.Offset]*dwarf.Entry }
Types that we need to parse
func (*FunctionEntry) GetComponents ¶
func (f *FunctionEntry) GetComponents() []Component
Function components are the associated fields
func (*FunctionEntry) GetEntry ¶
func (f *FunctionEntry) GetEntry() *dwarf.Entry
func (*FunctionEntry) GetType ¶
func (f *FunctionEntry) GetType() *dwarf.Type
func (*FunctionEntry) Name ¶
func (f *FunctionEntry) Name() string
Get the name of the entry or formal param
type GNUAssembly ¶
type GNUAssembly struct { SymbolName string File string PCLine uint64 SrcLine string Instructions []Instruction }
type GNUAssemblyLookup ¶
type GNUAssemblyLookup map[string]GNUAssembly
type Instruction ¶
GNUAssembly holds parsed assembly for symbols
type RelocStringer ¶
type Relocation ¶
type Relocation struct { Address uint64 // Address of first byte that reloc applies to. Size uint64 // Number of bytes Stringer RelocStringer // Added to suppored retriving raw SymbolName string Offset uint64 SymbolValue uint64 RelocType string // can be parse from into Info uint64 SectionIndex int }
https://cs.opensource.google/go/go/+/master:src/debug/elf/elf.go;l=3108
type SortByAddress ¶
type SortByAddress []Symbol
SortByAddress
func (SortByAddress) Len ¶
func (x SortByAddress) Len() int
Length returns the number of symbols in the sorter
func (SortByAddress) Less ¶
func (x SortByAddress) Less(i, j int) bool
type Symbol ¶
type Symbol interface { GetName() string // symbol name GetAddress() uint64 // virtual address of symbol GetSize() int64 // size in bytes GetCode() rune // nm code (T for text, D for data, and so on) GetType() string // string of type calculated from s.Info GetLibrary() string GetVersion() string GetBinding() string // binding calculated from s.Info GetRelocations() []Relocation GetOriginal() interface{} GetDirection() string // import or export based on symbol definition GetIntArch() int }
A raw symbol provides extra functions for interaction
type VariableEntry ¶
Types that we need to parse
func (*VariableEntry) GetComponents ¶
func (v *VariableEntry) GetComponents() []Component
Variable components is just one for the variable
func (*VariableEntry) GetData ¶
func (v *VariableEntry) GetData() *dwarf.Data
func (*VariableEntry) GetEntry ¶
func (v *VariableEntry) GetEntry() *dwarf.Entry
func (*VariableEntry) GetType ¶
func (v *VariableEntry) GetType() *dwarf.Type
func (*VariableEntry) Name ¶
func (v *VariableEntry) Name() string
Get the name of the entry or formal param