//============================================================================ // main : Entry point. //---------------------------------------------------------------------------- func main() { var dwarfData *dwarf.Data var theFile *macho.File var theErr os.Error var relativeAddress uint64 var runtimeAddress uint64 var loadAddress uint64 var segmentAddress uint64 var pathMacho string var pathDsym string // Parse our arguments flag.Uint64Var(&runtimeAddress, "raddr", 0, "") flag.Uint64Var(&loadAddress, "laddr", 0, "") flag.StringVar(&pathMacho, "macho", "", "") flag.StringVar(&pathDsym, "dsym", "", "") flag.Parse() if runtimeAddress == 0 || loadAddress == 0 || pathMacho == "" || pathDsym == "" { printHelp() } // Find the text segment address theFile, theErr = macho.Open(pathMacho) if theErr != nil { fatalError("Can't open Mach-O file: " + theErr.String()) } segmentAddress = theFile.Segment("__TEXT").Addr theFile.Close() // Calculate the target address relativeAddress = runtimeAddress - loadAddress gTargetAddress = segmentAddress + relativeAddress // Find the target theFile, theErr = macho.Open(pathDsym) if theErr != nil { fatalError("Can't open .dsym file: " + theErr.String()) } dwarfData, theErr = theFile.DWARF() if theErr != nil { fatalError("Can't find DWARF info: " + theErr.String()) } processChildren(dwarfData.Reader(), 0, false) theFile.Close() }