* [PATCH v2] modpost: Ignore Clang LTO suffixes in symbol matching
@ 2026-06-17 22:46 xur
2026-06-17 22:49 ` Rong Xu
2026-06-18 18:46 ` Nathan Chancellor
0 siblings, 2 replies; 3+ messages in thread
From: xur @ 2026-06-17 22:46 UTC (permalink / raw)
To: Nathan Chancellor, Nicolas Schier, Nick Desaulniers,
Bill Wendling, Justin Stitt, Sami Tolvanen, Siddharth Nayyar,
Petr Pavlu, Josh Poimboeuf, Rong Xu, Eric Dumazet,
René Rebe, Alexey Gladkov, Johan Hovold, linux-kbuild,
linux-kernel, llvm
Cc: kernel test robot
From: Rong Xu <xur@google.com>
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>
---
scripts/mod/modpost.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c
index d592548cbd60..a7b72a81d248 100644
--- a/scripts/mod/modpost.c
+++ b/scripts/mod/modpost.c
@@ -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 */
base-commit: e771677c937da5808f7b6c1f0e4a97ec1a84f8a8
--
2.55.0.rc0.738.g0c8ab3ebcc-goog
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH v2] modpost: Ignore Clang LTO suffixes in symbol matching
2026-06-17 22:46 [PATCH v2] modpost: Ignore Clang LTO suffixes in symbol matching xur
@ 2026-06-17 22:49 ` Rong Xu
2026-06-18 18:46 ` Nathan Chancellor
1 sibling, 0 replies; 3+ messages in thread
From: Rong Xu @ 2026-06-17 22:49 UTC (permalink / raw)
To: Nathan Chancellor, Nicolas Schier, Nick Desaulniers,
Bill Wendling, Justin Stitt, Sami Tolvanen, Siddharth Nayyar,
Petr Pavlu, Josh Poimboeuf, Rong Xu, Eric Dumazet,
René Rebe, Alexey Gladkov, Johan Hovold, linux-kbuild,
linux-kernel, llvm
Cc: kernel test robot
Changelog: This V2 integrated reviews from Petr Pavlu
<petr.pavlu@suse.com> and Nathan Chancellor <nathan@kernel.org> to
use a more direct fix.
Thanks,
Rong
On Wed, Jun 17, 2026 at 3:46 PM <xur@google.com> wrote:
>
> From: Rong Xu <xur@google.com>
>
> 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>
> ---
> scripts/mod/modpost.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c
> index d592548cbd60..a7b72a81d248 100644
> --- a/scripts/mod/modpost.c
> +++ b/scripts/mod/modpost.c
> @@ -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 */
>
> base-commit: e771677c937da5808f7b6c1f0e4a97ec1a84f8a8
> --
> 2.55.0.rc0.738.g0c8ab3ebcc-goog
>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH v2] modpost: Ignore Clang LTO suffixes in symbol matching
2026-06-17 22:46 [PATCH v2] modpost: Ignore Clang LTO suffixes in symbol matching xur
2026-06-17 22:49 ` Rong Xu
@ 2026-06-18 18:46 ` Nathan Chancellor
1 sibling, 0 replies; 3+ messages in thread
From: Nathan Chancellor @ 2026-06-18 18:46 UTC (permalink / raw)
To: Nicolas Schier, Nick Desaulniers, Bill Wendling, Justin Stitt,
Sami Tolvanen, Siddharth Nayyar, Petr Pavlu, Josh Poimboeuf,
Eric Dumazet, René Rebe, Alexey Gladkov, Johan Hovold,
linux-kbuild, linux-kernel, llvm, xur
Cc: kernel test robot
On Wed, 17 Jun 2026 15:46:23 -0700, xur@google.com wrote:
> modpost: Ignore Clang LTO suffixes in symbol matching
Sashiko notes that the console variables may need the same fix but I
have tried building several configurations with distributed ThinLTO and
I do not see any modpost warnings so we can just wait to address that
until later if necessary.
Applied to
https://git.kernel.org/pub/scm/linux/kernel/git/kbuild/linux.git kbuild-next-unstable
Thanks!
[1/1] modpost: Ignore Clang LTO suffixes in symbol matching
https://git.kernel.org/kbuild/c/9a289cc425bf4
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,
--
Cheers,
Nathan
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-06-18 18:48 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-06-17 22:46 [PATCH v2] modpost: Ignore Clang LTO suffixes in symbol matching xur
2026-06-17 22:49 ` Rong Xu
2026-06-18 18:46 ` Nathan Chancellor
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®