Documentation
¶
Overview ¶
Package sys provides low level system utilities, like architecture information and handling, and shared object handling.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // ErrNotELFFile is returned if the file does not have an ELF magic number. ErrNotELFFile = errors.New("is not an ELF file") // ErrOSABINotSupported is returned if the OS ABI of an ELF file is not // supported. ErrOSABINotSupported = errors.New("OSABI not supported") // ErrMachineNotSupported is returned if the machine type of an ELF file // is not supported. ErrMachineNotSupported = errors.New("machine type not supported") // ErrEmptyPath is returned if an empty path is given. ErrEmptyPath = errors.New("path must not be empty") // ErrArchNotSupported is returned if the requested architecture is not // supported for the requested operation. ErrArchNotSupported = errors.New("architecture not supported") )
Functions ¶
func AbsolutePath ¶ added in v0.15.0
AbsolutePath returns the absolute path as resolved by filepath.Abs.
It returns ErrEmptyPath if the given path is empty.
func Ldd ¶ added in v0.12.0
Ldd gathers the required shared objects of the ELF file with the given path.
It invokes the "ldd" executable which is expected to be present on the system. It returns an LDDExecError in case "ldd" is not available or it returned with a non-zero exit code. This might be the case if the binary is not dynamically linked.
func MustAbsolutePath ¶ added in v0.15.0
MustAbsolutePath calls AbsolutePath and panics in case of errors.
Types ¶
type Arch ¶
type Arch string
Arch is the name of a supported system architecture.
Supported guest architectures.
Native is the architecture of the host. Using the same architecture for the guest allows using KVM, if available. Use [KVMAvailable] to check.
func ReadELFArch ¶ added in v0.12.0
ReadELFArch returns the Arch of the given ELF file.
It returns an error if the ELF file is not for Linux or is for an unsupported architecture.
func (*Arch) KVMAvailable ¶
KVMAvailable checks if KVM support is available for the given architecture.
type LDDExecError ¶ added in v0.15.3
LDDExecError wraps errors that result when executing the "ldd" command. Along with the error the output received on stdout is added to the error message.
func (*LDDExecError) Error ¶ added in v0.15.3
func (e *LDDExecError) Error() string
Error implements the [error] interface.
func (*LDDExecError) Is ¶ added in v0.15.3
func (*LDDExecError) Is(other error) bool
Is implements the errors.Is interface.
func (*LDDExecError) Unwrap ¶ added in v0.15.3
func (e *LDDExecError) Unwrap() error
Unwrap implements the errors.Unwrap interface.
type LibCollection ¶ added in v0.12.0
type LibCollection struct {
// contains filtered or unexported fields
}
LibCollection is a deduplicated collection of dynamically linked libraries and paths they are found at.
func CollectLibsFor ¶ added in v0.12.0
func CollectLibsFor( ctx context.Context, files ...string, ) (LibCollection, error)
CollectLibsFor recursively resolves the dynamically linked shared objects of all given ELF files.
The dynamic linker consumed LD_LIBRARY_PATH from the environment.
func (*LibCollection) Libs ¶ added in v0.12.0
func (c *LibCollection) Libs() iter.Seq[string]
Libs returns an iterator that iterates all libraries sorted by path.
func (*LibCollection) SearchPaths ¶ added in v0.12.0
func (c *LibCollection) SearchPaths() iter.Seq[string]
SearchPaths returns an iterator that iterates all search paths sorted by path.