CodeSizer: Why is that binary so big?
Summary
CodeSizer is a static code size profiling tool for embedded firmware that uses objdump and addr2line to attribute code size to inline call trees and generates an HTML report.
View Cached Full Text
Cached at: 07/20/26, 09:35 AM
Wren6991/CodeSizer
Source: https://github.com/Wren6991/CodeSizer
CodeSizer
Why is that binary so big?
What
CodeSizer is a static code size profiling tool.
In size-focused embedded firmware development, the final binary is heavily inlined and link-time-optimised. A single function symbol may cover dozens of inlinees. CodeSizer uses objdump and addr2line to unwind the inline call stack at every instruction address, so code size can be attributed to the correct node in the inline call tree within each function.
The output is a static HTML report file, with a small amount of JavaScript for UI features like toggling expand/collapse of the tree view.
How
From the interactive help:
usage: codesizer.py [-h] [--cross-prefix CROSS_PREFIX] [--section SECTION]
elf output
Analyse static code size of an ELF file. Disassemble via objdump, unwind inline
call stacks via addr2line, and emit a static HTML report.
positional arguments:
elf input ELF file
output output HTML file
options:
-h, --help show this help message and exit
--cross-prefix CROSS_PREFIX
prefix for objdump and addr2line (default: riscv32-unknown-
elf-)
--section, -j SECTION
Specify ELF section. Pass multiple times for multiple
sections. If unspecified, .text is used.
The correct toolchain must be present on your $PATH with the given prefix, or you must specify a full file path to the toolchain binaries. For example:
-
If you’ve installed the
gcc-arm-none-eabipackage on Ubuntu, then use--cross-prefix=arm-none-eabi-. -
If you’ve installed a
riscv-gnu-toolchainbuild at/opt/riscv/gcc15, then use--cross-prefix=/opt/riscv/gcc15/bin/riscv32-unknown-elf-.
Example Output
This HTML report was generated by the following command:
./codesizer.py --cross-prefix arm-none-eabi- arm-bootrom.elf arm-bootrom.html -j .text -j .secure_gateways
The ELF file comes from the RP2350 A4 bootrom release.
Similar Articles
Sloc Cloc and Code 4.0 (scc) - Finding the files that need the most attention
This article announces the release of Sloc Cloc and Code (scc) version 4.0.0, featuring new hotspot analysis to identify code files requiring attention based on complexity and commit history.
Seriously, what is the large code-model even for?
The article explores the limitations of GCC's large code model (mcmodel=large), particularly its inability to handle Thread Local Storage (TLS) with 32-bit relocations, making it unusable for truly large binaries despite its stated purpose.
Golfing Zig ELF Binaries (2025)
A technical deep-dive into reducing the size of Zig ELF binaries, starting from 2180K to under 500 bytes by stripping debug info, switching to ReleaseSmall, and using a freestanding target.
C programmers commit fresh crimes against readability
The 2025 International Obfuscated C Code Contest winners are announced, featuring 23 entries including Adrian Cable's Subleq computer emulator that enables software preservation through a one-instruction set architecture.
@rauchg: http://fx.sh is 6.3mb. It starts up in 10µs¹. It's a Zig-compiled static ELF binary, or an even smaller 𝚕𝚒𝚋𝚏𝚡.𝚠𝚊…
A new open-source coding agent tool named fx, compiled with Zig, features a tiny 6.3MB binary, instant startup in 10µs, and WebAssembly support for optimized performance and embeddability.