Skip to content

Commit

Permalink
fix: python linting issues
Browse files Browse the repository at this point in the history
  • Loading branch information
bboilot-ledger committed Mar 25, 2024
1 parent 70adab7 commit 00778d5
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions speculos/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,24 +69,26 @@ def get_elf_ledger_metadata(app_path):
metadata[section_name] = "nanosp"
return metadata


def get_segment_from_section(elf, section):
for seg in elf.iter_segments(type='PT_LOAD'):
if seg.section_in_segment(section):
return seg
return None


def get_elf_infos(app_path):
with open(app_path, 'rb') as fp:
elf = ELFFile(fp)
text = elf.get_section_by_name('.text')
text_seg = get_segment_from_section(elf, text)
if text_seg is None:
raise RuntimeError("No program header with text section!")

nvm = elf.get_section_by_name('.nvm_data')
nvm_seg = get_segment_from_section(elf, nvm)
nvm_size = nvm_seg['p_filesz'] if nvm_seg is not None else 0
nvm_size = nvm_seg['p_filesz'] if nvm_seg is not None else 0

symtab = elf.get_section_by_name('.symtab')
bss = elf.get_section_by_name('.bss')
sh_offset = text_seg['p_offset']
Expand Down

0 comments on commit 00778d5

Please sign in to comment.