aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorcomex2015-02-24 20:39:14 -0500
committercomex2015-02-24 20:39:14 -0500
commit24eddaa8240137328a0522eccf741e7868a2ee58 (patch)
treeef7915f83133d966ff8986d3ea41c640832d3d96 /lib
parentAdd transform-dis-cases-arm64.S and fix a serious bug thus discovered. (diff)
downloadsubstitute-24eddaa8240137328a0522eccf741e7868a2ee58.tar.gz
fix arm64/armv7 ish
Diffstat (limited to 'lib')
-rw-r--r--lib/arm64/jump-patch.h2
-rw-r--r--lib/darwin/execmem.c4
-rw-r--r--lib/darwin/manual-syscall.h9
-rw-r--r--lib/jump-dis.h2
-rw-r--r--lib/transform-dis.h2
5 files changed, 13 insertions, 6 deletions
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 <stdint.h>
#include <stdbool.h>
-#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 <stdint.h>
#include <stdbool.h>
-#include stringify(TARGET_DIR/arch-dis.h)
+#include "dis.h"
#define TRANSFORM_DIS_BAN_CALLS 1