From 66bd9f17e9467b1eb5d6b2098b02241f03f8bbf6 Mon Sep 17 00:00:00 2001 From: comex Date: Tue, 15 Nov 2016 21:57:23 -0500 Subject: fix some ARM stuff including calls, and test it wow this code sucks --- test/test-transform-dis.c | 2 +- test/transform-dis-cases-arm.S | 15 +++++++++++++++ test/transform-dis-cases-arm64.S | 9 +++++---- test/transform-dis-cases-i386.S | 10 ++++------ test/transform-dis-cases.h | 4 ++++ 5 files changed, 29 insertions(+), 11 deletions(-) create mode 100644 test/transform-dis-cases-arm.S create mode 100644 test/transform-dis-cases.h (limited to 'test') 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"; -- cgit v1.2.3