Re: [PATCH -v2 7/7] module: Provide EXPORT_SYMBOL_GPL_FOR() helper

From: Masahiro Yamada
Date: Fri Feb 07 2025 - 03:11:56 EST


On Tue, Dec 3, 2024 at 12:11 AM Peter Zijlstra <peterz@xxxxxxxxxxxxx> wrote:
>

Commit description is needed.


[bikeshed]
Perhaps, I slightly prefer EXPORT_SYMBOL_GPL_FOR_MODULES().




>
> -#define ___EXPORT_SYMBOL(sym, license, ns) \
> +/*
> + * LLVM intregrated assembler refuses to merge adjacent string literals (like

"intregrated" is a typo.




> + * C and GNU-as) and chokes on:
> + *
> + * .asciz "MODULE_" "kvm" ;
> + *
> + * As would be generated when using EXPORT_SYMBOL_GPL_FOR(foo, "kvm"), use
> + * varargs to assemble it like so:
> + *
> + * .ascii "MODULE_", "kvm", "\0" ;


But, you do not need comma separators, right?



The following less-invasive diff worked for me with LLVM=1.



diff --git a/include/linux/export.h b/include/linux/export.h
index a8c23d945634..546279f4d0c2 100644
--- a/include/linux/export.h
+++ b/include/linux/export.h
@@ -24,11 +24,17 @@
.long sym
#endif

+/*
+ * LLVM integrated assembler can merge adjacent string literals (like
+ * C and GNU-as) passed to '.ascii', but not to '.asciz' and chokes on:
+ *
+ * .asciz "MODULE_" "kvm" ;
+ */
#define ___EXPORT_SYMBOL(sym, license, ns) \
.section ".export_symbol","a" ASM_NL \
__export_symbol_##sym: ASM_NL \
.asciz license ASM_NL \
- .asciz ns ASM_NL \
+ .ascii ns "\0" ASM_NL \
__EXPORT_SYMBOL_REF(sym) ASM_NL \
.previous

@@ -85,4 +91,6 @@
#define EXPORT_SYMBOL_NS(sym, ns) __EXPORT_SYMBOL(sym, "", ns)
#define EXPORT_SYMBOL_NS_GPL(sym, ns) __EXPORT_SYMBOL(sym, "GPL", ns)

+#define EXPORT_SYMBOL_GPL_FOR(sym, mods) __EXPORT_SYMBOL(sym, "GPL",
"MODULE_" mods)
+






--
Best Regards
Masahiro Yamada