tools: golang.org/x/tools/cmd/splitdwarf/internal/macho Index | Files

package macho

import "golang.org/x/tools/cmd/splitdwarf/internal/macho"

Package macho implements access to Mach-O object files.

Index

Package Files

fat.go file.go macho.go reloctype.go reloctype_string.go

Constants

const (
    Magic32  uint32 = 0xfeedface
    Magic64  uint32 = 0xfeedfacf
    MagicFat uint32 = 0xcafebabe
)

func RoundUp Uses

func RoundUp(x, align uint64) uint64

type Cpu Uses

type Cpu uint32

A Cpu is a Mach-O cpu type.

const (
    Cpu386   Cpu = 7
    CpuAmd64 Cpu = Cpu386 | cpuArch64
    CpuArm   Cpu = 12
    CpuArm64 Cpu = CpuArm | cpuArch64
    CpuPpc   Cpu = 18
    CpuPpc64 Cpu = CpuPpc | cpuArch64
)

func (Cpu) GoString Uses

func (i Cpu) GoString() string

func (Cpu) String Uses

func (i Cpu) String() string

type DyldInfo Uses

type DyldInfo struct {
    DyldInfoCmd
}

func (*DyldInfo) Copy Uses

func (s *DyldInfo) Copy() *DyldInfo

func (*DyldInfo) LoadSize Uses

func (s *DyldInfo) LoadSize(t *FileTOC) uint32

func (*DyldInfo) String Uses

func (s *DyldInfo) String() string

type DyldInfoCmd Uses

type DyldInfoCmd struct {
    LoadCmd
    Len                      uint32
    RebaseOff, RebaseLen     uint32 // file offset and length; data contains segment indices
    BindOff, BindLen         uint32 // file offset and length; data contains segment indices
    WeakBindOff, WeakBindLen uint32 // file offset and length
    LazyBindOff, LazyBindLen uint32 // file offset and length
    ExportOff, ExportLen     uint32 // file offset and length
}

LC_DYLD_INFO, LC_DYLD_INFO_ONLY

type Dylib Uses

type Dylib struct {
    DylibCmd
    Name           string
    Time           uint32
    CurrentVersion uint32
    CompatVersion  uint32
}

A Dylib represents a Mach-O load dynamic library command.

func (*Dylib) Copy Uses

func (s *Dylib) Copy() *Dylib

func (*Dylib) LoadSize Uses

func (s *Dylib) LoadSize(t *FileTOC) uint32

func (*Dylib) String Uses

func (s *Dylib) String() string

type DylibCmd Uses

type DylibCmd struct {
    LoadCmd
    Len            uint32
    Name           uint32
    Time           uint32
    CurrentVersion uint32
    CompatVersion  uint32
}

A DylibCmd is a Mach-O load dynamic library command.

type Dylinker Uses

type Dylinker struct {
    DylinkerCmd // shared by 3 commands, need the LoadCmd
    Name        string
}

func (*Dylinker) Copy Uses

func (s *Dylinker) Copy() *Dylinker

func (*Dylinker) LoadSize Uses

func (s *Dylinker) LoadSize(t *FileTOC) uint32

func (*Dylinker) String Uses

func (s *Dylinker) String() string

type DylinkerCmd Uses

type DylinkerCmd struct {
    LoadCmd
    Len  uint32
    Name uint32
}

A DylinkerCmd is a Mach-O load dynamic linker or environment command.

type Dysymtab Uses

type Dysymtab struct {
    DysymtabCmd
    IndirectSyms []uint32 // indices into Symtab.Syms
}

A Dysymtab represents a Mach-O dynamic symbol table command.

func (*Dysymtab) Copy Uses

func (s *Dysymtab) Copy() *Dysymtab

func (*Dysymtab) LoadSize Uses

func (s *Dysymtab) LoadSize(t *FileTOC) uint32

func (*Dysymtab) String Uses

func (s *Dysymtab) String() string

type DysymtabCmd Uses

