diff options
author | bellard <bellard@c046a42c-6fe2-441c-8c8c-71466251a162> | 2004-04-25 17:54:32 +0000 |
---|---|---|
committer | bellard <bellard@c046a42c-6fe2-441c-8c8c-71466251a162> | 2004-04-25 17:54:32 +0000 |
commit | 1190935d98ec8a8e2e2438858bee8bd5e49ee324 (patch) | |
tree | 46be849502cd2188d800c7fa24d6a035d4d61f95 /tests/test-i386.c | |
parent | bfbc9133eb419906fc2ed83c99d2a6049a2ad966 (diff) | |
download | qemu-1190935d98ec8a8e2e2438858bee8bd5e49ee324.zip qemu-1190935d98ec8a8e2e2438858bee8bd5e49ee324.tar.gz qemu-1190935d98ec8a8e2e2438858bee8bd5e49ee324.tar.bz2 |
precise self modifying code test
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@742 c046a42c-6fe2-441c-8c8c-71466251a162
Diffstat (limited to 'tests/test-i386.c')
-rw-r--r-- | tests/test-i386.c | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/tests/test-i386.c b/tests/test-i386.c index 3e10a993..27a8998 100644 --- a/tests/test-i386.c +++ b/tests/test-i386.c @@ -1580,8 +1580,23 @@ uint8_t code[] = { 0xc3, /* ret */ }; -typedef int FuncType(void); +asm("smc_code2:\n" + "movl 4(%esp), %eax\n" + "movl %eax, smc_patch_addr2 + 1\n" + "nop\n" + "nop\n" + "nop\n" + "nop\n" + "nop\n" + "nop\n" + "nop\n" + "nop\n" + "smc_patch_addr2:\n" + "movl $1, %eax\n" + "ret\n"); +typedef int FuncType(void); +extern int smc_code2(int); void test_self_modifying_code(void) { int i; @@ -1592,6 +1607,13 @@ void test_self_modifying_code(void) code[1] = i; printf("func%d = 0x%x\n", i, ((FuncType *)code)()); } + + /* more difficult test : the modified code is just after the + modifying instruction. It is forbidden in Intel specs, but it + is used by old DOS programs */ + for(i = 2; i <= 4; i++) { + printf("smc_code2(%d) = %d\n", i, smc_code2(i)); + } } static void *call_end __init_call = NULL; |