diff --git a/qiling/debugger/qdb/branch_predictor/branch_predictor_arm.py b/qiling/debugger/qdb/branch_predictor/branch_predictor_arm.py index 97f00964c..9c89532d9 100644 --- a/qiling/debugger/qdb/branch_predictor/branch_predictor_arm.py +++ b/qiling/debugger/qdb/branch_predictor/branch_predictor_arm.py @@ -3,11 +3,14 @@ # Cross Platform and Multi Architecture Advanced Binary Emulation Framework # - +from __future__ import annotations +from typing import Optional from .branch_predictor import * from ..arch import ArchARM, ArchCORTEX_M + + class BranchPredictorARM(BranchPredictor, ArchARM): """ predictor for ARM @@ -40,9 +43,9 @@ def get_cpsr(bits: int) -> (bool, bool, bool, bool): bits & 0x80000000 != 0, # N, sign flag ) - def predict(self): + def predict(self, pref_addr: Optional[int] = None) -> BranchPredictor.Prophecy: prophecy = self.Prophecy() - cur_addr = self.cur_addr + cur_addr = pref_addr or self.cur_addr line = self.disasm(cur_addr) prophecy.where = cur_addr + line.size @@ -160,7 +163,7 @@ def predict(self): next_addr = cur_addr + self.THUMB_INST_SIZE for each in it_block_range: _insn = self.read_insn(next_addr) - n2_addr = handle_bnj_arm(ql, next_addr) + n2_addr = self.predict(next_addr).where if (cond_met and each == "t") or (not cond_met and each == "e"): if n2_addr != (next_addr+len(_insn)): # branch detected