[PATCH 38/46] Kbuild, lto: don't include weak source file symbols in System.map

Jiri Slaby (SUSE)
2022-11-14T11:48:24Z

From: Andi Kleen <andi@firstfloor.org>

The gcc LTO build can generate some extra weak source code file name
symbols on the second kallsyms link like:
0000000002fdf20a W head64.c.552cf5a6

This causes the "Inconsistent kallsyms data" error due to mismatches in
the stage1 vs stage2 kallsyms link. Filter those out when generating
the System.map.

Cc: Masahiro Yamada <masahiroy@kernel.org>
Cc: Michal Marek <michal.lkml@markovi.net>
Cc: Nick Desaulniers <ndesaulniers@google.com>
Cc: linux-kbuild@vger.kernel.org
Signed-off-by: Andi Kleen <andi@firstfloor.org>
Signed-off-by: Martin Liska <mliska@suse.cz>
Signed-off-by: Jiri Slaby <jslaby@suse.cz>
---
scripts/mksysmap | 2 ++
1 file changed, 2 insertions(+)

diff --git a/scripts/mksysmap b/scripts/mksysmap
index 16a08b8ef2f8..0f19a44ab136 100755
--- a/scripts/mksysmap
+++ b/scripts/mksysmap
@@ -34,6 +34,7 @@
# U - undefined global symbols
# N - debugging symbols
# w - local weak symbols
+# W - weak symbols if they contain .c.

# readprofile starts reading symbols when _stext is found, and
# continue until it finds a symbol which is not either of 'T', 't',
@@ -57,4 +58,5 @@ $NM -n $1 | grep -v \
-e ' __kstrtab_' \
-e ' __kstrtabns_' \
-e ' L0$' \
+ -e ' W .*\.c\.' \
> $2
--
2.38.1