diff --git a/tools/winebuild/build.h b/tools/winebuild/build.h index 398d54200c7..f01ae4f04ff 100644 --- a/tools/winebuild/build.h +++ b/tools/winebuild/build.h @@ -304,7 +304,6 @@ extern void output_bin_res16_directory( DLLSPEC *spec, unsigned int data_offset extern void output_spec16_file( DLLSPEC *spec ); extern void output_fake_module16( DLLSPEC *spec16 ); extern void output_res_o_file( DLLSPEC *spec ); -extern void output_asm_relays(void); extern void output_asm_relays16(void); extern void BuildSpec32File( DLLSPEC *spec ); diff --git a/tools/winebuild/relay.c b/tools/winebuild/relay.c index 1cc6465f1c6..4b78f686b92 100644 --- a/tools/winebuild/relay.c +++ b/tools/winebuild/relay.c @@ -748,190 +748,6 @@ static void BuildCallTo32CBClient( int isEx ) } -/******************************************************************* - * build_call_from_regs_x86 - * - * Build a 32-bit-to-Wine call-back function for a 'register' function. - * 'args' is the number of dword arguments. - * - * Stack layout: - * ... - * (ebp+20) first arg - * (ebp+16) ret addr to user code - * (ebp+12) func to call (relative to relay code ret addr) - * (ebp+8) number of args - * (ebp+4) ret addr to relay code - * (ebp+0) saved ebp - * (ebp-128) buffer area to allow stack frame manipulation - * (ebp-332) CONTEXT86 struct - * (ebp-336) padding for stack alignment - * (ebp-336-n) CONTEXT86 *argument - * .... other arguments copied from (ebp+12) - * - * The entry point routine is called with a CONTEXT* extra argument, - * following the normal args. In this context structure, EIP_reg - * contains the return address to user code, and ESP_reg the stack - * pointer on return (with the return address and arguments already - * removed). - */ -static void build_call_from_regs_x86(void) -{ - static const int STACK_SPACE = 128 + 0x2cc /* sizeof(CONTEXT86) */; - - /* Function header */ - - output( "\t.text\n" ); - function_header( "__wine_call_from_regs" ); - - /* Allocate some buffer space on the stack */ - - output_cfi( ".cfi_startproc" ); - output( "\tpushl %%ebp\n" ); - output_cfi( ".cfi_adjust_cfa_offset 4" ); - output_cfi( ".cfi_rel_offset %%ebp,0" ); - output( "\tmovl %%esp,%%ebp\n" ); - output_cfi( ".cfi_def_cfa_register %%ebp" ); - output( "\tleal -%d(%%esp),%%esp\n", STACK_SPACE ); - - /* Build the context structure */ - - output( "\tmovl %%eax,0xb0(%%esp)\n" ); /* Eax */ - output( "\tpushfl\n" ); - output( "\tpopl %%eax\n" ); - output( "\tmovl %%eax,0xc0(%%esp)\n"); /* EFlags */ - output( "\tmovl 0(%%ebp),%%eax\n" ); - 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,0xbc(%%esp)\n"); /* SegCs */ - output( "\tmovw %%es,%%ax\n" ); - output( "\tmovl %%eax,0x94(%%esp)\n"); /* SegEs */ - output( "\tmovw %%fs,%%ax\n" ); - output( "\tmovl %%eax,0x90(%%esp)\n"); /* SegFs */ - output( "\tmovw %%gs,%%ax\n" ); - output( "\tmovl %%eax,0x8c(%%esp)\n"); /* SegGs */ - output( "\tmovw %%ss,%%ax\n" ); - output( "\tmovl %%eax,0xc8(%%esp)\n"); /* SegSs */ - output( "\tmovw %%ds,%%ax\n" ); - output( "\tmovl %%eax,0x98(%%esp)\n"); /* SegDs */ - output( "\tmovw %%ax,%%es\n" ); /* set %es equal to %ds just in case */ - - output( "\tmovl $0x10007,0(%%esp)\n"); /* ContextFlags */ - - output( "\tmovl 16(%%ebp),%%eax\n" ); /* Get %eip at time of call */ - output( "\tmovl %%eax,0xb8(%%esp)\n"); /* Eip */ - - /* Transfer the arguments */ - - output( "\tmovl 8(%%ebp),%%ecx\n" ); /* fetch number of args to copy */ - output( "\tleal 4(,%%ecx,4),%%edx\n" ); /* add 4 for context arg */ - output( "\tsubl %%edx,%%esp\n" ); - output( "\tandl $~15,%%esp\n" ); - output( "\tleal 20(%%ebp),%%esi\n" ); /* get %esp at time of call */ - output( "\tmovl %%esp,%%edi\n" ); - output( "\ttest %%ecx,%%ecx\n" ); - output( "\tjz 1f\n" ); - output( "\tcld\n" ); - 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", 0xc4 /* Esp */ - STACK_SPACE ); - - /* Call the entry point */ - - output( "\tmovl 4(%%ebp),%%eax\n" ); /* get relay code addr */ - output( "\taddl 12(%%ebp),%%eax\n" ); - output( "\tcall *%%eax\n" ); - output( "\tleal -%d(%%ebp),%%ecx\n", STACK_SPACE ); - - /* Restore the context structure */ - - output( "2:\tpushl 0x94(%%ecx)\n" ); /* SegEs */ - output( "\tpopl %%es\n" ); - output( "\tpushl 0x90(%%ecx)\n" ); /* SegFs */ - output( "\tpopl %%fs\n" ); - output( "\tpushl 0x8c(%%ecx)\n" ); /* SegGs */ - output( "\tpopl %%gs\n" ); - - output( "\tmovw %%ss,%%ax\n" ); - output( "\tcmpw 0xc8(%%ecx),%%ax\n" ); /* SegSs */ - output( "\tjne 3f\n" ); - - /* As soon as we have switched stacks the context structure could - * be invalid (when signal handlers are executed for example). Copy - * values on the target stack before changing ESP. */ - - output( "\tmovl 0xc4(%%ecx),%%eax\n" ); /* Esp */ - output( "\tleal -4*4(%%eax),%%eax\n" ); - - output( "\tmovl 0xc0(%%ecx),%%edx\n" ); /* EFlags */ - output( "\t.byte 0x36\n\tmovl %%edx,3*4(%%eax)\n" ); - output( "\tmovl 0xbc(%%ecx),%%edx\n" ); /* SegCs */ - output( "\t.byte 0x36\n\tmovl %%edx,2*4(%%eax)\n" ); - output( "\tmovl 0xb8(%%ecx),%%edx\n" ); /* Eip */ - output( "\t.byte 0x36\n\tmovl %%edx,1*4(%%eax)\n" ); - output( "\tmovl 0xb0(%%ecx),%%edx\n" ); /* Eax */ - output( "\t.byte 0x36\n\tmovl %%edx,0*4(%%eax)\n" ); - - output( "\tpushl 0x98(%%ecx)\n" ); /* SegDs */ - - output( "\tmovl 0x9c(%%ecx),%%edi\n" ); /* Edi */ - output( "\tmovl 0xa0(%%ecx),%%esi\n" ); /* Esi */ - output( "\tmovl 0xa4(%%ecx),%%ebx\n" ); /* Ebx */ - output( "\tmovl 0xa8(%%ecx),%%edx\n" ); /* Edx */ - output( "\tmovl 0xb4(%%ecx),%%ebp\n" ); /* Ebp */ - output( "\tmovl 0xac(%%ecx),%%ecx\n" ); /* Ecx */ - - output( "\tpopl %%ds\n" ); - output( "\tmovl %%eax,%%esp\n" ); - - output( "\tpopl %%eax\n" ); - output( "\tiret\n" ); - - output("3:\n"); - - /* Restore the context when the stack segment changes. We can't use - * the same code as above because we do not know if the stack segment - * is 16 or 32 bit, and 'movl' will throw an exception when we try to - * access memory above the limit. */ - - output( "\tmovl 0x9c(%%ecx),%%edi\n" ); /* Edi */ - output( "\tmovl 0xa0(%%ecx),%%esi\n" ); /* Esi */ - output( "\tmovl 0xa4(%%ecx),%%ebx\n" ); /* Ebx */ - output( "\tmovl 0xa8(%%ecx),%%edx\n" ); /* Edx */ - output( "\tmovl 0xb0(%%ecx),%%eax\n" ); /* Eax */ - output( "\tmovl 0xb4(%%ecx),%%ebp\n" ); /* Ebp */ - - output( "\tpushl 0xc8(%%ecx)\n" ); /* SegSs */ - output( "\tpopl %%ss\n" ); - output( "\tmovl 0xc4(%%ecx),%%esp\n" ); /* Esp */ - - 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" ); - output_cfi( ".cfi_endproc" ); - output_function_size( "__wine_call_from_regs" ); - - function_header( "__wine_restore_regs" ); - output_cfi( ".cfi_startproc" ); - output( "\tmovl 4(%%esp),%%ecx\n" ); - output( "\tjmp 2b\n" ); - output_cfi( ".cfi_endproc" ); - output_function_size( "__wine_restore_regs" ); -} - - /******************************************************************* * BuildPendingEventCheck * @@ -1027,27 +843,4 @@ void output_asm_relays16(void) output( "\n\t.data\n\t.align %d\n", get_alignment(4) ); output( "%s\n\t.long 0\n", asm_globl("CallTo16_DataSelector") ); output( "%s\n\t.long 0\n", asm_globl("CallTo16_TebSelector") ); - - output( "\t.text\n" ); - output( "%s:\n", asm_name("__wine_spec_thunk_text_32") ); - build_call_from_regs_x86(); - output_function_size( "__wine_spec_thunk_text_32" ); -} - - -/******************************************************************* - * output_asm_relays - * - * Build all the assembly relay callbacks - */ -void output_asm_relays(void) -{ - switch (target_cpu) - { - case CPU_x86: - build_call_from_regs_x86(); - break; - default: - break; - } } diff --git a/tools/winebuild/spec32.c b/tools/winebuild/spec32.c index 6536cd8a8b6..4a01238e0fb 100644 --- a/tools/winebuild/spec32.c +++ b/tools/winebuild/spec32.c @@ -651,7 +651,6 @@ void BuildSpec32File( DLLSPEC *spec ) output_stubs( spec ); output_exports( spec ); output_imports( spec ); - if (is_undefined( "__wine_call_from_regs" )) output_asm_relays(); if (needs_get_pc_thunk) output_get_pc_thunk(); output_resources( spec ); output_gnu_stack_note();