diff options
| author | Bernard Xiong <[email protected]> | 2019-03-17 09:33:47 +0800 |
|---|---|---|
| committer | GitHub <[email protected]> | 2019-03-17 09:33:47 +0800 |
| commit | d778c9df25cbbd8e202a0133453e4c8b8e179eff (patch) | |
| tree | 6dd97c1487eacf0a6d858b7541866f865b9203de /components/cplusplus | |
| parent | 2d69172ad39a52e574a22b4374ee89848d832fe8 (diff) | |
| parent | 94e3f77f25249b52c6f72921a2d2564f68bcd6ff (diff) | |
Merge pull request #2455 from armink/lts-v3.1.x
Lts v3.1.x
Diffstat (limited to 'components/cplusplus')
| -rwxr-xr-x | components/cplusplus/crt_init.c | 27 |
1 files changed, 12 insertions, 15 deletions
diff --git a/components/cplusplus/crt_init.c b/components/cplusplus/crt_init.c index e67939feeb..3294b51a40 100755 --- a/components/cplusplus/crt_init.c +++ b/components/cplusplus/crt_init.c @@ -13,10 +13,10 @@ #include <rtthread.h> -#ifdef __CC_ARM +#if defined(__CC_ARM) || defined(__CLANG_ARM) extern void $Super$$__cpp_initialize__aeabi_(void); /* we need to change the cpp_initialize order */ -void $Sub$$__cpp_initialize__aeabi_(void) +RT_WEAK void $Sub$$__cpp_initialize__aeabi_(void) { /* empty */ } @@ -34,19 +34,9 @@ RT_WEAK void *__dso_handle = 0; #endif -RT_WEAK -int cplusplus_system_init(void) +RT_WEAK int cplusplus_system_init(void) { -#if defined(__GNUC__) && !defined(__CC_ARM) - typedef void (*pfunc) (); - extern pfunc __ctors_start__[]; - extern pfunc __ctors_end__[]; - pfunc *p; - - for (p = __ctors_start__; p < __ctors_end__; p++) - (*p)(); - -#elif defined(__CC_ARM) +#if defined(__CC_ARM) || defined(__CLANG_ARM) /* If there is no SHT$$INIT_ARRAY, calling * $Super$$__cpp_initialize__aeabi_() will cause fault. At least until Keil5.12 * the problem still exists. So we have to initialize the C++ runtime by ourself. @@ -63,9 +53,16 @@ int cplusplus_system_init(void) PROC *proc = (PROC*)((const char*)base + *base); (*proc)(); } +#elif defined(__GNUC__) + typedef void(*pfunc) (); + extern pfunc __ctors_start__[]; + extern pfunc __ctors_end__[]; + pfunc *p; + + for (p = __ctors_start__; p < __ctors_end__; p++) + (*p)(); #endif return 0; } INIT_COMPONENT_EXPORT(cplusplus_system_init); - |
