On Fri, May 7, 2021 at 8:49 PM Alexei Starovoitov <alexei.starovoitov@xxxxxxxxx> wrote: > > From: Alexei Starovoitov <ast@xxxxxxxxxx> > > 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@xxxxxxxxxx> > --- LGTM. Acked-by: Andrii Nakryiko <andrii@xxxxxxxxxx> > tools/lib/bpf/libbpf.c | 86 ++++++++++++++++--- > .../selftests/bpf/progs/test_subprogs.c | 13 +++ > 2 files changed, 85 insertions(+), 14 deletions(-) > [...]