From eb9a863116212a937b280531c727530a2318d77e Mon Sep 17 00:00:00 2001 From: Alexandre Julliard Date: Tue, 11 Dec 2001 00:50:33 +0000 Subject: [PATCH] Exported CALL32_Regs from ntdll, renamed to __wine_call_from_32_regs to follow the naming convention for this type of functions. Split 16 and 32-bit relay functions into separate files, and moved the 32-bit ones to dlls/ntdll. --- dlls/ntdll/.cvsignore | 1 + dlls/ntdll/Makefile.in | 7 ++++- dlls/ntdll/ntdll.spec | 3 +++ if1632/.cvsignore | 2 +- if1632/Makefile.in | 6 ++--- include/winnt.h | 2 +- relay32/relay386.c | 2 +- relay32/snoop.c | 4 +-- tools/winebuild/build.h | 3 ++- tools/winebuild/import.c | 9 ++++++- tools/winebuild/main.c | 41 +++++++++++++++++++----------- tools/winebuild/relay.c | 55 ++++++++++++++++++++++++++++++++++------ tools/winebuild/spec32.c | 2 +- 13 files changed, 102 insertions(+), 35 deletions(-) diff --git a/dlls/ntdll/.cvsignore b/dlls/ntdll/.cvsignore index aeace462df1..09083b5016f 100644 --- a/dlls/ntdll/.cvsignore +++ b/dlls/ntdll/.cvsignore @@ -1,2 +1,3 @@ Makefile ntdll.spec.c +relay32.s diff --git a/dlls/ntdll/Makefile.in b/dlls/ntdll/Makefile.in index 3d7058aa02b..f3d214b0fde 100644 --- a/dlls/ntdll/Makefile.in +++ b/dlls/ntdll/Makefile.in @@ -3,7 +3,6 @@ TOPOBJDIR = ../.. SRCDIR = @srcdir@ VPATH = @srcdir@ MODULE = ntdll -SOVERSION = 1.0 EXTRALIBS = $(LIBUNICODE) C_SRCS = \ @@ -27,6 +26,9 @@ C_SRCS = \ time.c \ wcstring.c +GEN_ASM_SRCS = \ + relay32.s + EXTRA_OBJS = \ $(TOPOBJDIR)/files/files.o \ $(TOPOBJDIR)/if1632/if1632.o \ @@ -59,4 +61,7 @@ SUBDIRS = \ $(EXTRA_OBJS): dummy @cd `dirname $@` && $(MAKE) `basename $@` +relay32.s: $(WINEBUILD) + $(LDPATH) $(WINEBUILD) @DLLFLAGS@ -o $@ -relay32 + ### Dependencies: diff --git a/dlls/ntdll/ntdll.spec b/dlls/ntdll/ntdll.spec index 7d6bf16a5ff..e12175ecf3c 100644 --- a/dlls/ntdll/ntdll.spec +++ b/dlls/ntdll/ntdll.spec @@ -1021,6 +1021,9 @@ debug_channels (atom cdrom console debug delayhlp dll dosfs dosmem file fixup @ cdecl -norelay __wine_exception_handler(ptr ptr ptr ptr) __wine_exception_handler @ cdecl -norelay __wine_finally_handler(ptr ptr ptr ptr) __wine_finally_handler +# Relays +@ cdecl -norelay -i386 __wine_call_from_32_regs() __wine_call_from_32_regs + # Debugging interface @ cdecl -norelay wine_dbgstr_an(str long) wine_dbgstr_an @ cdecl -norelay wine_dbgstr_wn(str long) wine_dbgstr_wn diff --git a/if1632/.cvsignore b/if1632/.cvsignore index 8207650e9ec..2427368ab3c 100644 --- a/if1632/.cvsignore +++ b/if1632/.cvsignore @@ -1,3 +1,3 @@ Makefile -asmrelay.s +relay16.s thunk.glue.c diff --git a/if1632/Makefile.in b/if1632/Makefile.in index 8e72f0d0371..754bae0ce4a 100644 --- a/if1632/Makefile.in +++ b/if1632/Makefile.in @@ -12,7 +12,7 @@ C_SRCS = \ thunk.c GEN_ASM_SRCS = \ - asmrelay.s + relay16.s GLUE = thunk.c @@ -23,7 +23,7 @@ all: $(MODULE).o $(MODULE).o: $(OBJS) Makefile.in $(TOPSRCDIR)/Make.rules.in $(LDCOMBINE) $(OBJS) -o $@ -asmrelay.s: $(WINEBUILD) - $(LDPATH) $(WINEBUILD) @DLLFLAGS@ -o $@ -relay +relay16.s: $(WINEBUILD) + $(LDPATH) $(WINEBUILD) @DLLFLAGS@ -o $@ -relay16 ### Dependencies: diff --git a/include/winnt.h b/include/winnt.h index e5ede8aa63f..172fa5587f0 100644 --- a/include/winnt.h +++ b/include/winnt.h @@ -1106,7 +1106,7 @@ typedef CONTEXT *PCONTEXT; #define _DEFINE_REGS_ENTRYPOINT( name, fn, args ) \ __ASM_GLOBAL_FUNC( name, \ - "call " __ASM_NAME("CALL32_Regs") "\n\t" \ + "call " __ASM_NAME("__wine_call_from_32_regs") "\n\t" \ ".long " __ASM_NAME(#fn) "\n\t" \ ".byte " #args ", " #args ) #define DEFINE_REGS_ENTRYPOINT_0( name, fn ) \ diff --git a/relay32/relay386.c b/relay32/relay386.c index fc10b694183..3ea67580265 100644 --- a/relay32/relay386.c +++ b/relay32/relay386.c @@ -381,7 +381,7 @@ void WINAPI RELAY_DoCallFrom32Regs( CONTEXT86 *context ) void WINAPI RELAY_CallFrom32Regs(void); __ASM_GLOBAL_FUNC( RELAY_CallFrom32Regs, - "call " __ASM_NAME("CALL32_Regs") "\n\t" + "call " __ASM_NAME("__wine_call_from_32_regs") "\n\t" ".long " __ASM_NAME("RELAY_DoCallFrom32Regs") ",0" ); /*********************************************************************** diff --git a/relay32/snoop.c b/relay32/snoop.c index 30e5f42d1a0..585378b4d50 100644 --- a/relay32/snoop.c +++ b/relay32/snoop.c @@ -381,10 +381,10 @@ void WINAPI SNOOP_DoReturn( CONTEXT86 *context ) /* assembly wrappers that save the context */ __ASM_GLOBAL_FUNC( SNOOP_Entry, - "call " __ASM_NAME("CALL32_Regs") "\n\t" + "call " __ASM_NAME("__wine_call_from_32_regs") "\n\t" ".long " __ASM_NAME("SNOOP_DoEntry") ",0" ); __ASM_GLOBAL_FUNC( SNOOP_Return, - "call " __ASM_NAME("CALL32_Regs") "\n\t" + "call " __ASM_NAME("__wine_call_from_32_regs") "\n\t" ".long " __ASM_NAME("SNOOP_DoReturn") ",0" ); #else /* !__i386__ */ diff --git a/tools/winebuild/build.h b/tools/winebuild/build.h index 1ef1a914b87..e47949717fe 100644 --- a/tools/winebuild/build.h +++ b/tools/winebuild/build.h @@ -149,7 +149,8 @@ extern int output_res16_data( FILE *outfile ); extern int output_res16_directory( unsigned char *buffer ); extern void BuildGlue( FILE *outfile, FILE *infile ); -extern void BuildRelays( FILE *outfile ); +extern void BuildRelays16( FILE *outfile ); +extern void BuildRelays32( FILE *outfile ); extern void BuildSpec16File( FILE *outfile ); extern void BuildSpec32File( FILE *outfile ); extern SPEC_TYPE ParseTopLevel( FILE *file ); diff --git a/tools/winebuild/import.c b/tools/winebuild/import.c index 1909134195c..d0a2c8cf669 100644 --- a/tools/winebuild/import.c +++ b/tools/winebuild/import.c @@ -207,7 +207,7 @@ static int remove_symbol_holes(void) /* add the extra undefined symbols that will be contained in the generated spec file itself */ static void add_extra_undef_symbols(void) { - const char *extras[8]; + const char *extras[10]; int i, count = 0; #define ADD_SYM(name) \ @@ -247,6 +247,13 @@ static void add_extra_undef_symbols(void) ADD_SYM( "GetProcAddress" ); } + for (i = 0; i < nb_entry_points; i++) + { + ORDDEF *odp = EntryPoints[i]; + if (odp->type != TYPE_REGISTER) continue; + ADD_SYM( "__wine_call_from_32_regs" ); + } + if (count) { for (i = 0; i < count; i++) add_undef_symbol( extras[i] ); diff --git a/tools/winebuild/main.c b/tools/winebuild/main.c index e85263ede7d..6db57a81d7b 100644 --- a/tools/winebuild/main.c +++ b/tools/winebuild/main.c @@ -55,7 +55,7 @@ static FILE *input_file; static FILE *output_file; /* execution mode */ -static enum { MODE_NONE, MODE_SPEC, MODE_GLUE, MODE_RELAY } exec_mode = MODE_NONE; +static enum { MODE_NONE, MODE_SPEC, MODE_GLUE, MODE_RELAY16, MODE_RELAY32 } exec_mode = MODE_NONE; /* open the input file */ static void open_input( const char *name ) @@ -92,21 +92,23 @@ static void do_output( const char *arg ); static void do_usage(void); static void do_spec( const char *arg ); static void do_glue( const char *arg ); -static void do_relay(void); +static void do_relay16(void); +static void do_relay32(void); static void do_sym( const char *arg ); static void do_lib( const char *arg ); static const struct option_descr option_table[] = { - { "-fPIC", 0, do_pic, "-fPIC Generate PIC code" }, - { "-h", 0, do_usage, "-h Display this help message" }, - { "-L", 1, do_lib, "-L directory Look for imports libraries in 'directory'" }, - { "-o", 1, do_output, "-o name Set the output file name (default: stdout)" }, - { "-sym", 1, do_sym, "-sym file.o Read the list of undefined symbols from 'file.o'" }, - { "-spec", 1, do_spec, "-spec file.spec Build a .c file from a spec file" }, - { "-glue", 1, do_glue, "-glue file.c Build the 16-bit glue for a .c file" }, - { "-relay", 0, do_relay, "-relay Build the relay assembly routines" }, - { NULL, 0, NULL, NULL } + { "-fPIC", 0, do_pic, "-fPIC Generate PIC code" }, + { "-h", 0, do_usage, "-h Display this help message" }, + { "-L", 1, do_lib, "-L directory Look for imports libraries in 'directory'" }, + { "-o", 1, do_output, "-o name Set the output file name (default: stdout)" }, + { "-sym", 1, do_sym, "-sym file.o Read the list of undefined symbols from 'file.o'" }, + { "-spec", 1, do_spec, "-spec file.spec Build a .c file from a spec file" }, + { "-glue", 1, do_glue, "-glue file.c Build the 16-bit glue for a .c file" }, + { "-relay16", 0, do_relay16, "-relay16 Build the 16-bit relay assembly routines" }, + { "-relay32", 0, do_relay32, "-relay32 Build the 32-bit relay assembly routines" }, + { NULL, 0, NULL, NULL } }; static void do_pic(void) @@ -154,10 +156,16 @@ static void do_glue( const char *arg ) open_input( arg ); } -static void do_relay(void) +static void do_relay16(void) { if (exec_mode != MODE_NONE) do_usage(); - exec_mode = MODE_RELAY; + exec_mode = MODE_RELAY16; +} + +static void do_relay32(void) +{ + if (exec_mode != MODE_NONE) do_usage(); + exec_mode = MODE_RELAY32; } static void do_sym( const char *arg ) @@ -239,8 +247,11 @@ int main(int argc, char **argv) case MODE_GLUE: BuildGlue( output_file, input_file ); break; - case MODE_RELAY: - BuildRelays( output_file ); + case MODE_RELAY16: + BuildRelays16( output_file ); + break; + case MODE_RELAY32: + BuildRelays32( output_file ); break; default: do_usage(); diff --git a/tools/winebuild/relay.c b/tools/winebuild/relay.c index bb981e95cf6..145bdfd6052 100644 --- a/tools/winebuild/relay.c +++ b/tools/winebuild/relay.c @@ -1027,7 +1027,7 @@ static void BuildCallFrom32Regs( FILE *outfile ) /* Function header */ - function_header( outfile, "CALL32_Regs" ); + function_header( outfile, "__wine_call_from_32_regs" ); /* Allocate some buffer space on the stack */ @@ -1130,11 +1130,11 @@ static void BuildCallFrom32Regs( FILE *outfile ) /******************************************************************* - * BuildRelays + * BuildRelays16 * - * Build all the relay callbacks + * Build all the 16-bit relay callbacks */ -void BuildRelays( FILE *outfile ) +void BuildRelays16( FILE *outfile ) { /* File header */ @@ -1191,9 +1191,6 @@ void BuildRelays( FILE *outfile ) /* CBClientThunkSLEx routine */ BuildCallTo32CBClient( outfile, TRUE ); - /* 32-bit register entry point */ - BuildCallFrom32Regs( outfile ); - fprintf( outfile, PREFIX"Call16_End:\n" ); fprintf( outfile, "\t.globl "PREFIX"Call16_End\n" ); @@ -1221,9 +1218,51 @@ void BuildRelays( FILE *outfile ) fprintf( outfile, PREFIX "Call16_Ret_End:\n" ); } +/******************************************************************* + * BuildRelays32 + * + * Build all the 32-bit relay callbacks + */ +void BuildRelays32( FILE *outfile ) +{ + /* File header */ + + fprintf( outfile, "/* File generated automatically. Do not edit! */\n\n" ); + fprintf( outfile, "\t.text\n" ); + +#ifdef USE_STABS + if (output_file_name) + { + char buffer[1024]; + getcwd(buffer, sizeof(buffer)); + fprintf( outfile, "\t.file\t\"%s\"\n", output_file_name ); + + /* + * The stabs help the internal debugger as they are an indication that it + * is sensible to step into a thunk/trampoline. + */ + fprintf( outfile, ".stabs \"%s/\",100,0,0,Code_Start\n", buffer); + fprintf( outfile, ".stabs \"%s\",100,0,0,Code_Start\n", output_file_name ); + fprintf( outfile, "Code_Start:\n\n" ); + } +#endif + /* 32-bit register entry point */ + BuildCallFrom32Regs( outfile ); + +#ifdef USE_STABS + fprintf( outfile, "\t.stabs \"\",100,0,0,.Letext\n"); + fprintf( outfile, ".Letext:\n"); +#endif +} + #else /* __i386__ */ -void BuildRelays( FILE *outfile ) +void BuildRelays16( FILE *outfile ) +{ + fprintf( outfile, "/* File not used with this architecture. Do not edit! */\n\n" ); +} + +void BuildRelays32( FILE *outfile ) { fprintf( outfile, "/* File not used with this architecture. Do not edit! */\n\n" ); } diff --git a/tools/winebuild/spec32.c b/tools/winebuild/spec32.c index d3882682c70..f754c80fbbf 100644 --- a/tools/winebuild/spec32.c +++ b/tools/winebuild/spec32.c @@ -407,7 +407,7 @@ static void output_register_funcs( FILE *outfile ) "asm(\".align %d\\n\\t\"\n" " \"" __ASM_FUNC("%s") "\\n\\t\"\n" " \"" PREFIX "%s:\\n\\t\"\n" - " \"call " PREFIX "CALL32_Regs\\n\\t\"\n" + " \"call " PREFIX "__wine_call_from_32_regs\\n\\t\"\n" " \".long " PREFIX "%s\\n\\t\"\n" " \".byte %d,%d\");\n", get_alignment(4),