type DysymtabCmd struct {
    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 EncryptionInfo Uses

type EncryptionInfo struct {
    EncryptionInfoCmd
}

func (*EncryptionInfo) Copy Uses

func (s *EncryptionInfo) Copy() *EncryptionInfo

func (*EncryptionInfo) LoadSize Uses

func (s *EncryptionInfo) LoadSize(t *FileTOC) uint32

func (*EncryptionInfo) String Uses

func (s *EncryptionInfo) String() string

type EncryptionInfoCmd Uses

type EncryptionInfoCmd struct {
    LoadCmd
    Len                uint32
    CryptOff, CryptLen uint32 // file offset and length
    CryptId            uint32
}

LC_ENCRYPTION_INFO, LC_ENCRYPTION_INFO_64

type EntryPointCmd Uses

type EntryPointCmd struct {
    LoadCmd
    Len       uint32
    EntryOff  uint64 // file offset
    StackSize uint64 // if not zero, initial stack size
}

type FatArch Uses

type FatArch struct {
    FatArchHeader
    *File
}

A FatArch is a Mach-O File inside a FatFile.

type FatArchHeader Uses

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

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

type FatFile Uses

type FatFile struct {
    Magic  uint32
    Arches []FatArch
    // contains filtered or unexported fields
}

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

func NewFatFile Uses

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 OpenFat Uses

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.

func (*FatFile) Close Uses

func (ff *FatFile) Close() error

type File Uses

type File struct {
    FileTOC

    Symtab   *Symtab
    Dysymtab *Dysymtab
    // contains filtered or unexported fields
}

A File represents an open Mach-O file.

func NewFile Uses

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 Uses

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 (*File) Close Uses

func (f *File) Close() error

Close closes the File. If the File was created using NewFile directly instead of Open, Close has no effect.

func (*File) DWARF Uses

func (f *File) DWARF() (*dwarf.Data, error)

DWARF returns the DWARF debug information for the Mach-O file.

func (*File) ImportedLibraries Uses

func (f *File) ImportedLibraries() ([]string, error)

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 Uses

func (f *File) ImportedSymbols() ([]string, error)

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) Section Uses

func (f *File) Section(name string) *Section

Section returns the first section with the given name, or nil if no such section exists.

func (*File) Segment Uses

func (f *File) Segment(name string) *Segment

Segment returns the first Segment with the given name, or nil if no such segment exists.

type FileHeader Uses

type FileHeader struct {
    Magic        uint32
    Cpu          Cpu
    SubCpu       uint32
    Type         HdrType
    NCommands    uint32 // number of load commands
    SizeCommands uint32 // size of all the load commands, not including this header.
    Flags        HdrFlags
}

A FileHeader represents a Mach-O file header.

func (*FileHeader) Put Uses

func (h *FileHeader) Put(b []byte, o binary.ByteOrder) int

type FileTOC Uses

type FileTOC struct {
    FileHeader
    ByteOrder binary.ByteOrder
    Loads     []Load
    Sections  []*Section
}

func (*FileTOC) AddLoad Uses

func (t *FileTOC) AddLoad(l Load)

func (*FileTOC) AddSection Uses

func (t *FileTOC) AddSection(s *Section)

Adds section to the most recently added Segment

func (*FileTOC) AddSegment Uses

func (t *FileTOC) AddSegment(s *Segment)

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 Uses

func (t *FileTOC) DerivedCopy(Type HdrType, Flags HdrFlags) *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 Uses

func (t *FileTOC) FileSize() uint64

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 Uses

func (t *FileTOC) HdrSize() uint32

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 Uses

func (t *FileTOC) LoadAlign() uint64

LoadAlign returns the required alignment of Load commands in a binary. This is used to add padding for necessary alignment.

func (*FileTOC) LoadSize Uses

func (t *FileTOC) LoadSize() uint32

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) Put Uses

func (t *FileTOC) Put(buffer []byte) int

