Documentation ¶
Overview ¶
Package macho implements access to and creation of Mach-O object files.
Index ¶
- Constants
- Variables
- func Align(addr uint64, align uint64) uint64
- type AtomInfo
- type BitstreamWrapperHeader
- type BuildVersion
- type CodeSignature
- type DataInCode
- type DyldChainedFixups
- type DyldEnvironment
- type DyldExportsTrie
- type DyldInfo
- type DyldInfoOnly
- type Dylib
- type DylibCodeSignDrs
- type Dylinker
- type DylinkerID
- type Dysymtab
- type EncryptionInfo
- type EncryptionInfo64
- type EntryPoint
- type FatArch
- type FatArchHeader
- type FatFile
- type FatHeader
- type File
- func (f *File) BuildVersion() *BuildVersion
- func (f *File) Close() error
- func (f *File) CodeSign(config *codesign.Config) error
- func (f *File) CodeSignature() *CodeSignature
- func (f *File) DWARF() (*dwarf.Data, error)
- func (f *File) DataInCode() *DataInCode
- func (f *File) DyldChainedFixups() (*fixupchains.DyldChainedFixups, error)
- func (f *File) DyldExports() ([]trie.TrieExport, error)
- func (f *File) DyldExportsTrie() *DyldExportsTrie
- func (f *File) DyldInfo() *DyldInfo
- func (f *File) DyldInfoOnly() *DyldInfoOnly
- func (f *File) DylibID() *IDDylib
- func (f *File) Export(path string, dcf *fixupchains.DyldChainedFixups, baseAddress uint64, ...) (err error)
- func (f *File) FileSets() []*FilesetEntry
- func (f *File) FindAddressSymbols(addr uint64) ([]Symbol, error)
- func (f *File) FindSectionForVMAddr(vmAddr uint64) *types.Section
- func (f *File) FindSegmentForVMAddr(vmAddr uint64) *Segment
- func (f *File) FindSymbolAddress(symbol string) (uint64, error)
- func (f *File) ForEachV2SplitSegReference(...) error
- func (f *File) FunctionStarts() *FunctionStarts
- func (f *File) GetBaseAddress() uint64
- func (f *File) GetBindInfo() (types.Binds, error)
- func (f *File) GetBindName(pointer uint64) (string, error)
- func (f *File) GetCFStrings() ([]objc.CFString, error)
- func (f *File) GetCString(addr uint64) (string, error)
- func (f *File) GetCStringAtOffset(strOffset int64) (string, error)
- func (f *File) GetDyldExport(symbol string) (*trie.TrieExport, error)
- func (f *File) GetEmbeddedInfoPlist() ([]byte, error)
- func (f *File) GetEmbeddedLLVMBitcode() (*xar.Reader, error)
- func (f *File) GetExports() ([]trie.TrieExport, error)
- func (f *File) GetFileSetFileByName(name string) (*File, error)
- func (f *File) GetFunctionData(fn types.Function) ([]byte, error)
- func (f *File) GetFunctionForVMAddr(addr uint64) (types.Function, error)
- func (f *File) GetFunctions(data ...byte) []types.Function
- func (f *File) GetFunctionsForRange(start, end uint64) ([]types.Function, error)
- func (f *File) GetLoadsByName(name string) []Load
- func (f *File) GetObjC(addr uint64) (any, bool)
- func (f *File) GetObjCCategories() ([]objc.Category, error)
- func (f *File) GetObjCClass(vmaddr uint64) (*objc.Class, error)
- func (f *File) GetObjCClass2(vmaddr uint64) (*objc.Class, error)
- func (f *File) GetObjCClassInfo(vmaddr uint64) (*objc.ClassRO64, error)
- func (f *File) GetObjCClassNames() (map[uint64]string, error)
- func (f *File) GetObjCClassReferences() (map[uint64]*objc.Class, error)
- func (f *File) GetObjCClasses() ([]objc.Class, error)
- func (f *File) GetObjCImageInfo() (*objc.ImageInfo, error)
- func (f *File) GetObjCIntegerObjects() (map[uint64]*objc.IntObj, error)
- func (f *File) GetObjCIvars(vmaddr uint64) ([]objc.Ivar, error)
- func (f *File) GetObjCMethodLists() ([]objc.Method, error)
- func (f *File) GetObjCMethodNames() (map[uint64]string, error)
- func (f *File) GetObjCMethods(vmaddr uint64) ([]objc.Method, error)
- func (f *File) GetObjCNonLazyCategories() ([]objc.Category, error)
- func (f *File) GetObjCNonLazyClasses() ([]objc.Class, error)
- func (f *File) GetObjCProperties(vmaddr uint64) ([]objc.Property, error)
- func (f *File) GetObjCProtoReferences() (map[uint64]*objc.Protocol, error)
- func (f *File) GetObjCProtocols() ([]objc.Protocol, error)
- func (f *File) GetObjCSelectorReferences() (map[uint64]*objc.Selector, error)
- func (f *File) GetObjCStubs(parse func(uint64, []byte) (map[uint64]*objc.Stub, error)) (map[uint64]*objc.Stub, error)
- func (f *File) GetObjCSuperReferences() (map[uint64]*objc.Class, error)
- func (f *File) GetObjCToc() objc.Toc
- func (f *File) GetOffset(address uint64) (uint64, error)
- func (f *File) GetPointer(offset uint64) (uint64, error)
- func (f *File) GetPointerAtAddress(address uint64) (uint64, error)
- func (f *File) GetRebaseInfo() ([]types.Rebase, error)
- func (f *File) GetSectionsForSegment(name string) []*types.Section
- func (f *File) GetSwiftAccessibleFunctions() (funcs []swift.TargetAccessibleFunctionRecord, err error)
- func (f *File) GetSwiftAssociatedTypes() (asstypes []swift.AssociatedType, err error)
- func (f *File) GetSwiftBuiltinTypes() (builtins []swift.BuiltinType, err error)
- func (f *File) GetSwiftClosures() (closures []swift.Capture, err error)
- func (f *File) GetSwiftColocateMetadata() ([]swift.ConformanceDescriptor, error)
- func (f *File) GetSwiftColocateTypeDescriptors() ([]swift.Type, error)
- func (f *File) GetSwiftDynamicReplacementInfo() (*swift.AutomaticDynamicReplacements, error)
- func (f *File) GetSwiftDynamicReplacementInfoForOpaqueTypes() (*swift.AutomaticDynamicReplacementsSome, error)
- func (f *File) GetSwiftEntry() (uint64, error)
- func (f *File) GetSwiftFields() (fields []swift.Field, err error)
- func (f *File) GetSwiftMultiPayloadEnums() (mpenums []swift.MultiPayloadEnum, err error)
- func (f *File) GetSwiftProtocolConformances() (protoConfDescs []swift.ConformanceDescriptor, err error)
- func (f *File) GetSwiftProtocols() (protos []swift.Protocol, err error)
- func (f *File) GetSwiftReflectionStrings() (map[uint64]string, error)
- func (f *File) GetSwiftTOC() swift.TOC
- func (f *File) GetSwiftTypes() (typs []swift.Type, err error)
- func (f *File) GetVMAddress(offset uint64) (uint64, error)
- func (f *File) HasDyldChainedFixups() bool
- func (f *File) HasDyldInfoOnly() bool
- func (f *File) HasFixups() bool
- func (f *File) HasObjC() bool
- func (f *File) HasObjCMessageReferences() bool
- func (f *File) HasPlusLoadMethod() bool
- func (f *File) HasSwift() bool
- func (f *File) ImportedLibraries() []string
- func (f *File) ImportedSymbolNames() ([]string, error)
- func (f *File) ImportedSymbols() ([]Symbol, error)
- func (f *File) IsCString(addr uint64) (string, bool)
- func (f *File) LibraryOrdinalName(libraryOrdinal int) string
- func (f *File) PreCache() error
- func (f *File) PutObjC(addr uint64, obj any)
- func (f *File) ReadAt(p []byte, off int64) (n int, err error)
- func (f *File) Save(outpath string) error
- func (f *File) Section(segment, section string) *types.Section
- func (f *File) Segment(name string) *Segment
- func (f *File) Segments() Segments
- func (f *File) SlidePointer(ptr uint64) uint64
- func (f *File) SourceVersion() *SourceVersion
- func (f *File) UUID() *UUID
- type FileConfig
- type FileTOC
- func (t *FileTOC) AddLoad(l Load) uint32
- func (t *FileTOC) AddSection(s *types.Section)
- func (t *FileTOC) AddSegment(s *Segment)
- func (t *FileTOC) DerivedCopy(Type types.HeaderFileType, Flags types.HeaderFlag) *FileTOC
- func (t *FileTOC) FileSize() uint64
- func (t *FileTOC) HdrSize() uint32
- func (t *FileTOC) LoadAlign() uint64
- func (t *FileTOC) LoadSize() uint32
- func (t *FileTOC) MarshalJSON() ([]byte, error)
- func (t *FileTOC) ModifySizeCommands(prev, curr int32) int32
- func (t *FileTOC) Print(printer func(t *FileTOC) string) string
- func (t *FileTOC) RemoveLoad(l Load) error
- func (t *FileTOC) String() string
- func (t *FileTOC) TOCSize() uint32
- type FilesetEntry
- type FormatError
- type FunctionStarts
- type FvmFile
- type IDDylib
- type IDFvmlib
- type Ident
- type LazyLoadDylib
- type LinkEditData
- type LinkerOptimizationHint
- type LinkerOption
- type Load
- type LoadBytes
- type LoadCmdBytes
- type LoadDylib
- type LoadDylinker
- type LoadFvmlib
- type Note
- type PrebindCheckSum
- type PreboundDylib
- type Prepage
- type ReExportDylib
- type Regs386
- type RegsAMD64
- type RegsARM
- type RegsARM64
- type Routines
- type Routines64
- type Rpath
- type Segment
- func (s *Segment) Copy() *Segment
- func (s *Segment) CopyZeroed() *Segment
- func (s *Segment) Data() ([]byte, error)
- func (s *Segment) LessThan(o *Segment) bool
- func (s *Segment) LoadSize() uint32
- func (s *Segment) MarshalJSON() ([]byte, error)
- func (s *Segment) Open() io.ReadSeeker
- func (s *Segment) Put32(b []byte, o binary.ByteOrder) int
- func (s *Segment) Put64(b []byte, o binary.ByteOrder) int
- func (s *Segment) String() string
- func (s *Segment) UncompressedSize(t *FileTOC, align uint64) uint64
- func (s *Segment) Write(buf *bytes.Buffer, o binary.ByteOrder) error
- type SegmentHeader
- type Segments
- type SourceVersion
- type SplitInfo
- type SubClient
- type SubFramework
- type SubLibrary
- type SubUmbrella
- type SymSeg
- type Symbol
- type Symtab
- type Thread
- type TwolevelHints
- type UUID
- type UnixThread
- type UpwardDylib
- type VersionMin
- type VersionMinMacOSX
- type VersionMinTvOS
- type VersionMinWatchOS
- type VersionMiniPhoneOS
- type WeakDylib
Constants ¶
const ( BitcodeWrapperMagic = 0x0b17c0de RawBitcodeMagic = 0xdec04342 // 'BC' 0xc0de )
const ( ABIName = `N` SymbolNamespace = `S` RelatedEntityName = `R` CTypedef = `t` )
Variables ¶
var ErrMachODyldInfoNotFound = errors.New("LC_DYLD_INFO(_ONLY) not found")
var ErrMachOSectionNotFound = errors.New("MachO missing required section")
var ErrNotFat = &FormatError{0, "not a fat Mach-O file", nil}
ErrNotFat is returned from NewFatFile or OpenFat when the file is not a universal binary but may be a thin binary, based on its magic number.
var ErrObjcSectionNEmpty = errors.New("required ObjC section is empty")
var ErrObjcSectionNotFound = errors.New("missing required ObjC section")
var ErrSwiftSectionError = fmt.Errorf("missing swift section")
Functions ¶
Types ¶
type AtomInfo ¶
type AtomInfo struct {
LinkEditData
}
type BitstreamWrapperHeader ¶
type BuildVersion ¶
type BuildVersion struct { LoadBytes types.BuildVersionCmd Tools []types.BuildVersionTool }
A BuildVersion represents a Mach-O build for platform min OS version.
func (*BuildVersion) LoadSize ¶
func (b *BuildVersion) LoadSize() uint32
func (*BuildVersion) MarshalJSON ¶
func (b *BuildVersion) MarshalJSON() ([]byte, error)
func (*BuildVersion) String ¶
func (b *BuildVersion) String() string
type CodeSignature ¶
type CodeSignature struct { LoadBytes types.CodeSignatureCmd codesign.CodeSignature }
A CodeSignature represents a Mach-O LC_CODE_SIGNATURE command.
func (*CodeSignature) LoadSize ¶
func (l *CodeSignature) LoadSize() uint32
func (*CodeSignature) MarshalJSON ¶
func (l *CodeSignature) MarshalJSON() ([]byte, error)
func (*CodeSignature) String ¶
func (l *CodeSignature) String() string
type DataInCode ¶
type DataInCode struct { LoadBytes types.DataInCodeCmd Entries []types.DataInCodeEntry }
A DataInCode represents a Mach-O LC_DATA_IN_CODE command.
func (*DataInCode) LoadSize ¶
func (l *DataInCode) LoadSize() uint32
func (*DataInCode) MarshalJSON ¶
func (l *DataInCode) MarshalJSON() ([]byte, error)
func (*DataInCode) String ¶
func (d *DataInCode) String() string
type DyldChainedFixups ¶
type DyldChainedFixups struct {
LinkEditData
}
A DyldChainedFixups used with linkedit_data_command
type DyldEnvironment ¶
type DyldEnvironment struct {
Dylinker
}
DyldEnvironment represents a Mach-O LC_DYLD_ENVIRONMENT command.
type DyldExportsTrie ¶
type DyldExportsTrie struct {
LinkEditData
}
A DyldExportsTrie used with linkedit_data_command, payload is trie
type DyldInfo ¶
type DyldInfo struct { LoadBytes types.DyldInfoCmd }
A DyldInfo represents a Mach-O LC_DYLD_INFO command.
func (*DyldInfo) MarshalJSON ¶
type DyldInfoOnly ¶
type DyldInfoOnly struct {
DyldInfo
}
DyldInfoOnly is compressed dyld information only
type Dylib ¶
A Dylib represents a Mach-O LC_ID_DYLIB, LC_LOAD_{,WEAK_}DYLIB,LC_REEXPORT_DYLIB load command.
func (*Dylib) MarshalJSON ¶
type DylibCodeSignDrs ¶
type DylibCodeSignDrs struct {
LinkEditData
}
type Dylinker ¶
type Dylinker struct { LoadBytes types.DylinkerCmd Name string }
A Dylinker represents a Mach-O LC_ID_DYLINKER, LC_LOAD_DYLINKER or LC_DYLD_ENVIRONMENT load command.
func (*Dylinker) MarshalJSON ¶
type DylinkerID ¶
type DylinkerID struct {
Dylinker
}
DylinkerID represents a Mach-O LC_ID_DYLINKER command.
type Dysymtab ¶
type Dysymtab struct { LoadBytes types.DysymtabCmd IndirectSyms []uint32 // indices into Symtab.Syms }
A Dysymtab represents a Mach-O LC_DYSYMTAB command.
func (*Dysymtab) MarshalJSON ¶
type EncryptionInfo ¶
type EncryptionInfo struct { LoadBytes types.EncryptionInfoCmd }
A EncryptionInfo represents a Mach-O 32-bit encrypted segment information
func (*EncryptionInfo) LoadSize ¶
func (e *EncryptionInfo) LoadSize() uint32
func (*EncryptionInfo) MarshalJSON ¶
func (l *EncryptionInfo) MarshalJSON() ([]byte, error)
func (*EncryptionInfo) String ¶
func (e *EncryptionInfo) String() string
type EncryptionInfo64 ¶
type EncryptionInfo64 struct { LoadBytes types.EncryptionInfo64Cmd }
A EncryptionInfo64 represents a Mach-O 64-bit encrypted segment information
func (*EncryptionInfo64) LoadSize ¶
func (e *EncryptionInfo64) LoadSize() uint32
func (*EncryptionInfo64) MarshalJSON ¶
func (e *EncryptionInfo64) MarshalJSON() ([]byte, error)
func (*EncryptionInfo64) String ¶
func (e *EncryptionInfo64) String() string
type EntryPoint ¶
type EntryPoint struct { LoadBytes types.EntryPointCmd }
EntryPoint represents a Mach-O LC_MAIN command.
func (*EntryPoint) LoadSize ¶
func (e *EntryPoint) LoadSize() uint32
func (*EntryPoint) MarshalJSON ¶
func (e *EntryPoint) MarshalJSON() ([]byte, error)
func (*EntryPoint) String ¶
func (e *EntryPoint) String() string
type FatArch ¶
type FatArch struct { FatArchHeader *File // contains filtered or unexported fields }
A FatArch is a Mach-O File inside a FatFile.
type FatArchHeader ¶
type FatArchHeader struct { CPU types.CPU SubCPU types.CPUSubtype Offset uint32 Size uint32 Align uint32 }
A FatArchHeader represents a fat header for a specific image architecture.
type FatFile ¶
type FatFile struct { FatHeader // contains filtered or unexported fields }
A FatFile is a Mach-O universal binary that contains at least one architecture.
func NewFatFile ¶
NewFatFile creates a new FatFile for accessing all the Mach-O images in a universal binary. The Mach-O binary is expected to start at position 0 in the ReaderAt.
type File ¶
type File struct { FileTOC Symtab *Symtab Dysymtab *Dysymtab // contains filtered or unexported fields }
A File represents an open Mach-O file.
func NewFile ¶
func NewFile(r io.ReaderAt, config ...FileConfig) (*File, error)
NewFile creates a new File for accessing a Mach-O binary in an underlying reader. The Mach-O binary is expected to start at position 0 in the ReaderAt.
func (*File) BuildVersion ¶
func (f *File) BuildVersion() *BuildVersion
BuildVersion returns the build version load command, or nil if no build version exists.
func (*File) Close ¶
Close closes the File. If the File was created using NewFile directly instead of Open, Close has no effect.
func (*File) CodeSignature ¶
func (f *File) CodeSignature() *CodeSignature
CodeSignature returns the code signature, or nil if none exists.
func (*File) DataInCode ¶
func (f *File) DataInCode() *DataInCode
DataInCode returns the LC_DATA_IN_CODE, or nil if none exists.
func (*File) DyldChainedFixups ¶
func (f *File) DyldChainedFixups() (*fixupchains.DyldChainedFixups, error)
DyldChainedFixups returns the dyld chained fixups.
func (*File) DyldExports ¶
func (f *File) DyldExports() ([]trie.TrieExport, error)
DyldExports returns the dyld export trie symbols
func (*File) DyldExportsTrie ¶
func (f *File) DyldExportsTrie() *DyldExportsTrie
DyldExportsTrie returns the dyld export trie load command, or nil if no dyld info exists.
func (*File) DyldInfo ¶
DyldInfo returns the dyld info load command, or nil if no dyld info exists.
func (*File) DyldInfoOnly ¶
func (f *File) DyldInfoOnly() *DyldInfoOnly
DyldInfoOnly returns the dyld info only load command, or nil if no dyld info only exists.
func (*File) Export ¶
func (f *File) Export(path string, dcf *fixupchains.DyldChainedFixups, baseAddress uint64, locals []Symbol) (err error)
Export exports an in-memory or cached dylib|kext MachO to a file
func (*File) FileSets ¶
func (f *File) FileSets() []*FilesetEntry
FileSets returns an array of Fileset entries.
func (*File) FindSectionForVMAddr ¶
FindSectionForVMAddr returns the section containing a given virtual memory ddress.
func (*File) FindSegmentForVMAddr ¶
FindSegmentForVMAddr returns the segment containing a given virtual memory ddress.
func (*File) ForEachV2SplitSegReference ¶
func (f *File) ForEachV2SplitSegReference(handler func(fromSectionIndex, fromSectionOffset, toSectionIndex, toSectionOffset uint64, kind types.SplitInfoKind)) error
func (*File) FunctionStarts ¶
func (f *File) FunctionStarts() *FunctionStarts
FunctionStarts returns the function starts array, or nil if none exists.
func (*File) GetBaseAddress ¶
GetBaseAddress returns the MachO's preferred load address
func (*File) GetBindName ¶
GetBindName returns the import name for a given dyld chained pointer
func (*File) GetCFStrings ¶
GetCFStrings returns the Objective-C CFStrings
func (*File) GetCString ¶
GetCString returns a c-string at a given virtual address in the MachO
func (*File) GetCStringAtOffset ¶
GetCStringAtOffset returns a c-string at a given offset into the MachO
func (*File) GetDyldExport ¶
func (f *File) GetDyldExport(symbol string) (*trie.TrieExport, error)
DyldExports returns the dyld export trie symbols
func (*File) GetEmbeddedInfoPlist ¶
func (*File) GetExports ¶
func (f *File) GetExports() ([]trie.TrieExport, error)
func (*File) GetFileSetFileByName ¶
GetFileSetFileByName returns the Fileset MachO for a given name.
func (*File) GetFunctionForVMAddr ¶
GetFunctionForVMAddr returns the function containing a given virual address
func (*File) GetFunctions ¶
GetFunctions returns the function array, or nil if none exists.
func (*File) GetFunctionsForRange ¶
GetFunctionsForRange returns the functions contained in a given virual address range
func (*File) GetLoadsByName ¶
func (*File) GetObjCCategories ¶
GetObjCCategories returns an array of Objective-C categories by parsing the __objc_catlist data
func (*File) GetObjCClass ¶
GetObjCClass parses an Objective-C class at a given virtual memory address
func (*File) GetObjCClass2 ¶
TODO: get rid of old GetObjCClass GetObjCClass parses an Objective-C class at a given virtual memory address
func (*File) GetObjCClassInfo ¶
GetObjCClassInfo returns the ClassRO64 (class_ro_t) for a given virtual memory address
func (*File) GetObjCClassNames ¶
GetObjCClassNames returns a map of section data virtual memory address to their class names
func (*File) GetObjCClassReferences ¶
GetObjCClassReferences returns a map of classes to their section data virtual memory address
func (*File) GetObjCClasses ¶
GetObjCClasses returns an array of Objective-C classes
func (*File) GetObjCImageInfo ¶
GetObjCImageInfo returns the parsed __objc_imageinfo data
func (*File) GetObjCIntegerObjects ¶
GetObjCIntObj parses the __objc_intobj section and returns a map of
func (*File) GetObjCIvars ¶
GetObjCIvars returns the Objective-C instance variables
func (*File) GetObjCMethodLists ¶
GetObjCMethodLists parses the method lists in the __objc_methlist section
func (*File) GetObjCMethodNames ¶
GetObjCMethodNames returns a map of section data virtual memory addresses to their method names
func (*File) GetObjCNonLazyCategories ¶
GetObjCNonLazyCategories returns an array of Objective-C classes that implement +load
func (*File) GetObjCNonLazyClasses ¶
GetObjCNonLazyClasses returns an array of Objective-C classes that implement +load
func (*File) GetObjCProperties ¶
GetObjCProperties returns the Objective-C properties
func (*File) GetObjCProtoReferences ¶
GetObjCProtoReferences returns a map of protocol names to their section data virtual memory address
func (*File) GetObjCProtocols ¶
GetObjCProtocols returns the Objective-C protocols
func (*File) GetObjCSelectorReferences ¶
GetObjCSelectorReferences returns a map of selector names to their section data virtual memory address
func (*File) GetObjCStubs ¶
func (f *File) GetObjCStubs(parse func(uint64, []byte) (map[uint64]*objc.Stub, error)) (map[uint64]*objc.Stub, error)
GetObjCStubs returns the Objective-C stubs
func (*File) GetObjCSuperReferences ¶
GetObjCSuperReferences returns a map of super classes to their section data virtual memory address
func (*File) GetObjCToc ¶
GetObjCToc returns a table of contents of the ObjC objects in the MachO
func (*File) GetPointer ¶
GetPointer returns pointer at a given offset
func (*File) GetPointerAtAddress ¶
GetPointerAtAddress returns pointer at a given virtual address
func (*File) GetSectionsForSegment ¶
GetSectionsForSegment returns all the segment's sections or nil if it doesn't have any
func (*File) GetSwiftAccessibleFunctions ¶
func (f *File) GetSwiftAccessibleFunctions() (funcs []swift.TargetAccessibleFunctionRecord, err error)
GetSwiftAccessibleFunctions parses the __TEXT.__swift5_acfuncs section
func (*File) GetSwiftAssociatedTypes ¶
func (f *File) GetSwiftAssociatedTypes() (asstypes []swift.AssociatedType, err error)
GetSwiftAssociatedTypes parses all the associated types in the __TEXT.__swift5_assocty section
func (*File) GetSwiftBuiltinTypes ¶
func (f *File) GetSwiftBuiltinTypes() (builtins []swift.BuiltinType, err error)
GetSwiftBuiltinTypes parses all the built-in types in the __TEXT.__swift5_builtin section
func (*File) GetSwiftClosures ¶
GetSwiftClosures parses all the closure context objects in the __TEXT.__swift5_capture section
func (*File) GetSwiftColocateMetadata ¶
func (f *File) GetSwiftColocateMetadata() ([]swift.ConformanceDescriptor, error)
GetSwiftColocateMetadata parses all the colocated metadata in the __TEXT.__textg_swiftm section
func (*File) GetSwiftColocateTypeDescriptors ¶
GetSwiftColocateTypeDescriptors parses all the colocated type descriptors in the __TEXT.__constg_swiftt section
func (*File) GetSwiftDynamicReplacementInfo ¶
func (f *File) GetSwiftDynamicReplacementInfo() (*swift.AutomaticDynamicReplacements, error)
GetSwiftDynamicReplacementInfo parses the __TEXT.__swift5_replace section
func (*File) GetSwiftDynamicReplacementInfoForOpaqueTypes ¶
func (f *File) GetSwiftDynamicReplacementInfoForOpaqueTypes() (*swift.AutomaticDynamicReplacementsSome, error)
GetSwiftDynamicReplacementInfoForOpaqueTypes parses the __TEXT.__swift5_replac2 section
func (*File) GetSwiftEntry ¶
GetSwiftEntry parses the __TEXT.__swift5_entry section
func (*File) GetSwiftFields ¶
GetSwiftFields parses all the fields in the __TEXT.__swift5_fields section
func (*File) GetSwiftMultiPayloadEnums ¶
func (f *File) GetSwiftMultiPayloadEnums() (mpenums []swift.MultiPayloadEnum, err error)
GetSwiftMultiPayloadEnums TODO: finish me
func (*File) GetSwiftProtocolConformances ¶
func (f *File) GetSwiftProtocolConformances() (protoConfDescs []swift.ConformanceDescriptor, err error)
GetSwiftProtocolConformances parses all the protocol conformances in the __TEXT.__swift5_proto section
func (*File) GetSwiftProtocols ¶
GetSwiftProtocols parses all the protocols in the __TEXT.__swift5_protos section
func (*File) GetSwiftReflectionStrings ¶
GetSwiftReflectionStrings parses all the reflection strings in the __TEXT.__swift5_reflstr section
func (*File) GetSwiftTOC ¶
GetSwiftTOC returns a table of contents of the Swift objects in the MachO
func (*File) GetSwiftTypes ¶
GetSwiftTypes parses all the swift in the __TEXT.__swift5_types section
func (*File) GetVMAddress ¶
GetVMAddress returns the virtal address for a given file offset
func (*File) HasDyldChainedFixups ¶
func (*File) HasDyldInfoOnly ¶
func (*File) HasObjCMessageReferences ¶
HasObjCMessageReferences returns true if MachO contains a __objc_msgrefs section
func (*File) HasPlusLoadMethod ¶
HasPlusLoadMethod returns true if MachO contains a __objc_nlclslist or __objc_nlcatlist section
func (*File) ImportedLibraries ¶
ImportedLibraries returns the paths of all libraries referred to by the binary f that are expected to be linked with the binary at dynamic link time.
func (*File) ImportedSymbolNames ¶
ImportedSymbolNames returns the names of all symbols referred to by the binary f that are expected to be satisfied by other libraries at dynamic load time.
func (*File) ImportedSymbols ¶
ImportedSymbols returns the names of all symbols referred to by the binary f that are expected to be satisfied by other libraries at dynamic load time.
func (*File) IsCString ¶
IsCString returns cstring at given virtual address if is in a CstringLiterals section
func (*File) LibraryOrdinalName ¶
LibraryOrdinalName returns the depancy library oridinal's name
func (*File) PreCache ¶
PreCache will precache all swift fields, types and built-in types (to hopefully improve performance)
func (*File) Section ¶
Section returns the section with the given name in the given segment, or nil if no such section exists.
func (*File) Segment ¶
Segment returns the first Segment with the given name, or nil if no such segment exists.
func (*File) SlidePointer ¶
SlidePointer returns slid or un-chained pointer
func (*File) SourceVersion ¶
func (f *File) SourceVersion() *SourceVersion
SourceVersion returns the source version load command, or nil if no source version exists.
type FileConfig ¶
type FileConfig struct { Offset int64 LoadIncluding []types.LoadCmd LoadExcluding []types.LoadCmd VMAddrConverter types.VMAddrConverter SectionReader types.MachoReader CacheReader types.MachoReader RelativeSelectorBase uint64 }
FileConfig is a MachO file config object
type FileTOC ¶
type FileTOC struct { types.FileHeader ByteOrder binary.ByteOrder Loads loads Sections []*types.Section // contains filtered or unexported fields }
func (*FileTOC) AddSection ¶
AddSection adds section to the most recently added Segment
func (*FileTOC) AddSegment ¶
AddSegment adds segment s to the file table of contents, and also zeroes out the segment information with the expectation that this will be added next.
func (*FileTOC) DerivedCopy ¶
func (t *FileTOC) DerivedCopy(Type types.HeaderFileType, Flags types.HeaderFlag) *FileTOC
DerivedCopy returns a modified copy of the TOC, with empty loads and sections, and with the specified header type and flags.
func (*FileTOC) FileSize ¶
FileSize returns the size in bytes of the header, load commands, and the in-file contents of all the segments and sections included in those load commands, accounting for their offsets within the file.
func (*FileTOC) HdrSize ¶
HdrSize returns the size in bytes of the Macho header for a given magic number (where the magic number has been appropriately byte-swapped).
func (*FileTOC) LoadAlign ¶
LoadAlign returns the required alignment of Load commands in a binary. This is used to add padding for necessary alignment.
func (*FileTOC) LoadSize ¶
LoadSize returns the size of all the load commands in a file's table-of contents (but not their associated data, e.g., sections and symbol tables)
func (*FileTOC) MarshalJSON ¶
func (*FileTOC) ModifySizeCommands ¶
func (*FileTOC) RemoveLoad ¶
type FilesetEntry ¶
type FilesetEntry struct { LoadBytes types.FilesetEntryCmd EntryID string // contained entry id }
FilesetEntry used with fileset_entry_command
func (*FilesetEntry) LoadSize ¶
func (l *FilesetEntry) LoadSize() uint32
func (*FilesetEntry) MarshalJSON ¶
func (l *FilesetEntry) MarshalJSON() ([]byte, error)
func (*FilesetEntry) String ¶
func (f *FilesetEntry) String() string
type FormatError ¶
type FormatError struct {
// contains filtered or unexported fields
}
FormatError is returned by some operations if the data does not have the correct format for an object file.
func (*FormatError) Error ¶
func (e *FormatError) Error() string
type FunctionStarts ¶
type FunctionStarts struct {
LinkEditData
}
A FunctionStarts represents a Mach-O function starts command.
type FvmFile ¶
type FvmFile struct { LoadBytes types.FvmFileCmd Name string }
A FvmFile represents a Mach-O LC_FVMFILE command.
func (*FvmFile) MarshalJSON ¶
type IDFvmlib ¶
type IDFvmlib struct {
LoadFvmlib
}
A IDFvmlib represents a Mach-O LC_IDFVMLIB command.
type LazyLoadDylib ¶
type LazyLoadDylib struct {
Dylib
}
A LazyLoadDylib represents a Mach-O LC_LAZY_LOAD_DYLIB command.
type LinkEditData ¶
type LinkEditData struct { LoadBytes types.LinkEditDataCmd }
A LinkEditData represents a Mach-O linkedit data command.
LC_CODE_SIGNATURE, LC_SEGMENT_SPLIT_INFO, LC_FUNCTION_STARTS, LC_DATA_IN_CODE, LC_DYLIB_CODE_SIGN_DRS, LC_LINKER_OPTIMIZATION_HINT, LC_DYLD_EXPORTS_TRIE, or LC_DYLD_CHAINED_FIXUPS.
func (*LinkEditData) LoadSize ¶
func (l *LinkEditData) LoadSize() uint32
func (*LinkEditData) MarshalJSON ¶
func (l *LinkEditData) MarshalJSON() ([]byte, error)
func (*LinkEditData) String ¶
func (l *LinkEditData) String() string
type LinkerOptimizationHint ¶
type LinkerOptimizationHint struct {
LinkEditData
}
type LinkerOption ¶
type LinkerOption struct { LoadBytes types.LinkerOptionCmd Options []string }
A LinkerOption represents a Mach-O LC_LINKER_OPTION command.
func (*LinkerOption) LoadSize ¶
func (l *LinkerOption) LoadSize() uint32
func (*LinkerOption) MarshalJSON ¶
func (l *LinkerOption) MarshalJSON() ([]byte, error)
func (*LinkerOption) String ¶
func (l *LinkerOption) String() string
type Load ¶
type Load interface { Command() types.LoadCmd LoadSize() uint32 // Need the TOC for alignment, sigh. Raw() []byte Write(buf *bytes.Buffer, o binary.ByteOrder) error String() string MarshalJSON() ([]byte, error) }
A Load represents any Mach-O load command.
type LoadBytes ¶
type LoadBytes []byte
A LoadBytes is the uninterpreted bytes of a Mach-O load command.
func (LoadBytes) MarshalJSON ¶
type LoadCmdBytes ¶
LoadCmdBytes is a command-tagged sequence of bytes. This is used for Load Commands that are not (yet) interesting to us, and to common up this behavior for all those that are.
func (LoadCmdBytes) Copy ¶
func (s LoadCmdBytes) Copy() LoadCmdBytes
func (LoadCmdBytes) String ¶
func (s LoadCmdBytes) String() string
type LoadDylib ¶
type LoadDylib struct {
Dylib
}
A LoadDylib represents a Mach-O LC_LOAD_DYLIB command.
type LoadDylinker ¶
type LoadDylinker struct {
Dylinker
}
A LoadDylinker represents a Mach-O LC_LOAD_DYLINKER command.
type LoadFvmlib ¶
type LoadFvmlib struct { LoadBytes types.LoadFvmLibCmd Name string }
A LoadFvmlib represents a Mach-O LC_LOADFVMLIB command.
func (*LoadFvmlib) LoadSize ¶
func (l *LoadFvmlib) LoadSize() uint32
func (*LoadFvmlib) MarshalJSON ¶
func (l *LoadFvmlib) MarshalJSON() ([]byte, error)
func (*LoadFvmlib) String ¶
func (l *LoadFvmlib) String() string
type PrebindCheckSum ¶
type PrebindCheckSum struct { LoadBytes types.PrebindCksumCmd }
A PrebindCheckSum is a Mach-O LC_PREBIND_CKSUM command.
func (*PrebindCheckSum) LoadSize ¶
func (l *PrebindCheckSum) LoadSize() uint32
func (*PrebindCheckSum) MarshalJSON ¶
func (l *PrebindCheckSum) MarshalJSON() ([]byte, error)
func (*PrebindCheckSum) String ¶
func (l *PrebindCheckSum) String() string
type PreboundDylib ¶
type PreboundDylib struct { LoadBytes types.PreboundDylibCmd Name string LinkedModulesBitVector string }
PreboundDylib represents a Mach-O LC_PREBOUND_DYLIB command.
func (*PreboundDylib) LoadSize ¶
func (d *PreboundDylib) LoadSize() uint32
func (*PreboundDylib) MarshalJSON ¶
func (d *PreboundDylib) MarshalJSON() ([]byte, error)
func (*PreboundDylib) String ¶
func (d *PreboundDylib) String() string
type Prepage ¶
type Prepage struct { LoadBytes types.PrePageCmd }
A Prepage represents a Mach-O LC_PREPAGE command.
func (*Prepage) MarshalJSON ¶
type ReExportDylib ¶
type ReExportDylib struct {
Dylib
}
A ReExportDylib represents a Mach-O LC_REEXPORT_DYLIB command.
type Regs386 ¶
type Regs386 struct { AX uint32 BX uint32 CX uint32 DX uint32 DI uint32 SI uint32 BP uint32 SP uint32 SS uint32 FLAGS uint32 IP uint32 CS uint32 DS uint32 ES uint32 FS uint32 GS uint32 }
Regs386 is the Mach-O 386 register structure.
type RegsAMD64 ¶
type RegsAMD64 struct { AX uint64 BX uint64 CX uint64 DX uint64 DI uint64 SI uint64 BP uint64 SP uint64 R8 uint64 R9 uint64 R10 uint64 R11 uint64 R12 uint64 R13 uint64 R14 uint64 R15 uint64 IP uint64 FLAGS uint64 CS uint64 FS uint64 GS uint64 }
RegsAMD64 is the Mach-O AMD64 register structure.
type RegsARM ¶
type RegsARM struct { R0 uint32 R1 uint32 R2 uint32 R3 uint32 R4 uint32 R5 uint32 R6 uint32 R7 uint32 R8 uint32 R9 uint32 R10 uint32 R11 uint32 R12 uint32 SP uint32 LR uint32 PC uint32 CPSR uint32 }
RegsARM is the Mach-O ARM register structure.
type RegsARM64 ¶
type RegsARM64 struct { X0 uint64 X1 uint64 X2 uint64 X3 uint64 X4 uint64 X5 uint64 X6 uint64 X7 uint64 X8 uint64 X9 uint64 X10 uint64 X11 uint64 X12 uint64 X13 uint64 X14 uint64 X15 uint64 X16 uint64 X17 uint64 X18 uint64 X19 uint64 X20 uint64 X21 uint64 X22 uint64 X23 uint64 X24 uint64 X25 uint64 X26 uint64 X27 uint64 X28 uint64 FP uint64 LR uint64 SP uint64 PC uint64 CPSR uint32 PAD uint32 }
RegsARM64 is the Mach-O ARM 64 register structure.
type Routines ¶
type Routines struct { LoadBytes types.RoutinesCmd }
A Routines is a Mach-O LC_ROUTINES command.
func (*Routines) MarshalJSON ¶
type Routines64 ¶
type Routines64 struct { LoadBytes types.Routines64Cmd }
A Routines64 is a Mach-O LC_ROUTINES_64 command.
func (*Routines64) LoadSize ¶
func (l *Routines64) LoadSize() uint32
func (*Routines64) MarshalJSON ¶
func (l *Routines64) MarshalJSON() ([]byte, error)
func (*Routines64) String ¶
func (l *Routines64) String() string
type Segment ¶
type Segment struct { SegmentHeader LoadBytes // Embed ReaderAt for ReadAt method. // Do not embed SectionReader directly // to avoid having Read and Seek. // If a client wants Read and Seek it must use // Open() to avoid fighting over the seek offset // with other clients. io.ReaderAt // contains filtered or unexported fields }
A Segment represents a Mach-O 32-bit or 64-bit load segment command.
func (*Segment) CopyZeroed ¶
func (*Segment) MarshalJSON ¶
func (*Segment) Open ¶
func (s *Segment) Open() io.ReadSeeker
Open returns a new ReadSeeker reading the segment.
func (*Segment) UncompressedSize ¶
UncompressedSize returns the size of the segment with its sections uncompressed, ignoring its offset within the file. The returned size is rounded up to the power of two in align.
type SegmentHeader ¶
type SegmentHeader struct { types.LoadCmd Len uint32 Name string Addr uint64 Memsz uint64 Offset uint64 Filesz uint64 Maxprot types.VmProtection Prot types.VmProtection Nsect uint32 Flag types.SegFlag Firstsect uint32 }
A SegmentHeader is the header for a Mach-O 32-bit or 64-bit load segment command.
func (*SegmentHeader) String ¶
func (s *SegmentHeader) String() string
type SourceVersion ¶
type SourceVersion struct { LoadBytes types.SourceVersionCmd }
A SourceVersion represents a Mach-O LC_SOURCE_VERSION command.
func (*SourceVersion) LoadSize ¶
func (s *SourceVersion) LoadSize() uint32
func (*SourceVersion) MarshalJSON ¶
func (s *SourceVersion) MarshalJSON() ([]byte, error)
func (*SourceVersion) String ¶
func (s *SourceVersion) String() string
type SplitInfo ¶
type SplitInfo struct { LoadBytes types.SegmentSplitInfoCmd Version uint8 }
A SplitInfo represents a Mach-O LC_SEGMENT_SPLIT_INFO command.
func (*SplitInfo) MarshalJSON ¶
type SubClient ¶
type SubClient struct { LoadBytes types.SubClientCmd Name string }
A SubClient is a Mach-O LC_SUB_CLIENT command.
func (*SubClient) MarshalJSON ¶
type SubFramework ¶
type SubFramework struct { LoadBytes types.SubFrameworkCmd Framework string }
A SubFramework is a Mach-O LC_SUB_FRAMEWORK command.
func (*SubFramework) LoadSize ¶
func (l *SubFramework) LoadSize() uint32
func (*SubFramework) MarshalJSON ¶
func (l *SubFramework) MarshalJSON() ([]byte, error)
func (*SubFramework) String ¶
func (l *SubFramework) String() string
type SubLibrary ¶
type SubLibrary struct { LoadBytes types.SubLibraryCmd Library string }
A SubLibrary is a Mach-O LC_SUB_LIBRARY command.
func (*SubLibrary) LoadSize ¶
func (l *SubLibrary) LoadSize() uint32
func (*SubLibrary) MarshalJSON ¶
func (l *SubLibrary) MarshalJSON() ([]byte, error)
func (*SubLibrary) String ¶
func (l *SubLibrary) String() string
type SubUmbrella ¶
type SubUmbrella struct { LoadBytes types.SubUmbrellaCmd Umbrella string }
A SubUmbrella is a Mach-O LC_SUB_UMBRELLA command.
func (*SubUmbrella) LoadSize ¶
func (l *SubUmbrella) LoadSize() uint32
func (*SubUmbrella) MarshalJSON ¶
func (l *SubUmbrella) MarshalJSON() ([]byte, error)
func (*SubUmbrella) String ¶
func (l *SubUmbrella) String() string
type Symbol ¶
A Symbol is a Mach-O 32-bit or 64-bit symbol table entry.
func (*Symbol) MarshalJSON ¶
type Thread ¶
type Thread struct { LoadBytes types.ThreadCmd Threads []types.ThreadState // contains filtered or unexported fields }
A Thread represents a Mach-O LC_THREAD command.
func (*Thread) MarshalJSON ¶
type TwolevelHints ¶
type TwolevelHints struct { LoadBytes types.TwolevelHintsCmd Hints []types.TwolevelHint }
A TwolevelHints is a Mach-O LC_TWOLEVEL_HINTS command.
func (*TwolevelHints) LoadSize ¶
func (l *TwolevelHints) LoadSize() uint32
func (*TwolevelHints) MarshalJSON ¶
func (l *TwolevelHints) MarshalJSON() ([]byte, error)
func (*TwolevelHints) String ¶
func (l *TwolevelHints) String() string
type UnixThread ¶
type UnixThread struct {
Thread
}
A UnixThread represents a Mach-O LC_UNIXTHREAD command.
type UpwardDylib ¶
type UpwardDylib struct {
Dylib
}
A UpwardDylib represents a Mach-O LC_LOAD_UPWARD_DYLIB load command.
type VersionMin ¶
type VersionMin struct { LoadBytes types.VersionMinCmd }
A VersionMin represents a Mach-O LC_VERSION_MIN_* command.
func (*VersionMin) LoadSize ¶
func (v *VersionMin) LoadSize() uint32
func (*VersionMin) MarshalJSON ¶
func (v *VersionMin) MarshalJSON() ([]byte, error)
func (*VersionMin) String ¶
func (v *VersionMin) String() string
type VersionMinMacOSX ¶
type VersionMinMacOSX struct {
VersionMin
}
VersionMinMacOSX build for MacOSX min OS version
type VersionMinTvOS ¶
type VersionMinTvOS struct {
VersionMin
}
VersionMinTvOS build for AppleTV min OS version
type VersionMinWatchOS ¶
type VersionMinWatchOS struct {
VersionMin
}
VersionMinWatchOS build for Watch min OS version
type VersionMiniPhoneOS ¶
type VersionMiniPhoneOS struct {
VersionMin
}
VersionMiniPhoneOS build for iPhoneOS min OS version
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
internal
|
|
obscuretestdata
Package obscuretestdata contains functionality used by tests to more easily work with testdata that must be obscured primarily due to golang.org/issue/34986.
|
Package obscuretestdata contains functionality used by tests to more easily work with testdata that must be obscured primarily due to golang.org/issue/34986. |
pkg
|
|
xar
Package xar provides for reading and writing XAR archives.
|
Package xar provides for reading and writing XAR archives. |