about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorElias Bachaalany <elias.bachaalany@gmail.com>2021-11-12 15:04:47 -0800
committerGitHub <noreply@github.com>2021-11-12 15:04:47 -0800
commit3284421fe6a740ff5e85140a39256cda3f562778 (patch)
tree6f4e9b34c665fa3c5cff43d0b3b7ec4a88cf278e
parentb825e90d9376bfa1109a21b366c317e79283db8a (diff)
downloadmiasm-3284421fe6a740ff5e85140a39256cda3f562778.tar.gz
miasm-3284421fe6a740ff5e85140a39256cda3f562778.zip
Fixed "POP reg_sp" in all modes
POP SP/ESP were broken in x64 mode.
Same for POP SP in x32 mode.
etc.

Now, we don't increment reg_sp at all if it is the target of the POP.
-rw-r--r--miasm/arch/x86/sem.py4
1 files changed, 2 insertions, 2 deletions
diff --git a/miasm/arch/x86/sem.py b/miasm/arch/x86/sem.py
index 5b6ff917..ffa2641c 100644
--- a/miasm/arch/x86/sem.py
+++ b/miasm/arch/x86/sem.py
@@ -929,8 +929,8 @@ def pop_gen(ir, instr, src, size):
 
     sp = mRSP[instr.mode]
     new_sp = sp + m2_expr.ExprInt(src.size // 8, sp.size)
-    # don't generate ESP incrementation on POP ESP
-    if src != ir.sp:
+    # Don't generate SP/ESP/RSP incrementation on POP SP/ESP/RSP
+    if not (src in mRSP.values()):
         e.append(m2_expr.ExprAssign(sp, new_sp))
     # XXX FIX XXX for pop [esp]
     if isinstance(src, m2_expr.ExprMem):