🌐
GitHub
github.com › eliben › pyelftools
GitHub - eliben/pyelftools: Parsing ELF and DWARF in Python · GitHub
pyelftools is a pure-Python library for parsing and analyzing ELF files and DWARF debugging information.
Starred by 2.3K users
Forked by 543 users
Languages   Python 97.7% | C 1.5% | Assembly 0.5% | Linker Script 0.1% | Makefile 0.1% | Nix 0.1%
🌐
Linux Security Expert
linuxsecurity.expert › linux security expert › tools › pyelftools
Pyelftools review (ELF parsing toolkit) - Linux Security Expert
September 10, 2024 - Pyelftools is a Python library to parse ELF files and DWARF debugging information. It can be useful to perform dynamic binary analysis on files.
🌐
PyPI
pypi.org › project › pyelftools
pyelftools · PyPI
Library for analyzing ELF files and DWARF debugging information
      » pip install pyelftools
    
Published   May 29, 2026
Version   0.33
🌐
GitHub
github.com › eliben › pyelftools › pull › 141 › files
Make elffile and elfstructs on Dynamic public · Pull Request #141 · eliben/pyelftools
May 6, 2017 - This addresses issue 122 (#122), which I opened like 6 months ago. All I did was remove a leading underscore from self._elffile and self._elfstructs, which are each public on several other classes. Tests under tests/ pass; I haven't tested much further than that.
Author   eliben
🌐
Linux Security Expert
linuxsecurity.expert › linux security expert › tools › pyelftools › alternatives
pyelftools alternatives - Linux Security Expert
During the review of pyelftools we looked at other open source tools. Based on their category, tags, and text, these are the ones that have the best match. BAP (binary analysis toolkit) Manticore (dynamic binary analysis tool) LIEF (library for analysis of executable formats) These tools are ranked as the best alternatives to pyelftools.
🌐
RubyDoc
rubydoc.info › gems › elftools › 1.1.2
RubyDoc.info: File: README – Documentation for elftools (1.1.2) – RubyDoc.info
Section and segment parser Providing common sections and segments parser. For example, .symtab, .shstrtab .dynamic sections and INTERP, DYNAMIC segments, etc.
Find elsewhere
🌐
Hey There Buddo!
philipzucker.com › notes › Programming › linkers
Linkers and Loaders | Hey There Buddo!
April 18, 2026 - The .dynamic section of the elf file is symbols to look for at runtime.
🌐
Medium
medium.com › analytics-vidhya › exploring-elf-files-using-pyelftools-93bb7665cce3
Exploring ELF files using pyelftools | by Roman Storozhenko | Analytics Vidhya | Medium
October 27, 2020 - Most of them intended for providing sole piece of information extracted from a binary in the mentioned format. They are great, but sometimes we need a kind of an universal and yet highly specialized tool allowing to do much more than standard tools are able to. This is a moment when pyelftools come ...
🌐
DeepWiki
deepwiki.com › eliben › pyelftools
eliben/pyelftools | DeepWiki
August 19, 2025 - pyelftools Overview · Core Architecture · ELF File Processing · DWARF Debug Information · Binary Data Framework · Command Line Tools · readelf.py Script · dwarfdump.py Script · ELF Processing Details · Sections and Segments · Dynamic Linking and Relocations ·
🌐
Debian
packages.debian.org › sid › python3-pyelftools
Debian -- Details of package python3-pyelftools in sid
pyelftools is a pure-Python library for parsing and analyzing ELF files and DWARF debugging information.
🌐
SUSE Package Hub
packagehub.suse.com › packages › python-pyelftools › 0_26-bp153_1_15
SUSE Package Hub -
python3-pyelftools · Version: 0.26-bp152.2.1 · * Wed May 20 2020 Petr Gajdos <pgajdos@suse.com> - %python3_only -> %python_alternative · * Thu Mar 19 2020 Marketa Calabkova <mcalabkova@suse.com> - Update to 0.26 * Call relocation for ARM v3 (#194) * More complete architecture coverage for ENUM_E_MACHINE (#206) * Support for .debug_pubtypes and .debug_pubnames sections (#208) * Support for DWARF v4 location lists (#214) * Decode strings in dynamic string tables (#217) * Improve symbol table handling in dynamic segments (#219) * Improved handling of location information (#225) * Avoid deprecation warnings in Python 3.7+ * Add DWARF v5 OPs (#240) * Handle many new translation forms and constants * Lazy DIE parsing to speed up partial parsing of DWARF info (#249) * Sat May 25 2019 Tomá?
🌐
Anaconda.org
anaconda.org › conda-forge › pyelftools
pyelftools - conda-forge | Anaconda.org
May 29, 2026 - conda-forge/pyelftools · Community · Library for analyzing ELF files and DWARF debugging information · Copied fromcf-post-staging / pyelftools · Overview · Files 198 · Labels 3 · Badges · Versions · 0.33 · To install this package, run one of the following: $conda install conda-forge::pyelftools ·
🌐
Stack Overflow
stackoverflow.com › questions › tagged › pyelftools
Newest 'pyelftools' Questions - Stack Overflow
I am trying to modify an ELF file's .text segment using python. I successfully acquired the .text field so then I can simply change the bit that I want. The thing is that pyelftools does not provide ...
🌐
Stack Overflow
stackoverflow.com › questions › 10523242 › elf-parsing-accessing-a-die-directly-using-pyelftools
python - ELF Parsing : Accessing a DIE Directly using pyelftools - Stack Overflow
September 23, 2015 - 3 Getting the memory layout out of an (avr)elf file by useing python + pyElftools · 1 How can I read the dynamic section of an ELF file in python · 3 Extract function bytes from ELF binary file · 0 pyelftools: retrieve section flags like objdump does for an elf32-littlearm binary ·
Top answer
1 of 1
7

According to the author @eli-bendersky, pyelftools is a module for parsing and analyzing ELF/DWARF files and it has no direct way of modifying them. I had a look at the module source files and could not find any methods to edit/save either.

On the introductory post, within comments author acknowledges that pyelftools has no API-level support to do this but some tinkering around can help achieve what you need.

If pyelftools is not a hard dependency, here's an example on how to do the same using elffile:

Copyimport elffile

eo = elffile.open(name="/bin/ls")
eo.fileHeader.shnum = 30
with open('./ls.bin', 'wb') as f: f.write(eo.pack())

Using readelf, you can verify that changes were saved correctly:

Copyreadelf -h ls.bin 
ELF Header:
  Magic:   7f 45 4c 46 01 01 01 00 00 00 00 00 00 00 00 00 
  Class:                             ELF32
  Data:                              2's complement, little endian
  Version:                           1 (current)
  OS/ABI:                            UNIX - System V
  ABI Version:                       0
  Type:                              EXEC (Executable file)
  Machine:                           Intel 80386
  Version:                           0x1
  Entry point address:               0x804be34
  Start of program headers:          105068 (bytes into file)
  Start of section headers:          103948 (bytes into file)
  Flags:                             0x0
  Size of this header:               52 (bytes)
  Size of program headers:           32 (bytes)
  Number of program headers:         9
  Size of section headers:           40 (bytes)
  Number of section headers:         30
  Section header string table index: 27
readelf: Error: Unable to read in 0x708 bytes of section headers

There's not much documentation on elffile but you can have a look at the source and figure out ways to replicate pyelftools-specific functionality. If that doesn't work, you can try using both pyelftools for reading/analyzing tasks and elffile to edit sections and write changes.