debug/macho

Guided tour · Runtime & Debug · pkg.go.dev →

Read Mach-O binaries (macOS, iOS). Symbols, sections, load commands.

Usage

Open

f, err := macho.Open("/bin/ls")
if err != nil { log.Fatal(err) }
defer f.Close()
for _, s := range f.Sections {
    fmt.Println(s.Name, s.Seg, s.Size)
}

Fat (universal) binaries

fat, _ := macho.OpenFat("/bin/ls")
for _, arch := range fat.Arches {
    fmt.Println(arch.Cpu)
}