aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorcomex2016-11-15 21:57:23 -0500
committercomex2016-11-15 21:57:23 -0500
commit66bd9f17e9467b1eb5d6b2098b02241f03f8bbf6 (patch)
treedb2bde0572ddac99f148d46c43c7122849fb7487 /test
parentfix bool arguments with false default (diff)
downloadsubstitute-66bd9f17e9467b1eb5d6b2098b02241f03f8bbf6.tar.gz
fix some ARM stuff including calls, and test it
wow this code sucks
Diffstat (limited to 'test')
-rw-r--r--test/test-transform-dis.c2
-rw-r--r--test/transform-dis-cases-arm.S15
-rw-r--r--test/transform-dis-cases-arm64.S9
-rw-r--r--test/transform-dis-cases-i386.S10
-rw-r--r--test/transform-dis-cases.h4
5 files changed, 29 insertions, 11 deletions
diff --git a/test/test-transform-dis.c b/test/test-transform-dis.c
index 98c98e3..d147a49 100644
--- a/test/test-transform-dis.c
+++ b/test/test-transform-dis.c
@@ -127,7 +127,7 @@ static void do_auto(uint8_t *in, size_t in_size, struct arch_dis_ctx arch) {
pc_trampoline,
&arch,
offsets,
- TRANSFORM_DIS_BAN_CALLS);
+ 0);//TRANSFORM_DIS_BAN_CALLS);
if (ret) {
if (expect_err) {
printf("OK\n");
diff --git a/test/transform-dis-cases-arm.S b/test/transform-dis-cases-arm.S
new file mode 100644
index 0000000..a9e01b1
--- /dev/null
+++ b/test/transform-dis-cases-arm.S
@@ -0,0 +1,15 @@
+#include "transform-dis-cases.h"
+#ifdef THUMB
+.thumb
+#endif
+
+
+#ifndef THUMB
+GIVEN blne 0f; nop; nop; 0:
+EXPECT beq 1f; movw lr, #0x000c; movt lr, #0xdead; blx lr; 1: nop; nop
+GIVEN bl 0f; 0:
+EXPECT movw lr, #0x0004; movt lr, #0xdead; blx lr
+#else
+GIVEN bl 0f; 0:
+EXPECT movw lr, #0x0005; movt lr, #0xdead; blx lr
+#endif
diff --git a/test/transform-dis-cases-arm64.S b/test/transform-dis-cases-arm64.S
index cc3bd4c..99a353b 100644
--- a/test/transform-dis-cases-arm64.S
+++ b/test/transform-dis-cases-arm64.S
@@ -1,6 +1,4 @@
-#define GIVEN .ascii "GIVEN";
-#define EXPECT .ascii "EXPECT";
-#define EXPECT_ERR .ascii "EXPECT_ERR";
+#include "transform-dis-cases.h"
/* yay clang, no semicolons allowed */
@@ -12,7 +10,10 @@ EXPECT
GIVEN
blr x5
nop
-EXPECT_ERR
+//EXPECT_ERR (with ban_calls)
+EXPECT
+ blr x5
+
GIVEN
cbnz x8, .+0x100
diff --git a/test/transform-dis-cases-i386.S b/test/transform-dis-cases-i386.S
index c02a044..a39ee02 100644
--- a/test/transform-dis-cases-i386.S
+++ b/test/transform-dis-cases-i386.S
@@ -1,6 +1,4 @@
-#define GIVEN .ascii "GIVEN";
-#define EXPECT .ascii "EXPECT";
-#define EXPECT_ERR .ascii "EXPECT_ERR";
+#include "transform-dis-cases.h"
GIVEN call 0f; 0: pop %edx
/* XXX the extra push isn't necessary in 32-bit mode */
@@ -10,9 +8,9 @@ GIVEN jmp 0f; 0: nop
EXPECT_ERR
GIVEN jne .+0x1000
-/* we expect to generate an unnecessarily long jump, so hardcode it the 0x10000
- * is because we pretend our trampoline is 0x10000 bytes before the original
- * function */
+/* we expect to generate an unnecessarily long jump, so hardcode it
+ * the 0x10000 is because we pretend our trampoline is 0x10000 bytes before the
+ * original function */
EXPECT 2: .byte 0x0f, 0x85; .long 2; jmp 1f; 0: jmp .+0x10000+0x1000-8; 1:
GIVEN loopne .+0x80
diff --git a/test/transform-dis-cases.h b/test/transform-dis-cases.h
new file mode 100644
index 0000000..94f39bd
--- /dev/null
+++ b/test/transform-dis-cases.h
@@ -0,0 +1,4 @@
+#pragma once
+#define GIVEN .ascii "GIVEN";
+#define EXPECT .ascii "EXPECT";
+#define EXPECT_ERR .ascii "EXPECT_ERR";