/ go / profile / compile_ghidra_artifacts.go
compile_ghidra_artifacts.go
 1  package profile
 2  
 3  import (
 4  	"os"
 5  	"path/filepath"
 6  
 7  	"github.com/thunderbrewhq/binana/go/symbols"
 8  )
 9  
10  func compile_ghidra_artifacts(profile *Profile, params *CompileArtifactsParams) (err error) {
11  	ghidra_path := filepath.Join(profile.ArtifactsDirectory, "ghidra")
12  	if err = os.MkdirAll(ghidra_path, 0755); err != nil {
13  		return
14  	}
15  	var symbol_file *os.File
16  	symbol_file, err = os.Create(filepath.Join(ghidra_path, "all.sym"))
17  	if err != nil {
18  		return
19  	}
20  	// strip out autoanalysis symbols
21  	var symbol_table symbols.Table
22  	symbol_table.Init()
23  	for entry := range profile.Symbols.Entries() {
24  		if !entry.Symbol.Auto {
25  			if err = symbol_table.Insert(entry); err != nil {
26  				return
27  			}
28  		}
29  	}
30  
31  	_, err = symbol_table.WriteTo(symbol_file)
32  	symbol_file.Close()
33  	return
34  }