winebuild: Hardcode the i386 register context offsets instead of using the data structure.

This commit is contained in:
Alexandre Julliard 2009-04-09 20:01:56 +02:00
parent 5534cde72c
commit d71284f0b4

View File

@ -37,9 +37,6 @@
/* offset of a structure field relative to the start of the struct */
#define STRUCTOFFSET(type,field) ((int)FIELD_OFFSET(type,field))
/* offset of register relative to the start of the CONTEXT struct */
#define CONTEXTOFFSET(reg) STRUCTOFFSET(CONTEXT86,reg)
/* offset of register relative to the start of the STACK16FRAME struct */
#define STACK16OFFSET(reg) STRUCTOFFSET(STACK16FRAME,reg)
@ -246,41 +243,41 @@ static void BuildCallFrom16Core( int reg_func, int thunk )
{
output( "\tsubl $%d, %%esp\n", (int)sizeof(CONTEXT86) );
output( "\tmovl %%ecx, %d(%%esp)\n", CONTEXTOFFSET(EFlags) );
output( "\tmovl %%ecx,0xc0(%%esp)\n" ); /* EFlags */
output( "\tmovl %%eax, %d(%%esp)\n", CONTEXTOFFSET(Eax) );
output( "\tmovl %%ebx, %d(%%esp)\n", CONTEXTOFFSET(Ebx) );
output( "\tmovl %%esi, %d(%%esp)\n", CONTEXTOFFSET(Esi) );
output( "\tmovl %%edi, %d(%%esp)\n", CONTEXTOFFSET(Edi) );
output( "\tmovl %%eax,0xb0(%%esp)\n" ); /* Eax */
output( "\tmovl %%ebx,0xa4(%%esp)\n" ); /* Ebx */
output( "\tmovl %%esi,0xa0(%%esp)\n" ); /* Esi */
output( "\tmovl %%edi,0x9c(%%esp)\n" ); /* Edi */
output( "\tmovl %d(%%edx), %%eax\n", STACK16OFFSET(ebp) );
output( "\tmovl %%eax, %d(%%esp)\n", CONTEXTOFFSET(Ebp) );
output( "\tmovl %%eax,0xb4(%%esp)\n" ); /* Ebp */
output( "\tmovl %d(%%edx), %%eax\n", STACK16OFFSET(ecx) );
output( "\tmovl %%eax, %d(%%esp)\n", CONTEXTOFFSET(Ecx) );
output( "\tmovl %%eax,0xac(%%esp)\n" ); /* Ecx */
output( "\tmovl %d(%%edx), %%eax\n", STACK16OFFSET(edx) );
output( "\tmovl %%eax, %d(%%esp)\n", CONTEXTOFFSET(Edx) );
output( "\tmovl %%eax,0xa8(%%esp)\n" ); /* Edx */
output( "\tmovzwl %d(%%edx), %%eax\n", STACK16OFFSET(ds) );
output( "\tmovl %%eax, %d(%%esp)\n", CONTEXTOFFSET(SegDs) );
output( "\tmovl %%eax,0x98(%%esp)\n" ); /* SegDs */
output( "\tmovzwl %d(%%edx), %%eax\n", STACK16OFFSET(es) );
output( "\tmovl %%eax, %d(%%esp)\n", CONTEXTOFFSET(SegEs) );
output( "\tmovl %%eax,0x94(%%esp)\n" ); /* SegEs */
output( "\tmovzwl %d(%%edx), %%eax\n", STACK16OFFSET(fs) );
output( "\tmovl %%eax, %d(%%esp)\n", CONTEXTOFFSET(SegFs) );
output( "\tmovl %%eax,0x90(%%esp)\n" ); /* SegFs */
output( "\tmovzwl %d(%%edx), %%eax\n", STACK16OFFSET(gs) );
output( "\tmovl %%eax, %d(%%esp)\n", CONTEXTOFFSET(SegGs) );
output( "\tmovl %%eax,0x8c(%%esp)\n" ); /* SegGs */
output( "\tmovzwl %d(%%edx), %%eax\n", STACK16OFFSET(cs) );
output( "\tmovl %%eax, %d(%%esp)\n", CONTEXTOFFSET(SegCs) );
output( "\tmovl %%eax,0xbc(%%esp)\n" ); /* SegCs */
output( "\tmovzwl %d(%%edx), %%eax\n", STACK16OFFSET(ip) );
output( "\tmovl %%eax, %d(%%esp)\n", CONTEXTOFFSET(Eip) );
output( "\tmovl %%eax,0xb8(%%esp)\n" ); /* Eip */
output( "\t.byte 0x64\n\tmovzwl (%d), %%eax\n", STACKOFFSET+2 );
output( "\tmovl %%eax, %d(%%esp)\n", CONTEXTOFFSET(SegSs) );
output( "\tmovl %%eax,0xc8(%%esp)\n" ); /* SegSs */
output( "\t.byte 0x64\n\tmovzwl (%d), %%eax\n", STACKOFFSET );
output( "\taddl $%d, %%eax\n", STACK16OFFSET(ip) );
output( "\tmovl %%eax, %d(%%esp)\n", CONTEXTOFFSET(Esp) );
output( "\tmovl %%eax,0xc4(%%esp)\n" ); /* Esp */
#if 0
output( "\tfsave %d(%%esp)\n", CONTEXTOFFSET(FloatSave) );
output( "\tfsave 0x1c(%%esp)\n" ); /* FloatSave */
#endif
/* Push address of CONTEXT86 structure -- popped by the relay routine */
@ -317,31 +314,31 @@ static void BuildCallFrom16Core( int reg_func, int thunk )
output( "\tpopl %%edx\n" );
/* Restore all registers from CONTEXT */
output( "\tmovw %d(%%ebx), %%ss\n", CONTEXTOFFSET(SegSs) );
output( "\tmovl %d(%%ebx), %%esp\n", CONTEXTOFFSET(Esp) );
output( "\tmovw 0xc8(%%ebx),%%ss\n"); /* SegSs */
output( "\tmovl 0xc4(%%ebx),%%esp\n"); /* Esp */
output( "\taddl $4, %%esp\n" ); /* room for final return address */
output( "\tpushw %d(%%ebx)\n", CONTEXTOFFSET(SegCs) );
output( "\tpushw %d(%%ebx)\n", CONTEXTOFFSET(Eip) );
output( "\tpushw 0xbc(%%ebx)\n"); /* SegCs */
output( "\tpushw 0xb8(%%ebx)\n"); /* Eip */
output( "\tpushl %%edx\n" );
output( "\tpushl %%eax\n" );
output( "\tpushl %d(%%ebx)\n", CONTEXTOFFSET(EFlags) );
output( "\tpushl %d(%%ebx)\n", CONTEXTOFFSET(SegDs) );
output( "\tpushl 0xc0(%%ebx)\n"); /* EFlags */
output( "\tpushl 0x98(%%ebx)\n"); /* SegDs */
output( "\tpushl %d(%%ebx)\n", CONTEXTOFFSET(SegEs) );
output( "\tpushl 0x94(%%ebx)\n"); /* SegEs */
output( "\tpopl %%es\n" );
output( "\tpushl %d(%%ebx)\n", CONTEXTOFFSET(SegFs) );
output( "\tpushl 0x90(%%ebx)\n"); /* SegFs */
output( "\tpopl %%fs\n" );
output( "\tpushl %d(%%ebx)\n", CONTEXTOFFSET(SegGs) );
output( "\tpushl 0x8c(%%ebx)\n"); /* SegGs */
output( "\tpopl %%gs\n" );
output( "\tmovl %d(%%ebx), %%ebp\n", CONTEXTOFFSET(Ebp) );
output( "\tmovl %d(%%ebx), %%esi\n", CONTEXTOFFSET(Esi) );
output( "\tmovl %d(%%ebx), %%edi\n", CONTEXTOFFSET(Edi) );
output( "\tmovl %d(%%ebx), %%eax\n", CONTEXTOFFSET(Eax) );
output( "\tmovl %d(%%ebx), %%edx\n", CONTEXTOFFSET(Edx) );
output( "\tmovl %d(%%ebx), %%ecx\n", CONTEXTOFFSET(Ecx) );
output( "\tmovl %d(%%ebx), %%ebx\n", CONTEXTOFFSET(Ebx) );
output( "\tmovl 0xb4(%%ebx),%%ebp\n"); /* Ebp */
output( "\tmovl 0xa0(%%ebx),%%esi\n"); /* Esi */
output( "\tmovl 0x9c(%%ebx),%%edi\n"); /* Edi */
output( "\tmovl 0xb0(%%ebx),%%eax\n"); /* Eax */
output( "\tmovl 0xa8(%%ebx),%%edx\n"); /* Edx */
output( "\tmovl 0xac(%%ebx),%%ecx\n"); /* Ecx */
output( "\tmovl 0xa4(%%ebx),%%ebx\n"); /* Ebx */
output( "\tpopl %%ds\n" );
output( "\tpopfl\n" );
@ -445,12 +442,12 @@ static void BuildCallTo16Core( int reg_func )
output( "\tmovl %d(%%esp), %%edi\n", STACK32OFFSET(target) - STACK32OFFSET(edi));
/* everything above edi has been popped already */
output( "\tmovl %%eax, %d(%%edi)\n", CONTEXTOFFSET(Eax) );
output( "\tmovl %%ebx, %d(%%edi)\n", CONTEXTOFFSET(Ebx) );
output( "\tmovl %%ecx, %d(%%edi)\n", CONTEXTOFFSET(Ecx) );
output( "\tmovl %%edx, %d(%%edi)\n", CONTEXTOFFSET(Edx) );
output( "\tmovl %%ebp, %d(%%edi)\n", CONTEXTOFFSET(Ebp) );
output( "\tmovl %%esi, %d(%%edi)\n", CONTEXTOFFSET(Esp) );
output( "\tmovl %%eax,0xb0(%%edi)\n"); /* Eax */
output( "\tmovl %%ebx,0xa4(%%edi)\n"); /* Ebx */
output( "\tmovl %%ecx,0xac(%%edi)\n"); /* Ecx */
output( "\tmovl %%edx,0xa8(%%edi)\n"); /* Edx */
output( "\tmovl %%ebp,0xb4(%%edi)\n"); /* Ebp */
output( "\tmovl %%esi,0xc4(%%edi)\n"); /* Esp */
/* The return glue code saved %esp into %esi */
}
@ -485,24 +482,24 @@ static void BuildCallTo16Core( int reg_func )
{
/* Push the called routine address */
output( "\tmovl %d(%%edx),%%edx\n", STACK32OFFSET(target) );
output( "\tpushw %d(%%edx)\n", CONTEXTOFFSET(SegCs) );
output( "\tpushw %d(%%edx)\n", CONTEXTOFFSET(Eip) );
output( "\tpushw 0xbc(%%edx)\n"); /* SegCs */
output( "\tpushw 0xb8(%%edx)\n"); /* Eip */
/* Get the registers */
output( "\tpushw %d(%%edx)\n", CONTEXTOFFSET(SegDs) );
output( "\tpushl %d(%%edx)\n", CONTEXTOFFSET(SegEs) );
output( "\tpushw 0x98(%%edx)\n"); /* SegDs */
output( "\tpushl 0x94(%%edx)\n"); /* SegEs */
output( "\tpopl %%es\n" );
output( "\tpushl %d(%%edx)\n", CONTEXTOFFSET(SegFs) );
output( "\tpushl 0x90(%%edx)\n"); /* SegFs */
output( "\tpopl %%fs\n" );
output( "\tpushl %d(%%edx)\n", CONTEXTOFFSET(SegGs) );
output( "\tpushl 0x8c(%%edx)\n"); /* SegGs */
output( "\tpopl %%gs\n" );
output( "\tmovl %d(%%edx),%%ebp\n", CONTEXTOFFSET(Ebp) );
output( "\tmovl %d(%%edx),%%esi\n", CONTEXTOFFSET(Esi) );
output( "\tmovl %d(%%edx),%%edi\n", CONTEXTOFFSET(Edi) );
output( "\tmovl %d(%%edx),%%eax\n", CONTEXTOFFSET(Eax) );
output( "\tmovl %d(%%edx),%%ebx\n", CONTEXTOFFSET(Ebx) );
output( "\tmovl %d(%%edx),%%ecx\n", CONTEXTOFFSET(Ecx) );
output( "\tmovl %d(%%edx),%%edx\n", CONTEXTOFFSET(Edx) );
output( "\tmovl 0xb4(%%edx),%%ebp\n"); /* Ebp */
output( "\tmovl 0xa0(%%edx),%%esi\n"); /* Esi */
output( "\tmovl 0x9c(%%edx),%%edi\n"); /* Edi */
output( "\tmovl 0xb0(%%edx),%%eax\n"); /* Eax */
output( "\tmovl 0xa4(%%edx),%%ebx\n"); /* Ebx */
output( "\tmovl 0xac(%%edx),%%ecx\n"); /* Ecx */
output( "\tmovl 0xa8(%%edx),%%edx\n"); /* Edx */
/* Get the 16-bit ds */
output( "\tpopw %%ds\n" );
@ -775,38 +772,37 @@ static void BuildCallFrom32Regs(void)
/* Build the context structure */
output( "\tmovl %%eax,%d(%%ebp)\n", CONTEXTOFFSET(Eax) - STACK_SPACE );
output( "\tmovl %%eax,0xb0(%%esp)\n" ); /* Eax */
output( "\tpushfl\n" );
output( "\tpopl %%eax\n" );
output( "\tmovl %%eax,%d(%%ebp)\n", CONTEXTOFFSET(EFlags) - STACK_SPACE );
output( "\tmovl %%eax,0xc0(%%esp)\n"); /* EFlags */
output( "\tmovl 0(%%ebp),%%eax\n" );
output( "\tmovl %%eax,%d(%%ebp)\n", CONTEXTOFFSET(Ebp) - STACK_SPACE );
output( "\tmovl %%ebx,%d(%%ebp)\n", CONTEXTOFFSET(Ebx) - STACK_SPACE );
output( "\tmovl %%ecx,%d(%%ebp)\n", CONTEXTOFFSET(Ecx) - STACK_SPACE );
output( "\tmovl %%edx,%d(%%ebp)\n", CONTEXTOFFSET(Edx) - STACK_SPACE );
output( "\tmovl %%esi,%d(%%ebp)\n", CONTEXTOFFSET(Esi) - STACK_SPACE );
output( "\tmovl %%edi,%d(%%ebp)\n", CONTEXTOFFSET(Edi) - STACK_SPACE );
output( "\tmovl %%eax,0xb4(%%esp)\n"); /* Ebp */
output( "\tmovl %%ebx,0xa4(%%esp)\n"); /* Ebx */
output( "\tmovl %%ecx,0xac(%%esp)\n"); /* Ecx */
output( "\tmovl %%edx,0xa8(%%esp)\n"); /* Edx */
output( "\tmovl %%esi,0xa0(%%esp)\n"); /* Esi */
output( "\tmovl %%edi,0x9c(%%esp)\n"); /* Edi */
output( "\txorl %%eax,%%eax\n" );
output( "\tmovw %%cs,%%ax\n" );
output( "\tmovl %%eax,%d(%%ebp)\n", CONTEXTOFFSET(SegCs) - STACK_SPACE );
output( "\tmovl %%eax,0xbc(%%esp)\n"); /* SegCs */
output( "\tmovw %%es,%%ax\n" );
output( "\tmovl %%eax,%d(%%ebp)\n", CONTEXTOFFSET(SegEs) - STACK_SPACE );
output( "\tmovl %%eax,0x94(%%esp)\n"); /* SegEs */
output( "\tmovw %%fs,%%ax\n" );
output( "\tmovl %%eax,%d(%%ebp)\n", CONTEXTOFFSET(SegFs) - STACK_SPACE );
output( "\tmovl %%eax,0x90(%%esp)\n"); /* SegFs */
output( "\tmovw %%gs,%%ax\n" );
output( "\tmovl %%eax,%d(%%ebp)\n", CONTEXTOFFSET(SegGs) - STACK_SPACE );
output( "\tmovl %%eax,0x8c(%%esp)\n"); /* SegGs */
output( "\tmovw %%ss,%%ax\n" );
output( "\tmovl %%eax,%d(%%ebp)\n", CONTEXTOFFSET(SegSs) - STACK_SPACE );
output( "\tmovl %%eax,0xc8(%%esp)\n"); /* SegSs */
output( "\tmovw %%ds,%%ax\n" );
output( "\tmovl %%eax,%d(%%ebp)\n", CONTEXTOFFSET(SegDs) - STACK_SPACE );
output( "\tmovl %%eax,0x98(%%esp)\n"); /* SegDs */
output( "\tmovw %%ax,%%es\n" ); /* set %es equal to %ds just in case */
output( "\tmovl $0x%x,%%eax\n", CONTEXT86_FULL );
output( "\tmovl %%eax,%d(%%ebp)\n", CONTEXTOFFSET(ContextFlags) - STACK_SPACE );
output( "\tmovl $0x10007,0(%%esp)\n"); /* ContextFlags */
output( "\tmovl 16(%%ebp),%%eax\n" ); /* Get %eip at time of call */
output( "\tmovl %%eax,%d(%%ebp)\n", CONTEXTOFFSET(Eip) - STACK_SPACE );
output( "\tmovl %%eax,0xb8(%%esp)\n"); /* Eip */
/* Transfer the arguments */
@ -822,7 +818,7 @@ static void BuildCallFrom32Regs(void)
output( "\trep\n\tmovsl\n" ); /* copy args */
output( "1:\tleal %d(%%ebp),%%eax\n", -STACK_SPACE ); /* get addr of context struct */
output( "\tmovl %%eax,(%%edi)\n" ); /* and pass it as extra arg */
output( "\tmovl %%esi,%d(%%ebp)\n", CONTEXTOFFSET(Esp) - STACK_SPACE );
output( "\tmovl %%esi,%d(%%ebp)\n", 0xc4 /* Esp */ - STACK_SPACE );
/* Call the entry point */
@ -833,29 +829,29 @@ static void BuildCallFrom32Regs(void)
/* Restore the context structure */
output( "2:\tpushl %d(%%ecx)\n", CONTEXTOFFSET(SegEs) );
output( "2:\tpushl 0x94(%%ecx)\n"); /* SegEs */
output( "\tpopl %%es\n" );
output( "\tpushl %d(%%ecx)\n", CONTEXTOFFSET(SegFs) );
output( "\tpushl 0x90(%%ecx)\n"); /* SegFs */
output( "\tpopl %%fs\n" );
output( "\tpushl %d(%%ecx)\n", CONTEXTOFFSET(SegGs) );
output( "\tpushl 0x8c(%%ecx)\n"); /* SegGs */
output( "\tpopl %%gs\n" );
output( "\tmovl %d(%%ecx),%%edi\n", CONTEXTOFFSET(Edi) );
output( "\tmovl %d(%%ecx),%%esi\n", CONTEXTOFFSET(Esi) );
output( "\tmovl %d(%%ecx),%%edx\n", CONTEXTOFFSET(Edx) );
output( "\tmovl %d(%%ecx),%%ebx\n", CONTEXTOFFSET(Ebx) );
output( "\tmovl %d(%%ecx),%%eax\n", CONTEXTOFFSET(Eax) );
output( "\tmovl %d(%%ecx),%%ebp\n", CONTEXTOFFSET(Ebp) );
output( "\tmovl 0x9c(%%ecx),%%edi\n"); /* Edi */
output( "\tmovl 0xa0(%%ecx),%%esi\n"); /* Esi */
output( "\tmovl 0xa8(%%ecx),%%edx\n"); /* Edx */
output( "\tmovl 0xa4(%%ecx),%%ebx\n"); /* Ebx */
output( "\tmovl 0xb0(%%ecx),%%eax\n"); /* Eax */
output( "\tmovl 0xb4(%%ecx),%%ebp\n"); /* Ebp */
output( "\tpushl %d(%%ecx)\n", CONTEXTOFFSET(SegSs) );
output( "\tpushl 0xc8(%%ecx)\n"); /* SegSs */
output( "\tpopl %%ss\n" );
output( "\tmovl %d(%%ecx),%%esp\n", CONTEXTOFFSET(Esp) );
output( "\tmovl 0xc4(%%ecx),%%esp\n"); /* Esp */
output( "\tpushl %d(%%ecx)\n", CONTEXTOFFSET(EFlags) );
output( "\tpushl %d(%%ecx)\n", CONTEXTOFFSET(SegCs) );
output( "\tpushl %d(%%ecx)\n", CONTEXTOFFSET(Eip) );
output( "\tpushl %d(%%ecx)\n", CONTEXTOFFSET(SegDs) );
output( "\tmovl %d(%%ecx),%%ecx\n", CONTEXTOFFSET(Ecx) );
output( "\tpushl 0xc0(%%ecx)\n"); /* EFlags */
output( "\tpushl 0xbc(%%ecx)\n"); /* SegCs */
output( "\tpushl 0xb8(%%ecx)\n"); /* Eip */
output( "\tpushl 0x98(%%ecx)\n"); /* SegDs */
output( "\tmovl 0xac(%%ecx),%%ecx\n"); /* Ecx */
output( "\tpopl %%ds\n" );
output( "\tiret\n" );