Repository navigation
fix(symbols): resolve the linked ELF, not build_info's flashable .bin (#1144) - #2223
Merged
Merged
Conversation
…#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.
Open
6 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The bug (measured on a real ESP32-C6, not a fixture)
build_info.json'sprog_pathis the flashable image — fbuild writesfirmware.binthere — butdiscover_elf_in_project()returned that pathverbatim 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):
So
fbuild symbols <dir>refused every fbuild-built project, andfbuild debugwould have handed gdb a raw binary. Same helper is used byfbuild bloat lookup.Fix
elf_from_build_infonow yields a candidate ELF: an already-.elfprog_pathis returned unchanged; any otherprog_path(the.binshape)maps to the ELF linked beside it —
<stem>.elffirst, thenfirmware.elfin the same directory. When neither exists the step yields nothing, so the
existing
.fbuild/build/**walk still finds the ELF (e.g. after a cacheclean, where
prog_pathnames 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— theproduction shape (
.../release/firmware.bin+.../release/firmware.elf);asserts the result is not the
.bin, and that the publicdiscover_elf_in_projectagrees.build_info_bin_prog_path_falls_back_to_firmware_elf_in_its_directory—a differently-stemmed image (
app.bin) still resolves viafirmware.elf.build_info_bin_prog_path_without_a_sibling_falls_through_to_the_build_walk— no sibling: the build_info step must return
Noneand 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).
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 twoleft == rightfailures.soldr cargo clippy -p fbuild-build-engine --all-targets -- -D warningsexit 0;
soldr cargo fmt -p fbuild-build-engine -- --checkexit 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 debugstill cannot complete an attach on a stock fbuild host, andthe reason is not this bug:
riscv32-esp-elf-15.2.0_20251204bin/has 33 binaries, zeromatching
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).-D CONFIG_ESP_SYSTEM_PANIC_GDBSTUB=1escape hatch isinert. It is compiled into prebuilt
libesp_system.a(present infirmware.map); with the flag added the firmware byte size is identical(262 930 B) and a real
abort()still printed the register dump andrebooted 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 crashdumpremain).