summaryrefslogtreecommitdiff
path: root/tools/testing/selftests/bpf/progs/get_func_ip_test.c
diff options
context:
space:
mode:
authorJiri Olsa <jolsa@redhat.com>2021-07-21 23:58:09 +0200
committerAndrii Nakryiko <andrii@kernel.org>2021-07-22 20:09:16 -0700
commite3f9bc35ea7e9871667d7f769cf0079211828e89 (patch)
treead75453ffd707488d850db04610ec0a7fc79844f /tools/testing/selftests/bpf/progs/get_func_ip_test.c
parent1f71a468a75ff4f13c55966c74284aa4a6bcc334 (diff)
libbpf: Allow decimal offset for kprobes
Allow to specify decimal offset in SEC macro, like: SEC("kprobe/bpf_fentry_test7+5") Add selftest for that. Suggested-by: Andrii Nakryiko <andrii@kernel.org> Signed-off-by: Jiri Olsa <jolsa@kernel.org> Signed-off-by: Andrii Nakryiko <andrii@kernel.org> Reviewed-by: Alan Maguire <alan.maguire@oracle.com> Tested-by: Alan Maguire <alan.maguire@oracle.com> Link: https://lore.kernel.org/bpf/20210721215810.889975-3-jolsa@kernel.org
Diffstat (limited to 'tools/testing/selftests/bpf/progs/get_func_ip_test.c')
-rw-r--r--tools/testing/selftests/bpf/progs/get_func_ip_test.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/tools/testing/selftests/bpf/progs/get_func_ip_test.c b/tools/testing/selftests/bpf/progs/get_func_ip_test.c
index acd587b6e859..a587aeca5ae0 100644
--- a/tools/testing/selftests/bpf/progs/get_func_ip_test.c
+++ b/tools/testing/selftests/bpf/progs/get_func_ip_test.c
@@ -11,6 +11,7 @@ extern const void bpf_fentry_test3 __ksym;
extern const void bpf_fentry_test4 __ksym;
extern const void bpf_modify_return_test __ksym;
extern const void bpf_fentry_test6 __ksym;
+extern const void bpf_fentry_test7 __ksym;
__u64 test1_result = 0;
SEC("fentry/bpf_fentry_test1")
@@ -71,3 +72,13 @@ int test6(struct pt_regs *ctx)
test6_result = (const void *) addr == &bpf_fentry_test6 + 5;
return 0;
}
+
+__u64 test7_result = 0;
+SEC("kprobe/bpf_fentry_test7+5")
+int test7(struct pt_regs *ctx)
+{
+ __u64 addr = bpf_get_func_ip(ctx);
+
+ test7_result = (const void *) addr == &bpf_fentry_test7 + 5;
+ return 0;
+}