Documentation
¶
Overview ¶
Package gen contains utilities to generate Go bindings for eBPF ELF files.
Index ¶
- Variables
- func CollectGlobalTypes(spec *ebpf.CollectionSpec) []btf.Type
- func Compile(args CompileArgs) error
- func FindTarget(id string) (Target, GoArches, error)
- func Generate(args GenerateArgs) error
- func TargetsByGoArch() map[GoArch]Target
- type CompileArgs
- type GenerateArgs
- type GoArch
- type GoArches
- type Target
Constants ¶
This section is empty.
Variables ¶
var ErrInvalidTarget = errors.New("unsupported target")
Functions ¶
func CollectGlobalTypes ¶
func CollectGlobalTypes(spec *ebpf.CollectionSpec) []btf.Type
CollectGlobalTypes finds all types which are used in the global scope.
This currently includes the types of variables, map keys and values.
func FindTarget ¶
FindTarget turns a list of identifiers into targets and their respective GoArches.
The following are valid identifiers:
- bpf: compile generic BPF for host endianness
- bpfel: compile generic BPF for little endian
- bpfeb: compile generic BPF for big endian
- native: compile BPF for host target
- $GOARCH: compile BPF for $GOARCH target
Generic BPF can run on any target goarch with the correct endianness, but doesn't have access to some arch specific tracing functionality.
func TargetsByGoArch ¶
TargetsByGoArch returns all supported targets.
Types ¶
type CompileArgs ¶
type CompileArgs struct {
// Which compiler to use.
CC string
// Command used to strip DWARF from the ELF.
Strip string
// Flags to pass to the compiler.
Flags []string
// Absolute working directory
Workdir string
// Absolute input file name
Source string
// Absolute output file name
Dest string
// Target to compile for, defaults to compiling generic BPF in host endianness.
Target Target
DisableStripping bool
}
type GenerateArgs ¶
type GenerateArgs struct {
// Package of the resulting file.
Package string
// The prefix of all names declared at the top-level.
Stem string
// Build Constraints included in the resulting file.
Constraints constraint.Expr
// Maps to be emitted.
Maps []string
// Variables to be emitted.
Variables []string
// Programs to be emitted.
Programs []string
// Types to be emitted.
Types []btf.Type
// Filename of the object to embed.
ObjectFile string
// Output to write template to.
Output io.Writer
// Function which transforms the input into a valid go identifier. Uses the default behaviour if nil
Identifier func(string) string
}
type GoArch ¶
type GoArch string
GoArch is a Go arch string.
See https://go.dev/doc/install/source#environment for valid GOARCHes when GOOS=linux.
type GoArches ¶
type GoArches []GoArch
func (GoArches) Constraint ¶
func (arches GoArches) Constraint() constraint.Expr
Constraints is satisfied when GOARCH is any of the arches.
type Target ¶
type Target struct {
// contains filtered or unexported fields
}
func (*Target) ObsoleteSuffix ¶
ObsoleteSuffix returns an obsolete suffix for a subset of targets.
It's used to work around an old bug and should not be used in new code.