Mail Archives: djgpp-workers/2006/10/16/13:44:55
This is a multi-part message in MIME format.
--------------030900070007060105090208
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
Attached is a patch for DJGPP to execute constructors in LIFO order, to
match other platforms, like MinGW (gccmain.c) and gcc on Linux
(libgcc.c/crtstuff.c). On those platforms, the __CTOR_LIST__ is always
processed backwards. Destructor order as implemented in DJGPP now is
correct (FIFO).
The fix is by Andre Victor (av1ctor AT yahoo DOT com DOT br) of the FreeBASIC
project - we stumbled across this problem while working on runtime
initialization problems (the FB runtime's constructor must run before
any user constructors).
Thanks,
-- Daniel Verkamp <daniel AT drv DOT nu>
--------------030900070007060105090208
Content-Type: text/plain;
name="djgpp-ctor-order.patch"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
filename="djgpp-ctor-order.patch"
--- crt0/_main.c.orig 2006-10-16 13:15:38.250000000 -0400
+++ crt0/_main.c 2006-10-16 12:22:37.000000000 -0400
@@ -14,6 +14,9 @@
if (been_there_done_that == __bss_count)
return;
been_there_done_that = __bss_count;
- for (i=0; i<djgpp_last_ctor-djgpp_first_ctor; i++)
+
+ /* fixed: the global constructors should be called in LIFO order, see libgcc2.c or crtstuff.c */
+
+ for (i=(djgpp_last_ctor-djgpp_first_ctor)-1; i>=0; i--)
djgpp_first_ctor[i]();
}
--------------030900070007060105090208--
- Raw text -