Revision 1190935d tests/test-i386.c

b/tests/test-i386.c
1580 1580
    0xc3, /* ret */
1581 1581
};
1582 1582

  
1583
typedef int FuncType(void);
1583
asm("smc_code2:\n"
1584
    "movl 4(%esp), %eax\n"
1585
    "movl %eax, smc_patch_addr2 + 1\n"
1586
    "nop\n"
1587
    "nop\n"
1588
    "nop\n"
1589
    "nop\n"
1590
    "nop\n"
1591
    "nop\n"
1592
    "nop\n"
1593
    "nop\n"
1594
    "smc_patch_addr2:\n"
1595
    "movl $1, %eax\n"
1596
    "ret\n");
1584 1597

  
1598
typedef int FuncType(void);
1599
extern int smc_code2(int);
1585 1600
void test_self_modifying_code(void)
1586 1601
{
1587 1602
    int i;
......
1592 1607
        code[1] = i;
1593 1608
        printf("func%d = 0x%x\n", i, ((FuncType *)code)());
1594 1609
    }
1610

  
1611
    /* more difficult test : the modified code is just after the
1612
       modifying instruction. It is forbidden in Intel specs, but it
1613
       is used by old DOS programs */
1614
    for(i = 2; i <= 4; i++) {
1615
        printf("smc_code2(%d) = %d\n", i, smc_code2(i));
1616
    }
1595 1617
}
1596 1618
    
1597 1619
static void *call_end __init_call = NULL;

Also available in: Unified diff