package macho
Import Path
debug/macho (on golang.org and go.dev)
Dependency Relation
imports 9 packages, and imported by 0 packages
Involved Source Files
fat.go
d-> file.go
macho.go
reloctype.go
reloctype_string.go
Exported Type Names
type Cpu uint32
A Cpu is a Mach-O cpu type.
( T) GoString() string
( T) String() string
T : expvar.Var
T : fmt.GoStringer
T : fmt.Stringer
const Cpu386
const CpuAmd64
const CpuArm
const CpuArm64
const CpuPpc
const CpuPpc64
type Dylib (struct)
A Dylib represents a Mach-O load dynamic library command.
CompatVersion uint32
CurrentVersion uint32
LoadBytes LoadBytes
Name string
Time uint32
( T) Raw() []byte
T : Load
type DylibCmd (struct)
A DylibCmd is a Mach-O load dynamic library command.
Cmd LoadCmd
CompatVersion uint32
CurrentVersion uint32
Len uint32
Name uint32
Time uint32
type Dysymtab (struct)
A Dysymtab represents a Mach-O dynamic symbol table command.
DysymtabCmd DysymtabCmd
DysymtabCmd.Cmd LoadCmd
DysymtabCmd.Extrefsymoff uint32
DysymtabCmd.Extreloff uint32
DysymtabCmd.Iextdefsym uint32
DysymtabCmd.Ilocalsym uint32
DysymtabCmd.Indirectsymoff uint32
DysymtabCmd.Iundefsym uint32
DysymtabCmd.Len uint32
DysymtabCmd.Locreloff uint32
DysymtabCmd.Modtaboff uint32
DysymtabCmd.Nextdefsym uint32
DysymtabCmd.Nextrefsyms uint32
DysymtabCmd.Nextrel uint32
DysymtabCmd.Nindirectsyms uint32
DysymtabCmd.Nlocalsym uint32
DysymtabCmd.Nlocrel uint32
DysymtabCmd.Nmodtab uint32
DysymtabCmd.Ntoc uint32
DysymtabCmd.Nundefsym uint32
DysymtabCmd.Tocoffset uint32
// indices into Symtab.Syms
LoadBytes LoadBytes
( T) Raw() []byte
T : Load
type DysymtabCmd (struct)
A DysymtabCmd is a Mach-O dynamic symbol table command.
Cmd LoadCmd
Extrefsymoff uint32
Extreloff uint32
Iextdefsym uint32
Ilocalsym uint32
Indirectsymoff uint32
Iundefsym uint32
Len uint32
Locreloff uint32
Modtaboff uint32
Nextdefsym uint32
Nextrefsyms uint32
Nextrel uint32
Nindirectsyms uint32
Nlocalsym uint32
Nlocrel uint32
Nmodtab uint32
Ntoc uint32
Nundefsym uint32
Tocoffset uint32
type FatArch (struct)
A FatArch is a Mach-O File inside a FatFile.
FatArchHeader FatArchHeader
FatArchHeader.Align uint32
FatArchHeader.Cpu Cpu
FatArchHeader.Offset uint32
FatArchHeader.Size uint32
FatArchHeader.SubCpu uint32
File *File
File.ByteOrder binary.ByteOrder
File.Dysymtab *Dysymtab
File.FileHeader FileHeader
File.FileHeader.Cmdsz uint32
File.FileHeader.Flags uint32
File.FileHeader.Magic uint32
File.FileHeader.Ncmd uint32
File.FileHeader.Type Type
File.Loads []Load
File.Sections []*Section
File.Symtab *Symtab
Close closes the File.
If the File was created using NewFile directly instead of Open,
Close has no effect.
DWARF returns the DWARF debug information for the Mach-O file.
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.
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.
Section returns the first section with the given name, or nil if no such
section exists.
Segment returns the first Segment with the given name, or nil if no such segment exists.
T : io.Closer
type FatArchHeader (struct)
A FatArchHeader represents a fat header for a specific image architecture.
Align uint32
Cpu Cpu
Offset uint32
Size uint32
SubCpu uint32
type FatFile (struct)
A FatFile is a Mach-O universal binary that contains at least one architecture.
Arches []FatArch
Magic uint32
(*T) Close() error
*T : io.Closer
func NewFatFile(r io.ReaderAt) (*FatFile, error)
func OpenFat(name string) (*FatFile, error)
type File (struct)
A File represents an open Mach-O file.
ByteOrder binary.ByteOrder
Dysymtab *Dysymtab
FileHeader FileHeader
FileHeader.Cmdsz uint32
FileHeader.Cpu Cpu
FileHeader.Flags uint32
FileHeader.Magic uint32
FileHeader.Ncmd uint32
FileHeader.SubCpu uint32
FileHeader.Type Type
Loads []Load
Sections []*Section
Symtab *Symtab
Close closes the File.
If the File was created using NewFile directly instead of Open,
Close has no effect.
DWARF returns the DWARF debug information for the Mach-O file.
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.
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.
Section returns the first section with the given name, or nil if no such
section exists.
Segment returns the first Segment with the given name, or nil if no such segment exists.
*T : io.Closer
func NewFile(r io.ReaderAt) (*File, error)
func Open(name string) (*File, error)
type FileHeader (struct)
A FileHeader represents a Mach-O file header.
Cmdsz uint32
Cpu Cpu
Flags uint32
Magic uint32
Ncmd uint32
SubCpu uint32
Type Type
type FormatError (struct)
FormatError is returned by some operations if the data does
not have the correct format for an object file.
(*T) Error() string
*T : error
var ErrNotFat *FormatError
type Load (interface)
A Load represents any Mach-O load command.
( T) Raw() []byte
Dylib
Dysymtab
LoadBytes
Rpath
Segment
Symtab
type LoadBytes ([])
A LoadBytes is the uninterpreted bytes of a Mach-O load command.
( T) Raw() []byte
T : Load
type LoadCmd uint32
A LoadCmd is a Mach-O load command.
( T) GoString() string
( T) String() string
T : expvar.Var
T : fmt.GoStringer
T : fmt.Stringer
const LoadCmdDylib
const LoadCmdDylinker
const LoadCmdDysymtab
const LoadCmdRpath
const LoadCmdSegment
const LoadCmdSegment64
const LoadCmdSymtab
const LoadCmdThread
const LoadCmdUnixThread
type Nlist32 (struct)
An Nlist32 is a Mach-O 32-bit symbol table entry.
Desc uint16
Name uint32
Sect uint8
Type uint8
Value uint32
type Nlist64 (struct)
An Nlist64 is a Mach-O 64-bit symbol table entry.
Desc uint16
Name uint32
Sect uint8
Type uint8
Value uint64
type Regs386 (struct)
Regs386 is the Mach-O 386 register structure.
AX uint32
BP uint32
BX uint32
CS uint32
CX uint32
DI uint32
DS uint32
DX uint32
ES uint32
FLAGS uint32
FS uint32
GS uint32
IP uint32
SI uint32
SP uint32
SS uint32
type RegsAMD64 (struct)
RegsAMD64 is the Mach-O AMD64 register structure.
AX uint64
BP uint64
BX uint64
CS uint64
CX uint64
DI uint64
DX uint64
FLAGS uint64
FS uint64
GS uint64
IP uint64
R10 uint64
R11 uint64
R12 uint64
R13 uint64
R14 uint64
R15 uint64
R8 uint64
R9 uint64
SI uint64
SP uint64
type Reloc (struct)
A Reloc represents a Mach-O relocation.
Addr uint32
// valid if Scattered == false
// 0=byte, 1=word, 2=long, 3=quad
Pcrel bool
Scattered bool
when Scattered == false && Extern == true, Value is the symbol number.
when Scattered == false && Extern == false, Value is the section number.
when Scattered == true, Value is the value that this reloc refers to.
Value uint32
type RelocTypeARM int
( T) GoString() string
( T) String() string
T : expvar.Var
T : fmt.GoStringer
T : fmt.Stringer
const ARM_RELOC_BR24
const ARM_RELOC_HALF
const ARM_RELOC_HALF_SECTDIFF
const ARM_RELOC_LOCAL_SECTDIFF
const ARM_RELOC_PAIR
const ARM_RELOC_PB_LA_PTR
const ARM_RELOC_SECTDIFF
const ARM_RELOC_VANILLA
const ARM_THUMB_32BIT_BRANCH
const ARM_THUMB_RELOC_BR22
type RelocTypeARM64 int
( T) GoString() string
( T) String() string
T : expvar.Var
T : fmt.GoStringer
T : fmt.Stringer
const ARM64_RELOC_ADDEND
const ARM64_RELOC_BRANCH26
const ARM64_RELOC_GOT_LOAD_PAGE21
const ARM64_RELOC_GOT_LOAD_PAGEOFF12
const ARM64_RELOC_PAGE21
const ARM64_RELOC_PAGEOFF12
const ARM64_RELOC_POINTER_TO_GOT
const ARM64_RELOC_SUBTRACTOR
const ARM64_RELOC_TLVP_LOAD_PAGE21
const ARM64_RELOC_TLVP_LOAD_PAGEOFF12
const ARM64_RELOC_UNSIGNED
type RelocTypeGeneric int
( T) GoString() string
( T) String() string
T : expvar.Var
T : fmt.GoStringer
T : fmt.Stringer
const GENERIC_RELOC_LOCAL_SECTDIFF
const GENERIC_RELOC_PAIR
const GENERIC_RELOC_PB_LA_PTR
const GENERIC_RELOC_SECTDIFF
const GENERIC_RELOC_TLV
const GENERIC_RELOC_VANILLA
type RelocTypeX86_64 int
( T) GoString() string
( T) String() string
T : expvar.Var
T : fmt.GoStringer
T : fmt.Stringer
const X86_64_RELOC_BRANCH
const X86_64_RELOC_GOT
const X86_64_RELOC_GOT_LOAD
const X86_64_RELOC_SIGNED
const X86_64_RELOC_SIGNED_1
const X86_64_RELOC_SIGNED_2
const X86_64_RELOC_SIGNED_4
const X86_64_RELOC_SUBTRACTOR
const X86_64_RELOC_TLV
const X86_64_RELOC_UNSIGNED
type Rpath (struct)
A Rpath represents a Mach-O rpath command.
LoadBytes LoadBytes
Path string
( T) Raw() []byte
T : Load
type Section (struct)
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.
Relocs []Reloc
SectionHeader SectionHeader
SectionHeader.Addr uint64
SectionHeader.Align uint32
SectionHeader.Flags uint32
SectionHeader.Name string
SectionHeader.Nreloc uint32
SectionHeader.Offset uint32
SectionHeader.Reloff uint32
SectionHeader.Seg string
SectionHeader.Size uint64
Data reads and returns the contents of the Mach-O section.
Open returns a new ReadSeeker reading the Mach-O section.
( T) ReadAt(p []byte, off int64) (n int, err error)
T : io.ReaderAt
func (*File).Section(name string) *Section
type Section32 (struct)
A Section32 is a 32-bit Mach-O section header.
Addr uint32
Align uint32
Flags uint32
Name [16]byte
Nreloc uint32
Offset uint32
Reloff uint32
Reserve1 uint32
Reserve2 uint32
Seg [16]byte
Size uint32
type Section64 (struct)
A Section64 is a 64-bit Mach-O section header.
Addr uint64
Align uint32
Flags uint32
Name [16]byte
Nreloc uint32
Offset uint32
Reloff uint32
Reserve1 uint32
Reserve2 uint32
Reserve3 uint32
Seg [16]byte
Size uint64
type SectionHeader (struct)
Addr uint64
Align uint32
Flags uint32
Name string
Nreloc uint32
Offset uint32
Reloff uint32
Seg string
Size uint64
type Segment (struct)
A Segment represents a Mach-O 32-bit or 64-bit load segment command.
LoadBytes 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.
SegmentHeader SegmentHeader
SegmentHeader.Addr uint64
SegmentHeader.Cmd LoadCmd
SegmentHeader.Filesz uint64
SegmentHeader.Flag uint32
SegmentHeader.Len uint32
SegmentHeader.Maxprot uint32
SegmentHeader.Memsz uint64
SegmentHeader.Name string
SegmentHeader.Nsect uint32
SegmentHeader.Offset uint64
SegmentHeader.Prot uint32
Data reads and returns the contents of the segment.
Open returns a new ReadSeeker reading the segment.
( T) Raw() []byte
( T) ReadAt(p []byte, off int64) (n int, err error)
T : Load
T : io.ReaderAt
func (*File).Segment(name string) *Segment
type Segment32 (struct)
A Segment32 is a 32-bit Mach-O segment load command.
Addr uint32
Cmd LoadCmd
Filesz uint32
Flag uint32
Len uint32
Maxprot uint32
Memsz uint32
Name [16]byte
Nsect uint32
Offset uint32
Prot uint32
type Segment64 (struct)
A Segment64 is a 64-bit Mach-O segment load command.
Addr uint64
Cmd LoadCmd
Filesz uint64
Flag uint32
Len uint32
Maxprot uint32
Memsz uint64
Name [16]byte
Nsect uint32
Offset uint64
Prot uint32
type SegmentHeader (struct)
A SegmentHeader is the header for a Mach-O 32-bit or 64-bit load segment command.
Addr uint64
Cmd LoadCmd
Filesz uint64
Flag uint32
Len uint32
Maxprot uint32
Memsz uint64
Name string
Nsect uint32
Offset uint64
Prot uint32
type Symbol (struct)
A Symbol is a Mach-O 32-bit or 64-bit symbol table entry.
Desc uint16
Name string
Sect uint8
Type uint8
Value uint64
type Symtab (struct)
A Symtab represents a Mach-O symbol table command.
LoadBytes LoadBytes
Syms []Symbol
SymtabCmd SymtabCmd
SymtabCmd.Cmd LoadCmd
SymtabCmd.Len uint32
SymtabCmd.Nsyms uint32
SymtabCmd.Stroff uint32
SymtabCmd.Strsize uint32
SymtabCmd.Symoff uint32
( T) Raw() []byte
T : Load
type SymtabCmd (struct)
A SymtabCmd is a Mach-O symbol table command.
Cmd LoadCmd
Len uint32
Nsyms uint32
Stroff uint32
Strsize uint32
Symoff uint32
type Thread (struct)
A Thread is a Mach-O thread state command.
Cmd LoadCmd
Data []uint32
Len uint32
Type uint32
type Type uint32
A Type is the Mach-O file type, e.g. an object file, executable, or dynamic library.
( T) GoString() string
( T) String() string
T : expvar.Var
T : fmt.GoStringer
T : fmt.Stringer
const TypeBundle
const TypeDylib
const TypeExec
const TypeObj
Exported Values
const ARM64_RELOC_ADDEND RelocTypeARM64 = 10
const ARM64_RELOC_BRANCH26 RelocTypeARM64 = 2
const ARM64_RELOC_GOT_LOAD_PAGE21 RelocTypeARM64 = 5
const ARM64_RELOC_GOT_LOAD_PAGEOFF12 RelocTypeARM64 = 6
const ARM64_RELOC_PAGE21 RelocTypeARM64 = 3
const ARM64_RELOC_PAGEOFF12 RelocTypeARM64 = 4
const ARM64_RELOC_POINTER_TO_GOT RelocTypeARM64 = 7
const ARM64_RELOC_SUBTRACTOR RelocTypeARM64 = 1
const ARM64_RELOC_TLVP_LOAD_PAGE21 RelocTypeARM64 = 8
const ARM64_RELOC_UNSIGNED RelocTypeARM64 = 0
const ARM_RELOC_BR24 RelocTypeARM = 5
const ARM_RELOC_HALF RelocTypeARM = 8
const ARM_RELOC_HALF_SECTDIFF RelocTypeARM = 9
const ARM_RELOC_LOCAL_SECTDIFF RelocTypeARM = 3
const ARM_RELOC_PAIR RelocTypeARM = 1
const ARM_RELOC_PB_LA_PTR RelocTypeARM = 4
const ARM_RELOC_SECTDIFF RelocTypeARM = 2
const ARM_RELOC_VANILLA RelocTypeARM = 0
const ARM_THUMB_32BIT_BRANCH RelocTypeARM = 7
const ARM_THUMB_RELOC_BR22 RelocTypeARM = 6
var ErrNotFat *FormatError
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.
const FlagAllModsBound uint32 = 4096
const FlagAllowStackExecution uint32 = 131072
const FlagAppExtensionSafe uint32 = 33554432
const FlagBindAtLoad uint32 = 8
const FlagBindsToWeak uint32 = 65536
const FlagCanonical uint32 = 16384
const FlagDeadStrippableDylib uint32 = 4194304
const FlagDyldLink uint32 = 4
const FlagForceFlat uint32 = 256
const FlagHasTLVDescriptors uint32 = 8388608
const FlagIncrLink uint32 = 2
const FlagLazyInit uint32 = 64
const FlagNoFixPrebinding uint32 = 1024
const FlagNoHeapExecution uint32 = 16777216
const FlagNoMultiDefs uint32 = 512
const FlagNoReexportedDylibs uint32 = 1048576
const FlagNoUndefs uint32 = 1
const FlagPrebindable uint32 = 2048
const FlagPrebound uint32 = 16
const FlagRootSafe uint32 = 262144
const FlagSetuidSafe uint32 = 524288
const FlagSplitSegs uint32 = 32
const FlagSubsectionsViaSymbols uint32 = 8192
const FlagTwoLevel uint32 = 128
const FlagWeakDefines uint32 = 32768
const GENERIC_RELOC_LOCAL_SECTDIFF RelocTypeGeneric = 4
const GENERIC_RELOC_PAIR RelocTypeGeneric = 1
const GENERIC_RELOC_PB_LA_PTR RelocTypeGeneric = 3
const GENERIC_RELOC_SECTDIFF RelocTypeGeneric = 2
const GENERIC_RELOC_TLV RelocTypeGeneric = 5
const GENERIC_RELOC_VANILLA RelocTypeGeneric = 0
const LoadCmdDylib LoadCmd = 12 // load dylib command
const LoadCmdDylinker LoadCmd = 15 // id dylinker command (not load dylinker command)
const LoadCmdDysymtab LoadCmd = 11
const LoadCmdRpath LoadCmd = 2147483676
const LoadCmdSegment LoadCmd = 1
const LoadCmdSegment64 LoadCmd = 25
const LoadCmdSymtab LoadCmd = 2
const LoadCmdThread LoadCmd = 4
const LoadCmdUnixThread LoadCmd = 5 // thread+stack
func NewFatFile(r io.ReaderAt) (*FatFile, error)
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.
func NewFile(r io.ReaderAt) (*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 Open(name string) (*File, error)
Open opens the named file using os.Open and prepares it for use as a Mach-O binary.
func OpenFat(name string) (*FatFile, error)
OpenFat opens the named file using os.Open and prepares it for use as a Mach-O
universal binary.
const TypeBundle Type = 8
const X86_64_RELOC_BRANCH RelocTypeX86_64 = 2
const X86_64_RELOC_GOT RelocTypeX86_64 = 4
const X86_64_RELOC_GOT_LOAD RelocTypeX86_64 = 3
const X86_64_RELOC_SIGNED RelocTypeX86_64 = 1
const X86_64_RELOC_SIGNED_1 RelocTypeX86_64 = 6
const X86_64_RELOC_SIGNED_2 RelocTypeX86_64 = 7
const X86_64_RELOC_SIGNED_4 RelocTypeX86_64 = 8
const X86_64_RELOC_SUBTRACTOR RelocTypeX86_64 = 5
const X86_64_RELOC_TLV RelocTypeX86_64 = 9
const X86_64_RELOC_UNSIGNED RelocTypeX86_64 = 0
![]() |
The pages are generated with Golds v0.1.7. (GOOS=linux GOARCH=amd64) Golds is a Go 101 project and developed by Tapir Liu. PR and bug reports are welcome and can be submitted to the issue list. Please follow @Go100and1 (reachable from the left QR code) to get the latest news of Golds. |