summaryrefslogtreecommitdiff
path: root/components
diff options
context:
space:
mode:
authorbernard <[email protected]>2017-01-31 13:16:01 +0800
committerbernard <[email protected]>2017-01-31 13:16:01 +0800
commit876a9148e7fc632b88d0b69d749f050cb12de803 (patch)
tree0b7533288b30196406f719e631ec94ecdbad9a46 /components
parent924fc4fa881e1ebd981b8a56091c68b6c4d1024a (diff)
[C++] Add WEAK for cplusplus_system_init routine.
Diffstat (limited to 'components')
-rw-r--r--components/cplusplus/crt_init.c19
1 files changed, 8 insertions, 11 deletions
diff --git a/components/cplusplus/crt_init.c b/components/cplusplus/crt_init.c
index 0f89b35636..8641f93f40 100644
--- a/components/cplusplus/crt_init.c
+++ b/components/cplusplus/crt_init.c
@@ -22,6 +22,7 @@
* 2014-12-03 Bernard Add copyright header.
* 2014-12-29 Bernard Add cplusplus initialization for ARMCC.
* 2016-06-28 Bernard Add _init/_fini routines for GCC.
+* 2016-10-02 Bernard Add WEAK for cplusplus_system_init routine.
*/
#include <rtthread.h>
@@ -44,22 +45,18 @@ void _fini()
}
#endif
+WEAK
int cplusplus_system_init(void)
{
#if defined(__GNUC__) && !defined(__CC_ARM)
- extern unsigned char __ctors_start__;
- extern unsigned char __ctors_end__;
- typedef void (*func)(void);
+ typedef void (*pfunc) ();
+ extern pfunc __ctors_start__[];
+ extern pfunc __ctors_end__[];
+ pfunc *p;
- /* .ctors initalization */
- func *ctors_func;
+ for (p = __ctors_start__; p < __ctors_end__; p++)
+ (*p)();
- for (ctors_func = (func *)&__ctors_start__;
- ctors_func < (func *)&__ctors_end__;
- ctors_func ++)
- {
- (*ctors_func)();
- }
#elif defined(__CC_ARM)
/* If there is no SHT$$INIT_ARRAY, calling
* $Super$$__cpp_initialize__aeabi_() will cause fault. At least until Keil5.12