ELF reader-writer library (fork with fixes)
Project description
MakeELF
NOTE: This is a fork of the public makeelf library that has a few fixes and customizations.
ELF reader-writer library for Python3
Overview
MakeELF is a Python library to parse, modify and create ELF binaries. It provides following features:
- easy to use, standard Python interface
- reading existing ELF files to Python representation
- modification of every aspect of ELF format structures
- ability to skip any validation to test other parsers for potential errors
- creating new valid ELF files with just one step
- easy serialization of every structure present in ELF file
Installation
MakeELF could be installed either using PyPI and pip3 tool or manually with help of setup.py script.
Install from PyPI
It is as simple as typing:
pip3 install makeelf
Manual installation
Clone the Github repository and in root of the project execute:
python3 setup.py install
API
Creating new object
from makeelf.elf import *
elf = ELF(e_machine=EM.EM_LKV373A)
print(elf)
Parsing ELF file
Either using helper function:
elf = ELF.from_file('some.elf')
print(elf)
Then if you'd like to have full control on headers, low-level object can be extracted:
elf = elf.Elf
Or create low-level object manually:
fd = os.open('some.elf', os.O_RDONLY)
b = os.read(fd, 0xffff)
os.close(fd)
elf, b = Elf32.from_bytes(b)
print(elf)
Saving ELF to file
fd = os.open('other.elf', os.O_WRONLY | os.O_CREAT | os.O_TRUNC)
os.write(fd, bytes(elf))
os.close(fd)
Adding a section
data_id = elf.append_section('.data', b'\0\0\0\0', 0xfadd)
Adding a symbol
elf.append_symbol('NULL', data_id, 0, 4)
Modifying attributes
elf.Elf.Shdr_table[data_id].sh_flags = int(SHF.SHF_ALLOC)
License
All the software here is licensed under GNU General Public License 3.0, available in LICENSE file.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file makeelf_plus-0.1.0.tar.gz.
File metadata
- Download URL: makeelf_plus-0.1.0.tar.gz
- Upload date:
- Size: 59.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7a0eb9973e3f642b9c9850c98f3ef3078ef625babdacecf08ab895cd7ee8392c
|
|
| MD5 |
0b67abd5f09ae02b911181dc8fa29419
|
|
| BLAKE2b-256 |
6b402901d5a10bb919b63c28283f17d524c22ea66841c9a3cb88f5e66f2665ed
|
File details
Details for the file makeelf_plus-0.1.0-py3-none-any.whl.
File metadata
- Download URL: makeelf_plus-0.1.0-py3-none-any.whl
- Upload date:
- Size: 51.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
459bb38e7ecff602234f3479185e5ff59b1e9538c2908fd60a8e0e64b3db03db
|
|
| MD5 |
508fbf242d1d71cbbe3cd8083f6d491d
|
|
| BLAKE2b-256 |
5fba1e132d092d308c8b3549a0de8eb0d395b8528618f4495d7fb789e8a47ba4
|