From bfe5018a00555e10e7b73fd52b43242b42c113c2 Mon Sep 17 00:00:00 2001 From: Robert O'Callahan Date: Mon, 7 Oct 2024 16:45:09 +1300 Subject: [PATCH] Fix ARM register sizes for clang builds Resolves #3844 --- src/preload/syscallbuf.c | 11 +++++++---- src/test/rseq.c | 4 ++-- src/test/rseq_syscallbuf.c | 4 ++-- 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/src/preload/syscallbuf.c b/src/preload/syscallbuf.c index 918e7555950..66415bdd664 100644 --- a/src/preload/syscallbuf.c +++ b/src/preload/syscallbuf.c @@ -242,6 +242,7 @@ static void local_memcpy(void* dest, const void* source, int n) { #elif defined(__aarch64__) long c1; long c2; + long n_long = n; __asm__ __volatile__("subs %4, %2, 16\n\t" "b.lt 2f\n\t" "1:\n\t" @@ -267,7 +268,7 @@ static void local_memcpy(void* dest, const void* source, int n) { "ldrb %w3, [%1]\n\t" "strb %w3, [%0]\n\t" "3:\n\t" - : "+r"(dest), "+r"(source), "+r"(n), "=&r"(c1), "=&r"(c2) + : "+r"(dest), "+r"(source), "+r"(n_long), "=&r"(c1), "=&r"(c2) : : "cc", "memory"); #else @@ -289,8 +290,9 @@ static void local_memset(void* dest, uint8_t c, int n) { : : "cc", "memory"); #elif defined(__aarch64__) - double v1; + double v1 __attribute__((vector_size(16))); long n2; + long n_long = n; __asm__ __volatile__("subs %4, %2, 32\n\t" "b.lt 2f\n\t" "dup %3.16b, %w0\n" @@ -306,7 +308,7 @@ static void local_memset(void* dest, uint8_t c, int n) { "subs %2, %2, #1\n\t" "b.ne 3b\n" "4:\n\t" - : "+r"(c), "+r"(dest), "+r"(n), "=x"(v1), "=r"(n2) + : "+r"(c), "+r"(dest), "+r"(n_long), "=x"(v1), "=r"(n2) : : "cc", "memory"); #else @@ -1547,6 +1549,7 @@ static void memcpy_input_parameter(void* buf, void* src, int size) { #elif defined(__aarch64__) long c1; long c2; + long size_long = size; unsigned char *globals_in_replay = rr_page_replay_flag_addr(); __asm__ __volatile__("ldrb %w3, [%5]\n\t" "cmp %3, #0\n\t" // eq -> record @@ -1580,7 +1583,7 @@ static void memcpy_input_parameter(void* buf, void* src, int size) { "mov %4, xzr\n\t" "mov %1, xzr\n\t" : "+r"(buf), "+r"(src), - "+r"(size), "=&r"(c1), "=&r"(c2), "+r"(globals_in_replay) + "+r"(size_long), "=&r"(c1), "=&r"(c2), "+r"(globals_in_replay) : : "cc", "memory"); #else diff --git a/src/test/rseq.c b/src/test/rseq.c index 76616340856..86db56a6f27 100644 --- a/src/test/rseq.c +++ b/src/test/rseq.c @@ -19,7 +19,7 @@ static uint64_t jump_aborts; static volatile uint32_t dummy; static void do_section(void) { - int did_abort = 0; + long did_abort = 0; rs_ptr->rseq_cs = (uint64_t)(uintptr_t)&rs_cs; #if defined(__x86_64__) || defined(__i386__) @@ -37,7 +37,7 @@ static void do_section(void) { "1:\n\t" : : "m"(dummy), "m"(did_abort)); #elif defined(__aarch64__) - int dummy2; + long dummy2; __asm__ __volatile__ ( "start_ip:\n\t" "mov %1, 1234\n\t" diff --git a/src/test/rseq_syscallbuf.c b/src/test/rseq_syscallbuf.c index 60502d520a8..9088ad5a4ec 100644 --- a/src/test/rseq_syscallbuf.c +++ b/src/test/rseq_syscallbuf.c @@ -19,7 +19,7 @@ static uint64_t jump_aborts; static volatile uint32_t dummy; static void do_section(void) { - int did_abort = 0; + long did_abort = 0; rs_ptr->rseq_cs = (uint64_t)(uintptr_t)&rs_cs; #if defined(__x86_64__) || defined(__i386__) @@ -37,7 +37,7 @@ static void do_section(void) { "1:\n\t" : : "m"(dummy), "m"(did_abort)); #elif defined(__aarch64__) - int dummy2; + long dummy2; __asm__ __volatile__ ( "start_ip:\n\t" "mov %1, 1234\n\t"