util

package
v0.4.6 Latest Latest
Warning

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

Go to latest
Published: Aug 13, 2025 License: BSD-3-Clause Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DirName added in v0.4.1

func DirName() string

DirName returns the last element of the path to the current working directory.

func Fatal

func Fatal(f string, args ...any)

func FatalErr

func FatalErr(what string, err error)

FatalError prints an error description and exits the program if the err != nil.

func InOutFiles

func InOutFiles(inName, inSuffix, outName, outSuffix string) (string, string)

InOutFiles infers the name of the input and output files from the name of the current working directory if the inName is an empty strings.

func Module

func Module() string

func OpenUSB added in v0.4.1

func OpenUSB(vendor, product usb.ID, busAddr string) (ctx *usb.Context, devs []*usb.Device, err error)

func PadBytes

func PadBytes(cache *[]byte, n int, b byte) []byte

PadBytes returns the slice containing n bytes equal to b.

func Progress

func Progress(pre string, cur, max, scale int, post string)

func SetGOENV added in v0.4.2

func SetGOENV(always bool)

SetGOENV tries to find the go.env file and set GOENV to it.

func Warn

func Warn(f string, args ...any)

Types

type Section

type Section struct {
	Vaddr  uint64 // address in the memory during execution
	Paddr  uint64 // phisical location of the section in the Flash/ROM
	Offset uint64 // offset in the ELF file to the beggining of the section data
	Data   []byte // section data
}

type Sections

type Sections []*Section

func ReadBins

func ReadBins(descr string) (Sections, error)

ReadBins reads binary files acording to the description and returns them as a slice of sections.

func ReadELF

func ReadELF(name string) (Sections, error)

ReadELF reads the loadable sections of the program and returns them as a slice. The order of the returned sections is unspecified. It returns at least one section or error.

func (Sections) Flatten

func (ss Sections) Flatten(w io.Writer, pad byte) (n int, err error)

Flatten flattens sections by writting their data to the provided io.Writer according to the Paddr field (before writting the sections are sorted using SortPaddr method). The gaps between sections are filled using the pad byte.

func (Sections) Size

func (ss Sections) Size() int64

Size returns the total size of sections data. It may be less than the size of flatten binary because it doesn't take into account possible gaps between sections.

func (Sections) SortByPaddr

func (ss Sections) SortByPaddr()

SortByPaddr sorts sections according to the Paddr field.

Jump to

Keyboard shortcuts

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