loadmacho

Imports

Imports #

"bytes"
"cmd/internal/bio"
"cmd/internal/objabi"
"cmd/internal/sys"
"cmd/link/internal/loader"
"cmd/link/internal/sym"
"encoding/binary"
"fmt"

Constants & Variables

LdMachoCmdDysymtab const #

const LdMachoCmdDysymtab = 11

LdMachoCmdSegment const #

const LdMachoCmdSegment = 1

LdMachoCmdSegment64 const #

const LdMachoCmdSegment64 = 25

LdMachoCmdSymseg const #

const LdMachoCmdSymseg = 3

LdMachoCmdSymtab const #

const LdMachoCmdSymtab = 2

LdMachoCmdThread const #

const LdMachoCmdThread = 4

LdMachoCpu386 const #

const LdMachoCpu386 = 7

LdMachoCpu68000 const #

const LdMachoCpu68000 = 6

LdMachoCpu860 const #

const LdMachoCpu860 = 15

LdMachoCpu88000 const #

const LdMachoCpu88000 = 13

LdMachoCpu98000 const #

const LdMachoCpu98000 = 10

LdMachoCpuAlpha const #

const LdMachoCpuAlpha = 16

LdMachoCpuAmd64 const #

const LdMachoCpuAmd64 = *ast.BinaryExpr

LdMachoCpuArm const #

const LdMachoCpuArm = 12

LdMachoCpuArm64 const #

const LdMachoCpuArm64 = *ast.BinaryExpr

LdMachoCpuHppa const #

const LdMachoCpuHppa = 11

LdMachoCpuMips const #

const LdMachoCpuMips = 8

LdMachoCpuPower const #

const LdMachoCpuPower = 18

LdMachoCpuSparc const #

const LdMachoCpuSparc = 14

LdMachoCpuVax const #

const LdMachoCpuVax = 1

LdMachoFileCore const #

const LdMachoFileCore = 4

LdMachoFileExecutable const #

const LdMachoFileExecutable = 2

LdMachoFileFvmlib const #

const LdMachoFileFvmlib = 3

LdMachoFileObject const #

const LdMachoFileObject = 1

LdMachoFilePreload const #

const LdMachoFilePreload = 5

MACHO_ARM64_RELOC_ADDEND const #

TODO(crawshaw): de-duplicate these symbols with cmd/link/internal/ld

const MACHO_ARM64_RELOC_ADDEND = 10

MACHO_X86_64_RELOC_SIGNED const #

TODO(crawshaw): de-duplicate these symbols with cmd/link/internal/ld

const MACHO_X86_64_RELOC_SIGNED = 1

MACHO_X86_64_RELOC_UNSIGNED const #

TODO(crawshaw): de-duplicate these symbols with cmd/link/internal/ld

const MACHO_X86_64_RELOC_UNSIGNED = 0

N_EXT const #

ldMachoSym.type_

const N_EXT = 0x01

N_STAB const #

ldMachoSym.type_

const N_STAB = 0xe0

N_TYPE const #

ldMachoSym.type_

const N_TYPE = 0x1e

N_WEAK_DEF const #

ldMachoSym.desc

const N_WEAK_DEF = 0x80

N_WEAK_REF const #

ldMachoSym.desc

const N_WEAK_REF = 0x40

Structs

ldMachoCmd struct #

type ldMachoCmd struct {
type_ int
off uint32
size uint32
seg ldMachoSeg
sym ldMachoSymtab
dsym ldMachoDysymtab
}

ldMachoDysymtab struct #

type ldMachoDysymtab struct {
ilocalsym uint32
nlocalsym uint32
iextdefsym uint32
nextdefsym uint32
iundefsym uint32
nundefsym uint32
tocoff uint32
ntoc uint32
modtaboff uint32
nmodtab uint32
extrefsymoff uint32
nextrefsyms uint32
indirectsymoff uint32
nindirectsyms uint32
extreloff uint32
nextrel uint32
locreloff uint32
nlocrel uint32
indir []uint32
}

ldMachoObj struct #

type ldMachoObj struct {
f *bio.Reader
base int64
length int64
is64 bool
name string
e binary.ByteOrder
cputype uint
subcputype uint
filetype uint32
flags uint32
cmd []ldMachoCmd
ncmd uint
}

ldMachoRel struct #

type ldMachoRel struct {
addr uint32
symnum uint32
pcrel uint8
length uint8
extrn uint8
type_ uint8
scattered uint8
value uint32
}

ldMachoSect struct #

type ldMachoSect struct {
name string
segname string
addr uint64
size uint64
off uint32
align uint32
reloff uint32
nreloc uint32
flags uint32
res1 uint32
res2 uint32
sym loader.Sym
rel []ldMachoRel
}

ldMachoSeg struct #

type ldMachoSeg struct {
name string
vmaddr uint64
vmsize uint64
fileoff uint32
filesz uint32
maxprot uint32
initprot uint32
nsect uint32
flags uint32
sect []ldMachoSect
}

ldMachoSym struct #

type ldMachoSym struct {
name string
type_ uint8
sectnum uint8
desc uint16
kind int8
value uint64
sym loader.Sym
}

ldMachoSymtab struct #

type ldMachoSymtab struct {
symoff uint32
nsym uint32
stroff uint32
strsize uint32
str []byte
sym []ldMachoSym
}

Functions

Load function #

Load the Mach-O file pn from f. Symbols are written into syms, and a slice of the text symbols is returned.

func Load(l *loader.Loader, arch *sys.Arch, localSymVersion int, f *bio.Reader, pkg string, length int64, pn string) (textp []loader.Sym, err error)

cstring function #

func cstring(x []byte) string

macholoaddsym function #

func macholoaddsym(m *ldMachoObj, d *ldMachoDysymtab) int

macholoadrel function #

func macholoadrel(m *ldMachoObj, sect *ldMachoSect) int

macholoadsym function #

func macholoadsym(m *ldMachoObj, symtab *ldMachoSymtab) int

unpackcmd function #

func unpackcmd(p []byte, m *ldMachoObj, c *ldMachoCmd, type_ uint, sz uint) int

Generated with Arrow