Skip to content

Commit

Permalink
fix asm syntax to be clang-compatible
Browse files Browse the repository at this point in the history
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.

travis-ci: success for Fixes to compile on arm with clang
Cc: Christopher Covington <cov@codeaurora.org>
Dmitry Safonov <dsafonov@virtuozzo.com>
Signed-off-by: Kir Kolyshkin <kir@openvz.org>
Reviewed-by: Christopher Covington <cov@codeaurora.org>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
  • Loading branch information
kolyshkin authored and xemul committed Nov 12, 2016
1 parent d6d034a commit 6c7eb2e
Show file tree
Hide file tree
Showing 5 changed files with 52 additions and 52 deletions.
8 changes: 4 additions & 4 deletions criu/arch/arm/include/asm/restore.h
Original file line number Diff line number Diff line change
Expand Up @@ -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), \
Expand Down
52 changes: 26 additions & 26 deletions criu/arch/arm/include/asm/restorer.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,8 @@ struct rt_sigframe {

#define ARCH_RT_SIGRETURN(new_sp) \
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) \
Expand All @@ -80,28 +80,28 @@ struct rt_sigframe {
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) \
Expand All @@ -115,9 +115,9 @@ struct rt_sigframe {

#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")
Expand All @@ -144,12 +144,12 @@ static inline int sigreturn_prep_fpu_frame(struct rt_sigframe *sigframe,

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"
Expand Down
14 changes: 7 additions & 7 deletions criu/arch/arm/include/asm/syscall-aux.S
Original file line number Diff line number Diff line change
Expand Up @@ -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)
14 changes: 7 additions & 7 deletions criu/arch/arm/parasite-head.S
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
16 changes: 8 additions & 8 deletions criu/arch/arm/syscalls/syscall-common.S
Original file line number Diff line number Diff line change
Expand Up @@ -8,27 +8,27 @@
@ 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
.nr_\name :
.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)

0 comments on commit 6c7eb2e

Please sign in to comment.