]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
modpost: Ignore Clang LTO suffixes in symbol matching
authorRong Xu <xur@google.com>
Wed, 17 Jun 2026 22:46:23 +0000 (15:46 -0700)
committerNathan Chancellor <nathan@kernel.org>
Thu, 18 Jun 2026 18:35:22 +0000 (11:35 -0700)
When building the kernel with Clang ThinLTO enabled, the compiler
can mangle static variable names by appending suffixes such as
".llvm.<hash>" to prevent naming collisions across translation units.

This name mangling breaks the section mismatch whitelisting in modpost.
modpost relies on glob patterns (e.g., "*_ops" or "*_probe") to identify
safe references between permanent data and initialization code. Because
the LTO suffix modifies the end of the symbol name, legitimately
whitelisted structures fail the match, resulting in false positive
warnings.

For example, a static pernet_operations struct triggers the following:

  WARNING: modpost: vmlinux: section mismatch in reference: \
  ping_v4_net_ops.llvm.5641696707737373282 (section: .data) -> \
  ping_v4_proc_init_net (section: .init.text)

Fix this by ignoring "*_ops.llvm.*" in "from" symbol names (the same
as "*_ops").

Reported-by: kernel test robot <lkp@intel.com>
Closes: https://lore.kernel.org/oe-kbuild-all/202606111233.kM8oo8Df-lkp@intel.com/
Signed-off-by: Rong Xu <xur@google.com>
Link: https://patch.msgid.link/20260617224623.1346309-1-xur@google.com
Signed-off-by: Nathan Chancellor <nathan@kernel.org>
scripts/mod/modpost.c

index d592548cbd60f3afe7b582fbc782d7f6468f0dde..a7b72a81d2482ab9bfb0ea647b0b8a756afdbf3a 100644 (file)
@@ -969,7 +969,7 @@ static int secref_whitelist(const char *fromsec, const char *fromsym,
        /* symbols in data sections that may refer to any init/exit sections */
        if (match(fromsec, PATTERNS(DATA_SECTIONS)) &&
            match(tosec, PATTERNS(ALL_INIT_SECTIONS, ALL_EXIT_SECTIONS)) &&
-           match(fromsym, PATTERNS("*_ops", "*_console")))
+           match(fromsym, PATTERNS("*_ops", "*_ops.llvm.*", "*_console")))
                return 0;
 
        /* Check for pattern 3 */