summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDanny Smith <dannysmith@users.sourceforge.net>2007-06-11 08:38:16 +0000
committerDanny Smith <dannysmith@users.sourceforge.net>2007-06-11 08:38:16 +0000
commit657d7a46108952faf4128e872db0be3475258540 (patch)
tree127d9c092b5d61771a1862eb03de532a5e8b2743
parent32f67ec6ff30838169d7ded39dcfd6a7706b36d7 (diff)
downloadcygnal-657d7a46108952faf4128e872db0be3475258540.tar.gz
cygnal-657d7a46108952faf4128e872db0be3475258540.tar.bz2
cygnal-657d7a46108952faf4128e872db0be3475258540.zip
* crt1.c (__mingw_CRTStartup): Add explicit call to libgcc's __main.
-rw-r--r--winsup/mingw/ChangeLog4
-rw-r--r--winsup/mingw/crt1.c9
2 files changed, 13 insertions, 0 deletions
diff --git a/winsup/mingw/ChangeLog b/winsup/mingw/ChangeLog
index ff74c3b36..ae7d1ec67 100644
--- a/winsup/mingw/ChangeLog
+++ b/winsup/mingw/ChangeLog
@@ -1,3 +1,7 @@
+2007-06-11 Danny Smith <dannysmith@users.sourceforge.net>
+
+ * crt1.c (__mingw_CRTStartup): Add explicit call to gcc's __main.
+
2007-05-08 Danny Smith <dannysmith@users.sourceforge.net>
* include/stdint.h (intptr_t): Fix typo.
diff --git a/winsup/mingw/crt1.c b/winsup/mingw/crt1.c
index ad8270a04..6ab7c1d56 100644
--- a/winsup/mingw/crt1.c
+++ b/winsup/mingw/crt1.c
@@ -29,6 +29,7 @@
#include "init.c"
#include "cpu_features.h"
+extern void __main ();
extern void _pei386_runtime_relocator (void);
extern int main (int, char **, char **);
@@ -219,6 +220,14 @@ __mingw_CRTStartup (void)
or in functions inlined into main. */
asm __volatile__ ("andl $-16, %%esp" : : : "%esp");
+ /* From libgcc.a, __main calls global class constructors via
+ __do_global_ctors, This in turn registers __do_global_dtors
+ as the first entry of the app's atexit table. We do this
+ explicitly at app startup rather than rely on gcc to generate
+ the call in main's prologue, since main may be imported from a dll
+ which has its own __do_global_ctors. */
+ __main ();
+
/*
* Call the main function. If the user does not supply one
* the one in the 'libmingw32.a' library will be linked in, and