internal

package
v0.5.1 Latest Latest
Warning

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

Go to latest
Published: Jan 23, 2024 License: AGPL-3.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const ClangEndian = "el"

ClangEndian is set to either "el" or "eb" depending on the host's endianness.

View Source
const (
	// Version constant used in ELF binaries indicating that the loader needs to
	// substitute the eBPF program's version with the value of the kernel's
	// KERNEL_VERSION compile-time macro. Used for compatibility with BCC, gobpf
	// and RedSift.
	MagicKernelVersion = 0xFFFFFFFE
)

Variables

NativeEndian is set to either binary.BigEndian or binary.LittleEndian, depending on the host's endianness.

Functions

func Align

func Align(n, alignment int) int

Align returns 'n' updated to 'alignment' boundary.

func Htons

func Htons(i uint16) uint16

Htons converts the unsigned short integer hostshort from host byte order to network byte order.

func KernelRelease

func KernelRelease() (string, error)

KernelRelease returns the release string of the running kernel. Its format depends on the Linux distribution and corresponds to directory names in /lib/modules by convention. Some examples are 5.15.17-1-lts and 4.19.0-16-amd64.

func OpenRawSock

func OpenRawSock(index int) (int, error)

Types

type SafeELFFile

type SafeELFFile struct {
	*elf.File
}

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) DynamicSymbols

func (se *SafeELFFile) DynamicSymbols() (syms []elf.Symbol, err error)

DynamicSymbols is the safe version of elf.File.DynamicSymbols.

func (*SafeELFFile) SectionsByType

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

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

func (*SafeELFFile) Symbols

func (se *SafeELFFile) Symbols() (syms []elf.Symbol, err error)

Symbols is the safe version of elf.File.Symbols.

type Version

type Version [3]uint16

A Version in the form Major.Minor.Patch.

func KernelVersion

func KernelVersion() (Version, error)

KernelVersion returns the version of the currently running kernel.

func NewVersion

func NewVersion(ver string) (Version, error)

NewVersion creates a version from a string like "Major.Minor.Patch".

Patch is optional.

func NewVersionFromCode

func NewVersionFromCode(code uint32) Version

NewVersionFromCode creates a version from a LINUX_VERSION_CODE.

func (Version) Kernel

func (v Version) Kernel() uint32

Kernel implements the kernel's KERNEL_VERSION macro from linux/version.h. It represents the kernel version and patch level as a single value.

func (Version) Less

func (v Version) Less(other Version) bool

Less returns true if the version is less than another version.

func (Version) String

func (v Version) String() string

func (Version) Unspecified

func (v Version) Unspecified() bool

Unspecified returns true if the version is all zero.

Directories

Path Synopsis
internal
unix
Package unix re-exports Linux specific parts of golang.org/x/sys/unix.
Package unix re-exports Linux specific parts of golang.org/x/sys/unix.

Jump to

Keyboard shortcuts

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