package objfile
import "cmd/internal/objfile"
Package objfile implements portable access to OS-specific executable files.
Index ¶
- type CachedFile
- type Disasm
- func (d *Disasm) Decode(start, end uint64, relocs []Reloc, gnuAsm bool, f func(pc, size uint64, file string, line int, text string))
- func (d *Disasm) Print(w io.Writer, filter *regexp.Regexp, start, end uint64, printCode bool, gnuAsm bool)
- type Entry
- func (e *Entry) DWARF() (*dwarf.Data, error)
- func (e *Entry) Disasm() (*Disasm, error)
- func (e *Entry) GOARCH() string
- func (e *Entry) LoadAddress() (uint64, error)
- func (e *Entry) Name() string
- func (e *Entry) PCLineTable() (Liner, error)
- func (e *Entry) Symbols() ([]Sym, error)
- func (e *Entry) Text() (uint64, []byte, error)
- type File
- func Open(name string) (*File, error)
- func (f *File) Close() error
- func (f *File) DWARF() (*dwarf.Data, error)
- func (f *File) Disasm() (*Disasm, error)
- func (f *File) Entries() []*Entry
- func (f *File) GOARCH() string
- func (f *File) LoadAddress() (uint64, error)
- func (f *File) PCLineTable() (Liner, error)
- func (f *File) Symbols() ([]Sym, error)
- func (f *File) Text() (uint64, []byte, error)
- type FileCache
- func NewFileCache(maxLen int) *FileCache
- func (fc *FileCache) Line(filename string, line int) ([]byte, error)
- type Liner
- type Reloc
- type RelocStringer
- type Sym
Types ¶
type CachedFile ¶
CachedFile contains the content of a file split into lines.
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 []Reloc, 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) 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 Entry ¶
type Entry struct {
// contains filtered or unexported fields
}
func (*Entry) DWARF ¶
DWARF returns DWARF debug data for the file, if any. This is for cmd/pprof to locate cgo functions.
func (*Entry) Disasm ¶
Disasm returns a disassembler for the file f.
func (*Entry) GOARCH ¶
func (*Entry) LoadAddress ¶
LoadAddress returns the expected load address of the file. This differs from the actual load address for a position-independent executable.
func (*Entry) Name ¶
func (*Entry) PCLineTable ¶
func (*Entry) Symbols ¶
func (*Entry) Text ¶
type File ¶
type File struct {
// contains filtered or unexported fields
}
A File is an opened executable file.
func Open ¶
Open opens the named file. The caller must call f.Close when the file is no longer needed.
func (*File) Close ¶
func (*File) DWARF ¶
func (*File) Disasm ¶
func (*File) Entries ¶
func (*File) GOARCH ¶
func (*File) LoadAddress ¶
func (*File) PCLineTable ¶
func (*File) Symbols ¶
func (*File) Text ¶
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.
func (*FileCache) Line ¶
Line returns the source code line for the given file and line number. If the file is not already cached, reads it, inserts it into the cache, and removes the least recently used file if necessary. If the file is in cache, it is moved to the front of the list.
type Liner ¶
type Liner interface { // Given a pc, returns the corresponding file, line, and function data. // If unknown, returns "",0,nil. PCToLine(uint64) (string, int, *gosym.Func) }
type Reloc ¶
type Reloc struct { Addr uint64 // Address of first byte that reloc applies to. Size uint64 // Number of bytes Stringer RelocStringer }
type RelocStringer ¶
type RelocStringer interface { // insnOffset is the offset of the instruction containing the relocation // from the start of the symbol containing the relocation. String(insnOffset uint64) string }
type Sym ¶
type Sym struct { Name string // symbol name Addr 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 // XXX? Relocs []Reloc // in increasing Addr order }
A Sym is a symbol defined in an executable file.
Source Files ¶
disasm.go elf.go goobj.go macho.go objfile.go pe.go plan9obj.go xcoff.go
- Version
- v1.22.8
- Published
- Sep 28, 2024
- Platform
- js/wasm
- Imports
- 30 packages
- Last checked
- 20 seconds ago –
Tools for package owners.