about summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--miasm/arch/x86/arch.py13
-rw-r--r--miasm/arch/x86/sem.py8
-rw-r--r--miasm/core/objc.py4
-rw-r--r--miasm/expression/expression.py20
-rw-r--r--miasm/jitter/emulatedsymbexec.py3
5 files changed, 26 insertions, 22 deletions
diff --git a/miasm/arch/x86/arch.py b/miasm/arch/x86/arch.py
index 127dded4..2dd01ae3 100644
--- a/miasm/arch/x86/arch.py
+++ b/miasm/arch/x86/arch.py
@@ -187,6 +187,13 @@ gpreg = (
 )
 
 
+def is_op_segm(expr):
+    """Returns True if is ExprOp and op == 'segm'"""
+    return expr.is_op('segm')
+
+def is_mem_segm(expr):
+    """Returns True if is ExprMem and ptr is_op_segm"""
+    return expr.is_mem() and is_op_segm(expr.ptr)
 
 
 def cb_deref_segmoff(tokens):
@@ -588,7 +595,7 @@ class instruction_x86(instruction):
                 prefix = ""
             sz = SIZE2MEMPREFIX[expr.size]
             segm = ""
-            if expr.is_mem_segm():
+            if is_mem_segm(expr):
                 segm = "%s:" % expr.ptr.args[0]
                 expr = expr.ptr.args[1]
             else:
@@ -1718,10 +1725,10 @@ SIZE2BNDREG = {64:gpregs_mm,
 def parse_mem(expr, parent, w8, sx=0, xmm=0, mm=0, bnd=0):
     dct_expr = {}
     opmode = parent.v_opmode()
-    if expr.is_mem_segm() and expr.ptr.args[0].is_int():
+    if is_mem_segm(expr) and expr.ptr.args[0].is_int():
         return None, None, False
 
-    if expr.is_mem_segm():
+    if is_mem_segm(expr):
         segm = expr.ptr.args[0]
         ptr = expr.ptr.args[1]
     else:
diff --git a/miasm/arch/x86/sem.py b/miasm/arch/x86/sem.py
index d60794b7..cf58079c 100644
--- a/miasm/arch/x86/sem.py
+++ b/miasm/arch/x86/sem.py
@@ -24,7 +24,7 @@ import logging
 import miasm.expression.expression as m2_expr
 from miasm.expression.simplifications import expr_simp
 from miasm.arch.x86.regs import *
-from miasm.arch.x86.arch import mn_x86, repeat_mn, replace_regs
+from miasm.arch.x86.arch import mn_x86, repeat_mn, replace_regs, is_mem_segm
 from miasm.ir.ir import IntermediateRepresentation, IRBlock, AssignBlock
 from miasm.core.sembuilder import SemBuilder
 from miasm.jitter.csts import EXCEPT_DIV_BY_ZERO, EXCEPT_ILLEGAL_INSN, \
@@ -446,7 +446,7 @@ def movsx(_, instr, dst, src):
 
 def lea(_, instr, dst, src):
     ptr = src.ptr
-    if src.is_mem_segm():
+    if is_mem_segm(src):
         # Do not use segmentation here
         ptr = ptr.args[1]
 
@@ -3469,7 +3469,7 @@ def bittest_get(ir, instr, src, index):
         b_mask = {16: 4, 32: 5, 64: 6}
         b_decal = {16: 1, 32: 3, 64: 7}
         ptr = src.ptr
-        segm = src.is_mem_segm()
+        segm = is_mem_segm(src)
         if segm:
             ptr = ptr.args[1]
 
@@ -5780,7 +5780,7 @@ class ir_x86_16(IntermediateRepresentation):
                 instr.additional_info.g2.value]
         if my_ss is not None:
             for i, a in enumerate(args):
-                if a.is_mem() and not a.is_mem_segm():
+                if a.is_mem() and not is_mem_segm(a):
                     args[i] = self.ExprMem(m2_expr.ExprOp('segm', my_ss,
                                                           a.ptr), a.size)
 
