Skip to content

Commit

Permalink
Fix ARM register sizes for clang builds
Browse files Browse the repository at this point in the history
Resolves #3844
  • Loading branch information
rocallahan committed Oct 7, 2024
1 parent 75bd84e commit bfe5018
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 8 deletions.
11 changes: 7 additions & 4 deletions src/preload/syscallbuf.c
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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
Expand All @@ -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"
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions src/test/rseq.c
Original file line number Diff line number Diff line change
Expand Up @@ -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__)
Expand All @@ -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"
Expand Down
4 changes: 2 additions & 2 deletions src/test/rseq_syscallbuf.c
Original file line number Diff line number Diff line change
Expand Up @@ -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__)
Expand All @@ -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"
Expand Down

0 comments on commit bfe5018

Please sign in to comment.