From ce0cb0d900a6ea96d71a7b6b3e706ab7f58ea616 Mon Sep 17 00:00:00 2001 From: yomaytk Date: Tue, 27 Feb 2024 17:36:03 +0900 Subject: [PATCH] Fix relative PC calculation. --- backend/remill/lib/BC/InstructionLifter.cpp | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/backend/remill/lib/BC/InstructionLifter.cpp b/backend/remill/lib/BC/InstructionLifter.cpp index 40dfec6..b9791a6 100644 --- a/backend/remill/lib/BC/InstructionLifter.cpp +++ b/backend/remill/lib/BC/InstructionLifter.cpp @@ -761,15 +761,8 @@ llvm::Value *InstructionLifter::LiftAddressOperand(Instruction &inst, llvm::Basi << inst.pc << " is wider than the machine word size."; if ("PC" == arch_addr.base_reg.name) { - if (0 == arch_addr.displacement) { - return llvm::ConstantInt::get(word_type, static_cast(inst.pc)); - } else if (0 < arch_addr.displacement) { - return llvm::ConstantInt::get(word_type, - static_cast(inst.pc + arch_addr.displacement)); - } else { - return llvm::ConstantInt::get(word_type, - static_cast(inst.pc - arch_addr.displacement)); - } + return llvm::ConstantInt::get(word_type, + static_cast(inst.pc + arch_addr.displacement)); } auto addr = LoadWordRegValOrZero(block, state_ptr, arch_addr.base_reg.name, zero);