libbpf: implement BPF CO-RE offset relocation algorithm
authorAndrii Nakryiko <andriin@fb.com>
Wed, 7 Aug 2019 21:39:51 +0000 (14:39 -0700)
committerAlexei Starovoitov <ast@kernel.org>
Wed, 7 Aug 2019 21:43:49 +0000 (14:43 -0700)
commitddc7c3042614e273044f698d2beab25cc3842d45
tree9e80ac1aba335b955c31b13bd8f96bd960957576
parent4cedc0dad9b5bf55c4180c833be35e27e5d6cdbb
libbpf: implement BPF CO-RE offset relocation algorithm

This patch implements the core logic for BPF CO-RE offsets relocations.
Every instruction that needs to be relocated has corresponding
bpf_offset_reloc as part of BTF.ext. Relocations are performed by trying
to match recorded "local" relocation spec against potentially many
compatible "target" types, creating corresponding spec. Details of the
algorithm are noted in corresponding comments in the code.

Signed-off-by: Andrii Nakryiko <andriin@fb.com>
Acked-by: Song Liu <songliubraving@fb.com>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
tools/lib/bpf/libbpf.c
tools/lib/bpf/libbpf.h