Fix armv8/thumb IT blocks
ARMv8 specifies that an IT block should be followed by only one
16-bit instruction.
Moved the conditional code outside the inline assembly to let the
compiler make the right choice.
BUG=686903
Change-Id: I1b218dab30e395ea707dc08b82a26a3e3d2a54e4
Reviewed-on: https://chromium-review.googlesource.com/446525
Reviewed-by: Mike Frysinger <vapier@chromium.org>
Reviewed-by: Mark Seaborn <mseaborn@chromium.org>
diff --git a/linux_syscall_support.h b/linux_syscall_support.h
index a5bcb9b..f74eda1 100644
--- a/linux_syscall_support.h
+++ b/linux_syscall_support.h
@@ -2594,27 +2594,19 @@
int flags, void *arg, int *parent_tidptr,
void *newtls, int *child_tidptr) {
long __res;
- {
+ if (fn == NULL || child_stack == NULL) {
+ __res = -EINVAL;
+ } else {
register int __flags __asm__("r0") = flags;
register void *__stack __asm__("r1") = child_stack;
register void *__ptid __asm__("r2") = parent_tidptr;
register void *__tls __asm__("r3") = newtls;
register int *__ctid __asm__("r4") = child_tidptr;
- __asm__ __volatile__(/* if (fn == NULL || child_stack == NULL)
- * return -EINVAL;
- */
- "cmp %2,#0\n"
- "it ne\n"
- "cmpne %3,#0\n"
- "it eq\n"
- "moveq %0,%1\n"
- "beq 1f\n"
-
- /* Push "arg" and "fn" onto the stack that will be
+ __asm__ __volatile__(/* Push "arg" and "fn" onto the stack that will be
* used by the child.
*/
- "str %5,[%3,#-4]!\n"
- "str %2,[%3,#-4]!\n"
+ "str %4,[%2,#-4]!\n"
+ "str %1,[%2,#-4]!\n"
/* %r0 = syscall(%r0 = flags,
* %r1 = child_stack,
@@ -2622,7 +2614,7 @@
* %r3 = newtls,
* %r4 = child_tidptr)
*/
- "mov r7, %9\n"
+ "mov r7, %8\n"
"swi 0x0\n"
/* if (%r0 != 0)
@@ -2655,12 +2647,11 @@
/* Call _exit(%r0).
*/
- "mov r7, %10\n"
+ "mov r7, %9\n"
"swi 0x0\n"
"1:\n"
: "=r" (__res)
- : "i"(-EINVAL),
- "r"(fn), "r"(__stack), "r"(__flags), "r"(arg),
+ : "r"(fn), "r"(__stack), "r"(__flags), "r"(arg),
"r"(__ptid), "r"(__tls), "r"(__ctid),
"i"(__NR_clone), "i"(__NR_exit)
: "cc", "r7", "lr", "memory");