[CRIU] [PATCH 3/3] [arm] fix asm syntax to be clang-compatible

Kir Kolyshkin kir at openvz.org
Thu Nov 3 16:39:41 PDT 2016


I'm unsure where all these %%s before register names comes from,
but they confuse clang, like this:

> criu/arch/arm/parasite-head.S:6:6: error: unexpected token in operand
>  sub %r2, %pc, #8 @ get the address of this instruction
>     ^

This patch looks scary, but all it does is removing %s before
register names, fixing a few "many spaces instead of a tab" issues
along the way.

Cc: Christopher Covington <cov at codeaurora.org>
Dmitry Safonov <dsafonov at virtuozzo.com>
Signed-off-by: Kir Kolyshkin <kir at openvz.org>
---
 compel/arch/arm/plugins/std/syscalls/syscall-aux.S | 14 +++----
 .../arch/arm/plugins/std/syscalls/syscall-common.S | 16 ++++----
 criu/arch/arm/include/asm/restore.h                |  8 ++--
 criu/arch/arm/include/asm/restorer.h               | 48 +++++++++++-----------
 criu/arch/arm/include/asm/sigframe.h               |  4 +-
 criu/arch/arm/parasite-head.S                      | 14 +++----
 6 files changed, 52 insertions(+), 52 deletions(-)

diff --git a/compel/arch/arm/plugins/std/syscalls/syscall-aux.S b/compel/arch/arm/plugins/std/syscalls/syscall-aux.S
index 8bc01c3..22cc328 100644
--- a/compel/arch/arm/plugins/std/syscalls/syscall-aux.S
+++ b/compel/arch/arm/plugins/std/syscalls/syscall-aux.S
@@ -2,12 +2,12 @@ nr_sys_mmap:
 	.long	192
 
 ENTRY(sys_mmap)
