From 4fbe5a7f81ea2167d193a6d1503d3afc6c86329f Mon Sep 17 00:00:00 2001 From: Ethan Graham Date: Mon, 15 Sep 2025 12:54:36 +0000 Subject: prog/target: add Extend method As KFuzzTest targets are discovered at boot, we need a mechanism for adding these to the array of enabled system calls. This is implemented by the new Extend method, which performs this setup. Signed-off-by: Ethan Graham --- prog/target.go | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'prog') diff --git a/prog/target.go b/prog/target.go index 11127046b..5d35f7803 100644 --- a/prog/target.go +++ b/prog/target.go @@ -127,6 +127,17 @@ func AllTargets() []*Target { return res } +// Extend extends a target with a new set of syscalls, types, and resources. +// It is assumed that all new syscalls, types, and resources do not conflict +// with those already present in the target. +func (target *Target) Extend(syscalls []*Syscall, types []Type, resources []*ResourceDesc) { + target.Syscalls = append(target.Syscalls, syscalls...) + target.Types = append(target.Types, types...) + target.Resources = append(target.Resources, resources...) + // Updates the system call map and restores any links. + target.initTarget() +} + func (target *Target) lazyInit() { target.Neutralize = func(c *Call, fixStructure bool) error { return nil } target.AnnotateCall = func(c ExecCall) string { return "" } @@ -153,8 +164,6 @@ func (target *Target) lazyInit() { panic(fmt.Sprintf("bad special file length %v", ln)) } } - // These are used only during lazyInit. - target.Types = nil } func (target *Target) initTarget() { -- cgit mrf-deployment