binsize

raw JSON →
0.1.4 verified Fri May 01 auth: no python

A tool to analyze the size of a binary from an ELF file. Currently at version 0.1.4, released irregularly as a hobby project. It parses ELF files and provides detailed size breakdowns by sections, symbols, and memory regions.

pip install binsize
error ImportError: cannot import name 'analyze' from 'binsize'
cause The module name is correct but the package may not be installed or the import path is case-sensitive.
fix
Run pip install binsize and verify the import: from binsize import analyze.
error FileNotFoundError: [Errno 2] No such file or directory: 'file.elf'
cause The path provided to analyze does not exist or is not an ELF file.
fix
Check the file path and ensure it is a valid ELF file (e.g., compiled with arm-none-eabi-gcc).
error KeyError: 'sections'
cause The ELF file might be malformed or not contain expected sections.
fix
Verify the ELF file with readelf -S your.elf or use a different binary.
gotcha The `analyze` function expects an existing ELF file; it does not generate binaries.
fix Ensure you have an ELF binary (e.g., from GCC or Rust compilation) before calling analyze.
gotcha The output format is a nested dictionary that may change between minor versions; do not rely on exact keys without checking.
fix Inspect the result structure manually after upgrading.

Basic usage: import the analyze function and pass the path to an ELF file. Returns a dictionary with size information.

from binsize import analyze
import tempfile, os

# Example: analyze an ELF file (provide path to your .elf)
result = analyze('/path/to/your.elf')
print(result)