Documentation ¶
Overview ¶
Package macho implements access to Mach-O object files.
Index ¶
- Constants
- Variables
- type Cpu
- type Dylib
- type DylibCmd
- type Dysymtab
- type DysymtabCmd
- type FatArch
- type FatArchHeader
- type FatFile
- type File
- type FileHeader
- type FormatError
- type Load
- type LoadBytes
- type LoadCmd
- type Nlist32
- type Nlist64
- type Regs386
- type RegsAMD64
- type Section
- type Section32
- type Section64
- type SectionHeader
- type Segment
- type Segment32
- type Segment64
- type SegmentHeader
- type Symbol
- type Symtab
- type SymtabCmd
- type Thread
- type Type
Constants ¶
const ( Magic32 uint32 = 0xfeedface Magic64 uint32 = 0xfeedfacf MagicFat uint32 = 0xcafebabe )
Variables ¶
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.
Functions ¶
This section is empty.
Types ¶
type DylibCmd ¶
type DylibCmd struct { Cmd LoadCmd Len uint32 Name uint32 Time uint32 CurrentVersion uint32 CompatVersion uint32 }
A DylibCmd is a Mach-O load dynamic library command.
type Dysymtab ¶
type Dysymtab struct { LoadBytes DysymtabCmd IndirectSyms []uint32 // indices into Symtab.Syms }
A Dysymtab represents a Mach-O dynamic symbol table command.
type DysymtabCmd ¶
type DysymtabCmd struct { Cmd LoadCmd Len uint32 Ilocalsym uint32 Nlocalsym uint32 Iextdefsym uint32 Nextdefsym uint32 Iundefsym uint32 Nundefsym uint32 Tocoffset uint32 Ntoc uint32 Modtaboff uint32 Nmodtab uint32 Extrefsymoff uint32 Nextrefsyms uint32 Indirectsymoff uint32 Nindirectsyms uint32 Extreloff uint32 Nextrel uint32 Locreloff uint32 Nlocrel uint32 }
A DysymtabCmd is a Mach-O dynamic symbol table command.
type FatArch ¶
type FatArch struct { FatArchHeader *File }
A FatArch is a Mach-O File inside a FatFile.
type FatArchHeader ¶
A FatArchHeader represents a fat header for a specific image architecture.
type FatFile ¶
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 { FileHeader ByteOrder binary.ByteOrder Loads []Load Sections []*Section Symtab *Symtab Dysymtab *Dysymtab // contains filtered or unexported fields }
A File represents an open Mach-O file.
func NewFile ¶
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) Close ¶
Close closes the File. If the File was created using NewFile directly instead of Open, Close has no effect.
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) 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.
type FileHeader ¶
type FileHeader struct { Magic uint32 Cpu Cpu SubCpu uint32 Type Type Ncmd uint32 Cmdsz uint32 Flags uint32 }
A FileHeader represents a Mach-O file header.
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 LoadBytes ¶
type LoadBytes []byte
A LoadBytes is the uninterpreted bytes of a Mach-O load 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 Section ¶
type Section struct { SectionHeader // 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 }
func (*Section) Open ¶
func (s *Section) Open() io.ReadSeeker
Open returns a new ReadSeeker reading the Mach-O section.
type Section32 ¶
type Section32 struct { Name [16]byte Seg [16]byte Addr uint32 Size uint32 Offset uint32 Align uint32 Reloff uint32 Nreloc uint32 Flags uint32 Reserve1 uint32 Reserve2 uint32 }
A Section32 is a 32-bit Mach-O section header.
type Section64 ¶
type Section64 struct { Name [16]byte Seg [16]byte Addr uint64 Size uint64 Offset uint32 Align uint32 Reloff uint32 Nreloc uint32 Flags uint32 Reserve1 uint32 Reserve2 uint32 Reserve3 uint32 }
A Section64 is a 64-bit Mach-O section header.
type SectionHeader ¶
type Segment ¶
type Segment struct { LoadBytes SegmentHeader // 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) Open ¶
func (s *Segment) Open() io.ReadSeeker
Open returns a new ReadSeeker reading the segment.
type Segment32 ¶
type Segment32 struct { Cmd LoadCmd Len uint32 Name [16]byte Addr uint32 Memsz uint32 Offset uint32 Filesz uint32 Maxprot uint32 Prot uint32 Nsect uint32 Flag uint32 }
A Segment32 is a 32-bit Mach-O segment load command.
type Segment64 ¶
type Segment64 struct { Cmd LoadCmd Len uint32 Name [16]byte Addr uint64 Memsz uint64 Offset uint64 Filesz uint64 Maxprot uint32 Prot uint32 Nsect uint32 Flag uint32 }
A Segment64 is a 64-bit Mach-O segment load command.
type SegmentHeader ¶
type SegmentHeader struct { Cmd LoadCmd Len uint32 Name string Addr uint64 Memsz uint64 Offset uint64 Filesz uint64 Maxprot uint32 Prot uint32 Nsect uint32 Flag uint32 }
A SegmentHeader is the header for a Mach-O 32-bit or 64-bit load segment command.
type SymtabCmd ¶
type SymtabCmd struct { Cmd LoadCmd Len uint32 Symoff uint32 Nsyms uint32 Stroff uint32 Strsize uint32 }
A SymtabCmd is a Mach-O symbol table command.