objfile

Imports

Imports #

"cmd/internal/archive"
"cmd/internal/goobj"
"cmd/internal/objabi"
"cmd/internal/sys"
"debug/dwarf"
"debug/gosym"
"errors"
"fmt"
"io"
"os"
"debug/dwarf"
"debug/macho"
"fmt"
"io"
"slices"
"sort"
"cmd/internal/archive"
"cmp"
"debug/dwarf"
"debug/gosym"
"fmt"
"io"
"os"
"slices"
"debug/dwarf"
"debug/pe"
"fmt"
"io"
"slices"
"sort"
"debug/dwarf"
"debug/plan9obj"
"errors"
"fmt"
"io"
"slices"
"sort"
"debug/dwarf"
"fmt"
"internal/xcoff"
"io"
"unicode"
"debug/dwarf"
"debug/elf"
"encoding/binary"
"fmt"
"io"

Constants & Variables

openers var #

var openers = []func(io.ReaderAt) (rawFile, error){...}

stabTypeMask const #

const stabTypeMask = 0xe0

validSymType var #

var validSymType = map[rune]bool{...}

Interfaces

Liner interface #

type Liner interface {
PCToLine(uint64) (string, int, *gosym.Func)
}

RelocStringer interface #

type RelocStringer interface {
String(insnOffset uint64) string
}

rawFile interface #

type rawFile interface {
symbols() (syms []Sym, err error)
pcln() (textStart uint64, symtab []byte, pclntab []byte, err error)
text() (textStart uint64, text []byte, err error)
goarch() string
loadAddress() (uint64, error)
dwarf() (*dwarf.Data, error)
}

Structs

Entry struct #

type Entry struct {
name string
raw rawFile
}

File struct #

A File is an opened executable file.

type File struct {
r *os.File
entries []*Entry
}

Reloc struct #

type Reloc struct {
Addr uint64
Size uint64
Stringer RelocStringer
}

Sym struct #

A Sym is a symbol defined in an executable file.

type Sym struct {
Name string
Addr uint64
Size int64
Code rune
Type string
Relocs []Reloc
}

elfFile struct #

type elfFile struct {
elf *elf.File
}

goobjFile struct #

type goobjFile struct {
goobj *archive.GoObj
r *goobj.Reader
f *os.File
arch *sys.Arch
}

goobjReloc struct #

type goobjReloc struct {
Off int32
Size uint8
Type objabi.RelocType
Add int64
Sym string
}

machoFile struct #

type machoFile struct {
macho *macho.File
}

peFile struct #

type peFile struct {
pe *pe.File
}

plan9File struct #

type plan9File struct {
plan9 *plan9obj.File
}

xcoffFile struct #

type xcoffFile struct {
xcoff *xcoff.File
}

Functions

Close method #

func (f *File) Close() error

DWARF method #

DWARF returns DWARF debug data for the file, if any. This is for cmd/pprof to locate cgo functions.

func (e *Entry) DWARF() (*dwarf.Data, error)

DWARF method #

func (f *File) DWARF() (*dwarf.Data, error)

Entries method #

func (f *File) Entries() []*Entry

GOARCH method #

func (e *Entry) GOARCH() string

GOARCH method #

func (f *File) GOARCH() string

LoadAddress method #

func (f *File) LoadAddress() (uint64, error)

LoadAddress method #

LoadAddress returns the expected load address of the file. This differs from the actual load address for a position-independent executable.

func (e *Entry) LoadAddress() (uint64, error)

Name method #

func (e *Entry) Name() string

Open function #

Open opens the named file. The caller must call f.Close when the file is no longer needed.

func Open(name string) (*File, error)

PCLineTable method #

func (f *File) PCLineTable() (Liner, error)

PCLineTable method #

func (e *Entry) PCLineTable() (Liner, error)

PCToLine method #

Find returns the file name, line, and function data for the given pc. Returns "",0,nil if unknown. This function implements the Liner interface in preference to pcln() above.

func (f *goobjFile) PCToLine(pc uint64) (string, int, *gosym.Func)

String method #

func (r goobjReloc) String(insnOffset uint64) string

Symbols method #

func (e *Entry) Symbols() ([]Sym, error)

Symbols method #

func (f *File) Symbols() ([]Sym, error)

Text method #

func (f *File) Text() (uint64, []byte, error)

Text method #

func (e *Entry) Text() (uint64, []byte, error)

dwarf method #

func (f *goobjFile) dwarf() (*dwarf.Data, error)

dwarf method #

func (f *machoFile) dwarf() (*dwarf.Data, error)

dwarf method #

