# ld: section .data overlaps with .bss in region RAM

- **ID:** `embedded/linker-section-overlap-ram`
- **Domain:** embedded
- **Category:** build_error
- **Verification:** ai_generated
- **Fix Rate:** 92%

## Root Cause

The linker script has incorrect memory region definitions or section placement, causing the .data (initialized data) and .bss (zero-initialized data) sections to overlap in RAM, typically due to misaligned start addresses or insufficient region size.

## Workarounds

1. **Edit the linker script (e.g., STM32FLASH.ld) to add explicit alignment between .data and .bss. Example: .data : { *(.data) } >RAM AT>FLASH . = ALIGN(4); .bss : { *(.bss) } >RAM** (95% success)
   ```
   Edit the linker script (e.g., STM32FLASH.ld) to add explicit alignment between .data and .bss. Example: .data : { *(.data) } >RAM AT>FLASH . = ALIGN(4); .bss : { *(.bss) } >RAM
   ```
2. **Use the --print-memory-usage and --print-map flags to inspect section placement, then adjust the RAM region length to accommodate both sections.** (88% success)
   ```
   Use the --print-memory-usage and --print-map flags to inspect section placement, then adjust the RAM region length to accommodate both sections.
   ```

## Dead Ends

- **** — Simply increasing the RAM region size in the linker script without adjusting the section start addresses may shift the overlap but not resolve it. (65% fail)
- **** — Removing the .bss section entirely (by setting all variables to initialized) is not a scalable solution and may cause other linker errors. (80% fail)
