I'm happy and proud to announce the release of a new open-source Python package to the world. pyelftools is a pure-Python library for parsing and analyzing ELF files and DWARF debugging information. It provides both low-level and high-level APIs for querying ELF and DWARF, and is mostly feature-complete. As a proof of capability, pyelftools ships with a fairly powerful clone of readelf.
Some basic information:
- Website - managed as an open-source project on Github. It's the place for documentation, opening issues and closely following the development in general.
- Downloading - from PyPI, or the Github site.
- Documentation - there's a detailed user guide, and the source distribution contains several examples.
- License - public domain.
- Pre-requisites - Python version 2.6 or 2.7; 3.x support is in the works.
The goal of this project was two-fold. First, to better understand the ELF and DWARF formats. Second, to have a feature-complete pure-Python parser for these formats with a sufficiently high-level API to be generally useful.
Although the initial release of pyelftools (version 0.10) is formally "beta", it's quite well validated with a comprehensive test-suite. It should also be simple to learn and tweak, due to the detailed user's and hacker's guides on the Github site Wiki, along with several functioning examples that ship with the library.
There are some existing tools with overlapping functionality:
- pydevtools - an ambitious project by Emilio Monti. I initially planned to build my project on top of it (I wanted a much higher-level API than pydevtools aims to provide), but was deterred by its lack of support for the 64-bit ELF format. Adding 64-bit support appeared like a large work, so I preferred to go my own way. pyelftools is designed from scratch to support both 32-bit and 64-bit formats (as well as endianness).
- libelf and libdwarf - very authoritative and complete implementations, but are essentially C libraries with a C API, which leaves much to be desired in terms of usability and convenience.
- The LLVM project has an ELF reader (part of its libObject library) and recently started adding partial DWARF parsing capabilities. These parts of the project are still rather experimental and evolving, and I'm following its progress with interest.