diff --git a/components/libc/cplusplus/cxx_crt_init.c b/components/libc/cplusplus/cxx_crt_init.c index 9e5262c101..c5d1e434b5 100644 --- a/components/libc/cplusplus/cxx_crt_init.c +++ b/components/libc/cplusplus/cxx_crt_init.c @@ -34,6 +34,18 @@ rt_weak void *__dso_handle = 0; #endif +/** + * @brief This function initializes the C++ runtime environment for ARM and GCC compilers. + * + * @note If there is no SHT$$INIT_ARRAY section, calling $Super$$__cpp_initialize__aeabi_() will cause an error + * in ARMCC compiler. Therefore, this function manually iterates through the base addresses of the + * SHT$$INIT_ARRAY section to call the constructor functions of each object. In GCC compiler, this function + * uses the __ctors_start__ and __ctors_end__ global variables to determine the range of constructor function + * pointers and calls each constructor function of every object in that range. + * + * @return Returns 0 if the initialization of the C++ runtime environment is successful. Otherwise, it returns + * an error code indicating the failure of the operation. + */ rt_weak int cplusplus_system_init(void) { #if defined(__ARMCC_VERSION)