Skip to content

Commit 45f8da5

Browse files
Peter Zijlstramcgrof
authored andcommitted
module: Provide EXPORT_SYMBOL_GPL_FOR() helper
Requested-by: Masahiro Yamada <masahiroy@kernel.org> Requested-by: Christoph Hellwig <hch@infradead.org> Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
1 parent 60df6a4 commit 45f8da5

1 file changed

Lines changed: 20 additions & 6 deletions

File tree

include/linux/export.h

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,23 @@
2424
.long sym
2525
#endif
2626

27-
#define ___EXPORT_SYMBOL(sym, license, ns) \
27+
/*
28+
* LLVM intregrated assembler refuses to merge adjacent string literals (like
29+
* C and GNU-as) and chokes on:
30+
*
31+
* .asciz "MODULE_" "kvm" ;
32+
*
33+
* As would be generated when using EXPORT_SYMBOL_GPL_FOR(foo, "kvm"), use
34+
* varargs to assemble it like so:
35+
*
36+
* .ascii "MODULE_", "kvm", "\0" ;
37+
*
38+
*/
39+
#define ___EXPORT_SYMBOL(sym, license, ns...) \
2840
.section ".export_symbol","a" ASM_NL \
2941
__export_symbol_##sym: ASM_NL \
3042
.asciz license ASM_NL \
31-
.asciz ns ASM_NL \
43+
.ascii ns, "\0" ASM_NL \
3244
__EXPORT_SYMBOL_REF(sym) ASM_NL \
3345
.previous
3446

@@ -39,20 +51,20 @@
3951
* be reused in other execution contexts such as the UEFI stub or the
4052
* decompressor.
4153
*/
42-
#define __EXPORT_SYMBOL(sym, license, ns)
54+
#define __EXPORT_SYMBOL(sym, license, ns...)
4355

4456
#elif defined(__GENKSYMS__)
4557

46-
#define __EXPORT_SYMBOL(sym, license, ns) __GENKSYMS_EXPORT_SYMBOL(sym)
58+
#define __EXPORT_SYMBOL(sym, license, ns...) __GENKSYMS_EXPORT_SYMBOL(sym)
4759

4860
#elif defined(__ASSEMBLY__)
4961

50-
#define __EXPORT_SYMBOL(sym, license, ns) \
62+
#define __EXPORT_SYMBOL(sym, license, ns...) \
5163
___EXPORT_SYMBOL(sym, license, ns)
5264

5365
#else
5466

55-
#define __EXPORT_SYMBOL(sym, license, ns) \
67+
#define __EXPORT_SYMBOL(sym, license, ns...) \
5668
extern typeof(sym) sym; \
5769
__ADDRESSABLE(sym) \
5870
asm(__stringify(___EXPORT_SYMBOL(sym, license, ns)))
@@ -70,4 +82,6 @@
7082
#define EXPORT_SYMBOL_NS(sym, ns) __EXPORT_SYMBOL(sym, "", ns)
7183
#define EXPORT_SYMBOL_NS_GPL(sym, ns) __EXPORT_SYMBOL(sym, "GPL", ns)
7284

85+
#define EXPORT_SYMBOL_GPL_FOR(sym, mods) __EXPORT_SYMBOL(sym, "GPL", "MODULE_", mods)
86+
7387
#endif /* _LINUX_EXPORT_H */

0 commit comments

Comments
 (0)