本文整理汇总了Golang中debug/macho.Open函数的典型用法代码### 示例。如果您正苦于以下问题:Golang Open函数的具体用法?Golang Open怎么用?Golang Open使用的例子?那么恭喜您, 这里精选的函数代码### 示例或许可以为您提供帮助。

在下文中一共展示了Open函数的20个代码### 示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码### 示例。

示例1: main

//============================================================================
//      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()
}

开发者ID:refnum,项目名称:gatos,代码行数:55,代码来源:gatos.go

示例2: openBinary

func openBinary(name string) (Binary, error) {
    f, err := os.Open(name)
    if err != nil {
        return nil, err
    }
    magic := make([]byte, 4)
    if _, err := f.ReadAt(magic[:], 0); err != nil {
        return nil, err
    }

    if bytes.HasPrefix(magic, []byte{0x7f, 'E', 'L', 'F'}) {
        e, err := elf.NewFile(f)
        if err != nil {
            return nil, err
        }
        return &elfBinary{File: e}, nil
    } else if bytes.HasPrefix(magic, []byte{'M', 'Z'}) {
        p, err := pe.Open(name)
        if err != nil {
            return nil, err
        }
        return &peBinary{File: p}, nil
    } else if bytes.HasPrefix(magic, []byte{0xcf, 0xfa, 0xed, 0xfe}) {
        m, err := macho.Open(name)
        if err != nil {
            return nil, err
        }
        return &machoBinary{File: m}, nil
    }
    return nil, fmt.Errorf("unsupported binary format")
}

开发者ID:ebfe,项目名称:gover,代码行数:31,代码来源:main.go

示例3: TestMachO

func TestMachO(filename, expectedArch, expectedOs string, isVerbose bool) error {
    file, err := macho.Open(filename)
    if err != nil {

        log.Printf("File '%s' is not a Mach-O file: %v\n", filename, err)
        return err
    }
    defer file.Close()
    if isVerbose {
        log.Printf("File '%s' is a Mach-O file (arch: %s)\n", filename, file.FileHeader.Cpu.String())
    }
    if expectedArch == platforms.X86 {
        if file.FileHeader.Cpu != macho.Cpu386 {
            return errors.New("Not a 386 executable")
        }

    }
    if expectedArch == platforms.AMD64 {
        if file.FileHeader.Cpu != macho.CpuAmd64 {
            return errors.New("Not an AMD64 executable")
        }

    }
    return nil
}

开发者ID:yl10,项目名称:goxc,代码行数:25,代码来源:parseexe.go

示例4: getDwarf

func getDwarf(execname string) *dwarf.Data {
    e, err := elf.Open(execname)
    if err == nil {
        defer e.Close()
        d, err := e.DWARF()
        if err == nil {
            return d
        }
    }
    m, err := macho.Open(execname)
    if err == nil {
        defer m.Close()
        d, err := m.DWARF()
        if err == nil {
            return d
        }
    }
    p, err := pe.Open(execname)
    if err == nil {
        defer p.Close()
        d, err := p.DWARF()
        if err == nil {
            return d
        }
    }
    log.Fatal("can't get dwarf info from executable", err)
    return nil
}

开发者ID:lamproae,项目名称:hprof,代码行数:28,代码来源:parser.go

示例5: IsMACHO

func IsMACHO(fPath string) error {
    if _, err := macho.Open(fPath); err != nil {
        return err
    }

    return nil
}

开发者ID:hcninja,项目名称:malpic,代码行数:7,代码来源:anal.go

最后编辑: kuteng  文档更新时间: 2021-08-23 19:14   作者:kuteng