From: Tim Deegan Subject: [PATCH v2] asm-offsets: encode magic asm-offset runes as strings. Date: Thu, 3 Apr 2014 18:07:47 +0200 Message-ID: <20140403160747.GL38209@deinos.phlegethon.org> References: <1395766541-23979-1-git-send-email-julien.grall@linaro.org> <1395766541-23979-3-git-send-email-julien.grall@linaro.org> <5332CDE00200007800002490@nat28.tlf.novell.com> <20140326131625.GB7885@deinos.phlegethon.org> <5332ED80.5070305@linaro.org> <533300BC02000078000027D4@nat28.tlf.novell.com> <20140327180134.GN91759@deinos.phlegethon.org> <53353D9202000078000033F6@nat28.tlf.novell.com> <20140328112854.GB87844@deinos.phlegethon.org> <53356D990200007800003595@nat28.tlf.novell.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from mail6.bemta4.messagelabs.com ([85.158.143.247]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1WVkBE-00050S-Lu for xen-devel@lists.xenproject.org; Thu, 03 Apr 2014 16:07:52 +0000 Content-Disposition: inline In-Reply-To: <53356D990200007800003595@nat28.tlf.novell.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: xen-devel@lists.xenproject.org Cc: Keir Fraser , Julien Grall , stefano.stabellini@citrix.com, ian.campbell@citrix.com, Jan Beulich List-Id: xen-devel@lists.xenproject.org Newer versions of clang attempt to parse inline assembler even when not asked to assemble it. Wrap our not-for-assembly runes as strings of the form ``.ascii "==>MAGIC RUNES<=="'' so clang doesn't choke on them. While we're at it, assemble more of the final output line in the C file, to make the sed expression shorter. Reported-by: Julien Grall Suggested-by: Jan Beulich Signed-off-by: Tim Deegan --- v2: make up the '#define' in the C source rather then in sed. Not quite as neat as I'd hoped: need to match an extra space to stop the second sed expression eating the # in #define. diff --git a/xen/Makefile b/xen/Makefile index 79fa8f2..afbc962 100644 --- a/xen/Makefile +++ b/xen/Makefile @@ -150,7 +150,7 @@ include/asm-$(TARGET_ARCH)/asm-offsets.h: arch/$(TARGET_ARCH)/asm-offsets.s echo "#ifndef __ASM_OFFSETS_H__"; \ echo "#define __ASM_OFFSETS_H__"; \ echo ""; \ - sed -ne "/^->/{s:^->\([^ ]*\) [\$$#]*\([^ ]*\) \(.*\):#define \1 \2 /* \3 */:; s:->::; p;}"; \ + sed -rne "/==>/{s:.*==>(.*)<==.*:\1:; s: [\$$#]: :; p;}"; \ echo ""; \ echo "#endif") <$< >$@ diff --git a/xen/arch/arm/arm32/asm-offsets.c b/xen/arch/arm/arm32/asm-offsets.c index ac628c0..cd1dff7 100644 --- a/xen/arch/arm/arm32/asm-offsets.c +++ b/xen/arch/arm/arm32/asm-offsets.c @@ -13,11 +13,12 @@ #include #include -#define DEFINE(_sym, _val) \ - __asm__ __volatile__ ( "\n->" #_sym " %0 " #_val : : "i" (_val) ) -#define BLANK() \ - __asm__ __volatile__ ( "\n->" : : ) -#define OFFSET(_sym, _str, _mem) \ +#define DEFINE(_sym, _val) \ + asm volatile ("\n.ascii\"==>#define " #_sym " %0 /* " #_val " */<==\"" \ + : : "i" (_val) ) +#define BLANK() \ + asm volatile ( "\n.ascii\"==><==\"" : : ) +#define OFFSET(_sym, _str, _mem) \ DEFINE(_sym, offsetof(_str, _mem)); void __dummy__(void) diff --git a/xen/arch/arm/arm64/asm-offsets.c b/xen/arch/arm/arm64/asm-offsets.c index d7572fa..a3ce816 100644 --- a/xen/arch/arm/arm64/asm-offsets.c +++ b/xen/arch/arm/arm64/asm-offsets.c @@ -12,11 +12,12 @@ #include #include -#define DEFINE(_sym, _val) \ - __asm__ __volatile__ ( "\n->" #_sym " %0 " #_val : : "i" (_val) ) -#define BLANK() \ - __asm__ __volatile__ ( "\n->" : : ) -#define OFFSET(_sym, _str, _mem) \ +#define DEFINE(_sym, _val) \ + asm volatile ("\n.ascii\"==>#define " #_sym " %0 /* " #_val " */<==\"" \ + : : "i" (_val) ) +#define BLANK() \ + asm volatile ( "\n.ascii\"==><==\"" : : ) +#define OFFSET(_sym, _str, _mem) \ DEFINE(_sym, offsetof(_str, _mem)); void __dummy__(void) diff --git a/xen/arch/x86/x86_64/asm-offsets.c b/xen/arch/x86/x86_64/asm-offsets.c index b0098b3..9acb648 100644 --- a/xen/arch/x86/x86_64/asm-offsets.c +++ b/xen/arch/x86/x86_64/asm-offsets.c @@ -14,11 +14,12 @@ #include #include -#define DEFINE(_sym, _val) \ - __asm__ __volatile__ ( "\n->" #_sym " %0 " #_val : : "i" (_val) ) -#define BLANK() \ - __asm__ __volatile__ ( "\n->" : : ) -#define OFFSET(_sym, _str, _mem) \ +#define DEFINE(_sym, _val) \ + asm volatile ("\n.ascii\"==>#define " #_sym " %0 /* " #_val " */<==\"" \ + : : "i" (_val) ) +#define BLANK() \ + asm volatile ( "\n.ascii\"==><==\"" : : ) +#define OFFSET(_sym, _str, _mem) \ DEFINE(_sym, offsetof(_str, _mem)); void __dummy__(void)