Put writes the header and all load commands to buffer, using the byte ordering specified in FileTOC t. For sections, this writes the headers that come in-line with the segment Load commands, but does not write the reference data for those sections.

func (*FileTOC) SymbolSize Uses

func (t *FileTOC) SymbolSize() uint32

SymbolSize returns the size in bytes of a Symbol (Nlist32 or Nlist64)

func (*FileTOC) TOCSize Uses

func (t *FileTOC) TOCSize() uint32

TOCSize returns the size in bytes of the object file representation of the header and Load Commands (including Segments and Sections, but not their contents) at the beginning of a Mach-O file. This typically overlaps the text segment in the object file.

type FormatError Uses

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 Uses

func (e *FormatError) Error() string

func (*FormatError) String Uses

func (e *FormatError) String() string

type HdrFlags Uses

type HdrFlags uint32
const (
    FlagNoUndefs              HdrFlags = 0x1
    FlagIncrLink              HdrFlags = 0x2
    FlagDyldLink              HdrFlags = 0x4
    FlagBindAtLoad            HdrFlags = 0x8
    FlagPrebound              HdrFlags = 0x10
    FlagSplitSegs             HdrFlags = 0x20
    FlagLazyInit              HdrFlags = 0x40
    FlagTwoLevel              HdrFlags = 0x80
    FlagForceFlat             HdrFlags = 0x100
    FlagNoMultiDefs           HdrFlags = 0x200
    FlagNoFixPrebinding       HdrFlags = 0x400
    FlagPrebindable           HdrFlags = 0x800
    FlagAllModsBound          HdrFlags = 0x1000
    FlagSubsectionsViaSymbols HdrFlags = 0x2000
    FlagCanonical             HdrFlags = 0x4000
    FlagWeakDefines           HdrFlags = 0x8000
    FlagBindsToWeak           HdrFlags = 0x10000
    FlagAllowStackExecution   HdrFlags = 0x20000
    FlagRootSafe              HdrFlags = 0x40000
    FlagSetuidSafe            HdrFlags = 0x80000
    FlagNoReexportedDylibs    HdrFlags = 0x100000
    FlagPIE                   HdrFlags = 0x200000
    FlagDeadStrippableDylib   HdrFlags = 0x400000
    FlagHasTLVDescriptors     HdrFlags = 0x800000
    FlagNoHeapExecution       HdrFlags = 0x1000000
    FlagAppExtensionSafe      HdrFlags = 0x2000000
)

type HdrType Uses

type HdrType uint32

A HdrType is the Mach-O file type, e.g. an object file, executable, or dynamic library.

const (
    MhObject  HdrType = 1
    MhExecute HdrType = 2
    MhCore    HdrType = 4
    MhDylib   HdrType = 6
    MhBundle  HdrType = 8
    MhDsym    HdrType = 0xa
)

func (HdrType) GoString Uses

func (t HdrType) GoString() string

func (HdrType) String Uses

func (t HdrType) String() string

type LinkEditData Uses

type LinkEditData struct {
    LinkEditDataCmd
}

func (*LinkEditData) Copy Uses

func (s *LinkEditData) Copy() *LinkEditData

func (*LinkEditData) LoadSize Uses

func (s *LinkEditData) LoadSize(t *FileTOC) uint32

func (*LinkEditData) String Uses

func (s *LinkEditData) String() string

type LinkEditDataCmd Uses

type LinkEditDataCmd struct {
    LoadCmd
    Len              uint32
    DataOff, DataLen uint32 // file offset and length
}

LC_CODE_SIGNATURE, LC_SEGMENT_SPLIT_INFO, LC_FUNCTION_STARTS, LC_DATA_IN_CODE, LC_DYLIB_CODE_SIGN_DRS

type Load Uses

type Load interface {
    String() string
    Command() LoadCmd
    LoadSize(*FileTOC) uint32 // Need the TOC for alignment, sigh.
    Put([]byte, binary.ByteOrder) int
}

