elf

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: May 25, 2023 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const (
	FileOpenErr      = FileError("cannot open the file with the passed file name")
	NoSuchSectionErr = FileError("there is no such section in the passed elf file")
	OutOfBoundsErr   = FileError("attempting to write out of the section bounds")
)

Variables

This section is empty.

Functions

func CustomError

func CustomError(original FileError, msg string, args ...any) error

CustomError returns FileError that can use the classic fmt message/varargs.

Types

type File

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

File represents the contents of an elf binary file

func ReadAll

func ReadAll(file io.Reader) (*File, error)

ReadAll initializes an elf file object from a file stream

func (*File) AsBytes

func (ef *File) AsBytes() []byte

AsBytes returns a copy of the file as a byte array representation

func (*File) HasSection

func (ef *File) HasSection(name string) bool

HasSection returns whether an elf file has a section named 'name'

func (*File) ReadSection

func (ef *File) ReadSection(name string) ([]byte, error)

ReadSection reads the whole specified elf section

func (*File) SectionAddress added in v0.4.0

func (ef *File) SectionAddress(name string) (uint64, error)

SectionAddress returns the address of the section, if it exists

func (*File) SectionSize added in v0.4.0

func (ef *File) SectionSize(name string) (uint64, error)

SectionSize returns the size of the section, if it exists

func (*File) Sections

func (ef *File) Sections() []string

Sections returns a list of the sections within an elf file

func (*File) WriteSection

func (ef *File) WriteSection(name string, data []byte, offset uint64) error

WriteSection writes data at the specified offset within the specified section

type FileError

type FileError string

FileError identifies an error related to a hex file

func (FileError) Error

func (r FileError) Error() string

Error returns a string representation of a FileError

Jump to

Keyboard shortcuts

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