Add a SEC("!...") section-name prefix, letting a program declare itself manually loaded in its source following the exact convention already used for SEC("?..."). Suggested-by: Andrii Nakryiko Signed-off-by: Andrey Grodzovsky --- tools/lib/bpf/libbpf.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/tools/lib/bpf/libbpf.c b/tools/lib/bpf/libbpf.c index 1a5b582d63b2..bddc18f8eeff 100644 --- a/tools/lib/bpf/libbpf.c +++ b/tools/lib/bpf/libbpf.c @@ -955,11 +955,19 @@ bpf_object__init_prog(struct bpf_object *obj, struct bpf_program *prog, /* libbpf's convention for SEC("?abc...") is that it's just like * SEC("abc...") but the corresponding bpf_program starts out with * autoload set to false. + * + * Similarly, SEC("!abc...") marks the program for manual loading: + * it is skipped by the bulk auto-load pass and must be explicitly + * loaded via bpf_program__load(). */ if (sec_name[0] == '?') { prog->load_strategy = BPF_PROG_LOAD_STRATEGY_DISABLED; /* from now on forget there was ? in section name */ sec_name++; + } else if (sec_name[0] == '!') { + prog->load_strategy = BPF_PROG_LOAD_STRATEGY_MANUAL; + /* from now on forget there was ! in section name */ + sec_name++; } else { prog->load_strategy = BPF_PROG_LOAD_STRATEGY_AUTO; } -- 2.34.1