summaryrefslogtreecommitdiff
path: root/tools/testing/selftests/bpf/prog_tests/linked_funcs.c
diff options
context:
space:
mode:
authorAndrii Nakryiko <andrii@kernel.org>2022-04-25 17:45:06 -0700
committerAlexei Starovoitov <ast@kernel.org>2022-04-26 15:41:46 -0700
commitb82bb1ffbb9a20032853ef4e0d5b8f37c6ae7c25 (patch)
tree4f871fd99d03f0b83e22eec3c6a26279a05cb0d6 /tools/testing/selftests/bpf/prog_tests/linked_funcs.c
parent11d5daa89254ba2233d422777d52dbf24666b280 (diff)
selftests/bpf: Add CO-RE relos and SEC("?...") to linked_funcs selftests
Enhance linked_funcs selftest with two tricky features that might not obviously work correctly together. We add CO-RE relocations to entry BPF programs and mark those programs as non-autoloadable with SEC("?...") annotation. This makes sure that libbpf itself handles .BTF.ext CO-RE relocation data matching correctly for SEC("?...") programs, as well as ensures that BPF static linker handles this correctly (this was the case before, no changes are necessary, but it wasn't explicitly tested). Signed-off-by: Andrii Nakryiko <andrii@kernel.org> Signed-off-by: Alexei Starovoitov <ast@kernel.org> Link: https://lore.kernel.org/bpf/20220426004511.2691730-6-andrii@kernel.org
Diffstat (limited to 'tools/testing/selftests/bpf/prog_tests/linked_funcs.c')
-rw-r--r--tools/testing/selftests/bpf/prog_tests/linked_funcs.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/tools/testing/selftests/bpf/prog_tests/linked_funcs.c b/tools/testing/selftests/bpf/prog_tests/linked_funcs.c
index e9916f2817ec..cad664546912 100644
--- a/tools/testing/selftests/bpf/prog_tests/linked_funcs.c
+++ b/tools/testing/selftests/bpf/prog_tests/linked_funcs.c
@@ -14,6 +14,12 @@ void test_linked_funcs(void)
if (!ASSERT_OK_PTR(skel, "skel_open"))
return;
+ /* handler1 and handler2 are marked as SEC("?raw_tp/sys_enter") and
+ * are set to not autoload by default
+ */
+ bpf_program__set_autoload(skel->progs.handler1, true);
+ bpf_program__set_autoload(skel->progs.handler2, true);
+
skel->rodata->my_tid = syscall(SYS_gettid);
skel->bss->syscall_id = SYS_getpgid;