diff options
| author | Fabrice Desclaux <fabrice.desclaux@cea.fr> | 2020-07-21 14:47:16 +0200 |
|---|---|---|
| committer | Fabrice Desclaux <fabrice.desclaux@cea.fr> | 2020-07-21 16:47:59 +0200 |
| commit | 9bf0f4c1c14d318110b56df6952b0fcc2950539e (patch) | |
| tree | c6f51685615aa55a71c866f0667929222499e112 | |
| parent | 6ccbedd2928d52aff605ede73adbdfadb6152582 (diff) | |
| download | miasm-9bf0f4c1c14d318110b56df6952b0fcc2950539e.tar.gz miasm-9bf0f4c1c14d318110b56df6952b0fcc2950539e.zip | |
ExprInt only takes int
| -rw-r--r-- | miasm/arch/msp430/arch.py | 4 | ||||
| -rw-r--r-- | miasm/expression/expression.py | 24 | ||||
| -rw-r--r-- | miasm/jitter/llvmconvert.py | 2 |
3 files changed, 7 insertions, 23 deletions
diff --git a/miasm/arch/msp430/arch.py b/miasm/arch/msp430/arch.py index 93854153..46014b8c 100644 --- a/miasm/arch/msp430/arch.py +++ b/miasm/arch/msp430/arch.py @@ -136,9 +136,9 @@ class instruction_msp430(instruction): if not isinstance(expr, ExprInt): return if self.name == "call": - addr = expr.arg + addr = int(expr) else: - addr = expr.arg + int(self.offset) + addr = (int(expr) + int(self.offset)) & int(expr.mask) loc_key = loc_db.get_or_create_offset_location(addr) self.args[0] = ExprLoc(loc_key, expr.size) diff --git a/miasm/expression/expression.py b/miasm/expression/expression.py index b0f54992..1534bd3f 100644 --- a/miasm/expression/expression.py +++ b/miasm/expression/expression.py @@ -772,17 +772,8 @@ class ExprInt(Expr): @arg: 'intable' number @size: int size""" - if is_modint(arg): - assert size == arg.size - # Avoid a common blunder - assert not isinstance(arg, ExprInt) - - # Ensure arg is always a moduint - arg = int(arg) - if size not in mod_size2uint: - define_uint(size) - arg = mod_size2uint[size](arg) - + assert isinstance(arg, int_types) + arg = arg & ((1 << size) - 1) # Get the Singleton instance expr = Expr.get_object(cls, (arg, size)) @@ -790,15 +781,8 @@ class ExprInt(Expr): expr._arg = arg return expr - def _get_int(self): - "Return self integer representation" - return int(self._arg & size2mask(self._size)) - def __str__(self): - if self._arg < 0: - return str("-0x%X" % (- self._get_int())) - else: - return str("0x%X" % self._get_int()) + return str("0x%X" % self.arg) def get_w(self): return set() @@ -807,7 +791,7 @@ class ExprInt(Expr): return hash((EXPRINT, self._arg, self._size)) def _exprrepr(self): - return "%s(0x%X, %d)" % (self.__class__.__name__, self._get_int(), + return "%s(0x%X, %d)" % (self.__class__.__name__, self.arg, self._size) def copy(self): diff --git a/miasm/jitter/llvmconvert.py b/miasm/jitter/llvmconvert.py index e3a0e8c2..5289ed0b 100644 --- a/miasm/jitter/llvmconvert.py +++ b/miasm/jitter/llvmconvert.py @@ -768,7 +768,7 @@ class LLVMFunction(object): builder = self.builder if isinstance(expr, ExprInt): - ret = llvm_ir.Constant(LLVMType.IntType(expr.size), int(expr.arg)) + ret = llvm_ir.Constant(LLVMType.IntType(expr.size), int(expr)) self.update_cache(expr, ret) return ret |