python
from elftools.elf.elffile import ELFFile
with open('example.elf', 'rb') as f:
elf_file = ELFFile(f)
segments = elf_file.iter_segments()
for segment in segments:
print('Segment Name:', segment.header.p_type)
print('Segment Offset:', segment.header.p_offset)
print('Segment Size:', segment.header.p_filesz)
python
from elftools.elf.elffile import ELFFile
with open('example.elf', 'rb') as f:
elf_file = ELFFile(f)
sections = elf_file.iter_sections()
for section in sections:
print('Section Name:', section.name)
print('Section Type:', section.header.sh_type)
print('Section Offset:', section.header.sh_offset)
print('Section Size:', section.header.sh_size)
python
from elftools.elf.elffile import ELFFile
with open('example.elf', 'rb') as f:
elf_file = ELFFile(f)
relocations = elf_file.iter_relocations()
for relocation in relocations:
print('Symbol:', relocation.symbol.name)
print('Type:', relocation.type)
print('Offset:', relocation.entry.r_offset)