Always put the dll constructor in the .init section, and like the

.spec.o file first to ensure correct calling order of the constructors.
This commit is contained in:
Alexandre Julliard 2000-12-02 20:38:47 +00:00
parent 519346a47e
commit 218188c2d2
4 changed files with 20 additions and 11 deletions

View File

@ -15,7 +15,7 @@ SONAME = lib$(MODULE).so
IMPORTLIBS = $(IMPORTS:%=$(DLLDIR)/lib%.$(LIBEXT))
ALLNAMES = lib$(MODULE).so $(ALTNAMES:%=lib%.so)
SPEC_SRCS = $(ALTNAMES:%=%.spec)
ALL_OBJS = $(OBJS) $(MODULE).spec.o
ALL_OBJS = $(MODULE).spec.o $(OBJS)
ALL_LIBS = -L$(TOPOBJDIR) -lwine $(EXTRALIBS) $(LIBS)
all: lib$(MODULE).$(LIBEXT) $(ALTNAMES:%=lib%.$(LIBEXT))

View File

@ -10,7 +10,7 @@
DEFS = @DLLFLAGS@ $(EXTRADEFS)
LDDLLFLAGS = @LDDLLFLAGS@
ALL_OBJS = $(OBJS) $(MODULE).spec.o
ALL_OBJS = $(MODULE).spec.o $(OBJS)
ALL_LIBS = -L$(TOPOBJDIR) -lwine $(EXTRALIBS) $(LIBS)
SYMBOLFILE = $(MODULE).tmp.o

View File

@ -772,16 +772,17 @@ void BuildSpec16File( FILE *outfile )
/* Output the DLL constructor */
fprintf( outfile, "#ifdef __GNUC__\n" );
fprintf( outfile, "static void %s_init(void) __attribute__((constructor));\n", DLLName );
fprintf( outfile, "static void init(void) __attribute__((unused));\n" );
fprintf( outfile, "#else /* defined(__GNUC__) */\n" );
fprintf( outfile, "static void __asm__dummy_dll_init(void) {\n" );
fprintf( outfile, "#endif /* defined(__GNUC__) */\n" );
fprintf( outfile, "asm(\"\\t.section\t.init ,\\\"ax\\\"\\n\"\n" );
fprintf( outfile, " \"\\tcall %s_init\\n\"\n", DLLName );
fprintf( outfile, " \"\\tcall init\\n\"\n" );
fprintf( outfile, " \"\\t.previous\\n\");\n" );
fprintf( outfile, "#ifndef __GNUC__\n" );
fprintf( outfile, "}\n" );
fprintf( outfile, "#endif /* defined(__GNUC__) */\n" );
fprintf( outfile, "static void %s_init(void) { __wine_register_dll_16( &descriptor ); }\n",
DLLName );
fprintf( outfile, "static void init(void) { __wine_register_dll_16( &descriptor ); }\n" );
}

View File

@ -341,7 +341,7 @@ static void output_stub_funcs( FILE *outfile )
fprintf( outfile, " unsigned int params;\n" );
fprintf( outfile, " const void *info[15];\n" );
fprintf( outfile, " } rec;\n" );
fprintf( outfile, " extern void RtlRaiseException( struct exc_record * );\n\n" );
fprintf( outfile, " extern void __stdcall RtlRaiseException( struct exc_record * );\n\n" );
fprintf( outfile, " rec.code = 0x%08x;\n", EXCEPTION_WINE_STUB );
fprintf( outfile, " rec.flags = %d;\n", EH_NONCONTINUABLE );
fprintf( outfile, " rec.rec = 0;\n" );
@ -444,6 +444,12 @@ void BuildSpec32File( FILE *outfile )
fprintf( outfile, "static const char dllname[] = \"%s\";\n\n", DLLName );
#ifdef __i386__
fprintf( outfile, "#define __stdcall __attribute__((__stdcall__))\n\n" );
#else
fprintf( outfile, "#define __stdcall\n\n" );
#endif
/* Output the stub functions */
output_stub_funcs( outfile );
@ -549,13 +555,13 @@ void BuildSpec32File( FILE *outfile )
case SPEC_MODE_CUIEXE:
if (!init_func) init_func = has_imports ? "main" : "wine_main";
fprintf( outfile,
"\n#include <winbase.h>\n"
"int _ARGC;\n"
"\nint _ARGC;\n"
"char **_ARGV;\n"
"static void __wine_exe_main(void)\n"
"{\n"
" extern int %s( int argc, char *argv[] );\n"
" extern int __wine_get_main_args( char ***argv );\n"
" extern void __stdcall ExitProcess(int);\n"
" _ARGC = __wine_get_main_args( &_ARGV );\n"
" ExitProcess( %s( _ARGC, _ARGV ) );\n"
"}\n\n", init_func, init_func );
@ -665,11 +671,12 @@ void BuildSpec32File( FILE *outfile )
/* Output the DLL constructor */
fprintf( outfile, "#ifdef __GNUC__\n" );
fprintf( outfile, "static void init(void) __attribute__((constructor));\n" );
fprintf( outfile, "static void init(void) __attribute__((unused));\n" );
if (nr_debug)
fprintf( outfile, "static void fini(void) __attribute__((destructor));\n" );
fprintf( outfile, "static void fini(void) __attribute__((unused));\n" );
fprintf( outfile, "#else /* defined(__GNUC__) */\n" );
fprintf( outfile, "static void __asm__dummy_dll_init(void) {\n" );
fprintf( outfile, "#endif /* defined(__GNUC__) */\n" );
fprintf( outfile, "asm(\"\\t.section\t.init ,\\\"ax\\\"\\n\"\n" );
fprintf( outfile, " \"\\tcall init\\n\"\n" );
fprintf( outfile, " \"\\t.previous\\n\");\n" );
@ -679,6 +686,7 @@ void BuildSpec32File( FILE *outfile )
fprintf( outfile, " \"\\tcall fini\\n\"\n" );
fprintf( outfile, " \"\\t.previous\\n\");\n" );
}
fprintf( outfile, "#ifndef __GNUC__\n" );
fprintf( outfile, "}\n" );
fprintf( outfile, "#endif /* defined(__GNUC__) */\n\n" );
fprintf( outfile, "static void init(void)\n{\n" );