本文整理汇总了Golang中debug/elf.File.Symbols方法的典型用法代码示例。如果您正苦于以下问题:Golang File.Symbols方法的具体用法?Golang File.Symbols怎么用?Golang File.Symbols使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类debug/elf.File
的用法示例。
在下文中一共展示了File.Symbols方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: 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)
}
}
示例2: printFileInformation
func printFileInformation(f *elf.File) {
printHeader(&f.FileHeader)
printSections(f.Sections)
printProgs(f.Progs)
printImportedLibraries(f.ImportedLibraries())
printSymbols(f.Symbols())
printImportedSymbols(f.ImportedSymbols())
}
示例3: 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)
}
}
}
示例4: GetSymbols
func GetSymbols(e *elf.File) map[ds.Range]*ds.Symbol {
res := make(map[ds.Range]*ds.Symbol)
symbols, err := e.Symbols()
if err != nil {
log.WithFields(log.Fields{"error": err}).Info("Failed to Parse Symbols")
return res
}
for _, sym := range symbols {
sym_type := elfSymbolTypeToSymbolType(uint(sym.Info))
symbol := ds.NewSymbol(sym.Name, sym_type)
res[ds.NewRange(sym.Value, sym.Value+sym.Size)] = symbol
}
return res
}
示例5: canary
func canary(file *elf.File) string {
if symbols, e := file.Symbols(); e == nil {
for _, sym := range symbols {
if bytes.HasPrefix([]byte(sym.Name), []byte(STACK_CHK)) {
return ENABLED
}
}
}
if importedSymbols, e := file.ImportedSymbols(); e == nil {
for _, imp := range importedSymbols {
if bytes.HasPrefix([]byte(imp.Name), []byte(STACK_CHK)) {
return ENABLED
}
}
}
return DISABLED
}