]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
modpost: Add __llvm_covfun and __llvm_covmap to section_white_list
authorJames Lee <james@codeconstruct.com.au>
Thu, 4 Jun 2026 06:03:00 +0000 (14:03 +0800)
committerNathan Chancellor <nathan@kernel.org>
Sat, 6 Jun 2026 03:48:58 +0000 (20:48 -0700)
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>
Link: https://patch.msgid.link/20260604-dev-coverage-patch-v1-1-9f9368253cb4@codeconstruct.com.au
Signed-off-by: Nathan Chancellor <nathan@kernel.org>
scripts/mod/modpost.c

index da0f4bc755094d0b34c480aa0adf359980f4ef0f..d592548cbd60f3afe7b582fbc782d7f6468f0dde 100644 (file)
@@ -765,6 +765,8 @@ static const char *const section_white_list[] =
        ".gnu.lto*",
        ".discard.*",
        ".llvm.call-graph-profile",     /* call graph */
+       "__llvm_covfun",
+       "__llvm_covmap",
        NULL
 };