Building the Linux kernel with Clang and LLVM
 help / color / mirror / Atom feed
* [PATCH] modpost: Add __llvm_covfun and __llvm_covmap to section_white_list
@ 2026-06-04  6:03 James Lee
  0 siblings, 0 replies; only message in thread
From: James Lee @ 2026-06-04  6:03 UTC (permalink / raw)
  To: Masahiro Yamada, Nathan Chancellor, Nicolas Schier,
	Nick Desaulniers, Bill Wendling, Justin Stitt
  Cc: linux-kbuild, linux-kernel, llvm, James Lee

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.

Signed-off-by: James Lee <james@codeconstruct.com.au>
---
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(+)

diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c
index be89921d60b61d1db0398313aeb00bc1888843b1..287b7d67747dfe215640a4f8ec615519e9699921 100644
--- a/scripts/mod/modpost.c
+++ b/scripts/mod/modpost.c
@@ -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,
-- 
James Lee <james@codeconstruct.com.au>


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2026-06-04  6:03 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-06-04  6:03 [PATCH] modpost: Add __llvm_covfun and __llvm_covmap to section_white_list James Lee

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox