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/arm64/jump-patch.h | 2 +- lib/darwin/execmem.c | 4 ++-- lib/darwin/manual-syscall.h | 9 ++++++++- lib/jump-dis.h | 2 +- lib/transform-dis.h | 2 +- 5 files changed, 13 insertions(+), 6 deletions(-) (limited to 'lib') diff --git a/lib/arm64/jump-patch.h b/lib/arm64/jump-patch.h index 0a276ba..5a44174 100644 --- a/lib/arm64/jump-patch.h +++ b/lib/arm64/jump-patch.h @@ -22,5 +22,5 @@ static inline void make_jump_patch(void **codep, uintptr_t pc, uintptr_t dpc, MOVi64(codep, reg, dpc); else ADRP_ADD(codep, reg, pc, dpc); - BR(codep, reg); + BR(codep, reg, false); } 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 diff --git a/lib/jump-dis.h b/lib/jump-dis.h index fccd1a6..d82c4a8 100644 --- a/lib/jump-dis.h +++ b/lib/jump-dis.h @@ -1,7 +1,7 @@ #pragma once #include #include -#include stringify(TARGET_DIR/arch-dis.h) +#include "dis.h" bool jump_dis_main(void *code_ptr, uintptr_t pc_patch_start, uintptr_t pc_patch_end, struct arch_dis_ctx initial_dis_ctx); diff --git a/lib/transform-dis.h b/lib/transform-dis.h index e8969a8..90156af 100644 --- a/lib/transform-dis.h +++ b/lib/transform-dis.h @@ -1,7 +1,7 @@ #pragma once #include #include -#include stringify(TARGET_DIR/arch-dis.h) +#include "dis.h" #define TRANSFORM_DIS_BAN_CALLS 1 -- cgit v1.2.3