]> asedeno.scripts.mit.edu Git - linux.git/commit
libbpf: Support .text sub-calls relocations
authorAndrii Nakryiko <andriin@fb.com>
Wed, 15 Jan 2020 19:08:56 +0000 (11:08 -0800)
committerAlexei Starovoitov <ast@kernel.org>
Wed, 15 Jan 2020 19:51:48 +0000 (11:51 -0800)
commit9173cac3b64e6785dd604f5075e6035b045a0026
tree69fe32b9d326c5adacc059f02a5f653248407108
parent5640a771d7971412049d1934d2d030edfdd1c28e
libbpf: Support .text sub-calls relocations

The LLVM patch https://reviews.llvm.org/D72197 makes LLVM emit function call
relocations within the same section. This includes a default .text section,
which contains any BPF sub-programs. This wasn't the case before and so libbpf
was able to get a way with slightly simpler handling of subprogram call
relocations.

This patch adds support for .text section relocations. It needs to ensure
correct order of relocations, so does two passes:
- first, relocate .text instructions, if there are any relocations in it;
- then process all the other programs and copy over patched .text instructions
for all sub-program calls.

v1->v2:
- break early once .text program is processed.

Signed-off-by: Andrii Nakryiko <andriin@fb.com>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Acked-by: Yonghong Song <yhs@fb.com>
Cc: Alexei Starovoitov <ast@kernel.org>
Link: https://lore.kernel.org/bpf/20200115190856.2391325-1-andriin@fb.com
tools/lib/bpf/libbpf.c