macho

package module
v0.0.0-...-583cee0 Latest Latest
Warning

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

Go to latest
Published: Apr 28, 2023 License: Apache-2.0 Imports: 6 Imported by: 0

README

go-macholibre

A library for dealing with wrapping and unwrapping Mach-O multi-architecture binaries (a.k.a. Universal binaries).

Developing

When developing / running tests, note that there is data being referenced that is not checked into the source tree but instead residing in a separate store and is managed via git-lfs. You will need to install and initialize git-lfs to work with this data:

git lfs install
git lfs pull

Grab local tooling:

make bootstrap

To run tests:

make fixtures
make unit

Note on testing: since lipo is used to verify that the resulting binaries are as expected, these test fixtures can only be generated on a Mac.

To run all checks:

make

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsUniversalMachoBinary

func IsUniversalMachoBinary(reader io.ReaderAt) bool

IsUniversalMachoBinary returns true if this is a valid multi-architecture (universal) binary.

func Package

func Package(dest string, binaries ...string) error

Package takes paths to one or more existing NON-universal binaries and creates a universal binary at the given path.

Types

type ExtractedFile

type ExtractedFile struct {
	Path string
	UniversalArchInfo
}

func Extract

func Extract(reader io.ReaderAt, dir string) ([]ExtractedFile, error)

Extract takes a reader to a Mach-o universal binary and unpacks all contained binaries to the given directory.

type ExtractedReader

type ExtractedReader struct {
	Reader interface {
		io.Reader
		io.ReaderAt
	}
	UniversalArchHeader
}

func ExtractReaders

func ExtractReaders(r io.ReaderAt) ([]ExtractedReader, error)

type UniversalArchHeader

type UniversalArchHeader struct {
	UniversalArchInfo
	Offset uint32
	Size   uint32
	Align  uint32
}

A UniversalArchHeader represents a fat header for a specific image architecture.

type UniversalArchInfo

type UniversalArchInfo struct {
	CPU    macho.Cpu
	SubCPU uint32
}

type UniversalFile

type UniversalFile struct {
	UniversalFileHeader
	Payloads [][]byte
}

A UniversalFile is a Mach-O universal binary that contains at least one architecture.

func NewUniversalFile

func NewUniversalFile() UniversalFile

NewUniversalFile creates a new universal file object

func (*UniversalFile) Add

func (u *UniversalFile) Add(binaries ...string) error

Add takes one or more paths to Mach-O formatted binaries to be added to the universal binary.

func (*UniversalFile) Write

func (u *UniversalFile) Write(writer io.Writer) error

Write packs in all of the binaries previously given into a single Mach-O universal binary file.

type UniversalFileHeader

type UniversalFileHeader struct {
	Magic  uint32
	Count  uint32
	Arches []UniversalArchHeader
}

Directories

Path Synopsis
test-fixtures

Jump to

Keyboard shortcuts

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