From 9f1b5977403f4cd2eaa131019ab76ac6e25bbafa Mon Sep 17 00:00:00 2001 From: Daniel Botnik Date: Sat, 7 Feb 2026 20:38:02 +0200 Subject: [PATCH] fix(IRSB): removed wrong `instruction_addresses` calculaion from lift, now only deriving from statments --- pyvex/block.py | 4 +--- tests/test_pyvex.py | 9 +++++++++ 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/pyvex/block.py b/pyvex/block.py index ce598431..91dbe3aa 100644 --- a/pyvex/block.py +++ b/pyvex/block.py @@ -1,5 +1,4 @@ import copy -import itertools import logging from typing import Optional @@ -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 @@ -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 = [] diff --git a/tests/test_pyvex.py b/tests/test_pyvex.py index d382abff..0a373fcd 100644 --- a/tests/test_pyvex.py +++ b/tests/test_pyvex.py @@ -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 ### ##################