示例#1
0
// 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
0
func printFileInformation(f *elf.File) {
	printHeader(&f.FileHeader)
	printSections(f.Sections)
	printProgs(f.Progs)
	printImportedLibraries(f.ImportedLibraries())
	printSymbols(f.Symbols())
	printImportedSymbols(f.ImportedSymbols())
}
示例#3
0
文件: main.go 项目: n4ss/GoPlay
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
0
文件: elf.go 项目: eqv/indika
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
0
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
}