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
SDCC – Small Device C Compiler
SDCC is a Small Device C Compiler, a development tool for programming small and embedded systems in the C language.
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.
New Compiler based agent cuts costs by 2x and improves code intelligence (78.2% SWE-bench Verified @ 0.1¢)
Benzi is a compiler-backed coding agent that first compiles a codebase into a queryable map of calls, data flow, and class hierarchies, reportedly hitting 78.2% on SWE-bench Verified with DeepSeek V4 flash at under 10 cents per fix. It claims 2x less source code read than Claude Code while being 40% faster and 2x cheaper, and ships as a VS Code extension, headless runtime, and MCP tools.