libbpf: Add support for custom exception callbacks
authorKumar Kartikeya Dwivedi <memxor@gmail.com>
Tue, 12 Sep 2023 23:32:12 +0000 (01:32 +0200)
committerAlexei Starovoitov <ast@kernel.org>
Sat, 16 Sep 2023 16:36:43 +0000 (09:36 -0700)
commit7e2925f6723702bcfcfdf8f73d5e85f7514d4b9f
treef4424e5728ae2d88c436a28fe73ea52da23a85ec
parent6c918709bd30852258e66b3f566c9614e3f29e35
libbpf: Add support for custom exception callbacks

Add support to libbpf to append exception callbacks when loading a
program. The exception callback is found by discovering the declaration
tag 'exception_callback:<value>' and finding the callback in the value
of the tag.

The process is done in two steps. First, for each main program, the
bpf_object__sanitize_and_load_btf function finds and marks its
corresponding exception callback as defined by the declaration tag on
it. Second, bpf_object__reloc_code is modified to append the indicated
exception callback at the end of the instruction iteration (since
exception callback will never be appended in that loop, as it is not
directly referenced).

Signed-off-by: Kumar Kartikeya Dwivedi <memxor@gmail.com>
Link: https://lore.kernel.org/r/20230912233214.1518551-16-memxor@gmail.com
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
tools/lib/bpf/libbpf.c