plugin: Add InitPreExecution()

Currently, plugins do not have a way to further inspect or even mutate
script functions after ZAM optimization ran. One use-case here is
zeek-perf-support [1]. This plugin wraps Stmt instances of functions,
events and hooks hooks with a small assembly stub to support JIT map
files [2] and for integration with perf tools.

This change introduces a new InitPreExecution() hook that runs after
ZAM optimization completed, just before the zeek_init() event is enqueued.

Additionally, remove the existing CPP_activation_hook. It doesn't seem
to be used. If it becomes necessary in the future, the new
InitPreExecution() hook can be leveraged instead.

[1] https://github.com/zeek/zeek-perf-support
[2] https://github.com/torvalds/linux/blob/master/tools/perf/Documentation/jit-interface.txt
This commit is contained in:
Arne Welzel 2024-11-18 13:33:29 +01:00
parent 2125a1f558
commit 993cdd03e0
7 changed files with 27 additions and 7 deletions

View file

@ -271,8 +271,4 @@ extern bool IsZAM_BuiltInCond(const CallExpr* c);
// to a non-empty value.
extern void (*CPP_init_hook)();
// Used for "standalone" C++-compiled scripts to complete their activation;
// called after parsing and BiF initialization, but before zeek_init.
extern void (*CPP_activation_hook)();
} // namespace zeek::detail