A Load represents any Mach-O load command.

type LoadBytes Uses

type LoadBytes []byte

LoadBytes is the uninterpreted bytes of a Mach-O load command.

func (LoadBytes) Copy Uses

func (b LoadBytes) Copy() LoadBytes

func (LoadBytes) LoadSize Uses

func (b LoadBytes) LoadSize(t *FileTOC) uint32

func (LoadBytes) Raw Uses

func (b LoadBytes) Raw() []byte

func (LoadBytes) String Uses

func (b LoadBytes) String() string

type LoadCmd Uses

type LoadCmd uint32

A LoadCmd is a Mach-O load command.

const (
    // Note 3 and 8 are obsolete
    LcSegment            LoadCmd = 0x1
    LcSymtab             LoadCmd = 0x2
    LcThread             LoadCmd = 0x4
    LcUnixthread         LoadCmd = 0x5 // thread+stack
    LcDysymtab           LoadCmd = 0xb
    LcDylib              LoadCmd = 0xc // load dylib command
    LcIdDylib            LoadCmd = 0xd // dynamically linked shared lib ident
    LcLoadDylinker       LoadCmd = 0xe // load a dynamic linker
    LcIdDylinker         LoadCmd = 0xf // id dylinker command (not load dylinker command)
    LcSegment64          LoadCmd = 0x19
    LcUuid               LoadCmd = 0x1b
    LcCodeSignature      LoadCmd = 0x1d
    LcSegmentSplitInfo   LoadCmd = 0x1e
    LcRpath              LoadCmd = 0x8000001c
    LcEncryptionInfo     LoadCmd = 0x21
    LcDyldInfo           LoadCmd = 0x22
    LcDyldInfoOnly       LoadCmd = 0x80000022
    LcVersionMinMacosx   LoadCmd = 0x24
    LcVersionMinIphoneos LoadCmd = 0x25
    LcFunctionStarts     LoadCmd = 0x26
    LcDyldEnvironment    LoadCmd = 0x27
    LcMain               LoadCmd = 0x80000028 // replacement for UnixThread
    LcDataInCode         LoadCmd = 0x29       // There are non-instructions in text
    LcSourceVersion      LoadCmd = 0x2a       // Source version used to build binary
    LcDylibCodeSignDrs   LoadCmd = 0x2b
    LcEncryptionInfo64   LoadCmd = 0x2c
    LcVersionMinTvos     LoadCmd = 0x2f
    LcVersionMinWatchos  LoadCmd = 0x30
)

func (LoadCmd) Command Uses

func (c LoadCmd) Command() LoadCmd

func (LoadCmd) GoString Uses

func (i LoadCmd) GoString() string

func (LoadCmd) Put Uses

func (lc LoadCmd) Put(b []byte, o binary.ByteOrder) int

func (LoadCmd) String Uses

func (i LoadCmd) String() string

type LoadCmdBytes Uses

type LoadCmdBytes struct {
    LoadCmd
    LoadBytes
}

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 Uses

func (s LoadCmdBytes) Copy() LoadCmdBytes

func (LoadCmdBytes) String Uses

func (s LoadCmdBytes) String() string

type Nlist32 Uses

type Nlist32 struct {
    Name  uint32
    Type  uint8
    Sect  uint8
    Desc  uint16
    Value uint32
}

An Nlist32 is a Mach-O 32-bit symbol table entry.

type Nlist64 Uses

type Nlist64 struct {
    Name  uint32
    Type  uint8
    Sect  uint8
    Desc  uint16
    Value uint64
}

An Nlist64 is a Mach-O 64-bit symbol table entry.

func (*Nlist64) Put32 Uses

func (n *Nlist64) Put32(b []byte, o binary.ByteOrder) uint32

func (*Nlist64) Put64 Uses

func (n *Nlist64) Put64(b []byte, o binary.ByteOrder) uint32

type NoteCmd Uses

