OSDN Git Service

libbpf: Change the order of data and text relocations.
authorAlexei Starovoitov <ast@kernel.org>
Fri, 14 May 2021 00:36:13 +0000 (17:36 -0700)
committerDaniel Borkmann <daniel@iogearbox.net>
Tue, 18 May 2021 22:33:40 +0000 (00:33 +0200)
commitb12688267280b223256c8cf912486577d3adce25
tree4a403f6872b12f2638eb4deaca367381fa69d495
parent3abea089246f76c1517b054ddb5946f3f1dbd2c0
libbpf: Change the order of data and text relocations.

In order to be able to generate loader program in the later
patches change the order of data and text relocations.
Also improve the test to include data relos.

If the kernel supports "FD array" the map_fd relocations can be processed
before text relos since generated loader program won't need to manually
patch ld_imm64 insns with map_fd.
But ksym and kfunc relocations can only be processed after all calls
are relocated, since loader program will consist of a sequence
of calls to bpf_btf_find_by_name_kind() followed by patching of btf_id
and btf_obj_fd into corresponding ld_imm64 insns. The locations of those
ld_imm64 insns are specified in relocations.
Hence process all data relocations (maps, ksym, kfunc) together after call relos.

Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Acked-by: Andrii Nakryiko <andrii@kernel.org>
Link: https://lore.kernel.org/bpf/20210514003623.28033-12-alexei.starovoitov@gmail.com
tools/lib/bpf/libbpf.c
tools/testing/selftests/bpf/progs/test_subprogs.c