lmacho

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: May 13, 2024 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const MagicFat = macho.MagicFat
View Source
const MagicFat64 = macho.MagicFat + 1

Variables

View Source
var (
	ErrThin = errors.New("the file is thin file, not fat")
)

Functions

func CpuNames

func CpuNames() []string

func Create

func Create[T Object](w io.Writer, objects []T, fat64 bool, hideARM64 bool) error

func FatArchHeaderSize

func FatArchHeaderSize(magic uint32) uint64

func FatHeaderSize

func FatHeaderSize() uint64

func GuessAlignBit

func GuessAlignBit(addr uint64, min, max uint32) uint32

func IsSupportedCpu

func IsSupportedCpu(v string) bool

func SegmentAlignBit

func SegmentAlignBit(f *macho.File) uint32

func ToCpu

func ToCpu(v string) (cpu Cpu, sub SubCpu, ok bool)

func ToCpuString

func ToCpuString(cpu Cpu, subCpu SubCpu) string

func ToCpuValues

func ToCpuValues(c Cpu, s SubCpu) (cpu string, sub string)

Types

type Arch

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

Arch presents an object of thin file

func NewArch

func NewArch(sr *io.SectionReader) (*Arch, error)

func (*Arch) Align

func (a *Arch) Align() uint32

func (*Arch) CPU

func (a *Arch) CPU() Cpu

func (*Arch) CPUString

func (a *Arch) CPUString() string

func (*Arch) Read

func (a *Arch) Read(p []byte) (int, error)

func (*Arch) ReadAt

func (a *Arch) ReadAt(p []byte, off int64) (int, error)

func (*Arch) Seek

func (a *Arch) Seek(offset int64, whence int) (int64, error)

func (*Arch) Size

func (a *Arch) Size() uint64

func (*Arch) SubCPU

func (a *Arch) SubCPU() SubCpu

func (*Arch) Type

func (a *Arch) Type() macho.Type

type Cpu

type Cpu = macho.Cpu
const (
	// skip
	TypeX86    Cpu = 7
	TypeI386   Cpu = TypeX86
	TypeX86_64 Cpu = TypeI386 | cpuArch64
	// skip
	TypeArm      Cpu = 12
	TypeArm64    Cpu = TypeArm | cpuArch64
	TypeArm64_32 Cpu = TypeArm | cpuArch64_32
	TypePpc      Cpu = 18
	CTypePpc64   Cpu = TypePpc | 64
)

type FatArch

type FatArch struct {
	Hidden bool
	// contains filtered or unexported fields
}

FatArch presents an object of fat file

func (*FatArch) Align

func (fa *FatArch) Align() uint32

func (*FatArch) CPU

func (fa *FatArch) CPU() Cpu

func (*FatArch) CPUString

func (fa *FatArch) CPUString() string

func (*FatArch) FatArchHeader

func (fa *FatArch) FatArchHeader() FatArchHeader

func (*FatArch) Read

func (fa *FatArch) Read(p []byte) (int, error)

func (*FatArch) ReadAt

func (fa *FatArch) ReadAt(p []byte, off int64) (int, error)

func (*FatArch) Seek

func (fa *FatArch) Seek(offset int64, whence int) (int64, error)

func (*FatArch) Size

func (fa *FatArch) Size() uint64

func (*FatArch) SubCPU

func (fa *FatArch) SubCPU() SubCpu

func (*FatArch) Type

func (fa *FatArch) Type() macho.Type

type FatArchHeader

type FatArchHeader struct {
	Cpu    Cpu
	SubCpu SubCpu
	Offset uint64
	Size   uint64
	Align  uint32
}

FatArchHeader presents an architecture header for a Macho-0 32 bit and 64 bit

type FatFile

type FatFile struct {
	FatHeader
	Arches []*FatArch
}

func NewFatFile

func NewFatFile(ra io.ReaderAt) (*FatFile, error)

NewFatFile is wrapper for Fat Reader

type FatHeader

type FatHeader struct {
	Magic uint32
	NArch uint32
}

FatHeader presents a header for a fat 32 bit and fat 64 bit see /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/mach-o/fat.h

type FormatError

type FormatError struct {
	Err error
}

func (*FormatError) Error

func (e *FormatError) Error() string

type Object

type Object interface {
	CPU() Cpu
	SubCPU() SubCpu
	Size() uint64
	Align() uint32
	Type() macho.Type
	CPUString() string
	io.Reader
	io.ReaderAt
}

type Reader

type Reader struct {
	FatHeader FatHeader
	// contains filtered or unexported fields
}

func NewReader

func NewReader(r io.ReaderAt) (*Reader, error)

func (*Reader) Next

func (r *Reader) Next() (*FatArch, error)

type SubCpu

type SubCpu = uint32
const (
	SubTypeX86All    SubCpu = 3
	SubTypeX86_64All SubCpu = 3
	SubTypeX86Arch1  SubCpu = 4
	SubTypeX86_64H   SubCpu = 8
)
const (
	SubTypeArmAll SubCpu = 0
	SubTypeArmV4T SubCpu = 5
	SubTypeArmV6  SubCpu = 6
	// skip
	SubTypeArmV7  SubCpu = 9
	SubTypeArmV7F SubCpu = 10
	SubTypeArmV7S SubCpu = 11
	SubTypeArmV7K SubCpu = 12
	// skip
	SubTypeArmV6M  SubCpu = 14
	SubTypeArmV7M  SubCpu = 15
	SubTypeArmV7EM SubCpu = 16
	SubTypeArmV8M  SubCpu = 17
)
const (
	SubTypeArm64All SubCpu = 0
	SubTypeArm64V8  SubCpu = 1
	SubTypeArm64E   SubCpu = 2
)
const MaskSubCpuType SubCpu = 0xff000000
const (
	SubTypeArm64_32V8 SubCpu = 1
)

Jump to

Keyboard shortcuts

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