embedded
build_error
ai_generated
true
arm-none-eabi-ld:段 .data 的 VMA 0x20000000 与段 .bss 的 VMA 0x20000000 在 RAM 区域重叠
arm-none-eabi-ld: section .data VMA 0x20000000 overlaps section .bss VMA 0x20000000 in region RAM
ID: embedded/arm-gcc-section-overlap-in-ram
95%修复率
90%置信度
1证据数
2023-11-08首次发现
版本兼容性
| 版本 | 状态 | 引入 | 弃用 | 备注 |
|---|---|---|---|---|
| ARM GCC 12.3.1 | active | — | — | — |
| GNU ld 2.40 | active | — | — | — |
| STM32CubeIDE 1.14.0 | active | — | — | — |
根因分析
链接脚本在 RAM 区域中为 .data 和 .bss 段定义了重叠的虚拟内存地址,通常是由于 LMA/VMA 对齐错误或缺少段填充。
English
Linker script defines .data and .bss sections with overlapping virtual memory addresses in RAM region, typically due to incorrect LMA/VMA alignment or missing section padding.
官方文档
https://gcc.gnu.org/onlinedocs/gcc-12.3.0/gnu_lnk.html解决方案
-
Edit linker script (.ld file) to add explicit alignment and gap between .data and .bss sections: . = ALIGN(4); .data : { *(.data) } >RAM AT>FLASH; . = ALIGN(4); .bss : { *(.bss) } >RAM; Ensure .bss VMA starts after .data end address, e.g., .bss VMA = .data VMA + SIZEOF(.data) + 4. -
Use the linker script's built-in PROVIDE and ASSERT to detect overlap at build time: add ASSERT(SIZEOF(.data) + SIZEOF(.bss) <= LENGTH(RAM), "RAM overflow"); in the script.
无效尝试
常见但无效的做法:
-
Increase RAM size in linker script (e.g., change RAM length from 64K to 128K)
90% 失败
Overlap is due to address assignment, not insufficient total RAM; increasing size does not separate overlapping addresses.
-
Move all variables to .data section by removing __attribute__((section(".bss")))
80% 失败
This may shift the problem but not resolve the underlying VMA collision; .data and .bss still share same base address.