pip install pyelftools
python
from elftools.elf.elffile import ELFFile
with open('example.elf', 'rb') as file:
elf = ELFFile(file)
debug_info_section = elf.get_section_by_name('.debug_info')
debug_info_data = debug_info_section.data()
python
from elftools.elf.elffile import ELFFile
from elftools.elf.sections import NoteSection
with open('example.elf', 'rb') as file:
elf = ELFFile(file)
debug_info_section = elf.get_section_by_name('.debug_info')
with open('modified.elf', 'wb') as modified_file:
modified_file.write(elf.stream.build())