elf

package
v1.8.0 Latest Latest
Warning

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

Go to latest
Published: Oct 30, 2026 License: Apache-2.0 Imports: 13 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const (
	USDT_ARG_TYPE_NONE      uint8 = 0
	USDT_ARG_TYPE_CONST     uint8 = 1
	USDT_ARG_TYPE_REG       uint8 = 2
	USDT_ARG_TYPE_REG_DEREF uint8 = 3
	USDT_ARG_TYPE_SIB       uint8 = 4
)
View Source
const KernelBuildIDSize = 20

KernelBuildIDSize is the size of all buildIDs in the kernel.

Variables

This section is empty.

Functions

func ParseBuildIdFromNotes added in v1.8.0

func ParseBuildIdFromNotes(dat []byte, order binary.ByteOrder) ([]byte, bool)

ParseBuildIdFromNotes returns the GNU build ID found in a raw ELF notes blob, decoded with the given byte order. Callers holding notes without an ELF container around them, such as the running kernel's /sys/kernel/notes, can use this directly; ParseBuildId wraps it for a parsed ELF file.

Types

type GoPclntab added in v1.7.0

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

Holds parsed .gopclntab uprobe offsets for a Go binary

func (*GoPclntab) AllFuncs added in v1.7.0

func (t *GoPclntab) AllFuncs() []UprobeOffset

Returns all function symbols sorted by file offset

func (*GoPclntab) OffsetByName added in v1.7.0

func (t *GoPclntab) OffsetByName(name string) (uint64, bool)

Returns the ABI-deduped file offset for the named function

type Integer added in v1.6.0

type Integer interface {
	~int | ~int8 | ~int16 | ~int32 | ~int64 | ~uint | ~uint8 | ~uint16 | ~uint32 | ~uint64 | ~uintptr
}

Integer represents all possible integer types. Remove when x/exp/constraints is moved to the standard library.

type RegScanner added in v1.6.0

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

func (*RegScanner) Reset added in v1.6.0

func (sc *RegScanner) Reset() *RegScanner

func (*RegScanner) Scan added in v1.6.0

func (sc *RegScanner) Scan(state fmt.ScanState, _ rune) error

type SafeELFFile

type SafeELFFile struct {
	*elf.File
	// contains filtered or unexported fields
}

func NewSafeELFFile

func NewSafeELFFile(r io.ReaderAt) (safe *SafeELFFile, err error)

NewSafeELFFile reads an ELF safely.

Any panic during parsing is turned into an error. This is necessary since there are a bunch of unfixed bugs in debug/elf.

https://github.com/golang/go/issues?q=is%3Aissue+is%3Aopen+debug%2Felf+in%3Atitle

func OpenSafeELFFile

func OpenSafeELFFile(path string) (safe *SafeELFFile, err error)

OpenSafeELFFile reads an ELF from a file.

It works like NewSafeELFFile, with the exception that safe.Close will close the underlying file.

func (*SafeELFFile) AddrFromOffset added in v1.8.0

func (se *SafeELFFile) AddrFromOffset(offset uint64) (uint64, error)

func (*SafeELFFile) Address added in v1.6.0

func (se *SafeELFFile) Address(name string) (uint64, error)

func (*SafeELFFile) DynamicAddress added in v1.8.0

func (se *SafeELFFile) DynamicAddress(name string) (uint64, error)

func (*SafeELFFile) IsStrippedPureGoBinary added in v1.7.0

func (se *SafeELFFile) IsStrippedPureGoBinary() bool

func (*SafeELFFile) NormalizedBuildID added in v1.8.0

func (se *SafeELFFile) NormalizedBuildID() ([KernelBuildIDSize]byte, error)

The kernel expects BuildIDs to be <=20. If the BuildID is shorter than 20 bytes, it is padded with zeros. Return the BuildID so that it matches the kernel's in e.g., `bpf_stack_build_id`

func (*SafeELFFile) Offset

func (se *SafeELFFile) Offset(name string) (uint64, error)

Offset returns the file offset for the named symbol, for uprobe attachment. Resolves via ELF symtab only. For stripped Go binaries, use Pclntab().OffsetByName instead.

func (*SafeELFFile) OffsetFromAddr added in v1.6.0

func (se *SafeELFFile) OffsetFromAddr(addr uint64) (uint64, error)

func (*SafeELFFile) ParseBuildID added in v1.8.0

func (se *SafeELFFile) ParseBuildID() ([]byte, error)

func (*SafeELFFile) Pclntab added in v1.7.0

func (se *SafeELFFile) Pclntab() (*GoPclntab, error)

Parses .gopclntab and returns a GoPclntab of function offsets, which can then be queried by name for uprobe attachment

func (*SafeELFFile) ProgByVaddr added in v1.6.0

func (se *SafeELFFile) ProgByVaddr(vaddr uint64) *elf.Prog

ProgByVaddr returns elf program header for the specified vaddr.

func (*SafeELFFile) SectionsByName added in v1.6.0

func (se *SafeELFFile) SectionsByName(name string) []*elf.Section

SectionsByName returns all sections in the file with the specified section name.

func (*SafeELFFile) SectionsByType added in v1.6.0

func (se *SafeELFFile) SectionsByType(typ elf.SectionType) []*elf.Section

SectionsByType returns all sections in the file with the specified section type.

func (*SafeELFFile) SymbolSize added in v1.8.0

func (se *SafeELFFile) SymbolSize(name string) (uint64, error)

func (*SafeELFFile) UsdtTargets added in v1.6.0

func (se *SafeELFFile) UsdtTargets() ([]*UsdtTarget, error)

type UprobeOffset added in v1.7.0

type UprobeOffset struct {
	Name   string
	Offset uint64
	End    uint64
}

type UsdtArg added in v1.6.0

type UsdtArg struct {
	ValOff    uint64
	RegOff    uint16
	RegIdxOff uint16
	Shift     uint8
	Scale     uint8
	Type      uint8
	Signed    bool
	Size      int
	Str       string
}

type UsdtArgType added in v1.6.0

type UsdtArgType int

type UsdtSpec added in v1.6.0

type UsdtSpec struct {
	Off      uint64
	Base     uint64
	Sema     uint64
	Provider string
	Name     string
	ArgsStr  string
	ArgsCnt  uint32
	Args     [12]UsdtArg
}

type UsdtTarget added in v1.6.0

type UsdtTarget struct {
	Spec    *UsdtSpec
	IpAbs   uint64
	IpRel   uint64
	SemaOff uint64
}

Jump to

Keyboard shortcuts

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