Take a look at radare2. It can parse file formats (see here for an example of parsing the ELF header).
Radare2 supports multiple architectures and is being actively developed. On top of that it has bindings for a lot of languages, including Python of course. Read through the bindings source code to see it is pretty straightforward to script it.
HTH!
Answer from Carlos Garcia on Stack ExchangeTake a look at radare2. It can parse file formats (see here for an example of parsing the ELF header).
Radare2 supports multiple architectures and is being actively developed. On top of that it has bindings for a lot of languages, including Python of course. Read through the bindings source code to see it is pretty straightforward to script it.
HTH!
LIEF is a good choice for parsing ELF binaries. It's written in C++, but comes with proper Python bindings and is readily available via PyPi. Besides parsing ELF files it also supports Windows PE and MacOS binaries, reading and modifying and writing all of them, that is.
It's available since 2017 and is actively maintained (example).
LIEF is pretty light-weight and doesn't require many dependencies.
There's a new kid on the block - pyelftools - a pure Python library for parsing the ELF and DWARF formats. Give it a try.
It aims to be feature-complete and is currently in active development, so any problems should be handled quickly and enthusiastically :-)
The concept of "ELF debug info" doesn't really exist: the ELF specification leaves the content of the .debug section deliberately unspecified.
Common debug formats are STAB and DWARF. A library to read DWARF is libdwarf.
» pip install elffile