aboutsummaryrefslogtreecommitdiffstats
path: root/tools/syz-declextract
diff options
context:
space:
mode:
authorDmitry Vyukov <dvyukov@google.com>2024-11-25 11:55:37 +0100
committerDmitry Vyukov <dvyukov@google.com>2024-11-26 11:32:06 +0000
commita1990d2bd9d1f54baf83802e2874069ee73b4fa4 (patch)
tree0ae1e16cc24fc433027ea78ca2af972ad3dcef83 /tools/syz-declextract
parent66b9eb592907501b2caa11568313a324ee7cd6b8 (diff)
tools/syz-declextract: accept manager config
Make the tool accept a manager config. This will be required for dynamic extraction of info from the kernel.
Diffstat (limited to 'tools/syz-declextract')
-rw-r--r--tools/syz-declextract/run.go26
1 files changed, 11 insertions, 15 deletions
diff --git a/tools/syz-declextract/run.go b/tools/syz-declextract/run.go
index 181fca96c..5e5e546fd 100644
--- a/tools/syz-declextract/run.go
+++ b/tools/syz-declextract/run.go
@@ -23,6 +23,7 @@ import (
"github.com/google/syzkaller/pkg/ast"
"github.com/google/syzkaller/pkg/compiler"
+ "github.com/google/syzkaller/pkg/mgrconfig"
"github.com/google/syzkaller/pkg/osutil"
"github.com/google/syzkaller/pkg/subsystem"
_ "github.com/google/syzkaller/pkg/subsystem/lists"
@@ -37,21 +38,16 @@ var (
func main() {
var (
- binary = flag.String("binary", "syz-declextract", "path to binary")
- sourceDir = flag.String("sourcedir", "", "kernel source directory")
- buildDir = flag.String("builddir", "", "kernel build directory (defaults to source directory)")
+ flagConfig = flag.String("config", "", "manager config file")
+ flagBinary = flag.String("binary", "syz-declextract", "path to syz-declextract binary")
)
defer tool.Init()()
- if *sourceDir == "" {
- tool.Failf("path to kernel source directory is required")
- }
- if *buildDir == "" {
- *buildDir = *sourceDir
+ cfg, err := mgrconfig.LoadFile(*flagConfig)
+ if err != nil {
+ tool.Failf("failed to load manager config: %v", err)
}
- *sourceDir = filepath.Clean(osutil.Abs(*sourceDir))
- *buildDir = filepath.Clean(osutil.Abs(*buildDir))
- compilationDatabase := filepath.Join(*buildDir, "compile_commands.json")
+ compilationDatabase := filepath.Join(cfg.KernelObj, "compile_commands.json")
cmds, err := loadCompileCommands(compilationDatabase)
if err != nil {
tool.Failf("failed to load compile commands: %v", err)
@@ -62,7 +58,7 @@ func main() {
outputs := make(chan *output, len(cmds))
files := make(chan string, len(cmds))
for w := 0; w < runtime.NumCPU(); w++ {
- go worker(outputs, files, *binary, compilationDatabase)
+ go worker(outputs, files, *flagBinary, compilationDatabase)
}
for _, cmd := range cmds {
@@ -70,7 +66,7 @@ func main() {
}
close(files)
- syscallNames := readSyscallMap(*sourceDir)
+ syscallNames := readSyscallMap(cfg.KernelSrc)
var nodes []ast.Node
interfaces := make(map[string]Interface)
@@ -80,7 +76,7 @@ func main() {
if out == nil {
continue
}
- file, err := filepath.Rel(*sourceDir, out.file)
+ file, err := filepath.Rel(cfg.KernelSrc, out.file)
if err != nil {
tool.Fail(err)
}
@@ -91,7 +87,7 @@ func main() {
if parse == nil {
tool.Failf("%v: parsing error:\n%s", file, out.output)
}
- appendNodes(&nodes, interfaces, parse.Nodes, syscallNames, *sourceDir, *buildDir, file)
+ appendNodes(&nodes, interfaces, parse.Nodes, syscallNames, cfg.KernelSrc, cfg.KernelObj, file)
}
desc := finishDescriptions(nodes)