Commit d1fe2b245910d42715e556458afe7d975d9417ef

Authored by bellard
1 parent d4e8164f

self modifying code also tests translation block chaining invalidation


git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@184 c046a42c-6fe2-441c-8c8c-71466251a162
Showing 1 changed file with 8 additions and 5 deletions
tests/test-i386.c
@@ -1218,15 +1218,18 @@ uint8_t code[] = { @@ -1218,15 +1218,18 @@ uint8_t code[] = {
1218 0xc3, /* ret */ 1218 0xc3, /* ret */
1219 }; 1219 };
1220 1220
  1221 +typedef int FuncType(void);
  1222 +
1221 void test_self_modifying_code(void) 1223 void test_self_modifying_code(void)
1222 { 1224 {
1223 - int (*func)(void); 1225 + int i;
1224 1226
1225 - func = (void *)code;  
1226 printf("self modifying code:\n"); 1227 printf("self modifying code:\n");
1227 - printf("func1 = 0x%x\n", func());  
1228 - code[1] = 0x2;  
1229 - printf("func1 = 0x%x\n", func()); 1228 + printf("func1 = 0x%x\n", ((FuncType *)code)());
  1229 + for(i = 2; i <= 4; i++) {
  1230 + code[1] = i;
  1231 + printf("func%d = 0x%x\n", i, ((FuncType *)code)());
  1232 + }
1230 } 1233 }
1231 1234
1232 static void *call_end __init_call = NULL; 1235 static void *call_end __init_call = NULL;