Add ability for user applications and libraries to register custom BPF program SEC() handlers. See patch #2 for examples where this is useful. Patch #1 does some preliminary refactoring to allow exponsing program init, preload, and attach callbacks as public API. It also establishes a protocol to allow optional auto-attach behavior. This will also help the case of sometimes auto-attachable uprobes. Cc: Alan Maguire <alan.maguire@xxxxxxxxxx> Andrii Nakryiko (3): libbpf: allow BPF program auto-attach handlers to bail out libbpf: support custom SEC() handlers selftests/bpf: add custom SEC() handling selftest tools/lib/bpf/libbpf.c | 299 ++++++++++++------ tools/lib/bpf/libbpf.h | 81 +++++ tools/lib/bpf/libbpf.map | 2 + .../bpf/prog_tests/custom_sec_handlers.c | 136 ++++++++ .../bpf/progs/test_custom_sec_handlers.c | 51 +++ 5 files changed, 480 insertions(+), 89 deletions(-) create mode 100644 tools/testing/selftests/bpf/prog_tests/custom_sec_handlers.c create mode 100644 tools/testing/selftests/bpf/progs/test_custom_sec_handlers.c -- 2.30.2