Skip to content

Conversation

@EricRahm
Copy link
Collaborator

@EricRahm EricRahm commented Dec 1, 2025

When encountering a symbol table (SYMTAB or DYNSYM) whose sh_link field
does not point to a valid string table (STRTAB) section, bloaty would
previously throw an error and stop. This caused bloaty to fail on some
binaries, such as U-Boot, which have such sections.

This change modifies bloaty to warn about the invalid section and skip
it, allowing processing to continue. This matches the behavior of other
tools like readelf, which warn but do not fail on such binaries.

A lit test is also included.

Confirmed that bloaty can now read u-boot without throwing an error:

% build/130/bloaty u-boot -d compileunits
    FILE SIZE        VM SIZE
 --------------  --------------
  51.3%  4.43Mi  71.6%   446Ki    [340 Others]
  18.4%  1.59Mi   0.0%       0    [section .rel.debug_info]
  10.3%   913Ki   0.0%       0    [section .rel.debug_loc]
   4.1%   359Ki   0.0%       0    [section .debug_frame]
   2.1%   188Ki   0.0%       0    [section .debug_loc]
   1.6%   140Ki   0.0%       0    [section .rel.text]
   1.1%  98.9Ki   1.8%  11.1Ki    lib/efi_loader/efi_boottime.c
   1.1%  93.8Ki   3.3%  20.5Ki    drivers/net/e1000.c
   1.0%  91.7Ki   0.0%       0    [section .rel.debug_ranges]
   1.0%  90.5Ki   2.4%  14.8Ki    fs/fat/fat_write.c
   0.9%  81.6Ki  13.1%  81.6Ki    [section .rodata]
   0.9%  75.4Ki   1.7%  10.4Ki    fs/ext4/ext4_common.c
   0.8%  71.6Ki   1.4%  9.01Ki    cmd/eficonfig.c
   0.8%  67.4Ki   0.0%       0    [section .rel.debug_frame]
   0.7%  65.8Ki   0.3%  2.11Ki    drivers/core/ofnode.c
   0.7%  64.1Ki   1.2%  7.25Ki    boot/image-fit.c
   0.7%  63.8Ki   0.5%  3.18Ki    boot/fdt_support.c
   0.6%  57.3Ki   1.4%  8.71Ki    drivers/mmc/mmc.c
   0.6%  51.4Ki   0.5%  3.41Ki    drivers/pci/pci-uclass.c
   0.6%  51.2Ki   0.0%       0    [section .bss]
   0.6%  50.0Ki   0.8%  4.71Ki    drivers/usb/host/xhci.c
 100.0%  8.63Mi 100.0%   623Ki    TOTAL

Fixes #130

@EricRahm EricRahm requested a review from haberman December 2, 2025 00:42
@EricRahm
Copy link
Collaborator Author

EricRahm commented Dec 2, 2025

@haberman this is just converting a TRHOW to a WARN when an invalid strtab link is encountered.

When encountering a symbol table (SYMTAB or DYNSYM) whose sh_link field
does not point to a valid string table (STRTAB) section, Bloaty would
previously throw an error and stop. This caused Bloaty to fail on some
binaries, such as U-Boot, which have such sections.

This change modifies Bloaty to warn about the invalid section and then
continue processing using a synthetic "Anonymous" symbol name. The
existing `SymbolTable` alias is replaced with a class that supports
adding synthetic entries that aren't backed by the original file.

Fixes google#130
Verifies that Bloaty warns and continues when encountering a symbol table
with an invalid string table link, instead of crashing.
@EricRahm EricRahm merged commit 894ef64 into google:main Dec 10, 2025
9 checks passed
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.

bloaty: Tried to add range that is not covered by base map.

2 participants