Skip to content

fix(symbols): resolve the linked ELF, not build_info's flashable .bin (#1144) - #2223

Merged
zackees merged 1 commit into
mainfrom
agent/1144-prog-path-elf
Nov 30, 2026
Merged

zackees merged 1 commit into
mainfrom
agent/1144-prog-path-elf

Conversation

@zackees

@zackees zackees commented Nov 30, 2026

Copy link
Copy Markdown
Member

The bug (measured on a real ESP32-C6, not a fixture)

build_info.json's prog_path is the flashable image — fbuild writes
firmware.bin there — but discover_elf_in_project() returned that path
verbatim as if it were an ELF. On the attached ESP32-C6 (303A:1001,
/dev/ttyACM1, fixture: esp32-c6-devkitc-1 + board_upload.flash_size=4MB,
USB-CDC console, built by fbuild 2.5.50 in 204 s):

$ fbuild symbols .
ERROR fbuild::output: build failed: nm failed:
  .../riscv32-esp-elf-nm: .../.fbuild/build/esp32c6/release/firmware.bin:
  file format not recognized                       # exit 1

$ fbuild debug -e esp32c6 --no-flash --port /dev/ttyACM1
Using ELF: .../.fbuild/build/esp32c6/release/firmware.bin   # <- a .bin, for gdb

So fbuild symbols <dir> refused every fbuild-built project, and
fbuild debug would have handed gdb a raw binary. Same helper is used by
fbuild bloat lookup.

Fix

elf_from_build_info now yields a candidate ELF: an already-.elf
prog_path is returned unchanged; any other prog_path (the .bin shape)
maps to the ELF linked beside it — <stem>.elf first, then firmware.elf
in the same directory. When neither exists the step yields nothing, so the
existing .fbuild/build/** walk still finds the ELF (e.g. after a cache
clean, where prog_path names a directory that no longer exists).

discover_elf_in_project's documented order is unchanged.

Tests

Three new tests in symbol_analyzer/tests.rs:

  • build_info_prog_path_pointing_at_a_bin_resolves_the_sibling_elf — the
    production shape (.../release/firmware.bin + .../release/firmware.elf);
    asserts the result is not the .bin, and that the public
    discover_elf_in_project agrees.
  • build_info_bin_prog_path_falls_back_to_firmware_elf_in_its_directory —
    a differently-stemmed image (app.bin) still resolves via firmware.elf.
  • build_info_bin_prog_path_without_a_sibling_falls_through_to_the_build_walk
    — no sibling: the build_info step must return None and the
    .fbuild/build/** walk must supply the ELF.

Real output:

  • soldr cargo test -p fbuild-build-engine symbol_analyzer → 31 passed,
    0 failed, 3 ignored
    (584 filtered).
  • RED proven by restoring the pre-fix behaviour (elf_for_prog_path →
    Some(prog.to_path_buf())): the three tests FAIL, exit 101 —
    assertion left != right failed: a .bin prog_path must never be returned as an ELF, plus the two left == right failures.
  • soldr cargo clippy -p fbuild-build-engine --all-targets -- -D warnings
    exit 0; soldr cargo fmt -p fbuild-build-engine -- --check exit 0;
    ci/enforce_platform_boundary.py --print-totals → rows=0; dylint_rows=0.

What the same hardware run proved is still missing (not in this PR)

fbuild debug still cannot complete an attach on a stock fbuild host, and
the reason is not this bug:

  1. fbuild's ESP32 toolchain ships no gdb. The installed
    riscv32-esp-elf-15.2.0_20251204 bin/ has 33 binaries, zero
    matching gdb, and the error text says "Install the ESP32 GCC toolchain
    (it ships gdb alongside gcc)" — Espressif ships gdb as a separate
    package (riscv32-esp-elf-gdb).
  2. The documented -D CONFIG_ESP_SYSTEM_PANIC_GDBSTUB=1 escape hatch is
    inert.
    It is compiled into prebuilt libesp_system.a (present in
    firmware.map); with the flag added the firmware byte size is identical
    (262 930 B) and a real abort() still printed the register dump and
    rebooted instead of waiting for gdb.

Both need their own decisions (host-gdb fallback vs. downloading the gdb
package; the sdkconfig-override layer tracked separately), so they are
recorded on #1144 rather than smuggled into this fix.

#1144 stays open (CH32V injected stub + fbuild crashdump remain).

…#1144)

build_info.json's prog_path is the image that gets flashed, and fbuild
writes firmware.bin there. discover_elf_in_project returned that path
verbatim, so every consumer got a raw binary: on a real ESP32-C6,
`fbuild symbols <dir>` died with "riscv32-esp-elf-nm: .../firmware.bin:
file format not recognized" and `fbuild debug` printed
"Using ELF: .../firmware.bin" before handing it to gdb.

A non-.elf prog_path now maps to the ELF linked beside it (<stem>.elf,
then firmware.elf in the same directory); when neither exists the step
yields nothing and the .fbuild/build/** walk finds the ELF.
@zackees
zackees added this pull request to the merge queue Nov 30, 2026
Merged via the queue into main with commit 9ffa384 Nov 30, 2026
68 of 71 checks passed
@fastled-project-sync fastled-project-sync Bot moved this to Triage in FastLED Tracker Dec 1, 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.

1 participant