diff options
author | comex | 2015-02-14 23:14:14 -0500 |
---|---|---|
committer | comex | 2015-02-14 23:41:06 -0500 |
commit | 67ebaf0d22fefa885d29c3c697fbe61956d18354 (patch) | |
tree | f9d3f5395054e8eca4292b344b03b4c97f3fa3ad /test/transform-dis-cases-i386.S | |
parent | test harness (diff) | |
download | substitute-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 'test/transform-dis-cases-i386.S')
-rw-r--r-- | test/transform-dis-cases-i386.S | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/test/transform-dis-cases-i386.S b/test/transform-dis-cases-i386.S index 31508ca..57707cc 100644 --- a/test/transform-dis-cases-i386.S +++ b/test/transform-dis-cases-i386.S @@ -2,15 +2,16 @@ #define EXPECT .ascii "EXPECT"; #define EXPECT_ERR .ascii "EXPECT_ERR"; -GIVEN call .; pop %edx +GIVEN call 0f; 0: pop %edx /* XXX the extra push isn't necessary in 32-bit mode */ -EXPECT push %eax; push %eax; mov $0xdead0005, %eax; pop %eax; pop %edx +EXPECT push %eax; push %eax; mov $0xdead0005, %eax; mov %eax, 4(%esp); pop %eax; pop %edx -GIVEN jmp 0f; 0: +GIVEN jmp 0f; 0: nop EXPECT_ERR -GIVEN jne 0xdead1000 -EXPECT jne 0f; jmp 1f; 0: jmp 0xdead1000; 1: +GIVEN jne .+0x1000 +/* we expect to generate an unnecessarily long jump, so hardcode it */ +EXPECT 2: .byte 0x0f, 0x85; .long 2; jmp 1f; 0: jmp 2b+0x1000; 1: GIVEN loopne 0xdead0080 EXPECT loopne 0f; jmp 1f; 0: jmp 0xdead1000; 1: |