diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/test-td-simple.c | 5 | ||||
-rw-r--r-- | test/test-transform-dis.c | 12 | ||||
-rw-r--r-- | test/transform-dis-cases-i386.S | 12 |
3 files changed, 25 insertions, 4 deletions
diff --git a/test/test-td-simple.c b/test/test-td-simple.c index be84ef3..d776d0e 100644 --- a/test/test-td-simple.c +++ b/test/test-td-simple.c @@ -49,6 +49,11 @@ static void P_ret(UNUSED struct tc *ctx) { } NOINLINE UNUSED +static void P_indirect_call(UNUSED struct tc *ctx) { + printf("indirect call\n"); +} + +NOINLINE UNUSED static void P_branch(UNUSED struct tc *ctx, uint64_t dpc, int cc) { printf("branch(%s,%s) => %08llx\n", (cc & CC_CONDITIONAL) ? "cond" : "uncond", diff --git a/test/test-transform-dis.c b/test/test-transform-dis.c index 2d7de9e..98c98e3 100644 --- a/test/test-transform-dis.c +++ b/test/test-transform-dis.c @@ -37,7 +37,8 @@ static void do_manual(uint8_t *in, size_t in_size, int patch_size, &pc_patch_end, pc_trampoline, &arch, - offsets); + offsets, + TRANSFORM_DIS_BAN_CALLS); printf("=> %d\n", ret); printf("#endif\n"); int print_out_idx = 0; @@ -97,8 +98,10 @@ static void do_auto(uint8_t *in, size_t in_size, struct arch_dis_ctx arch) { if (!memcmp(expect, "_ERR", 4)) { expect_err = true; in += 4; - assert(!memcmp(in, "GIVEN", 5)); - in += 5; + if (in != end) { + assert(!memcmp(in, "GIVEN", 5)); + in += 5; + } } else { in = memmem(in, end - in, "GIVEN", 5); if (in) { @@ -123,7 +126,8 @@ static void do_auto(uint8_t *in, size_t in_size, struct arch_dis_ctx arch) { &pc_patch_end, pc_trampoline, &arch, - offsets); + offsets, + TRANSFORM_DIS_BAN_CALLS); if (ret) { if (expect_err) { printf("OK\n"); diff --git a/test/transform-dis-cases-i386.S b/test/transform-dis-cases-i386.S index 3e468d4..c02a044 100644 --- a/test/transform-dis-cases-i386.S +++ b/test/transform-dis-cases-i386.S @@ -17,3 +17,15 @@ EXPECT 2: .byte 0x0f, 0x85; .long 2; jmp 1f; 0: jmp .+0x10000+0x1000-8; 1: GIVEN loopne .+0x80 EXPECT loopne 0f; jmp 1f; 0: jmp .+0x10000+0x80-4; 1: + +GIVEN call .+0x1000; nop +EXPECT_ERR + +GIVEN call *%edi +EXPECT call *%edi + +GIVEN call *%edi; nop +EXPECT_ERR + +GIVEN call *(%edi); nop +EXPECT_ERR |