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

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

示例1: hasDynTag

func hasDynTag(f *elf.File, tag elf.DynTag) bool {
    ds := f.SectionByType(elf.SHT_DYNAMIC)
    if ds == nil {
        return false
    }
    d, err := ds.Data()
    if err != nil {
        return false
    }
    for len(d) > 0 {
        var t elf.DynTag
        switch f.Class {
        case elf.ELFCLASS32:
            t = elf.DynTag(f.ByteOrder.Uint32(d[0:4]))
            d = d[8:]
        case elf.ELFCLASS64:
            t = elf.DynTag(f.ByteOrder.Uint64(d[0:8]))
            d = d[16:]
        }
        if t == tag {
            return true
        }
    }
    return false
}

开发者ID:danny8002,项目名称:go,代码行数:25,代码来源:shared_test.go

示例2: hasDynTag

func hasDynTag(t *testing.T, f *elf.File, tag elf.DynTag) bool {
    ds := f.SectionByType(elf.SHT_DYNAMIC)
    if ds == nil {
        t.Error("no SHT_DYNAMIC section")
        return false
    }
    d, err := ds.Data()
    if err != nil {
        t.Errorf("can't read SHT_DYNAMIC contents: %v", err)
        return false
    }
    for len(d) > 0 {
        var t elf.DynTag
        switch f.Class {
        case elf.ELFCLASS32:
            t = elf.DynTag(f.ByteOrder.Uint32(d[:4]))
            d = d[8:]
        case elf.ELFCLASS64:
            t = elf.DynTag(f.ByteOrder.Uint64(d[:8]))
            d = d[16:]
        }
        if t == tag {
            return true
        }
    }
    return false
}

开发者ID:hurkgu,项目名称:go,代码行数:27,代码来源:carchive_test.go

示例3: testABIHashNote

// The shared library contains a note containing the ABI hash that is mapped into
// memory and there is a local symbol called go.link.abihashbytes that points 16
// bytes into it.
func testABIHashNote(t *testing.T, f *elf.File, note *note) {
    if note.section.Flags != elf.SHF_ALLOC {
        t.Errorf("abi hash section has flags %v", note.section.Flags)
    }
    if !isOffsetLoaded(f, note.section.Offset) {
        t.Errorf("abihash section not contained in PT_LOAD segment")
    }
    var hashbytes elf.Symbol
    symbols, err := f.Symbols()
    if err != nil {
        t.Errorf("error reading symbols %v", err)
        return
    }
    for _, sym := range symbols {
        if sym.Name == "go.link.abihashbytes" {
            hashbytes = sym
        }
    }
    if hashbytes.Name == "" {
        t.Errorf("no symbol called go.link.abihashbytes")
        return
    }
    if elf.ST_BIND(hashbytes.Info) != elf.STB_LOCAL {
        t.Errorf("%s has incorrect binding %v", hashbytes.Name, elf.ST_BIND(hashbytes.Info))
    }
    if f.Sections[hashbytes.Section] != note.section {
        t.Errorf("%s has incorrect section %v", hashbytes.Name, f.Sections[hashbytes.Section].Name)
    }
    if hashbytes.Value-note.section.Addr != 16 {
        t.Errorf("%s has incorrect offset into section %d", hashbytes.Name, hashbytes.Value-note.section.Addr)
    }
}

开发者ID:danny8002,项目名称:go,代码行数:35,代码来源:shared_test.go

示例4: haveDynTag

func haveDynTag(file *elf.File, tag elf.DynTag) bool {

    if section := file.Section(".dynamic"); section != nil {

        reader := io.NewSectionReader(section, 0, int64(section.Size))
        switch file.Machine {

        case elf.EM_X86_64:
            for {
                var entry elf.Dyn64
                if err := binary.Read(reader, binary.LittleEndian, &entry); err != io.EOF {
                    if elf.DynTag(entry.Tag) == tag {
                        return true
                    }
                } else {
                    break
                }
            }

        case elf.EM_386:
            for {
                var entry elf.Dyn32
                if err := binary.Read(reader, binary.LittleEndian, &entry); err != io.EOF {
                    if elf.DynTag(entry.Tag) == tag {
                        return true
                    }
                } else {
                    break
                }
            }
        }
    }
    return false
}

开发者ID:postfix,项目名称:checksec,代码行数:34,代码来源:dyntag.go

示例5: dump_symbols

func dump_symbols(file *elf.File) {
    fmt.Printf("Symbols:\n")
    symbols, _ := file.Symbols()
    for _, e := range symbols {
        if !strings.EqualFold(e.Name, "") {
            fmt.Printf("\t%s\n", e.Name)
        }
    }
}

开发者ID:n4ss,项目名称:GoPlay,代码行数:9,代码来源:main.go

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