elf

package
v1.6.12 Latest Latest
Warning

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

Go to latest
Published: Sep 30, 2020 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Overview

Package elf provides utility functions for manipulating ELF files on the filesystem.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IgnoreSymbolPrefixes

func IgnoreSymbolPrefixes(prefixes []string)

IgnoreSymbolPrefixes configures the ELF package to ignore symbols that have any of the specified prefixes. It must be called by only one thread at a time.

This slice will be iterated once per ELF.Write(), so try not to let it grow out of hand...

Types

type ELF

type ELF struct {

	// lock concurrent writes of the ELF. This library probably isn't far
	// off from allowing concurrent Write() execution, but it's just not
	// supported for now.
	lock.Mutex
	// contains filtered or unexported fields
}

ELF is an in-memory representation of a BPF ELF object from the filesystem.

func NewELF

func NewELF(ra io.ReaderAt, scopedLog *logrus.Entry) (*ELF, error)

NewELF returns a new object from the specified reader.

The ELF binary is expected to start at position 0 in the specified reader.

func Open

func Open(path string) (*ELF, error)

Open an ELF file from the specified path.

func (*ELF) Close

func (elf *ELF) Close() (err error)

Close closes the ELF. If the File was created using NewELF directly instead of Open, Close has no effect.

func (*ELF) Write

func (elf *ELF) Write(path string, intOptions map[string]uint32, strOptions map[string]string) error

Write the received ELF to a new file at the specified location, with the specified options (indexed by name) substituted:

  • intOptions: 32-bit values substituted in the data section.
  • strOptions: strings susbtituted in the string table. For each key/value pair, both key and value must be same length.

Only one goroutine may Write() the same *ELF concurrently.

On success, writes the new file to the specified path. On failure, returns an error and no file is left on the filesystem.

Jump to

Keyboard shortcuts

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