diff options
| author | Ethan Graham <ethangraham@google.com> | 2025-09-15 12:54:36 +0000 |
|---|---|---|
| committer | Aleksandr Nogikh <nogikh@google.com> | 2025-09-22 09:11:54 +0000 |
| commit | 4fbe5a7f81ea2167d193a6d1503d3afc6c86329f (patch) | |
| tree | de9b62fc181012286564922d5239d09ed559fbf6 /prog | |
| parent | 490f32238051336d5a498cbc3ecc47140052b502 (diff) | |
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 <ethangraham@google.com>
Diffstat (limited to 'prog')
| -rw-r--r-- | prog/target.go | 13 |
1 files changed, 11 insertions, 2 deletions
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() { |
