Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions pyvex/block.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import copy
import itertools
import logging
from typing import Optional

Expand Down Expand Up @@ -424,7 +423,7 @@ def instruction_addresses(self) -> tuple[int, ...]:
self._instruction_addresses = ()
else:
self._instruction_addresses = tuple(
(s.addr + s.delta) for s in self.statements if type(s) is stmt.IMark
(s.addr + s.delta) for s in self.statements if type(s) is stmt.IMark and s.len > 0
)
return self._instruction_addresses

Expand Down Expand Up @@ -559,7 +558,6 @@ def _from_c(self, lift_r, skip_stmts=False):
self._size = lift_r.size
self.is_noop_block = lift_r.is_noop_block == 1
self._instructions = lift_r.insts
self._instruction_addresses = tuple(itertools.islice(lift_r.inst_addrs, lift_r.insts))

# Conditional exits
exit_statements = []
Expand Down
9 changes: 9 additions & 0 deletions tests/test_pyvex.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,15 @@ def test_irsb_tyenv(self):
irsb2.tyenv = copy.deepcopy(irsb.tyenv)
print(irsb2.tyenv)

def test_irsb_instruction_addresses_contains_empty_imarks(self):
# 0x2000: MOV R0, 3
# 0x2004: SEV
# 0x2008: SEV
# 0x200C: MOV R1, 3
opcodes = b"\x03\x00\xa0\xe3\x04\xf0\x20\xe3\x04\xf0\x20\xe3\x03\x10\xa0\xe3"
irsb = pyvex.IRSB(data=opcodes, mem_addr=0x2000, arch=pyvex.ARCH_ARM_LE)
assert irsb.instruction_addresses == (0x2000, 0x2004, 0x2008, 0x200C)

##################
### Statements ###
##################
Expand Down