Skip to content

Commit 975f624

Browse files
Yonghong SongKernel Patches Daemon
authored andcommitted
selftests/bpf: Fix possible ksyms test failure with LTO kernel
In my locally build clang LTO kernel (enabling CONFIG_LTO and CONFIG_LTO_CLANG_THIN), ksyms test failed like: test_ksyms:PASS:kallsyms_fopen 0 nsec test_ksyms:FAIL:ksym_find symbol 'bpf_link_fops' not found #118 ksyms:FAIL The reason is that 'bpf_link_fops' is renamed to bpf_link_fops.llvm.8325593422554671469 Due to cross-file inlining, the static variable 'bpf_link_fops' in syscall.c is used by a function in another file. To avoid potential duplicated names, the llvm added suffix '.llvm.<hash>'. To fix the failure, we can skip this test with LTO kernel if the symbol 'bpf_link_fops' is not found in kallsyms. After this patch, with the same LTO kernel: #118 ksyms:SKIP Signed-off-by: Yonghong Song <yonghong.song@linux.dev>
1 parent d551232 commit 975f624

File tree

1 file changed

+5
-1
lines changed
  • tools/testing/selftests/bpf/prog_tests

1 file changed

+5
-1
lines changed

tools/testing/selftests/bpf/prog_tests/ksyms.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,11 @@ void test_ksyms(void)
2121
return;
2222
}
2323
if (err == -ENOENT) {
24-
ASSERT_TRUE(false, "ksym_find for bpf_link_fops");
24+
/* bpf_link_fops might be renamed to bpf_link_fops.llvm.<hash> in LTO kernel. */
25+
if (check_lto_kernel() == 1)
26+
test__skip();
27+
else
28+
ASSERT_TRUE(false, "ksym_find for bpf_link_fops");
2529
return;
2630
}
2731

0 commit comments

Comments
 (0)