]> git.baikalelectronics.ru Git - kernel.git/commit
libbpf: Support CO-RE relocations for multi-prog sections
authorAndrii Nakryiko <andriin@fb.com>
Thu, 3 Sep 2020 20:35:31 +0000 (13:35 -0700)
committerAlexei Starovoitov <ast@kernel.org>
Fri, 4 Sep 2020 00:14:39 +0000 (17:14 -0700)
commit1dbf03242c2ca254d107723b3feeee3bb5f69a27
tree659d1f49c91fea72fafc15d6baf8c0ca0a803da0
parent6ed6027551aae5e6a8f3ef9fffc2c1fa702fc379
libbpf: Support CO-RE relocations for multi-prog sections

Fix up CO-RE relocation code to handle relocations against ELF sections
containing multiple BPF programs. This requires lookup of a BPF program by its
section name and instruction index it contains. While it could have been done
as a simple loop, it could run into performance issues pretty quickly, as
number of CO-RE relocations can be quite large in real-world applications, and
each CO-RE relocation incurs BPF program look up now. So instead of simple
loop, implement a binary search by section name + insn offset.

Signed-off-by: Andrii Nakryiko <andriin@fb.com>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Acked-by: John Fastabend <john.fastabend@gmail.com>
Link: https://lore.kernel.org/bpf/20200903203542.15944-4-andriin@fb.com
tools/lib/bpf/libbpf.c