libbpf: Fix global variable relocation
Similarly to a0d7da26 ("libbpf: Fix call relocation offset calculation bug"), relocations against global variables need to take into account referenced symbol's st_value, which holds offset into a corresponding data section (and, subsequently, offset into internal backing map). For static variables this offset is always zero and data offset is completely described by respective instruction's imm field. Convert a bunch of selftests to global variables. Previously they were relying on `static volatile` trick to ensure Clang doesn't inline static variables, which with global variables is not necessary anymore. Fixes: 393cdfbe ("libbpf: Support initialized global variables") Signed-off-by:Andrii Nakryiko <andriin@fb.com> Signed-off-by:
Alexei Starovoitov <ast@kernel.org> Acked-by:
Yonghong Song <yhs@fb.com> Link: https://lore.kernel.org/bpf/20191127200651.1381348-1-andriin@fb.com
Showing
- tools/lib/bpf/libbpf.c 19 additions, 24 deletionstools/lib/bpf/libbpf.c
- tools/testing/selftests/bpf/progs/fentry_test.c 6 additions, 6 deletionstools/testing/selftests/bpf/progs/fentry_test.c
- tools/testing/selftests/bpf/progs/fexit_bpf2bpf.c 3 additions, 3 deletionstools/testing/selftests/bpf/progs/fexit_bpf2bpf.c
- tools/testing/selftests/bpf/progs/fexit_test.c 6 additions, 6 deletionstools/testing/selftests/bpf/progs/fexit_test.c
- tools/testing/selftests/bpf/progs/test_mmap.c 2 additions, 2 deletionstools/testing/selftests/bpf/progs/test_mmap.c
Loading
Please register or sign in to comment