libbpf: Parse multi-function sections into multiple BPF programs
authorAndrii Nakryiko <andriin@fb.com>
Thu, 3 Sep 2020 20:35:30 +0000 (13:35 -0700)
committerAlexei Starovoitov <ast@kernel.org>
Fri, 4 Sep 2020 00:14:39 +0000 (17:14 -0700)
commitc112239272c6bacf7fcd0a0dc71999ad8eb1c55c
treea9c9783cbd84642ce17b548c58bf1416385fa7d6
parent0201c575831171292489f14a8b6f79f98936b4d1
libbpf: Parse multi-function sections into multiple BPF programs

Teach libbpf how to parse code sections into potentially multiple bpf_program
instances, based on ELF FUNC symbols. Each BPF program will keep track of its
position within containing ELF section for translating section instruction
offsets into program instruction offsets: regardless of BPF program's location
in ELF section, it's first instruction is always at local instruction offset
0, so when libbpf is working with relocations (which use section-based
instruction offsets) this is critical to make proper translations.

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-3-andriin@fb.com
tools/lib/bpf/libbpf.c