MakeELF
ELF reader-writer library
|
Public Member Functions | |
def | __init__ (self, e_class=ELFCLASS.ELFCLASS32, e_data=ELFDATA.ELFDATA2MSB, e_type=ET.ET_EXEC, e_machine=EM.EM_NONE) |
def | __str__ (self) |
def | __repr__ (self) |
def | __bytes__ (self) |
def | from_bytes (b) |
def | from_file (filename) |
def | get_section_by_name (self, sec_name) |
Get section with header based on its name. More... | |
def | append_section (self, sec_name, sec_data, sec_addr) |
Add new section to ELF file. More... | |
def | append_special_section (self, sec_name) |
Add new special section to ELF file. More... | |
def | append_segment (self, sec_id, addr=None, mem_size=-1, flags='rwx') |
Add new program header, describing segment in memory. More... | |
def | append_symbol (self, sym_name, sym_section, sym_offset, sym_size, sym_binding=STB.STB_LOCAL, sym_type=STT.STT_NOTYPE, sym_visibility=STV.STV_DEFAULT) |
Append new symbol to symbol table. More... | |
Public Attributes | |
little | |
Header endianness indicator. More... | |
Elf | |
Instance of elfstruct.Elf32 class. More... | |
This class is a wrapper on ELF structures provided by elfstruct module It provides set of functions allowing easy manipulation of ELF as a whole, without requirement of update of particular fields, especially offsets and section headers
def makeelf.elf.ELF.__bytes__ | ( | self | ) |
Serialize ELF object into block of bytes Makes some header updates and serializes object to file, so output should always be valid ELF file
def makeelf.elf.ELF.append_section | ( | self, | |
sec_name, | |||
sec_data, | |||
sec_addr | |||
) |
Add new section to ELF file.
Name is automatically appended to .shstrtab section (section is created if does not exists)
sec_name | Name of the section to append |
def makeelf.elf.ELF.append_segment | ( | self, | |
sec_id, | |||
addr = None , |
|||
mem_size = -1 , |
|||
flags = 'rwx' |
|||
) |
Add new program header, describing segment in memory.
This function is for executable and shared objects only. On other types of ELFs causes exception. Currently appended segment can only be of type PT_LOAD
sec_id | id of section already describing this segment |
addr | virtual address at which segment will be loaded |
mem_size | size of segment after loading into memory |
def makeelf.elf.ELF.append_special_section | ( | self, | |
sec_name | |||
) |
def makeelf.elf.ELF.append_symbol | ( | self, | |
sym_name, | |||
sym_section, | |||
sym_offset, | |||
sym_size, | |||
sym_binding = STB.STB_LOCAL , |
|||
sym_type = STT.STT_NOTYPE , |
|||
sym_visibility = STV.STV_DEFAULT |
|||
) |
Append new symbol to symbol table.
Creates symbol table, if necessary, adds new symbol name to symbol string table and symbol descriptor to symbol table.
sym_name | name of symbol as str or bytes, or None if unnamed |
sym_section | number of section, where symbol is located |
sym_offset | location of symbol from start of the section |
sym_size | size of the symbol in bytes |
def makeelf.elf.ELF.from_bytes | ( | b | ) |
Deserializes ELF from block of bytes
def makeelf.elf.ELF.from_file | ( | filename | ) |
Deserializes ELF from filesystem
def makeelf.elf.ELF.get_section_by_name | ( | self, | |
sec_name | |||
) |
Get section with header based on its name.
sec_name | Name of the section |
makeelf.elf.ELF.Elf |
Instance of elfstruct.Elf32 class.
Provides possibility to make any modification to ELF file, including setting fields to invalid values.
makeelf.elf.ELF.little |
Header endianness indicator.
Is true, if header values are meant to be stored as little-endian or false otherwise