From 24eddaa8240137328a0522eccf741e7868a2ee58 Mon Sep 17 00:00:00 2001 From: comex Date: Tue, 24 Feb 2015 20:39:14 -0500 Subject: fix arm64/armv7 ish --- lib/darwin/execmem.c | 4 ++-- lib/darwin/manual-syscall.h | 9 ++++++++- 2 files changed, 10 insertions(+), 3 deletions(-) (limited to 'lib/darwin') diff --git a/lib/darwin/execmem.c b/lib/darwin/execmem.c index 0155b1f..b142aff 100644 --- a/lib/darwin/execmem.c +++ b/lib/darwin/execmem.c @@ -115,7 +115,7 @@ static bool apply_one_pcp_with_state(native_thread_state *state, uintptr_t old = *pcp; #ifdef __arm__ /* thumb */ - if (state.cpsr & 0x20) + if (state->__cpsr & 0x20) old |= 1; #endif uintptr_t new = callback(ctx, *pcp); @@ -123,7 +123,7 @@ static bool apply_one_pcp_with_state(native_thread_state *state, *pcp = new; #ifdef __arm__ *pcp &= ~1; - state.cpsr = (state.cpsr & ~0x20) | ((new & 1) * 0x20); + state->__cpsr = (state->__cpsr & ~0x20) | ((new & 1) * 0x20); #endif return changed; } diff --git a/lib/darwin/manual-syscall.h b/lib/darwin/manual-syscall.h index 88ac179..f16ec54 100644 --- a/lib/darwin/manual-syscall.h +++ b/lib/darwin/manual-syscall.h @@ -3,10 +3,12 @@ #define GEN_SYSCALL(name, num) \ __asm__(".globl _manual_" #name "\n" \ ".pushsection __TEXT,__text,regular,pure_instructions\n" \ + GEN_SYSCALL_PRE(name) \ "_manual_" #name ":\n" \ ".set num, " #num "\n" \ GEN_SYSCALL_INNER() \ ".popsection\n") +#define GEN_SYSCALL_PRE(name) #if defined(__x86_64__) /* Look at me, I'm different! */ @@ -30,13 +32,18 @@ "sysenter\n" \ "1: ret\n" #elif defined(__arm__) +#ifdef __thumb__ +#undef GEN_SYSCALL_PRE +#define GEN_SYSCALL_PRE(name) \ + ".thumb_func _manual_" #name "\n" +#endif #define GEN_SYSCALL_INNER() \ "mov r12, #num\n" \ "svc #0x80\n" \ "bx lr\n" #elif defined(__arm64__) #define GEN_SYSCALL_INNER() \ - "mov x12, #num\n" \ + "mov x16, #num\n" \ "svc #0x80\n" \ "ret\n" #else -- cgit v1.2.3