Skip to content

fix(inspect): make the default symbols view readable - #133

Open
adi0x90 wants to merge 1 commit into
masterfrom
fix/inspect-symbols-default-view
Open

adi0x90 wants to merge 1 commit into
masterfrom
fix/inspect-symbols-default-view

Conversation

@adi0x90

@adi0x90 adi0x90 commented Nov 30, 2026 •

Copy link
Copy Markdown
Member

Problem

fat inspect symbols --file jtag_lab.elf (an ESP32-C6 app ELF) printed 4,841 lines:

  • every symbol, sorted by address, with no limit;
  • 2,837 zero-size labels and 1,616 absolute symbols (register offsets such as RV_STK_*, peripheral bases such as LP_I2C, and ROM functions such as _vfprintf_r) before the first real symbol;
  • an alias warning on one line naming about 130 symbols.

The total was also too high: 215,966 B against 175,738 B actually in the image. It counted aliased address ranges more than once and included ROM functions that sit outside the image.

Change

  • Default table: largest symbols first, capped at 25 rows. --limit N changes the cap and --limit 0 removes it. CSV, JSONL and --json stay complete unless --limit is given.
  • Hidden by default: zero-size, absolute and undefined symbols, with a count of how many were hidden. --all brings them back, and so does selecting exact names with --name or --names-file.
  • Bytes-by-section summary at the top whenever rows are left out.
  • Aliases counted once: the total is the union of address ranges per section. The warning now gives the overlap in bytes and up to three short example groups.
  • Footer: the legend lists only the type letters that appear. The N sizes summed: … line is gone, and the per-term sum is shown only for 2–8 rows with no overlap.
  • --diff text output lists only changed, added and removed rows; --json still has every row.
  • --help: descriptions added for the flags that had none.

JSON schema moves to elf-symbols/v3. total_size now means covered bytes, and overlap_size, sections, hidden and omitted_count are new fields. The feature is still under Unreleased, so no released schema changes.

Result on jtag_lab.elf

The table output is now 51 lines:

Bytes by section
│ .flash.text       │     833 │ 95.2 KiB (97,490 B) │ 55.5% │
│ .iram0.text       │     529 │ 45.4 KiB (46,456 B) │ 26.4% │
│ .dram0.bss        │     152 │ 13.4 KiB (13,713 B) │  7.8% │
…
Largest 25 of 1,898 symbols
│ 0x4080dff0 │ 0x2000 │ 8.0 KiB (8,192 B) │  4.7% │ B │ .dram0.bss    │ _ZN12_GLOBAL__N_17g_ar… │
│ 0x42021b10 │  0xa90 │ 2.6 KiB (2,704 B) │  1.5% │ r │ .flash.rodata │ g_sine_model            │
…
… 1,873 more not shown; --limit N shows more, --limit 0 or --all shows every row
! 49 addresses are shared by aliases (_open_r = esp_vfs_open; …); shared bytes are counted once in the total
Hidden: 2,837 zero-size, 99 absolute symbols that occupy no bytes in this image; --all includes them
B = writable .bss, D = writable .data, r = read-only, T = code
Total matched bytes: 175,738 (0x2ae7a) in 1,898 symbols; 4,896 B of aliased ranges counted once

Verification

  • cargo test --workspace --no-fail-fast: 2,165 passed, 0 failed, 220 suites
  • cargo fmt --all --check and cargo clippy -p firmware-analysis-toolkit --all-targets are clean
  • Built on adi-mac and run against jtag_lab.elf with these flag sets:
    • the default (no flags)
    • --all
    • --filter, --name (including a missing name)
    • --in-ram --limit 5 --demangle
    • --format csv, --format jsonl, --json, --json --limit 3
    • --diff

Not changed here

  • --in-ram and --writable include .flash.init_array, because the section has SHF_WRITE set. That is how the existing code classifies regions.
  • Table width still comes from COLUMNS and falls back to 100, as in report.rs. Most shells don't export COLUMNS, so long names are truncated unless --width is passed.

@adi0x90
adi0x90 force-pushed the fix/inspect-symbols-default-view branch from 23a1f70 to b172733 Compare November 30, 2026 08:57
`fat inspect symbols --file app.elf` printed every symbol sorted by address.
On an ESP32-C6 application ELF that was 4,841 lines: 2,837 zero-size labels
and 1,616 absolute symbols (register offsets, peripheral bases, ROM
functions) before the first real symbol, followed by a single-line alias
warning naming ~130 symbols. The total also summed aliased ranges and ROM
functions, overstating image bytes by 23% (215,966 vs 175,738).

- Sort by size, largest first, and cap tables at 25 rows (`--limit N`,
  `--limit 0`); CSV, JSONL and `--json` stay complete unless limited.
- Hide zero-size, absolute and undefined symbols by default and report how
  many were hidden; `--all` or exact `--name` selections include them.
- Lead a truncated table with a bytes-by-section summary.
- Count each covered address range once per section, so aliases no longer
  double-count; report the overlap and up to three short alias examples.
- Show only the legend letters that appear, and drop the long
  "N sizes summed" line.
- List only changed, added and removed rows in text diffs.
- Document the previously undescribed flags in `--help`.

The JSON schema moves to elf-symbols/v3: `total_size` is now covered bytes,
and `overlap_size`, `sections`, `hidden` and `omitted_count` are new.
@adi0x90
adi0x90 force-pushed the fix/inspect-symbols-default-view branch from b172733 to d7e6cc3 Compare November 30, 2026 09:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant