]> git.baikalelectronics.ru Git - kernel.git/commit
libbpf: Fix CO-RE relocs against .text section
authorAndrii Nakryiko <andriin@fb.com>
Fri, 19 Jun 2020 23:04:22 +0000 (16:04 -0700)
committerAlexei Starovoitov <ast@kernel.org>
Wed, 24 Jun 2020 00:01:43 +0000 (17:01 -0700)
commitee48a326e023132ec9b0d89af33ccba07ddb4a2a
treebfb824ed84b2adfc6f06deca4e02b720a0df58f7
parentea0dd2b950ec7ef1af2229358330c199d80d491f
libbpf: Fix CO-RE relocs against .text section

bpf_object__find_program_by_title(), used by CO-RE relocation code, doesn't
return .text "BPF program", if it is a function storage for sub-programs.
Because of that, any CO-RE relocation in helper non-inlined functions will
fail. Fix this by searching for .text-corresponding BPF program manually.

Adjust one of bpf_iter selftest to exhibit this pattern.

Fixes: 299b4e30e1c4 ("libbpf: implement BPF CO-RE offset relocation algorithm")
Reported-by: Yonghong Song <yhs@fb.com>
Signed-off-by: Andrii Nakryiko <andriin@fb.com>
Signed-off-by: Yonghong Song <yhs@fb.com>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Acked-by: Yonghong Song <yhs@fb.com>
Link: https://lore.kernel.org/bpf/20200619230423.691274-1-andriin@fb.com
tools/lib/bpf/libbpf.c
tools/testing/selftests/bpf/progs/bpf_iter_netlink.c