[tip: x86/core] gendwarfksyms: Define __GENKSYMS__ when processing <asm/asm-protoypes.h>

From: tip-bot2 for Ard Biesheuvel
Date: Thu Mar 20 2025 - 05:02:07 EST


The following commit has been merged into the x86/core branch of tip:

Commit-ID: fb3135208f688c5cab7d05e3a0d229935ee7611a
Gitweb: https://git.kernel.org/tip/fb3135208f688c5cab7d05e3a0d229935ee7611a
Author: Ard Biesheuvel <ardb@xxxxxxxxxx>
AuthorDate: Thu, 20 Mar 2025 08:07:47 +01:00
Committer: Ingo Molnar <mingo@xxxxxxxxxx>
CommitterDate: Thu, 20 Mar 2025 09:48:49 +01:00

gendwarfksyms: Define __GENKSYMS__ when processing <asm/asm-protoypes.h>

Ensure that __GENKSYMS__ is #define'd when passing <asm/asm-prototypes.h>
through the compiler to capture the exported symbols. This ensures that
exported symbols such as __ref_stack_chk_guard on x86, which is declared
conditionally, is visible to the tool.

Otherwise the build might break when CONFIG_GENDWARFKSYMS=y:

<stdin>:4:15: error: use of undeclared identifier '__ref_stack_chk_guard'

Reported-by: syzbot+06fd1a3613c50d36129e@xxxxxxxxxxxxxxxxxxxxxxxxx
Signed-off-by: Ard Biesheuvel <ardb@xxxxxxxxxx>
Signed-off-by: Ingo Molnar <mingo@xxxxxxxxxx>
Tested-by: syzbot+06fd1a3613c50d36129e@xxxxxxxxxxxxxxxxxxxxxxxxx
Cc: Masahiro Yamada <yamada.masahiro@xxxxxxxxxxxxx>
Cc: Michal Marek <michal.lkml@xxxxxxxxxxx>
Cc: Brian Gerst <brgerst@xxxxxxxxx>
Cc: Uros Bizjak <ubizjak@xxxxxxxxx>
Cc: "H. Peter Anvin" <hpa@xxxxxxxxx>
Link: https://lore.kernel.org/r/20250320070746.101552-2-ardb+git@xxxxxxxxxx
---
scripts/Makefile.build | 1 +
1 file changed, 1 insertion(+)

diff --git a/scripts/Makefile.build b/scripts/Makefile.build
index 993708d..7855cdc 100644
--- a/scripts/Makefile.build
+++ b/scripts/Makefile.build
@@ -305,6 +305,7 @@ $(obj)/%.rs: $(obj)/%.rs.S FORCE
getasmexports = \
{ echo "\#include <linux/kernel.h>" ; \
echo "\#include <linux/string.h>" ; \
+ echo "\#define __GENKSYMS__" ; \
echo "\#include <asm/asm-prototypes.h>" ; \
$(call getexportsymbols,EXPORT_SYMBOL(\1);) ; }