aboutsummaryrefslogtreecommitdiff
path: root/lib/x86/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/x86/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/x86/arch-dis.h')
-rw-r--r--lib/x86/arch-dis.h10
1 files changed, 9 insertions, 1 deletions
diff --git a/lib/x86/arch-dis.h b/lib/x86/arch-dis.h
index 6447f38..d121549 100644
--- a/lib/x86/arch-dis.h
+++ b/lib/x86/arch-dis.h
@@ -1,6 +1,11 @@
#pragma once
#define MIN_INSN_SIZE 1
-#define TD_MAX_REWRITTEN_SIZE 100 /* XXX */
+/* min([18 * 3,
+ * 4 + 18 + 15 + 18,
+ * 6 + 12])
+ * See transform_dis_* for size figures. Technically unsafe, since we don't
+ * check for overlong x86 instructions. */
+#define TD_MAX_REWRITTEN_SIZE 55
struct arch_pcrel_info {
int reg;
@@ -8,3 +13,6 @@ struct arch_pcrel_info {
struct arch_dis_ctx {};
static inline void arch_dis_ctx_init(UNUSED struct arch_dis_ctx *ctx) {}
+static inline int arch_code_alignment(UNUSED struct arch_dis_ctx ctx) {
+ return 4;
+}