Skip to content

Commit

Permalink
Fix relative PC calculation.
Browse files Browse the repository at this point in the history
  • Loading branch information
yomaytk committed Feb 27, 2024
1 parent e829a2b commit ce0cb0d
Showing 1 changed file with 2 additions and 9 deletions.
11 changes: 2 additions & 9 deletions backend/remill/lib/BC/InstructionLifter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<uint64_t>(inst.pc));
} else if (0 < arch_addr.displacement) {
return llvm::ConstantInt::get(word_type,
static_cast<uint64_t>(inst.pc + arch_addr.displacement));
} else {
return llvm::ConstantInt::get(word_type,
static_cast<uint64_t>(inst.pc - arch_addr.displacement));
}
return llvm::ConstantInt::get(word_type,
static_cast<uint64_t>(inst.pc + arch_addr.displacement));
}

auto addr = LoadWordRegValOrZero(block, state_ptr, arch_addr.base_reg.name, zero);
Expand Down

0 comments on commit ce0cb0d

Please sign in to comment.