aboutsummaryrefslogtreecommitdiff
path: root/lib/arm64/jump-patch.h
diff options
context:
space:
mode:
authorcomex2015-02-14 23:14:14 -0500
committercomex2015-02-14 23:41:06 -0500
commit67ebaf0d22fefa885d29c3c697fbe61956d18354 (patch)
treef9d3f5395054e8eca4292b344b03b4c97f3fa3ad /lib/arm64/jump-patch.h
parenttest harness (diff)
downloadsubstitute-67ebaf0d22fefa885d29c3c697fbe61956d18354.tar.gz
Trampoline fixes.
The transformed code was incorrect because it assumed the pointer it was writing to was where the code would execute, but it was actually 'rewritten_temp'. Changed transform_dis_main to take a pc_trampoline pointer, which also helps the test harness. However, this means that it has to be called after the trampoline has been allocated, while before the trampoline allocation depended on the generated size; this change doesn't bother to use two passes or anything, but just allocates a new code buffer if the maximum possible size isn't available - not the end of the world, since trampoline_ptr will still only be increased by the actual size before the next hook in the series (if any).
Diffstat (limited to '')
-rw-r--r--lib/arm64/jump-patch.h5
1 files changed, 3 insertions, 2 deletions
diff --git a/lib/arm64/jump-patch.h b/lib/arm64/jump-patch.h
index 3d3d653..0a276ba 100644
--- a/lib/arm64/jump-patch.h
+++ b/lib/arm64/jump-patch.h
@@ -1,12 +1,13 @@
#pragma once
#include "arm64/assemble.h"
-#define MAX_JUMP_PATCH_SIZE 12
+#define MAX_JUMP_PATCH_SIZE 20
+
static inline int jump_patch_size(uintptr_t pc, uintptr_t dpc,
UNUSED struct arch_dis_ctx arch,
bool force) {
intptr_t diff = (dpc & ~0xfff) - (pc & ~0xfff);
if (!(diff >= -0x100000000 && diff < 0x100000000))
- return force ? 16 : -1;
+ return force ? (size_of_MOVi64(dpc) + 4) : -1;
else if (!(dpc & 0xfff))
return 8;
else