[libc][cpp] 增加 cxx_crt_init.c 函数注释 (#7535)

This commit is contained in:
Mengxi-Xu 2023-05-20 13:27:55 +08:00 committed by GitHub
parent a36d2df236
commit 1e5dc5509e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 12 additions and 0 deletions

View File

@ -34,6 +34,18 @@ rt_weak void *__dso_handle = 0;
#endif #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) rt_weak int cplusplus_system_init(void)
{ {
#if defined(__ARMCC_VERSION) #if defined(__ARMCC_VERSION)