]> git.baikalelectronics.ru Git - kernel.git/commit
libbpf: Fix global variable relocation
authorAndrii Nakryiko <andriin@fb.com>
Wed, 27 Nov 2019 20:06:50 +0000 (12:06 -0800)
committerAlexei Starovoitov <ast@kernel.org>
Thu, 28 Nov 2019 00:34:21 +0000 (16:34 -0800)
commit43b9a4a5baf48d297b9c1a3e01cdf6f10a909fae
treebe37020c2c607328241889de5890eb1ed460a2d7
parent5902c7dd2c2e7baa187b3c38fd7b4f80b0ab3e37
libbpf: Fix global variable relocation

Similarly to 54653981fb33 ("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: 5111fd9bb6aa ("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
tools/lib/bpf/libbpf.c
tools/testing/selftests/bpf/progs/fentry_test.c
tools/testing/selftests/bpf/progs/fexit_bpf2bpf.c
tools/testing/selftests/bpf/progs/fexit_test.c
tools/testing/selftests/bpf/progs/test_mmap.c