[C++] Add WEAK for cplusplus_system_init routine.
* 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