diff --git a/miasm/core/objc.py b/miasm/core/objc.py
index 117e3b7d..87d19dde 100644
--- a/miasm/core/objc.py
+++ b/miasm/core/objc.py
@@ -14,8 +14,8 @@ from functools import total_ordering
 
 from miasm.core.utils import cmp_elts
 from miasm.expression.expression_reduce import ExprReducer
-from miasm.expression.expression import ExprInt, ExprId, ExprOp, ExprMem, \
-    is_op_segm
+from miasm.expression.expression import ExprInt, ExprId, ExprOp, ExprMem
+from miasm.arch.x86.arch import is_op_segm
 
 from miasm.core.ctypesmngr import CTypeUnion, CTypeStruct, CTypeId, CTypePtr,\
     CTypeArray, CTypeOp, CTypeSizeof, CTypeEnum, CTypeFunc, CTypeEllipsis
diff --git a/miasm/expression/expression.py b/miasm/expression/expression.py
index c2bf5b8b..b0f54992 100644
--- a/miasm/expression/expression.py
+++ b/miasm/expression/expression.py
@@ -158,14 +158,6 @@ def is_commutative(expr):
     "Return True iff current operation is commutative"
     return (expr.op in ['+', '*', '^', '&', '|'])
 
-def is_op_segm(expr):
-    """Returns True if is ExprOp and op == 'segm'"""
-    return expr.is_op('segm')
-
-def is_mem_segm(expr):
-    """Returns True if is ExprMem and ptr is_op_segm"""
-    return expr.is_mem() and is_op_segm(expr.ptr)
-
 def canonize_to_exprloc(locdb, expr):
     """
     If expr is ExprInt, return ExprLoc with corresponding loc_key
@@ -715,11 +707,13 @@ class Expr(object):
 
     def is_op_segm(self):
         """Returns True if is ExprOp and op == 'segm'"""
-        return False
+        warnings.warn('DEPRECATION WARNING: use is_op_segm(expr)')
+        raise RuntimeError("Moved api")
 
     def is_mem_segm(self):
         """Returns True if is ExprMem and ptr is_op_segm"""
-        return False
+        warnings.warn('DEPRECATION WARNING: use is_mem_segm(expr)')
+        raise RuntimeError("Moved api")
 
     def __contains__(self, expr):
         ret = contains_visitor.contains(self, expr)
@@ -1196,7 +1190,8 @@ class ExprMem(Expr):
 
     def is_mem_segm(self):
         """Returns True if is ExprMem and ptr is_op_segm"""
-        return self._ptr.is_op_segm()
+        warnings.warn('DEPRECATION WARNING: use is_mem_segm(expr)')
+        raise RuntimeError("Moved api")
 
     def depth(self):
         return self._ptr.depth() + 1
@@ -1373,7 +1368,8 @@ class ExprOp(Expr):
 
     def is_op_segm(self):
         """Returns True if is ExprOp and op == 'segm'"""
-        return self.is_op('segm')
+        warnings.warn('DEPRECATION WARNING: use is_op_segm(expr)')
+        raise RuntimeError("Moved api")
 
 class ExprSlice(Expr):
 
diff --git a/miasm/jitter/emulatedsymbexec.py b/miasm/jitter/emulatedsymbexec.py
index 844e7d5f..b8ca52e3 100644
--- a/miasm/jitter/emulatedsymbexec.py
+++ b/miasm/jitter/emulatedsymbexec.py
@@ -1,6 +1,7 @@
 from miasm.core.utils import decode_hex, encode_hex
 import miasm.expression.expression as m2_expr
 from miasm.ir.symbexec import SymbolicExecutionEngine
+from miasm.arch.x86.arch import is_op_segm
 
 
 class EmulatedSymbExec(SymbolicExecutionEngine):
@@ -140,7 +141,7 @@ class EmulatedSymbExec(SymbolicExecutionEngine):
     # CPU specific simplifications
     def _simp_handle_segm(self, e_s, expr):
         """Handle 'segm' operation"""
-        if not m2_expr.is_op_segm(expr):
+        if not is_op_segm(expr):
             return expr
         if not expr.args[0].is_int():
             return expr