libbpf: Prepare light skeleton for the kernel.
authorAlexei Starovoitov <ast@kernel.org>
Wed, 9 Feb 2022 23:19:58 +0000 (15:19 -0800)
committerDaniel Borkmann <daniel@iogearbox.net>
Thu, 10 Feb 2022 22:31:51 +0000 (23:31 +0100)
commit6fe65f1b4db3fff305896e997c2804b7b42236ce
tree3ce3bc5eba4cef9417e0416db1cfec1fc1f24c8e
parentb1d18a7574d0df5eb4117c14742baf8bc2b9bb74
libbpf: Prepare light skeleton for the kernel.

Prepare light skeleton to be used in the kernel module and in the user space.
The look and feel of lskel.h is mostly the same with the difference that for
user space the skel->rodata is the same pointer before and after skel_load
operation, while in the kernel the skel->rodata after skel_open and the
skel->rodata after skel_load are different pointers.
Typical usage of skeleton remains the same for kernel and user space:
skel = my_bpf__open();
skel->rodata->my_global_var = init_val;
err = my_bpf__load(skel);
err = my_bpf__attach(skel);
// access skel->rodata->my_global_var;
// access skel->bss->another_var;

Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Acked-by: Yonghong Song <yhs@fb.com>
Acked-by: Andrii Nakryiko <andrii@kernel.org>
Link: https://lore.kernel.org/bpf/20220209232001.27490-3-alexei.starovoitov@gmail.com
tools/lib/bpf/gen_loader.c
tools/lib/bpf/skel_internal.h