Skip to contentSkip to conversation

modpost: Add __llvm_covfun and __llvm_covmap to section_white_list

PATCH In review James Lee 2 participants 2 messages Jun 4 – Jun 9 Kbuild

lore
Share & tools
lore

James Lee

author
#0 lore raw

PATCH 1/1 modpost: Add __llvm_covfun and __llvm_covmap to section_white_list

Modpost emits hundreds of warnings when using Clang to build for ARCH=um and CONFIG_GCOV=y. e.g.:
vmlinux (__llvm_covfun): unexpected non-allocatable section. Did you forget to use "ax"/"aw" in a .S file?
Note that for example <linux/init.h> contains
section definitions for use in .S files.

For example, when we use LLVM for a kunit user mode build with coverage:

    python3 tools/testing/kunit/kunit.py build --make_options LLVM=1 \
        --kunitconfig=tools/testing/kunit/configs/default.config \
        --kunitconfig=tools/testing/kunit/configs/coverage_uml.config

The behaviour occurs when building the kernel for ARCH=um with code coverage enabled. The warnings come from modpost's check_sec_ref function, which ensures no sections reference others that will be discarded. covfun and covmap sections must reference __init and __exit sections to collect coverage data, triggering the modpost warning.

To suppress these warnings, these section names have been added to modpost's whitelist. This is unlikely to suppress legitimate warnings as Clang will only insert these sections when building with coverage, and can be assumed to manage these references safely.

---
Unsure if there are Clang options that might better suppress this. Certainly open to other options if they're available.

---
 scripts/mod/modpost.c | 2 ++
 1 file changed, 2 insertions(+)
scripts/mod/modpost.c +2 -0
index be89921d60b61d1db0398313aeb00bc1888843b1..287b7d67747dfe215640a4f8ec615519e9699921 100644
@@ -749,6 +749,8 @@ static const char *const section_white_list[] =
 	".gnu.lto*",
 	".discard.*",
 	".llvm.call-graph-profile",	/* call graph */
+	"__llvm_covfun",
+	"__llvm_covmap",
 	NULL
 };
 

---
base-commit: d76bb1ebb5587f66b0f8b8099bfbb44722bc08b3
change-id: 20260604-dev-coverage-patch-b7234012f11d

Best regards,

Signature · 1 line
James Lee <[email protected]>
#1 lore raw
Quoted 1 line · James Lee

modpost: Add __llvm_covfun and __llvm_covmap to section_white_list

Applied to

https://git.kernel.org/pub/scm/linux/kernel/git/kbuild/linux.git kbuild-next

Thanks!

[1/1] modpost: Add __llvm_covfun and __llvm_covmap to section_white_list

      https://git.kernel.org/kbuild/c/29c52907334a8

Please look out for regression or issue reports or other follow up comments, as they may result in the patch/series getting dropped or reverted. Patches applied to an "unstable" branch are accepted pending wider testing in -next and any post-commit review; they will generally be moved to the main branch in a week if no issues are found.

Best regards,

Signature · 2 lines
Cheers,
Nathan