type NoteCmd struct {
    LoadCmd
    Len            uint32
    Name           [16]byte
    Offset, Filesz uint64 // file offset and length
}

type Regs386 Uses

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 Uses

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 Reloc Uses

type Reloc struct {
    Addr  uint32
    Value uint32
    // 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.
    Type      uint8
    Len       uint8 // 0=byte, 1=word, 2=long, 3=quad
    Pcrel     bool
    Extern    bool // valid if Scattered == false
    Scattered bool
}

A Reloc represents a Mach-O relocation.

type RelocTypeARM Uses

type RelocTypeARM int
const (
    ARM_RELOC_VANILLA        RelocTypeARM = 0
    ARM_RELOC_PAIR           RelocTypeARM = 1
    ARM_RELOC_SECTDIFF       RelocTypeARM = 2
    ARM_RELOC_LOCAL_SECTDIFF RelocTypeARM = 3
    ARM_RELOC_PB_LA_PTR      RelocTypeARM = 4
    ARM_RELOC_BR24           RelocTypeARM = 5
    ARM_THUMB_RELOC_BR22     RelocTypeARM = 6
    ARM_THUMB_32BIT_BRANCH   RelocTypeARM = 7
    ARM_RELOC_HALF           RelocTypeARM = 8
    ARM_RELOC_HALF_SECTDIFF  RelocTypeARM = 9
)

func (RelocTypeARM) GoString Uses

func (r RelocTypeARM) GoString() string

func (RelocTypeARM) String Uses

func (i RelocTypeARM) String() string

type RelocTypeARM64 Uses

type RelocTypeARM64 int
const (
    ARM64_RELOC_UNSIGNED            RelocTypeARM64 = 0
    ARM64_RELOC_SUBTRACTOR          RelocTypeARM64 = 1
    ARM64_RELOC_BRANCH26            RelocTypeARM64 = 2
    ARM64_RELOC_PAGE21              RelocTypeARM64 = 3
    ARM64_RELOC_PAGEOFF12           RelocTypeARM64 = 4
    ARM64_RELOC_GOT_LOAD_PAGE21     RelocTypeARM64 = 5
    ARM64_RELOC_GOT_LOAD_PAGEOFF12  RelocTypeARM64 = 6
    ARM64_RELOC_POINTER_TO_GOT      RelocTypeARM64 = 7
    ARM64_RELOC_TLVP_LOAD_PAGE21    RelocTypeARM64 = 8
    ARM64_RELOC_TLVP_LOAD_PAGEOFF12 RelocTypeARM64 = 9
    ARM64_RELOC_ADDEND              RelocTypeARM64 = 10
)

func (RelocTypeARM64) GoString Uses

func (r RelocTypeARM64) GoString() string

func (RelocTypeARM64) String Uses

func (i RelocTypeARM64) String() string

type RelocTypeGeneric Uses

type RelocTypeGeneric int
const (
    GENERIC_RELOC_VANILLA        RelocTypeGeneric = 0
    GENERIC_RELOC_PAIR           RelocTypeGeneric = 1
    GENERIC_RELOC_SECTDIFF       RelocTypeGeneric = 2
    GENERIC_RELOC_PB_LA_PTR      RelocTypeGeneric = 3
    GENERIC_RELOC_LOCAL_SECTDIFF RelocTypeGeneric = 4
    GENERIC_RELOC_TLV            RelocTypeGeneric = 5
)

func (RelocTypeGeneric) GoString Uses

func (r RelocTypeGeneric) GoString() string

func (RelocTypeGeneric) String Uses

func (i RelocTypeGeneric) String() string

type RelocTypeX86_64 Uses

