Darwin/Mac OS X _init/_fini and _end symbols support

Pierre d'Herbemont stegefin at free.fr
Sat Mar 20 15:20:47 CST 2004


Hi!

Here is an other fix for Darwin. There is no __init nor __fini function 
defined on darwin to call all the init and fini functions. You have to 
use some obscure function provided by the system. So here goes the fix 
for winelib :)

Also I did add the fix for the _end symbol you (Alexandre) you 
suggested, that I forgot to submit before.

Thanks,

Pierre

ChangeLog:
Darwin Support for _init/_fini functions and _end symbol.

-------------- next part --------------
Index: tools/winebuild/spec32.c
===================================================================
RCS file: /home/wine/wine/tools/winebuild/spec32.c,v
retrieving revision 1.77
diff -u -r1.77 spec32.c
--- tools/winebuild/spec32.c	16 Feb 2004 20:24:32 -0000	1.77
+++ tools/winebuild/spec32.c	20 Mar 2004 21:10:57 -0000
@@ -522,7 +522,12 @@
     fprintf( outfile, "}\n" );
     fprintf( outfile, "#endif\n" );
 
+#ifdef __APPLE__
+    fprintf( outfile, "static char _end[4];\n" );
+#else
     fprintf( outfile, "extern char _end[];\n" );
+#endif
+    
     fprintf( outfile, "extern int __wine_spec_data_start[], __wine_spec_exports[];\n\n" );
 
 #ifdef __i386__
@@ -569,8 +574,24 @@
     fprintf( outfile, "extern char **__wine_main_argv;\n" );
     fprintf( outfile, "extern char **__wine_main_environ;\n" );
     fprintf( outfile, "extern unsigned short **__wine_main_wargv;\n" );
+#ifdef __APPLE__
+    fprintf( outfile, "extern _dyld_func_lookup(char *, void *);");
+    fprintf( outfile, "void _init(int argc, char** argv, char** chr)\n" );
+    fprintf( outfile, "{ \n");
+    fprintf( outfile, "		void (*init)(void);\n");
+    fprintf( outfile, "		_dyld_func_lookup(\"__dyld_make_delayed_module_initializer_calls\", (unsigned long *)&init);\n");
+    fprintf( outfile, "		init(); \n");
+    fprintf( outfile, "}\n");
+    fprintf( outfile, "void _fini()\n" );
+    fprintf( outfile, "{ \n");
+    fprintf( outfile, "		void (*fini)(void);\n");
+    fprintf( outfile, "		_dyld_func_lookup(\"__dyld_mod_term_funcs\", (unsigned long *)&fini);\n");
+    fprintf( outfile, "		fini(); \n");
+    fprintf( outfile, "}\n");
+#else
     fprintf( outfile, "extern void _init(int, char**, char**);\n" );
     fprintf( outfile, "extern void _fini();\n" );
+#endif
 
     characteristics = subsystem = 0;
     switch(spec->mode)


More information about the wine-patches mailing list