-	push	{%r4, %r5, %r7, %lr}
-	ldr		%r4, [%sp, #16]
-	ldr		%r5, [%sp, #20]
-	lsr		%r5, #12
-	adr		%r7, nr_sys_mmap
-	ldr		%r7, [%r7]
+	push	{r4, r5, r7, lr}
+	ldr		r4, [sp, #16]
+	ldr		r5, [sp, #20]
+	lsr		r5, #12
+	adr		r7, nr_sys_mmap
+	ldr		r7, [r7]
 	svc		0x00000000
-	pop		{%r4, %r5, %r7, %pc}
+	pop		{r4, r5, r7, pc}
 END(sys_mmap)
diff --git a/compel/arch/arm/plugins/std/syscalls/syscall-common.S b/compel/arch/arm/plugins/std/syscalls/syscall-common.S
index c3cbf71..0e43670 100644
--- a/compel/arch/arm/plugins/std/syscalls/syscall-common.S
+++ b/compel/arch/arm/plugins/std/syscalls/syscall-common.S
@@ -8,11 +8,11 @@
 @ between parasite_service() and sys_munmap().
 
 syscall_common:
-	ldr	%r7, [%r7]
-	add	%r8, %sp, #24
-	ldm	%r8, {%r4, %r5, %r6}
+	ldr	r7, [r7]
+	add	r8, sp, #24
+	ldm	r8, {r4, r5, r6}
 	svc	0x00000000
-	pop	{%r4, %r5, %r6, %r7, %r8, %pc}
+	pop	{r4, r5, r6, r7, r8, pc}
 
 
 .macro syscall name, nr
@@ -20,15 +20,15 @@ syscall_common:
 		.long \nr
 
 	ENTRY(\name)
-		push	{%r4, %r5, %r6, %r7, %r8, %lr}
-		adr		%r7, .nr_\name
+		push	{r4, r5, r6, r7, r8, lr}
+		adr		r7, .nr_\name
 		b		syscall_common
 	END(\name)
 .endm
 
 
 ENTRY(__cr_restore_rt)
-	adr	%r7, .nr_sys_rt_sigreturn
-	ldr	%r7, [%r7]
+	adr	r7, .nr_sys_rt_sigreturn
+	ldr	r7, [r7]
 	svc	#0
 END(__cr_restore_rt)
diff --git a/criu/arch/arm/include/asm/restore.h b/criu/arch/arm/include/asm/restore.h
index ef4704f..4c64d58 100644
--- a/criu/arch/arm/include/asm/restore.h
+++ b/criu/arch/arm/include/asm/restore.h
@@ -8,10 +8,10 @@
 #define JUMP_TO_RESTORER_BLOB(new_sp, restore_task_exec_start,		\
 			      task_args)				\
 	asm volatile(							\
-		     "mov %%sp, %%%0				    \n" \
-		     "mov %%r1, %%%1				    \n" \
-		     "mov %%r0, %%%2				    \n" \
-		     "bx  %%r1					    \n"	\
+		     "mov sp, %0				    \n" \
+		     "mov r1, %1				    \n" \
+		     "mov r0, %2				    \n" \
+		     "bx  r1					    \n"	\
 		     :							\
 		     : "r"(new_sp),					\
 		       "r"(restore_task_exec_start),			\
diff --git a/criu/arch/arm/include/asm/restorer.h b/criu/arch/arm/include/asm/restorer.h
index 6a550b8..095a9b3 100644
--- a/criu/arch/arm/include/asm/restorer.h
+++ b/criu/arch/arm/include/asm/restorer.h
@@ -10,28 +10,28 @@
 			     thread_args, clone_restore_fn)		\
 	asm volatile(							\
 		     "clone_emul:				\n"	\
-		     "ldr %%r1, %2				\n"	\
-		     "sub %%r1, #16				\n"	\
-		     "mov %%r0, %%%6				\n"	\
-		     "str %%r0, [%%r1, #4]			\n"	\
-		     "mov %%r0, %%%5				\n"	\
-		     "str %%r0, [%%r1]				\n"	\
-		     "mov %%r0, %%%1				\n"	\
-		     "mov %%r2, %%%3				\n"	\
-		     "mov %%r3, %%%4				\n"	\
-		     "mov %%r7, #"__stringify(__NR_clone)"	\n"	\
+		     "ldr r1, %2				\n"	\
+		     "sub r1, #16				\n"	\
+		     "mov r0, %6				\n"	\
+		     "str r0, [r1, #4]				\n"	\
+		     "mov r0, %5				\n"	\
+		     "str r0, [r1]				\n"	\
+		     "mov r0, %1				\n"	\
+		     "mov r2, %3				\n"	\
+		     "mov r3, %4				\n"	\
+		     "mov r7, #"__stringify(__NR_clone)"	\n"	\
 		     "svc #0					\n"	\
 									\
-		     "cmp %%r0, #0				\n"	\
+		     "cmp r0, #0				\n"	\
 		     "beq thread_run				\n"	\
 									\
-		     "mov %%%0, %%r0				\n"	\
+		     "mov %0, r0				\n"	\
 		     "b   clone_end				\n"	\
 									\
 		     "thread_run:				\n"	\
-		     "pop { %%r1 }				\n"	\
-		     "pop { %%r0 }				\n"	\
-		     "bx  %%r1					\n"	\
+		     "pop { r1 }				\n"	\
+		     "pop { r0 }				\n"	\
+		     "bx  r1					\n"	\
 									\
 		     "clone_end:				\n"	\
 		     : "=r"(ret)					\
@@ -45,9 +45,9 @@
 
 #define ARCH_FAIL_CORE_RESTORE					\
 	asm volatile(						\
-		     "mov %%sp, %0			    \n"	\
-		     "mov %%r0, #0			    \n"	\
-		     "bx  %%r0				    \n"	\
+		     "mov sp, %0			\n"	\
+		     "mov r0, #0			\n"	\
+		     "bx  r0				\n"	\
 		     :						\
 		     : "r"(ret)					\
 		     : "memory")
@@ -61,12 +61,12 @@ int restore_nonsigframe_gpregs(UserArmRegsEntry *r);
 
 static inline void restore_tls(tls_t *ptls) {
 	asm (
-	     "mov %%r7, #15  \n"
-	     "lsl %%r7, #16  \n"
-	     "mov %%r0, #5   \n"
-	     "add %%r7, %%r0 \n"	/* r7 = 0xF005 */
-	     "ldr %%r0, [%0] \n"
-	     "svc #0         \n"
+	     "mov r7, #15	\n"
+	     "lsl r7, #16	\n"
+	     "mov r0, #5	\n"
+	     "add r7, r0	\n"	/* r7 = 0xF005 */
+	     "ldr r0, [%0]	\n"
+	     "svc #0		\n"
 	     :
 	     : "r"(ptls)
 	     : "r0", "r7"
diff --git a/criu/arch/arm/include/asm/sigframe.h b/criu/arch/arm/include/asm/sigframe.h
index d679f71..c9433e0 100644
--- a/criu/arch/arm/include/asm/sigframe.h
+++ b/criu/arch/arm/include/asm/sigframe.h
@@ -66,8 +66,8 @@ struct rt_sigframe {
 
 #define ARCH_RT_SIGRETURN(new_sp, rt_sigframe)				\
 	asm volatile(							\
-		     "mov %%sp, %0				    \n"	\
-		     "mov %%r7,  #"__stringify(__NR_rt_sigreturn)"  \n" \
+		     "mov sp, %0				    \n"	\
+		     "mov r7,  #"__stringify(__NR_rt_sigreturn)"  \n" \
 		     "svc #0					    \n"	\
 		     :							\
 		     : "r"(new_sp)					\
diff --git a/criu/arch/arm/parasite-head.S b/criu/arch/arm/parasite-head.S
index b15fcba..7b41f56 100644
--- a/criu/arch/arm/parasite-head.S
+++ b/criu/arch/arm/parasite-head.S
@@ -3,17 +3,17 @@
 
 	.section .head.text, "ax"
 ENTRY(__export_parasite_head_start)
-	sub	%r2, %pc, #8			@ get the address of this instruction
+	sub	r2, pc, #8			@ get the address of this instruction
 
-        adr     %r0, __export_parasite_cmd
-	ldr	%r0, [%r0]
+	adr     r0, __export_parasite_cmd
+	ldr	r0, [r0]
 
-        adr     %r1, parasite_args_ptr
-	ldr	%r1, [%r1]
-	add	%r1, %r1, %r2			@ fixup __export_parasite_args
+	adr     r1, parasite_args_ptr
+	ldr	r1, [r1]
+	add	r1, r1, r2			@ fixup __export_parasite_args
 
 	bl	parasite_service
-        .byte   0xf0, 0x01, 0xf0, 0xe7          @ the instruction UDF #32 generates the signal SIGTRAP in Linux
+	.byte   0xf0, 0x01, 0xf0, 0xe7		@ the instruction UDF #32 generates the signal SIGTRAP in Linux
 
 parasite_args_ptr:
 	.long __export_parasite_args
-- 
2.7.4



More information about the CRIU mailing list