aboutsummaryrefslogtreecommitdiffstats
path: root/tools/testing/selftests/bpf/progs/fexit_bpf2bpf.c
diff options
context:
space:
mode:
authorAndrii Nakryiko <andriin@fb.com>2019-11-27 12:06:50 -0800
committerAlexei Starovoitov <ast@kernel.org>2019-11-27 16:34:21 -0800
commit53f8dd434b6fe666b1c4e0be80a8727e8fa9839f (patch)
treebe37020c2c607328241889de5890eb1ed460a2d7 /tools/testing/selftests/bpf/progs/fexit_bpf2bpf.c
parentlibbpf: Fix Makefile' libbpf symbol mismatch diagnostic (diff)
downloadlinux-dev-53f8dd434b6fe666b1c4e0be80a8727e8fa9839f.tar.xz
linux-dev-53f8dd434b6fe666b1c4e0be80a8727e8fa9839f.zip
libbpf: Fix global variable relocation
Similarly to a0d7da26ce86 ("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: 393cdfbee809 ("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
Diffstat (limited to 'tools/testing/selftests/bpf/progs/fexit_bpf2bpf.c')
-rw-r--r--tools/testing/selftests/bpf/progs/fexit_bpf2bpf.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/tools/testing/selftests/bpf/progs/fexit_bpf2bpf.c b/tools/testing/selftests/bpf/progs/fexit_bpf2bpf.c
index 525d47d7b589..2d211ee98a1c 100644
--- a/tools/testing/selftests/bpf/progs/fexit_bpf2bpf.c
+++ b/tools/testing/selftests/bpf/progs/fexit_bpf2bpf.c
@@ -8,7 +8,7 @@ struct sk_buff {
unsigned int len;
};
-static volatile __u64 test_result;
+__u64 test_result = 0;
BPF_TRACE_2("fexit/test_pkt_access", test_main,
struct sk_buff *, skb, int, ret)
{
@@ -23,7 +23,7 @@ BPF_TRACE_2("fexit/test_pkt_access", test_main,
return 0;
}
-static volatile __u64 test_result_subprog1;
+__u64 test_result_subprog1 = 0;
BPF_TRACE_2("fexit/test_pkt_access_subprog1", test_subprog1,
struct sk_buff *, skb, int, ret)
{
@@ -56,7 +56,7 @@ struct args_subprog2 {
__u64 args[5];
__u64 ret;
};
-static volatile __u64 test_result_subprog2;
+__u64 test_result_subprog2 = 0;
SEC("fexit/test_pkt_access_subprog2")
int test_subprog2(struct args_subprog2 *ctx)
{