Skip to main content

Tool to extract information about symbols and sections from an ELF file and filters them.

Project description

elf-size-analyze

elf-size-analyze is a Python tool that uses regular binutils programs (readelf, nm, c++filt) to extract information about symbols and sections from an ELF file and filters them. Information is presented in a tree based on paths to files where the symbols have been defined.

It's main usage is optimization of memory usage (FLASHH/RAM/etc.) by inspecting which modules/symbols in code contribute the most to final size. Main output format is an ASCII tree, but it supports other formats, e.g. JSON (for usage in other scripts), or HTML-based visualization (e.g. static HTML or Plotly graph).

This script was initially based on size_report from Zephyr Project scripts (some old version), but it has been almost fully rewritten but the idea is the same.

Gallery

cmdline
Plotly treemap Plotly sunburst HTML table
treemap sunburst html

Requirements

  • Python 3
  • binutils: readelf, nm, c++filt (optional)

Installation

For normal usage it's best to install from PyPI:

pip install elf-size-analyze

There are some optional dependencies not installed by default, e.g. to include support for Plotly graphs output use

pip insatll elf-size-analyze[plotly]

For development it's recommended to install from sources in virtual environment in editable mode:

python -m venv venv
source ./venv/bin/activate
git clone https://github.com/jedrzejboczar/elf-size-analyze.git
pip install -e ./elf-size-analyze[dev,plotly]

Usage

Select the ELF file to be analyzed. To be able to extract path information about symbols from the ELF file, the program should be compiled with debug information (gcc -g).

If installed using pip then the package provides an entry point and you can just use the elf-size-analyze command. Otherwise use python -m elf_size_analyze from the source directory.

Example usage (assumes that we're using arm-none-eabi-gcc toolchain):

elf-size-analyze -t arm-none-eabi- -w 120 -HaF build/myapp

For more options see help:

elf-size-analyze -h

For HTML output:

elf-size-analyze -t arm-none-eabi- -w 120 -HaF build/myapp -W > /tmp/index.html
firefox /tmp/index.html  # or other browser / xdg-open

For Plotly output (for big executables you might want to use --plotly-max-depth):

elf-size-analyze -t arm-none-eabi- -w 120 -HaF build/myapp --plotly --plotly-type treemap

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

elf_size_analyze-0.3.1.tar.gz (25.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

elf_size_analyze-0.3.1-py3-none-any.whl (28.3 kB view details)

Uploaded Python 3

File details

Details for the file elf_size_analyze-0.3.1.tar.gz.

File metadata

  • Download URL: elf_size_analyze-0.3.1.tar.gz
  • Upload date:
  • Size: 25.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.25

File hashes

Hashes for elf_size_analyze-0.3.1.tar.gz
Algorithm Hash digest
SHA256 f14eb62da3d77cbf08ba2234447fb8fbeec61ce0d2eb82f5dd749300a5958445
MD5 636574c6ed122c1eba63bbf8c5ce9959
BLAKE2b-256 b999a18b49eb42443a250334873ba94c02e5f2be5af4349a933bb2aa2908f038

See more details on using hashes here.

File details

Details for the file elf_size_analyze-0.3.1-py3-none-any.whl.

File metadata

File hashes

Hashes for elf_size_analyze-0.3.1-py3-none-any.whl
Algorithm Hash digest
SHA256 1a066b2cc42981473268359767f0d29ee6040fce0208d6bbe1a008e8d33165b6
MD5 7b104915f30471e392e1d68df25f6794
BLAKE2b-256 846747730e5efc784b4477b65c315984ab6b27d71d836f352c658bfaa74a7e72

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page