Skip to content

fix(symbols): flash-mapped output sections are not RAM (#1832) - #1838

Merged
zackees merged 2 commits into
mainfrom
agent/symbols-flash-rodata-1832
Nov 1, 2026
Merged

zackees merged 2 commits into
mainfrom
agent/symbols-flash-rodata-1832

Conversation

@zackees

@zackees zackees commented Nov 1, 2026

Copy link
Copy Markdown
Member

symbols: a flash-mapped output section beats nm's type letter (#1832)

fbuild symbols counted 293 symbols of one ESP32-S3 Arduino Blink ELF as
region: "ram" although the linker had placed them in .flash.rodata:
total_ram read 25,565 B instead of 13,803 B (+85% inflated), and 8 more
(vtable for …, typeinfo …) were still wrong after the first fix.

Two independent sites derived the region from something weaker than the
actual placement:

  1. fbuild-core/src/symbol_analysis/mod.rs — build_fine_grained_map only
    consulted the output section for weak objects (V/v). Everything else
    used the nm letter, so ESP-IDF __func__/__FUNCTION__ string literals
    (d, folded by the linker into .flash.rodata) were counted as DRAM.
  2. fbuild-build-engine/src/symbol_analyzer/reference_analysis.rs — the
    debug-info pass for V/v re-derived the region from the input
    section flags; .data.rel.ro vtables are SHF_WRITE before relocation
    even though the linker lands them in flash-mapped .flash.rodata.

Both now ask one shared rule, is_flash_mapped_output_section(name)
(.flash* output sections): those bytes are part of the image, so the
region is flash whatever the type letter or pre-relocation flags say.
Everything else keeps its previous behaviour — in particular .iram0.data
storage is still counted as RAM, because it occupies real DRAM even though
it is loaded from the image.

Verification

Unit (new, build_fine_grained_map_flash_rodata_beats_nm_type_letter):
a d in .flash.rodata -> flash, a V there -> flash, a d in
.dram0.data -> ram, a d in .iram0.data -> ram (the last one pins the
no-regression case).

End to end on the real bench/blink ESP32-S3 ELF (firmware.elf +
firmware.map, xtensa-esp32s3-elf-nm), same inputs, CLI before/after:

before after
symbols region=ram in .flash* 293 (11,772 B) 0
total_ram 25,565 B 13,803 B (-11,762 B)
.flash.rodata flash / ram split 207 / 293 508 / 0

The 293 flips are ram -> flash only; no symbol moved in the other
direction. .dram0.data (209) and .dram0.bss (167) are unchanged.

Gates run on this branch: bash test 4128 passed / 0 failed (47 suites,
rc 0, TMPDIR=/home/niteris/t), cargo clippy --workspace --all-targets -- -D warnings rc 0, cargo fmt clean, platform boundary rows=44; dylint_rows=43 rc 0, ci/check_test_layout.py ok. No new file exceeds the
1000-LOC cap (mod.rs 943 -> 961, tests.rs 920 -> 997).

Closes #1832. Relates to FastLED/FastLED#4982 (budget guard that fired on
the inflated total_ram).

…1832)

`fbuild symbols` reported 293 symbols of one ESP32 Arduino Blink ELF as
`region: "ram"` although the linker had placed every one of them in
`.flash.rodata`: `total_ram` read 25,565 B instead of 13,803 B.

Two sites trusted something weaker than the actual placement:

- `build_fine_grained_map` consulted the output section only for weak
  objects (`V`/`v`); everything else used the nm letter, so ESP-IDF
  `__func__`/`__FUNCTION__` string literals (`d`, folded into
  `.flash.rodata`) were counted as DRAM.
- the debug-info pass for `V`/`v` re-derived the region from the *input*
  section flags; `.data.rel.ro` vtables are `SHF_WRITE` before relocation
  even though the linker lands them in flash-mapped `.flash.rodata`.

Both now ask one shared rule, `is_flash_mapped_output_section`: bytes in a
`.flash*` output section are part of the image, so the region is `flash`
whatever the type letter or pre-relocation flags say. Everything else is
unchanged — `.iram0.data` storage stays RAM, because it occupies real
DRAM even though the image loads it.
@coderabbitai

coderabbitai Bot commented Nov 1, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

Run configuration

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • Trigger review
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@zackees
zackees added this pull request to the merge queue Nov 1, 2026
Merged via the queue into main with commit 4cde73c Nov 1, 2026
29 checks passed
@zackees
zackees deleted the agent/symbols-flash-rodata-1832 branch November 1, 2026 05:47
@fastled-project-sync fastled-project-sync Bot moved this to Triage in FastLED Tracker Nov 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Triage

Development

Successfully merging this pull request may close these issues.

fbuild symbols: ESP32 .flash.rodata symbols classified as region=ram, inflating total_ram

1 participant