From 0d5dac515a5a8a824e5817e0175208e0307dbedc Mon Sep 17 00:00:00 2001 From: Stefan Agner Date: Sun, 17 Aug 2014 22:26:30 +0200 Subject: [PATCH] init: call pre_main before C++ constructors This moves the platform specific initialization function pre_main in front of C++ constructors. This is especially necessary for platforms which need to setup the stack pointer (pre_main itself is inline, hence no stack needed for this function). --- lib/cm3/vector.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/cm3/vector.c b/lib/cm3/vector.c index 4523d31d..c2041f33 100644 --- a/lib/cm3/vector.c +++ b/lib/cm3/vector.c @@ -74,6 +74,9 @@ void WEAK __attribute__ ((naked)) reset_handler(void) *dest++ = 0; } + /* might be provided by platform specific vector.c */ + pre_main(); + /* Constructors. */ for (fp = &__preinit_array_start; fp < &__preinit_array_end; fp++) { (*fp)(); @@ -82,9 +85,6 @@ void WEAK __attribute__ ((naked)) reset_handler(void) (*fp)(); } - /* might be provided by platform specific vector.c */ - pre_main(); - /* Call the application's entry point. */ main();