]> git.baikalelectronics.ru Git - kernel.git/commit
libbpf: Add typeless ksym support to gen_loader
authorKumar Kartikeya Dwivedi <memxor@gmail.com>
Thu, 28 Oct 2021 06:34:55 +0000 (12:04 +0530)
committerAlexei Starovoitov <ast@kernel.org>
Thu, 28 Oct 2021 23:30:06 +0000 (16:30 -0700)
commite32770b5428e6f6ca6bd8b26e180be08bfd6fb57
tree986c39d2900886f2dc7b7eb2366dc946020fd548
parent4d6f7cfc9449a1c790c54802d8d9da7f5b3a90e6
libbpf: Add typeless ksym support to gen_loader

This uses the bpf_kallsyms_lookup_name helper added in previous patches
to relocate typeless ksyms. The return value ENOENT can be ignored, and
the value written to 'res' can be directly stored to the insn, as it is
overwritten to 0 on lookup failure. For repeating symbols, we can simply
copy the previously populated bpf_insn.

Also, we need to take care to not close fds for typeless ksym_desc, so
reuse the 'off' member's space to add a marker for typeless ksym and use
that to skip them in cleanup_relos.

We add a emit_ksym_relo_log helper that avoids duplicating common
logging instructions between typeless and weak ksym (for future commit).

Signed-off-by: Kumar Kartikeya Dwivedi <memxor@gmail.com>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Link: https://lore.kernel.org/bpf/20211028063501.2239335-3-memxor@gmail.com
tools/lib/bpf/bpf_gen_internal.h
tools/lib/bpf/gen_loader.c
tools/lib/bpf/libbpf.c