[PATCH 19/46] export, lto: Mark __kstrtab* in EXPORT_SYMBOL() as global and __visible

From: Jiri Slaby (SUSE)
Date: Mon Nov 14 2022 - 06:45:51 EST


From: Andi Kleen <ak@xxxxxxxxxxxxxxx>

Symbols referenced from assembler (either directly or e.f. from
DEFINE_STATIC_KEY()) need to be global and visible in gcc LTO because
they could end up in a different object file than the assembler. This
can lead to linker errors without this patch.

So mark __kstrtab_*[] and __kstrtabns_*[] symbols as global and
__visible.

Signed-off-by: Andi Kleen <ak@xxxxxxxxxxxxxxx>
Signed-off-by: Martin Liska <mliska@xxxxxxx>
Signed-off-by: Jiri Slaby <jslaby@xxxxxxx>
---
include/linux/export.h | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/include/linux/export.h b/include/linux/export.h
index 3f31ced0d977..3cb5f85327da 100644
--- a/include/linux/export.h
+++ b/include/linux/export.h
@@ -85,11 +85,13 @@ struct kernel_symbol {
*/
#define ___EXPORT_SYMBOL(sym, sec, ns) \
extern typeof(sym) sym; \
- extern const char __kstrtab_##sym[]; \
- extern const char __kstrtabns_##sym[]; \
+ extern const char __visible __kstrtab_##sym[]; \
+ extern const char __visible __kstrtabns_##sym[]; \
asm(" .section \"__ksymtab_strings\",\"aMS\",%progbits,1 \n" \
+ " .globl __kstrtab_" #sym " \n" \
"__kstrtab_" #sym ": \n" \
" .asciz \"" #sym "\" \n" \
+ " .globl __kstrtabns_" #sym " \n" \
"__kstrtabns_" #sym ": \n" \
" .asciz \"" ns "\" \n" \
" .previous \n"); \
--
2.38.1