From 843d29b5a9bb0bdc4c311bbd53758dd014275ac6 Mon Sep 17 00:00:00 2001 From: MerryMage Date: Mon, 22 Aug 2016 14:38:06 +0100 Subject: [PATCH] translate_arm/branch: Read-after-write in arm_BLX_reg When BLX LR is translated, BXWritePC(GetRegister(Reg::LR)) was executed after the SetRegister(Reg::LR, _) update was done. --- src/frontend/translate/translate_arm/branch.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/frontend/translate/translate_arm/branch.cpp b/src/frontend/translate/translate_arm/branch.cpp index b9b3596a..8a5066fc 100644 --- a/src/frontend/translate/translate_arm/branch.cpp +++ b/src/frontend/translate/translate_arm/branch.cpp @@ -51,8 +51,8 @@ bool ArmTranslatorVisitor::arm_BLX_reg(Cond cond, Reg m) { // BLX if (ConditionPassed(cond)) { ir.PushRSB(ir.current_location.AdvancePC(4)); - ir.SetRegister(Reg::LR, ir.Imm32(ir.current_location.PC() + 4)); ir.BXWritePC(ir.GetRegister(m)); + ir.SetRegister(Reg::LR, ir.Imm32(ir.current_location.PC() + 4)); ir.SetTerm(IR::Term::ReturnToDispatch{}); return false; }