From: Peter Zijlstra <peterz@infradead.org>
To: kernel test robot <lkp@intel.com>
Cc: llvm@lists.linux.dev, oe-kbuild-all@lists.linux.dev
Subject: Re: [peterz-queue:module/namespace 8/8] <inline asm>:1191:93: error: unexpected token
Date: Mon, 18 Nov 2024 11:45:10 +0100 [thread overview]
Message-ID: <20241118104510.GI38972@noisy.programming.kicks-ass.net> (raw)
In-Reply-To: <20241117113212.GC27667@noisy.programming.kicks-ass.net>
On Sun, Nov 17, 2024 at 12:32:12PM +0100, Peter Zijlstra wrote:
> On Sun, Nov 17, 2024 at 06:49:12AM +0800, kernel test robot wrote:
>
> > 1191 | .section ".export_symbol","a" ; __export_symbol_kvm_caps: ; .asciz "GPL" ; .asciz "MODULE_" "kvm,kvm-intel,kvm-amd" ; .balign 8 ; .quad kvm_caps ; .previous
> > | ^
>
> Urgh.. so GCC does the expected string concatenation here, while LLVM is
> having a wobble because it expects a single string constant, and not
> two.
>
> I've tried the whole CONCATENATE() trick, but that doesn't work right
> for strings.
>
> And I'm not sure what else to try.. The whole of C is build on the
> expectation that two string constants are merged into one, but LLVM
> integrated assembler clearly disagrees :-/
>
> Anybody?
Made it work like so.
diff --git a/include/linux/export.h b/include/linux/export.h
index 176671624420..2bf1eb80c86b 100644
--- a/include/linux/export.h
+++ b/include/linux/export.h
@@ -24,11 +24,23 @@
.long sym
#endif
-#define ___EXPORT_SYMBOL(sym, license, ns) \
+/*
+ * LLVM intregrated assembler refuses to merge adjacent string literals (like
+ * 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" ;
+ *
+ */
+#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
@@ -39,20 +51,20 @@
* be reused in other execution contexts such as the UEFI stub or the
* decompressor.
*/
-#define __EXPORT_SYMBOL(sym, license, ns)
+#define __EXPORT_SYMBOL(sym, license, ns...)
#elif defined(__GENKSYMS__)
-#define __EXPORT_SYMBOL(sym, license, ns) __GENKSYMS_EXPORT_SYMBOL(sym)
+#define __EXPORT_SYMBOL(sym, license, ns...) __GENKSYMS_EXPORT_SYMBOL(sym)
#elif defined(__ASSEMBLY__)
-#define __EXPORT_SYMBOL(sym, license, ns) \
+#define __EXPORT_SYMBOL(sym, license, ns...) \
___EXPORT_SYMBOL(sym, license, ns)
#else
-#define __EXPORT_SYMBOL(sym, license, ns) \
+#define __EXPORT_SYMBOL(sym, license, ns...) \
extern typeof(sym) sym; \
__ADDRESSABLE(sym) \
asm(__stringify(___EXPORT_SYMBOL(sym, license, ns)))
@@ -68,9 +80,8 @@
#define EXPORT_SYMBOL(sym) _EXPORT_SYMBOL(sym, "")
#define EXPORT_SYMBOL_GPL(sym) _EXPORT_SYMBOL(sym, "GPL")
#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_NS_GPL(sym, ns...) __EXPORT_SYMBOL(sym, "GPL", ns)
-#define EXPORT_SYMBOL_FOR(sym, mods) EXPORT_SYMBOL_NS(sym, "MODULE_" mods)
-#define EXPORT_SYMBOL_GPL_FOR(sym, mods) EXPORT_SYMBOL_NS_GPL(sym, "MODULE_" mods)
+#define EXPORT_SYMBOL_GPL_FOR(sym, mods) EXPORT_SYMBOL_NS_GPL(sym, "MODULE_", mods)
#endif /* _LINUX_EXPORT_H */
prev parent reply other threads:[~2024-11-18 10:45 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-11-16 22:49 [peterz-queue:module/namespace 8/8] <inline asm>:1191:93: error: unexpected token kernel test robot
2024-11-17 11:32 ` Peter Zijlstra
2024-11-18 10:45 ` Peter Zijlstra [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20241118104510.GI38972@noisy.programming.kicks-ass.net \
--to=peterz@infradead.org \
--cc=lkp@intel.com \
--cc=llvm@lists.linux.dev \
--cc=oe-kbuild-all@lists.linux.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.