type RelocTypeX86_64 int
const (
    X86_64_RELOC_UNSIGNED   RelocTypeX86_64 = 0
    X86_64_RELOC_SIGNED     RelocTypeX86_64 = 1
    X86_64_RELOC_BRANCH     RelocTypeX86_64 = 2
    X86_64_RELOC_GOT_LOAD   RelocTypeX86_64 = 3
    X86_64_RELOC_GOT        RelocTypeX86_64 = 4
    X86_64_RELOC_SUBTRACTOR RelocTypeX86_64 = 5
    X86_64_RELOC_SIGNED_1   RelocTypeX86_64 = 6
    X86_64_RELOC_SIGNED_2   RelocTypeX86_64 = 7
    X86_64_RELOC_SIGNED_4   RelocTypeX86_64 = 8
    X86_64_RELOC_TLV        RelocTypeX86_64 = 9
)

func (RelocTypeX86_64) GoString Uses

func (r RelocTypeX86_64) GoString() string

func (RelocTypeX86_64) String Uses

func (i RelocTypeX86_64) String() string

type Rpath Uses

type Rpath struct {
    LoadCmd
    Path string
}

A Rpath represents a Mach-O rpath command.

func (*Rpath) Command Uses

func (s *Rpath) Command() LoadCmd

func (*Rpath) Copy Uses

func (s *Rpath) Copy() *Rpath

func (*Rpath) LoadSize Uses

func (s *Rpath) LoadSize(t *FileTOC) uint32

func (*Rpath) String Uses

func (s *Rpath) String() string

type RpathCmd Uses

type RpathCmd struct {
    LoadCmd
    Len  uint32
    Path uint32
}

A RpathCmd is a Mach-O rpath command.

type SecFlags Uses

type SecFlags uint32

type Section Uses

