diff options
author | Vegard Storheil Eriksen <zyp@jvnv.net> | 2011-09-03 15:25:23 +0200 |
---|---|---|
committer | Vegard Storheil Eriksen <zyp@jvnv.net> | 2011-09-03 15:25:23 +0200 |
commit | 28284d92087d8915f0032a6edb76a622d9d07966 (patch) | |
tree | 8815f9a490bb3835e1d562f7930a70e51bc7e5a2 | |
parent | 7fd8db2c1c2dea60d5e96e2a47e5dde2039e94f0 (diff) |
Call constructors and destructors.
-rw-r--r-- | entry.cpp | 16 |
1 files changed, 16 insertions, 0 deletions
@@ -3,12 +3,18 @@ int main(); +typedef void (*funcp_t)(); + // Symbols from linker script. extern uint32_t _data_rom; extern uint32_t _data_start; extern uint32_t _data_end; extern uint32_t _bss_start; extern uint32_t _bss_end; +extern funcp_t _init_array_start; +extern funcp_t _init_array_end; +extern funcp_t _fini_array_start; +extern funcp_t _fini_array_end; void __attribute__((naked)) entry() { // Initialize clock. @@ -30,11 +36,21 @@ void __attribute__((naked)) entry() { } // Call constructors. + funcp_t* fp = &_init_array_start; + + while(fp < &_init_array_end) { + (*fp++)(); + } // Call main(). main(); // Call destructors. + fp = &_fini_array_start; + + while(fp < &_fini_array_end) { + (*fp++)(); + } // Halt. while(1); |