Fellows, this is actually a proposal, yet code committed: binutils-current should be updated shortly, gcc-3.4 is in CVS on SF.
So, this is all about how mspgcc will handle startup for different languages. Mainly this has been done cause of c++/java/fortran implementation. This does not discard old approach and backward compatible. This extends current .text section layout only. Section .text is broken down into a couple of sections which will be arranged on a link stage (you will see a few tricks from AVR port): .init .init0 ... .init9 constructors list destructors list .text .fini9 ... .fini0 .fini Subsection '.init' remains a first field of text section. An old style (gcc-3.2 and earlier) start-up code will reside here with no changes (see doc.txt). Subsection init0: the _reset_vector__ is defined here. only one machine instruction will be executed here: mov #23168, &288 ; disable watchdog Subsection init2: in this section all data from data section being initialized. Subsection init4: in this section all data from bss section being zeroed Subsection init6: being linked only when constructors necesary. all global constructors will be called here. stack pointer will be initialized here with RAM top. so, main's attribute reserve(x) will be useless. Subsection init9: jump to main. constructors list: data pointers to the global constructors. Being accessed from subsection init6 by __do_global_ctors() destructors list: data pointers to the global constructors. Being accessed from subsection fini6 by __do_global_dtors() .text: user code will reside here (including ROMs user defined sections) Subsection fini9: this one where __stop_progExec__ label resides. executes one machine insn: push r15 Subsection fini6: being linked only when destructors necesary. all global destructors will be called here. subsection fini0: where real stop prog exec being executed: pop r15 __stop_progLoop: bis r15, r2 jmp __stop_progLoop subsection fini: for backward compatibility... User can put his code to sections init1,3,5,7,8, text, text.*, his.own.sections, fini8,7,5,4,3,2,1 There are no branches between section. All the code in there will be executed consequentally. Actually, this might be much easier (better?) to call constructors in main's code just before first main's instruction after stack initialization, but then user cannot pass parametres to main(). Actually, this might be much easier (better?) to call destructors just before returning from main(). But then destructors will not be called when execution aborts with abort(). So, any suggestion? cheers, ~d -- /******************************************************************** ("`-''-/").___..--''"`-._ (\ Dimmy the Wild UA1ACZ `6_ 6 ) `-. ( ).`-.__.`) Enterprise Information Sys (_Y_.)' ._ ) `._ `. ``-..-' Nevsky prospekt, 20 / 44 _..`--'_..-_/ /--'_.' ,' Saint Petersburg, Russia (il),-'' (li),' ((!.-' +7 (812) 3468202, 5585314 ********************************************************************/