Repository navigation
[components][libc] cplusplus_system_init 补上 .init_array 的构造函数 - #11856
cms19859230182-lang wants to merge 1 commit into
Conversation
|
👋 感谢您对 RT-Thread 的贡献!Thank you for your contribution to RT-Thread! 为确保代码符合 RT-Thread 的编码规范,请在你的仓库中执行以下步骤运行代码格式化工作流(如果格式化CI运行失败)。 🛠 操作步骤 | Steps
完成后,提交将自动更新至 如有问题欢迎联系我们,再次感谢您的贡献!💐 |
📌 Code Review Assignment🏷️ Tag: componentsReviewers: @Maihuanyi Changed Files (Click to expand)
🏷️ Tag: components_libcReviewers: @GorrayLi @mysterywolf Changed Files (Click to expand)
📊 Current Review Status (Last Updated: 2026-10-08 19:34 CST)
📝 Review Instructions
|
指针比较改走 uintptr_t,for 循环补上花括号。
38e2573 to
479b204
Compare
Fixes #11778
新版 GCC 把 C++ 全局构造函数放进 .init_array,不再放 .ctors。
cplusplus_system_init() 原来只跑 ctors_start 到 ctors_end 这一段,
而很多 BSP 的链接脚本没把 .init_array 收进这个区间,全局对象的构造函数就没被调用。
现在再把 __init_array_start 到 __init_array_end 跑一遍。这两个符号声明成 weak,
链接脚本没提供时就是空,直接跳过,不会链接失败。如果脚本已经把 .init_array
合并进 ctors 区间了,两段重叠,也跳过,避免构造函数跑两遍。
在 bsp/simulator 上打开 RT_USING_CPLUSPLUS 编过,rtthread.elf 里能看到 cplusplus_system_init。