aboutsummaryrefslogtreecommitdiff
path: root/lib/arm64/arch-dis.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/arch-dis.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 'lib/arm64/arch-dis.h')
-rw-r--r--lib/arm64/arch-dis.h4
1 files changed, 4 insertions, 0 deletions
diff --git a/lib/arm64/arch-dis.h b/lib/arm64/arch-dis.h
index 2990f5a..f5b0518 100644
--- a/lib/arm64/arch-dis.h
+++ b/lib/arm64/arch-dis.h
@@ -26,6 +26,10 @@ static inline void arch_dis_ctx_init(struct arch_dis_ctx *ctx) {
ctx->regs_possibly_written = 0;
}
+static inline int arch_code_alignment(UNUSED struct arch_dis_ctx ctx) {
+ return 4;
+}
+
static inline int arm64_get_unwritten_temp_reg(struct arch_dis_ctx *ctx) {
uint32_t avail = ~ctx->regs_possibly_written & ((1 << 19) - (1 << 9));
if (!avail)