diff options
| author | Grissiom <[email protected]> | 2015-01-22 17:22:01 +0800 |
|---|---|---|
| committer | Grissiom <[email protected]> | 2015-01-22 17:27:17 +0800 |
| commit | 01ab0c1d1ef31fc7f36d518661e4141c0eaf4c5f (patch) | |
| tree | b2d678f7215dd7f1217e52b0dfd3bcb6f97288b7 /components/cplusplus | |
| parent | 247556819072e6fd0be9dae831ad8854df5cb3ff (diff) | |
crt_init: fix hardfault in Keil toolchain when there is no cpp object
If there is no SHT$$INIT_ARRAY, calling
$Super$$__cpp_initialize__aeabi_() will fault. At least until Keil5.12
the problem still exists. So we have to initialize the C++ runtime our
own.
Diffstat (limited to 'components/cplusplus')
| -rw-r--r-- | components/cplusplus/crt_init.c | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/components/cplusplus/crt_init.c b/components/cplusplus/crt_init.c index 4c4451a5c3..e345052edd 100644 --- a/components/cplusplus/crt_init.c +++ b/components/cplusplus/crt_init.c @@ -51,8 +51,26 @@ int cplusplus_system_init(void) (*ctors_func)(); } #elif defined(__CC_ARM) +# if 1 + /* If there is no SHT$$INIT_ARRAY, calling + * $Super$$__cpp_initialize__aeabi_() will fault. At least until Keil5.12 + * the problem still exists. So we have to initialize the C++ runtime our + * own. */ + typedef void PROC(); + extern const unsigned long SHT$$INIT_ARRAY$$Base[]; + extern const unsigned long SHT$$INIT_ARRAY$$Limit[]; + const unsigned long *base = SHT$$INIT_ARRAY$$Base; + const unsigned long *lim = SHT$$INIT_ARRAY$$Limit; + + for (; base != lim; base++) + { + PROC *proc = (PROC*)((const char*)base + *base); + (*proc)(); + } +# else /* call armcc lib to initialize cplusplus */ $Super$$__cpp_initialize__aeabi_(); +# endif #endif return 0; |
