From d8bee60947bc2481acdbfacfcffbfce7ac598965 Mon Sep 17 00:00:00 2001 From: MerryMage Date: Mon, 22 Aug 2016 14:28:51 +0100 Subject: [PATCH] translate_thumb: Read-after-write in thumb16_BLX_reg When the instruction BLX LR is translated, BXWritePC(GetRegister(Reg::LR)) was executed after the SetRegister(Reg::LR, _) update was performed. --- src/frontend/translate/translate_thumb.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/frontend/translate/translate_thumb.cpp b/src/frontend/translate/translate_thumb.cpp index c77c492c..917c284d 100644 --- a/src/frontend/translate/translate_thumb.cpp +++ b/src/frontend/translate/translate_thumb.cpp @@ -763,8 +763,8 @@ struct ThumbTranslatorVisitor final { bool thumb16_BLX_reg(Reg m) { // BLX ir.PushRSB(ir.current_location.AdvancePC(2)); - ir.SetRegister(Reg::LR, ir.Imm32((ir.current_location.PC() + 2) | 1)); ir.BXWritePC(ir.GetRegister(m)); + ir.SetRegister(Reg::LR, ir.Imm32((ir.current_location.PC() + 2) | 1)); ir.SetTerm(IR::Term::ReturnToDispatch{}); return false; }