func (f *peFile) dwarf() (*dwarf.Data, error)

dwarf method #

func (f *plan9File) dwarf() (*dwarf.Data, error)

dwarf method #

func (f *xcoffFile) dwarf() (*dwarf.Data, error)

dwarf method #

func (f *elfFile) dwarf() (*dwarf.Data, error)

findPESymbol function #

func findPESymbol(f *pe.File, name string) (*pe.Symbol, error)

findPlan9Symbol function #

func findPlan9Symbol(f *plan9obj.File, name string) (*plan9obj.Sym, error)

findXCOFFSymbol function #

func findXCOFFSymbol(f *xcoff.File, name string) (*xcoff.Symbol, error)

goarch method #

func (f *machoFile) goarch() string

goarch method #

func (f *peFile) goarch() string

goarch method #

func (f *plan9File) goarch() string

goarch method #

func (f *goobjFile) goarch() string

goarch method #

func (f *xcoffFile) goarch() string

goarch method #

func (f *elfFile) goarch() string

goobjName function #

func goobjName(name string, ver int) string

imageBase method #

func (f *peFile) imageBase() (uint64, error)

loadAddress method #

func (f *plan9File) loadAddress() (uint64, error)

loadAddress method #

func (f *peFile) loadAddress() (uint64, error)

loadAddress method #

func (f *xcoffFile) loadAddress() (uint64, error)

loadAddress method #

func (f *goobjFile) loadAddress() (uint64, error)

loadAddress method #

func (f *elfFile) loadAddress() (uint64, error)

loadAddress method #

func (f *machoFile) loadAddress() (uint64, error)

loadPETable function #

func loadPETable(f *pe.File, sname string, ename string) ([]byte, error)

loadPlan9Table function #

func loadPlan9Table(f *plan9obj.File, sname string, ename string) ([]byte, error)

loadXCOFFTable function #

func loadXCOFFTable(f *xcoff.File, sname string, ename string) ([]byte, error)

openElf function #

func openElf(r io.ReaderAt) (rawFile, error)

openGoFile function #

func openGoFile(f *os.File) (*File, error)

openMacho function #

func openMacho(r io.ReaderAt) (rawFile, error)

openPE function #

func openPE(r io.ReaderAt) (rawFile, error)

openPlan9 function #

func openPlan9(r io.ReaderAt) (rawFile, error)

openXcoff function #

func openXcoff(r io.ReaderAt) (rawFile, error)

pcValue function #

pcValue looks up the given PC in a pc value table. target is the offset of the pc from the entry point.

func pcValue(tab []byte, target uint64, arch *sys.Arch) int32

pcln method #

func (f *goobjFile) pcln() (textStart uint64, symtab []byte, pclntab []byte, err error)

pcln method #

func (f *plan9File) pcln() (textStart uint64, symtab []byte, pclntab []byte, err error)

pcln method #

func (f *elfFile) pcln() (textStart uint64, symtab []byte, pclntab []byte, err error)

pcln method #

func (f *machoFile) pcln() (textStart uint64, symtab []byte, pclntab []byte, err error)

pcln method #

func (f *peFile) pcln() (textStart uint64, symtab []byte, pclntab []byte, err error)

pcln method #

func (f *xcoffFile) pcln() (textStart uint64, symtab []byte, pclntab []byte, err error)

readvarint function #

readvarint reads, removes, and returns a varint from *p.

func readvarint(p *[]byte) uint32

step function #

step advances to the next pc, value pair in the encoded table.

func step(p *[]byte, pc *uint64, val *int32, first bool, arch *sys.Arch) bool

symbolData method #

func (f *elfFile) symbolData(start string, end string) []byte

symbols method #

func (f *machoFile) symbols() ([]Sym, error)

symbols method #

func (f *xcoffFile) symbols() ([]Sym, error)

symbols method #

func (f *elfFile) symbols() ([]Sym, error)

symbols method #

func (f *plan9File) symbols() ([]Sym, error)

symbols method #

func (f *goobjFile) symbols() ([]Sym, error)

symbols method #

func (f *peFile) symbols() ([]Sym, error)

text method #

func (f *xcoffFile) text() (textStart uint64, text []byte, err error)

text method #

We treat the whole object file as the text section.

func (f *goobjFile) text() (textStart uint64, text []byte, err error)

text method #

func (f *plan9File) text() (textStart uint64, text []byte, err error)

text method #

func (f *elfFile) text() (textStart uint64, text []byte, err error)

text method #

func (f *machoFile) text() (textStart uint64, text []byte, err error)

text method #

func (f *peFile) text() (textStart uint64, text []byte, err error)

Generated with Arrow