type Section struct {
    SectionHeader
    Relocs []Reloc

    // 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) Copy Uses

func (s *Section) Copy() *Section

func (*Section) Data Uses

func (s *Section) Data() ([]byte, error)

Data reads and returns the contents of the Mach-O section.

func (*Section) Open Uses

func (s *Section) Open() io.ReadSeeker

Open returns a new ReadSeeker reading the Mach-O section.

func (*Section) Put32 Uses

func (s *Section) Put32(b []byte, o binary.ByteOrder) int

func (*Section) Put64 Uses

func (s *Section) Put64(b []byte, o binary.ByteOrder) int

func (*Section) PutData Uses

func (s *Section) PutData(b []byte)

func (*Section) PutRelocs Uses

func (s *Section) PutRelocs(b []byte, o binary.ByteOrder) int

func (*Section) PutUncompressedData Uses

func (s *Section) PutUncompressedData(b []byte)

func (*Section) UncompressedSize Uses

func (s *Section) UncompressedSize() uint64

type Section32 Uses

type Section32 struct {
    Name     [16]byte
    Seg      [16]byte
    Addr     uint32
    Size     uint32
    Offset   uint32
    Align    uint32
    Reloff   uint32
    Nreloc   uint32
    Flags    SecFlags
    Reserve1 uint32
    Reserve2 uint32
}

A Section32 is a 32-bit Mach-O section header.

type Section64 Uses

type Section64 struct {
    Name     [16]byte
    Seg      [16]byte
    Addr     uint64
    Size     uint64
    Offset   uint32
    Align    uint32
    Reloff   uint32
    Nreloc   uint32
    Flags    SecFlags
    Reserve1 uint32
    Reserve2 uint32
    Reserve3 uint32
}

A Section64 is a 64-bit Mach-O section header.

type SectionHeader Uses

type SectionHeader struct {
    Name      string
    Seg       string
    Addr      uint64
    Size      uint64
    Offset    uint32
    Align     uint32
    Reloff    uint32
    Nreloc    uint32
    Flags     SecFlags
    Reserved1 uint32
    Reserved2 uint32
    Reserved3 uint32 // only present if original was 64-bit
}

type SegFlags Uses

type SegFlags uint32

type Segment Uses

type Segment struct {
    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) Copy Uses

func (s *Segment) Copy() *Segment

func (*Segment) CopyZeroed Uses

func (s *Segment) CopyZeroed() *Segment

func (*Segment) Data Uses

func (s *Segment) Data() ([]byte, error)

Data reads and returns the contents of the segment.

func (*Segment) LoadSize Uses

func (s *Segment) LoadSize(t *FileTOC) uint32

func (*Segment) Open Uses

func (s *Segment) Open() io.ReadSeeker

Open returns a new ReadSeeker reading the segment.

func (*Segment) Put32 Uses

func (s *Segment) Put32(b []byte, o binary.ByteOrder) int

func (*Segment) Put64 Uses

func (s *Segment) Put64(b []byte, o binary.ByteOrder) int

func (*Segment) String Uses

func (s *Segment) String() string

func (*Segment) UncompressedSize Uses

func (s *Segment) UncompressedSize(t *FileTOC, align uint64) uint64

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 Segment32 Uses

type Segment32 struct {
    LoadCmd
    Len     uint32
    Name    [16]byte
    Addr    uint32
    Memsz   uint32
    Offset  uint32
    Filesz  uint32
    Maxprot uint32
    Prot    uint32
    Nsect   uint32
    Flag    SegFlags
}

A Segment32 is a 32-bit Mach-O segment load command.

type Segment64 Uses

type Segment64 struct {
    LoadCmd
    Len     uint32
    Name    [16]byte
    Addr    uint64
    Memsz   uint64
    Offset  uint64
    Filesz  uint64
    Maxprot uint32
    Prot    uint32
    Nsect   uint32
    Flag    SegFlags
}

A Segment64 is a 64-bit Mach-O segment load command.

type SegmentHeader Uses

type SegmentHeader struct {
    LoadCmd
    Len       uint32
    Name      string // 16 characters or fewer
    Addr      uint64 // memory address
    Memsz     uint64 // memory size
    Offset    uint64 // file offset
    Filesz    uint64 // number of bytes starting at that file offset
    Maxprot   uint32
    Prot      uint32
    Nsect     uint32
    Flag      SegFlags
    Firstsect uint32
}

A SegmentHeader is the header for a Mach-O 32-bit or 64-bit load segment command.

func (*SegmentHeader) String Uses

func (s *SegmentHeader) String() string

type Symbol Uses

type Symbol struct {
    Name  string
    Type  uint8
    Sect  uint8
    Desc  uint16
    Value uint64
}

A Symbol is a Mach-O 32-bit or 64-bit symbol table entry.

type Symtab Uses

type Symtab struct {
    SymtabCmd
    Syms []Symbol
}

A Symtab represents a Mach-O symbol table command.

func (*Symtab) Copy Uses

func (s *Symtab) Copy() *Symtab

func (*Symtab) LoadSize Uses

func (s *Symtab) LoadSize(t *FileTOC) uint32

func (*Symtab) Put Uses

func (s *Symtab) Put(b []byte, o binary.ByteOrder) int

func (*Symtab) String Uses

func (s *Symtab) String() string

type SymtabCmd Uses

type SymtabCmd struct {
    LoadCmd
    Len     uint32
    Symoff  uint32
    Nsyms   uint32
    Stroff  uint32
    Strsize uint32
}

A SymtabCmd is a Mach-O symbol table command.

type Thread Uses

type Thread struct {
    LoadCmd
    Len  uint32
    Type uint32
    Data []uint32
}

A Thread is a Mach-O thread state command.

type Uuid Uses

type Uuid struct {
    UuidCmd
}

func (*Uuid) Copy Uses

func (s *Uuid) Copy() *Uuid

func (*Uuid) LoadSize Uses

func (s *Uuid) LoadSize(t *FileTOC) uint32

func (*Uuid) Put Uses

func (s *Uuid) Put(b []byte, o binary.ByteOrder) int

func (*Uuid) String Uses

func (s *Uuid) String() string

type UuidCmd Uses

type UuidCmd struct {
    LoadCmd
    Len uint32
    Id  [16]byte
}

Package macho imports 10 packages (graph) and is imported by 1 packages. Updated 2019-09-15. Refresh now. Tools for package owners.