Miasm2
 All Classes Namespaces Files Functions Variables Typedefs Properties Macros
Classes | Functions | Variables
miasm2.arch.aarch64.sem Namespace Reference

Classes

class  aarch64info
 
class  ir_aarch64b
 
class  ir_aarch64l
 

Functions

def update_flag_zf
 
def update_flag_nf
 
def update_flag_zn
 
def update_flag_logic
 
def update_flag_arith
 
def check_ops_msb
 
def arith_flag
 
def update_flag_add_cf
 
def update_flag_add_of
 
def update_flag_sub_cf
 
def update_flag_sub_of
 
def update_flag_add
 
def update_flag_sub
 
def extend_arg
 
def add
 
def sub
 
def neg
 
def and_l
 
def eor
 
def eon
 
def orr
 
def orn
 
def bic
 
def mvn
 
def adds
 
def subs
 
def cmp
 
def cmn
 
def ands
 
def tst
 
def lsl
 
def lsr
 
def asr
 
def mov
 
def movk
 
def movz
 
def movn
 
def bl
 
def csel
 
def csinc
 
def csinv
 
def csneg
 
def cset
 
def csetm
 
def get_mem_access
 
def ldr
 
def ldrb
 
def ldrh
 
def l_str
 
def strb
 
def strh
 
def stp
 
def ldp
 
def ldrsw
 
def sbfm
 
def ubfm
 
def bfm
 
def madd
 
def msub
 
def udiv
 
def cbz
 
def cbnz
 
def tbz
 
def tbnz
 
def b_ne
 
def b_eq
 
def b_ge
 
def b_gt
 
def b_cc
 
def b_cs
 
def b_hi
 
def b_le
 
def b_ls
 
def b_lt
 
def ret
 
def adrp
 
def b
 
def br
 
def nop
 
def extr
 
def get_mnemo_expr
 

Variables

tuple EXCEPT_PRIV_INSN = (1 << 17)
 
dictionary cond2expr
 
dictionary ctx
 
tuple sbuild = SemBuilder(ctx)
 
 mnemo_func = sbuild.functions
 

Function Documentation

def miasm2.arch.aarch64.sem.add (   arg1,
  arg2,
  arg3 
)

Definition at line 148 of file sem.py.

149 def add(arg1, arg2, arg3):
150  arg1 = arg2 + extend_arg(arg2, arg3)
151 
152 
@sbuild.parse

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

def miasm2.arch.aarch64.sem.adds (   ir,
  instr,
  arg1,
  arg2,
  arg3 
)

Definition at line 197 of file sem.py.

198 def adds(ir, instr, arg1, arg2, arg3):
199  e = []
200  arg3 = extend_arg(arg2, arg3)
201  res = arg2 + arg3
202  e += update_flag_arith(res)
203  e += update_flag_add(arg2, arg3, res)
204  e.append(m2_expr.ExprAff(arg1, res))
205  return e, []
206 

+ Here is the call graph for this function:

def miasm2.arch.aarch64.sem.adrp (   arg1,
  arg2 
)

Definition at line 651 of file sem.py.

652 def adrp(arg1, arg2):
653  arg1 = (PC & m2_expr.ExprInt64(0xfffffffffffff000)) + arg2
654 
655 
@sbuild.parse
def miasm2.arch.aarch64.sem.and_l (   arg1,
  arg2,
  arg3 
)

Definition at line 163 of file sem.py.

164 def and_l(arg1, arg2, arg3):
165  arg1 = arg2 & extend_arg(arg2, arg3)
166 
167 
@sbuild.parse

+ Here is the call graph for this function:

def miasm2.arch.aarch64.sem.ands (   ir,
  instr,
  arg1,
  arg2,
  arg3 
)

Definition at line 235 of file sem.py.

236 def ands(ir, instr, arg1, arg2, arg3):
237  e = []
238  arg3 = extend_arg(arg2, arg3)
239  res = arg2 & arg3
240  e += update_flag_logic(res)
241  e.append(m2_expr.ExprAff(arg1, res))
242  return e, []

+ Here is the call graph for this function:

def miasm2.arch.aarch64.sem.arith_flag (   a,
  b,
  c 
)

Definition at line 46 of file sem.py.

46 
47 def arith_flag(a, b, c):
48  a_s, b_s, c_s = a.size, b.size, c.size
49  check_ops_msb(a_s, b_s, c_s)
50  a_s, b_s, c_s = a.msb(), b.msb(), c.msb()
51  return a_s, b_s, c_s
52 
53 # checked: ok for adc add because b & c before +cf
54 

+ Here is the call graph for this function:

def miasm2.arch.aarch64.sem.asr (   arg1,
  arg2,
  arg3 
)

Definition at line 262 of file sem.py.

263 def asr(arg1, arg2, arg3):
264  arg1 = m2_expr.ExprOp(
265  'a>>', arg2, (arg3 & m2_expr.ExprInt_from(arg3, arg3.size - 1)))
266 
267 
@sbuild.parse
def miasm2.arch.aarch64.sem.b (   arg1)

Definition at line 656 of file sem.py.

657 def b(arg1):
658  PC = arg1
659  ir.IRDst = arg1
660 
661 
@sbuild.parse

+ Here is the caller graph for this function:

def miasm2.arch.aarch64.sem.b_cc (   arg1)

Definition at line 597 of file sem.py.

598 def b_cc(arg1):
599  cond = cond2expr['CC']
600  dst = arg1 if cond else m2_expr.ExprId(ir.get_next_label(instr), 64)
601  PC = dst
602  ir.IRDst = dst
603 
604 
@sbuild.parse
def miasm2.arch.aarch64.sem.b_cs (   arg1)

Definition at line 605 of file sem.py.

606 def b_cs(arg1):
607  cond = cond2expr['CS']
608  dst = arg1 if cond else m2_expr.ExprId(ir.get_next_label(instr), 64)
609  PC = dst
610  ir.IRDst = dst
611 
612 
@sbuild.parse
def miasm2.arch.aarch64.sem.b_eq (   arg1)

Definition at line 574 of file sem.py.

575 def b_eq(arg1):
576  dst = arg1 if zf else m2_expr.ExprId(ir.get_next_label(instr), 64)
577  PC = dst
578  ir.IRDst = dst
579 
580 
@sbuild.parse
def miasm2.arch.aarch64.sem.b_ge (   arg1)

Definition at line 581 of file sem.py.

582 def b_ge(arg1):
583  cond = cond2expr['GE']
584  dst = arg1 if cond else m2_expr.ExprId(ir.get_next_label(instr), 64)
585  PC = dst
586  ir.IRDst = dst
587 
588 
@sbuild.parse
def miasm2.arch.aarch64.sem.b_gt (   arg1)

Definition at line 589 of file sem.py.

590 def b_gt(arg1):
591  cond = cond2expr['GT']
592  dst = arg1 if cond else m2_expr.ExprId(ir.get_next_label(instr), 64)
593  PC = dst
594  ir.IRDst = dst
595 
596 
@sbuild.parse
def miasm2.arch.aarch64.sem.b_hi (   arg1)

Definition at line 613 of file sem.py.

614 def b_hi(arg1):
615  cond = cond2expr['HI']
616  dst = arg1 if cond else m2_expr.ExprId(ir.get_next_label(instr), 64)
617  PC = dst
618  ir.IRDst = dst
619 
620 
@sbuild.parse
def miasm2.arch.aarch64.sem.b_le (   arg1)

Definition at line 621 of file sem.py.

622 def b_le(arg1):
623  cond = cond2expr['LE']
624  dst = arg1 if cond else m2_expr.ExprId(ir.get_next_label(instr), 64)
625  PC = dst
626  ir.IRDst = dst
627 
628 
@sbuild.parse
def miasm2.arch.aarch64.sem.b_ls (   arg1)

Definition at line 629 of file sem.py.

630 def b_ls(arg1):
631  cond = cond2expr['LS']
632  dst = arg1 if cond else m2_expr.ExprId(ir.get_next_label(instr), 64)
633  PC = dst
634  ir.IRDst = dst
635 
636 
@sbuild.parse
def miasm2.arch.aarch64.sem.b_lt (   arg1)

Definition at line 637 of file sem.py.

638 def b_lt(arg1):
639  cond = cond2expr['LT']
640  dst = arg1 if cond else m2_expr.ExprId(ir.get_next_label(instr), 64)
641  PC = dst
642  ir.IRDst = dst
643 
644 
@sbuild.parse
def miasm2.arch.aarch64.sem.b_ne (   arg1)

Definition at line 567 of file sem.py.

568 def b_ne(arg1):
569  dst = m2_expr.ExprId(ir.get_next_label(instr), 64) if zf else arg1
570  PC = dst
571  ir.IRDst = dst
572 
573 
@sbuild.parse
def miasm2.arch.aarch64.sem.bfm (   ir,
  instr,
  arg1,
  arg2,
  arg3,
  arg4 
)

Definition at line 505 of file sem.py.

506 def bfm(ir, instr, arg1, arg2, arg3, arg4):
507  e = []
508  rim, sim = int(arg3.arg), int(arg4.arg) + 1
509  if sim > rim:
510  res = arg2[rim:sim]
511  e.append(m2_expr.ExprAff(arg1[:sim-rim], res))
512  else:
513  shift_i = arg2.size - rim
514  shift = m2_expr.ExprInt_from(arg2, shift_i)
515  res = arg2[:sim]
516  e.append(m2_expr.ExprAff(arg1[shift_i:shift_i+sim], res))
517  return e, []
518 
519 
@sbuild.parse
def miasm2.arch.aarch64.sem.bic (   arg1,
  arg2,
  arg3 
)

Definition at line 188 of file sem.py.

189 def bic(arg1, arg2, arg3):
190  arg1 = arg2 & (~extend_arg(arg2, arg3))
191 
192 
@sbuild.parse

+ Here is the call graph for this function:

def miasm2.arch.aarch64.sem.bl (   arg1)

Definition at line 298 of file sem.py.

299 def bl(arg1):
300  PC = arg1
301  ir.IRDst = arg1
302  LR = m2_expr.ExprInt64(instr.offset + instr.l)
303 
@sbuild.parse
def miasm2.arch.aarch64.sem.br (   arg1)

Definition at line 662 of file sem.py.

663 def br(arg1):
664  PC = arg1
665  ir.IRDst = arg1
666 
667 
@sbuild.parse
def miasm2.arch.aarch64.sem.cbnz (   arg1,
  arg2 
)

Definition at line 542 of file sem.py.

543 def cbnz(arg1, arg2):
544  dst = arg2 if arg1 else m2_expr.ExprId(ir.get_next_label(instr), 64)
545  PC = dst
546  ir.IRDst = dst
547 
548 
@sbuild.parse
def miasm2.arch.aarch64.sem.cbz (   arg1,
  arg2 
)

Definition at line 535 of file sem.py.

536 def cbz(arg1, arg2):
537  dst = m2_expr.ExprId(ir.get_next_label(instr), 64) if arg1 else arg2
538  PC = dst
539  ir.IRDst = dst
540 
541 
@sbuild.parse
def miasm2.arch.aarch64.sem.check_ops_msb (   a,
  b,
  c 
)

Definition at line 41 of file sem.py.

41 
42 def check_ops_msb(a, b, c):
43  if not a or not b or not c or a != b or a != c:
44  raise ValueError('bad ops size %s %s %s' % (a, b, c))
45 

+ Here is the caller graph for this function:

def miasm2.arch.aarch64.sem.cmn (   ir,
  instr,
  arg1,
  arg2 
)

Definition at line 226 of file sem.py.

227 def cmn(ir, instr, arg1, arg2):
228  e = []
229  arg2 = extend_arg(arg1, arg2)
230  res = arg1 + arg2
231  e += update_flag_arith(res)
232  e += update_flag_add(arg1, arg2, res)
233  return e, []
234 

+ Here is the call graph for this function:

def miasm2.arch.aarch64.sem.cmp (   ir,
  instr,
  arg1,
  arg2 
)

Definition at line 217 of file sem.py.

218 def cmp(ir, instr, arg1, arg2):
219  e = []
220  arg2 = extend_arg(arg1, arg2)
221  res = arg1 - arg2
222  e += update_flag_arith(res)
223  e += update_flag_sub(arg1, arg2, res)
224  return e, []
225 

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

def miasm2.arch.aarch64.sem.csel (   arg1,
  arg2,
  arg3,
  arg4 
)

Definition at line 304 of file sem.py.

305 def csel(arg1, arg2, arg3, arg4):
306  cond_expr = cond2expr[arg4.name]
307  arg1 = arg2 if cond_expr else arg3
308 
def miasm2.arch.aarch64.sem.cset (   ir,
  instr,
  arg1,
  arg2 
)

Definition at line 336 of file sem.py.

337 def cset(ir, instr, arg1, arg2):
338  e = []
339  cond_expr = cond2expr[arg2.name]
340  e.append(m2_expr.ExprAff(arg1, m2_expr.ExprCond(cond_expr,
341  m2_expr.ExprInt_from(
342  arg1, 1),
343  m2_expr.ExprInt_from(arg1, 0))))
344  return e, []
345 
def miasm2.arch.aarch64.sem.csetm (   ir,
  instr,
  arg1,
  arg2 
)

Definition at line 346 of file sem.py.

347 def csetm(ir, instr, arg1, arg2):
348  e = []
349  cond_expr = cond2expr[arg2.name]
350  e.append(m2_expr.ExprAff(arg1, m2_expr.ExprCond(cond_expr,
351  m2_expr.ExprInt_from(
352  arg1, -1),
353  m2_expr.ExprInt_from(arg1, 0))))
354  return e, []
355 
def miasm2.arch.aarch64.sem.csinc (   ir,
  instr,
  arg1,
  arg2,
  arg3,
  arg4 
)

Definition at line 309 of file sem.py.

310 def csinc(ir, instr, arg1, arg2, arg3, arg4):
311  e = []
312  cond_expr = cond2expr[arg4.name]
313  e.append(m2_expr.ExprAff(arg1, m2_expr.ExprCond(cond_expr,
314  arg2,
315  arg3 + m2_expr.ExprInt_from(arg3, 1))))
316  return e, []
317 
def miasm2.arch.aarch64.sem.csinv (   ir,
  instr,
  arg1,
  arg2,
  arg3,
  arg4 
)

Definition at line 318 of file sem.py.

319 def csinv(ir, instr, arg1, arg2, arg3, arg4):
320  e = []
321  cond_expr = cond2expr[arg4.name]
322  e.append(m2_expr.ExprAff(arg1, m2_expr.ExprCond(cond_expr,
323  arg2,
324  ~arg3)))
325  return e, []
326 
def miasm2.arch.aarch64.sem.csneg (   ir,
  instr,
  arg1,
  arg2,
  arg3,
  arg4 
)

Definition at line 327 of file sem.py.

328 def csneg(ir, instr, arg1, arg2, arg3, arg4):
329  e = []
330  cond_expr = cond2expr[arg4.name]
331  e.append(m2_expr.ExprAff(arg1, m2_expr.ExprCond(cond_expr,
332  arg2,
333  -arg3)))
334  return e, []
335 
def miasm2.arch.aarch64.sem.eon (   arg1,
  arg2,
  arg3 
)

Definition at line 173 of file sem.py.

174 def eon(arg1, arg2, arg3):
175  arg1 = arg2 ^ (~extend_arg(arg2, arg3))
176 
177 
@sbuild.parse

+ Here is the call graph for this function:

def miasm2.arch.aarch64.sem.eor (   arg1,
  arg2,
  arg3 
)

Definition at line 168 of file sem.py.

169 def eor(arg1, arg2, arg3):
170  arg1 = arg2 ^ extend_arg(arg2, arg3)
171 
172 
@sbuild.parse

+ Here is the call graph for this function:

def miasm2.arch.aarch64.sem.extend_arg (   dst,
  arg 
)

Definition at line 115 of file sem.py.

116 def extend_arg(dst, arg):
117  if not isinstance(arg, m2_expr.ExprOp):
118  return arg
119 
120  op, (reg, shift) = arg.op, arg.args
121  if op == 'SXTW':
122  base = reg.signExtend(dst.size)
123  else:
124  base = reg.zeroExtend(dst.size)
125 
126  out = base << (shift.zeroExtend(dst.size)
127  & m2_expr.ExprInt_from(dst, dst.size - 1))
128  return out
129 
130 
# SemBuilder context

+ Here is the caller graph for this function:

def miasm2.arch.aarch64.sem.extr (   arg1,
  arg2,
  arg3,
  arg4 
)

Definition at line 674 of file sem.py.

675 def extr(arg1, arg2, arg3, arg4):
676  compose = m2_expr.ExprCompose([(arg2, 0, arg2.size),
677  (arg3, arg2.size, arg2.size+arg3.size)])
678  arg1 = compose[int(arg4.arg):int(arg4.arg)+arg1.size]
def miasm2.arch.aarch64.sem.get_mem_access (   mem)

Definition at line 356 of file sem.py.

357 def get_mem_access(mem):
358  updt = None
359  if isinstance(mem, m2_expr.ExprOp):
360  if mem.op == 'preinc':
361  addr = mem.args[0] + mem.args[1]
362  elif mem.op == 'segm':
363  base = mem.args[0]
364  op, (reg, shift) = mem.args[1].op, mem.args[1].args
365  if op == 'SXTW':
366  off = reg.signExtend(base.size) << shift.zeroExtend(base.size)
367  addr = base + off
368  elif op == 'UXTW':
369  off = reg.zeroExtend(base.size) << shift.zeroExtend(base.size)
370  addr = base + off
371  elif op == 'LSL':
372  if isinstance(shift, m2_expr.ExprInt) and int(shift.arg) == 0:
373  addr = base + reg.zeroExtend(base.size)
374  else:
375  addr = base + \
376  (reg.zeroExtend(base.size)
377  << shift.zeroExtend(base.size))
378  else:
379  raise NotImplementedError('bad op')
380  elif mem.op == "postinc":
381  addr, off = mem.args
382  updt = m2_expr.ExprAff(addr, addr + off)
383  elif mem.op == "preinc_wb":
384  base, off = mem.args
385  addr = base + off
386  updt = m2_expr.ExprAff(base, base + off)
387  else:
388  raise NotImplementedError('bad op')
389  else:
390  raise NotImplementedError('bad op')
391  return addr, updt
392 
393 

+ Here is the caller graph for this function:

def miasm2.arch.aarch64.sem.get_mnemo_expr (   ir,
  instr,
  args 
)

Definition at line 738 of file sem.py.

739 def get_mnemo_expr(ir, instr, *args):
740  if not instr.name.lower() in mnemo_func:
741  raise NotImplementedError('unknown mnemo %s' % instr)
742  instr, extra_ir = mnemo_func[instr.name.lower()](ir, instr, *args)
743  return instr, extra_ir
744 

+ Here is the caller graph for this function:

def miasm2.arch.aarch64.sem.l_str (   ir,
  instr,
  arg1,
  arg2 
)

Definition at line 423 of file sem.py.

424 def l_str(ir, instr, arg1, arg2):
425  e = []
426  addr, updt = get_mem_access(arg2)
427  e.append(m2_expr.ExprAff(m2_expr.ExprMem(addr, arg1.size), arg1))
428  if updt:
429  e.append(updt)
430  return e, []
431 

+ Here is the call graph for this function:

def miasm2.arch.aarch64.sem.ldp (   ir,
  instr,
  arg1,
  arg2,
  arg3 
)

Definition at line 461 of file sem.py.

462 def ldp(ir, instr, arg1, arg2, arg3):
463  e = []
464  addr, updt = get_mem_access(arg3)
465  e.append(m2_expr.ExprAff(arg1, m2_expr.ExprMem(addr, arg1.size)))
466  e.append(
467  m2_expr.ExprAff(arg2, m2_expr.ExprMem(addr + m2_expr.ExprInt_from(addr, arg1.size / 8), arg2.size)))
468  if updt:
469  e.append(updt)
470  return e, []
471 

+ Here is the call graph for this function:

def miasm2.arch.aarch64.sem.ldr (   ir,
  instr,
  arg1,
  arg2 
)

Definition at line 394 of file sem.py.

395 def ldr(ir, instr, arg1, arg2):
396  e = []
397  addr, updt = get_mem_access(arg2)
398  e.append(m2_expr.ExprAff(arg1, m2_expr.ExprMem(addr, arg1.size)))
399  if updt:
400  e.append(updt)
401  return e, []
402 

+ Here is the call graph for this function:

def miasm2.arch.aarch64.sem.ldrb (   ir,
  instr,
  arg1,
  arg2 
)

Definition at line 403 of file sem.py.

404 def ldrb(ir, instr, arg1, arg2):
405  e = []
406  addr, updt = get_mem_access(arg2)
407  e.append(
408  m2_expr.ExprAff(arg1, m2_expr.ExprMem(addr, 8).zeroExtend(arg1.size)))
409  if updt:
410  e.append(updt)
411  return e, []
412 

+ Here is the call graph for this function:

def miasm2.arch.aarch64.sem.ldrh (   ir,
  instr,
  arg1,
  arg2 
)

Definition at line 413 of file sem.py.

414 def ldrh(ir, instr, arg1, arg2):
415  e = []
416  addr, updt = get_mem_access(arg2)
417  e.append(
418  m2_expr.ExprAff(arg1, m2_expr.ExprMem(addr, 16).zeroExtend(arg1.size)))
419  if updt:
420  e.append(updt)
421  return e, []
422 

+ Here is the call graph for this function:

def miasm2.arch.aarch64.sem.ldrsw (   ir,
  instr,
  arg1,
  arg2 
)

Definition at line 472 of file sem.py.

473 def ldrsw(ir, instr, arg1, arg2):
474  e = []
475  addr, updt = get_mem_access(arg2)
476  e.append(
477  m2_expr.ExprAff(arg1, m2_expr.ExprMem(addr, 32).signExtend(arg1.size)))
478  if updt:
479  e.append(updt)
480  return e, []
481 

+ Here is the call graph for this function:

def miasm2.arch.aarch64.sem.lsl (   arg1,
  arg2,
  arg3 
)

Definition at line 252 of file sem.py.

253 def lsl(arg1, arg2, arg3):
254  arg1 = arg2 << (arg3 & m2_expr.ExprInt_from(arg3, arg3.size - 1))
255 
256 
@sbuild.parse
def miasm2.arch.aarch64.sem.lsr (   arg1,
  arg2,
  arg3 
)

Definition at line 257 of file sem.py.

258 def lsr(arg1, arg2, arg3):
259  arg1 = arg2 >> (arg3 & m2_expr.ExprInt_from(arg3, arg3.size - 1))
260 
261 
@sbuild.parse
def miasm2.arch.aarch64.sem.madd (   arg1,
  arg2,
  arg3,
  arg4 
)

Definition at line 520 of file sem.py.

521 def madd(arg1, arg2, arg3, arg4):
522  arg1 = arg2 * arg3 + arg4
523 
524 
@sbuild.parse
def miasm2.arch.aarch64.sem.mov (   arg1,
  arg2 
)

Definition at line 268 of file sem.py.

269 def mov(arg1, arg2):
270  arg1 = arg2
271 
def miasm2.arch.aarch64.sem.movk (   ir,
  instr,
  arg1,
  arg2 
)

Definition at line 272 of file sem.py.

273 def movk(ir, instr, arg1, arg2):
274  e = []
275  if isinstance(arg2, m2_expr.ExprOp):
276  assert(arg2.op == 'slice_at' and
277  isinstance(arg2.args[0], m2_expr.ExprInt) and
278  isinstance(arg2.args[1], m2_expr.ExprInt))
279  value, shift = int(arg2.args[0].arg), int(arg2.args[1].arg)
280  e.append(
281  m2_expr.ExprAff(arg1[shift:shift + 16], m2_expr.ExprInt16(value)))
282  else:
283  e.append(m2_expr.ExprAff(arg1[:16], m2_expr.ExprInt16(int(arg2.arg))))
284 
285  return e, []
286 
287 
@sbuild.parse
def miasm2.arch.aarch64.sem.movn (   arg1,
  arg2 
)

Definition at line 293 of file sem.py.

294 def movn(arg1, arg2):
295  arg1 = ~arg2
296 
297 
@sbuild.parse
def miasm2.arch.aarch64.sem.movz (   arg1,
  arg2 
)

Definition at line 288 of file sem.py.

289 def movz(arg1, arg2):
290  arg1 = arg2
291 
292 
@sbuild.parse
def miasm2.arch.aarch64.sem.msub (   arg1,
  arg2,
  arg3,
  arg4 
)

Definition at line 525 of file sem.py.

526 def msub(arg1, arg2, arg3, arg4):
527  arg1 = arg4 - (arg2 * arg3)
528 
529 
@sbuild.parse
def miasm2.arch.aarch64.sem.mvn (   arg1,
  arg2 
)

Definition at line 193 of file sem.py.

194 def mvn(arg1, arg2):
195  arg1 = (~extend_arg(arg1, arg2))
196 

+ Here is the call graph for this function:

def miasm2.arch.aarch64.sem.neg (   arg1,
  arg2 
)

Definition at line 158 of file sem.py.

159 def neg(arg1, arg2):
160  arg1 = - arg2
161 
162 
@sbuild.parse
def miasm2.arch.aarch64.sem.nop ( )
Do nothing

Definition at line 668 of file sem.py.

669 def nop():
670  """Do nothing"""
671 
672 
673 
@sbuild.parse
def miasm2.arch.aarch64.sem.orn (   arg1,
  arg2,
  arg3 
)

Definition at line 183 of file sem.py.

184 def orn(arg1, arg2, arg3):
185  arg1 = arg2 | (~extend_arg(arg2, arg3))
186 
187 
@sbuild.parse

+ Here is the call graph for this function:

def miasm2.arch.aarch64.sem.orr (   arg1,
  arg2,
  arg3 
)

Definition at line 178 of file sem.py.

179 def orr(arg1, arg2, arg3):
180  arg1 = arg2 | extend_arg(arg2, arg3)
181 
182 
@sbuild.parse

+ Here is the call graph for this function:

def miasm2.arch.aarch64.sem.ret (   arg1)

Definition at line 645 of file sem.py.

646 def ret(arg1):
647  PC = arg1
648  ir.IRDst = arg1
649 
650 
@sbuild.parse

+ Here is the caller graph for this function:

def miasm2.arch.aarch64.sem.sbfm (   ir,
  instr,
  arg1,
  arg2,
  arg3,
  arg4 
)

Definition at line 482 of file sem.py.

483 def sbfm(ir, instr, arg1, arg2, arg3, arg4):
484  e = []
485  rim, sim = int(arg3.arg), int(arg4.arg) + 1
486  if sim > rim:
487  res = arg2[rim:sim].signExtend(arg1.size)
488  else:
489  shift = m2_expr.ExprInt_from(arg2, arg2.size - rim)
490  res = (arg2[:sim].signExtend(arg1.size) << shift)
491  e.append(m2_expr.ExprAff(arg1, res))
492  return e, []
493 
def miasm2.arch.aarch64.sem.stp (   ir,
  instr,
  arg1,
  arg2,
  arg3 
)

Definition at line 450 of file sem.py.

451 def stp(ir, instr, arg1, arg2, arg3):
452  e = []
453  addr, updt = get_mem_access(arg3)
454  e.append(m2_expr.ExprAff(m2_expr.ExprMem(addr, arg1.size), arg1))
455  e.append(
456  m2_expr.ExprAff(m2_expr.ExprMem(addr + m2_expr.ExprInt_from(addr, arg1.size / 8), arg2.size), arg2))
457  if updt:
458  e.append(updt)
459  return e, []
460 

+ Here is the call graph for this function:

def miasm2.arch.aarch64.sem.strb (   ir,
  instr,
  arg1,
  arg2 
)

Definition at line 432 of file sem.py.

433 def strb(ir, instr, arg1, arg2):
434  e = []
435  addr, updt = get_mem_access(arg2)
436  e.append(m2_expr.ExprAff(m2_expr.ExprMem(addr, 8), arg1[:8]))
437  if updt:
438  e.append(updt)
439  return e, []
440 

+ Here is the call graph for this function:

def miasm2.arch.aarch64.sem.strh (   ir,
  instr,
  arg1,
  arg2 
)

Definition at line 441 of file sem.py.

442 def strh(ir, instr, arg1, arg2):
443  e = []
444  addr, updt = get_mem_access(arg2)
445  e.append(m2_expr.ExprAff(m2_expr.ExprMem(addr, 16), arg1[:16]))
446  if updt:
447  e.append(updt)
448  return e, []
449 

+ Here is the call graph for this function:

def miasm2.arch.aarch64.sem.sub (   arg1,
  arg2,
  arg3 
)

Definition at line 153 of file sem.py.

154 def sub(arg1, arg2, arg3):
155  arg1 = arg2 - extend_arg(arg2, arg3)
156 
157 
@sbuild.parse

+ Here is the call graph for this function:

def miasm2.arch.aarch64.sem.subs (   ir,
  instr,
  arg1,
  arg2,
  arg3 
)

Definition at line 207 of file sem.py.

208 def subs(ir, instr, arg1, arg2, arg3):
209  e = []
210  arg3 = extend_arg(arg2, arg3)
211  res = arg2 - arg3
212  e += update_flag_arith(res)
213  e += update_flag_sub(arg2, arg3, res)
214  e.append(m2_expr.ExprAff(arg1, res))
215  return e, []
216 

+ Here is the call graph for this function:

def miasm2.arch.aarch64.sem.tbnz (   arg1,
  arg2,
  arg3 
)

Definition at line 558 of file sem.py.

559 def tbnz(arg1, arg2, arg3):
560  bitmask = m2_expr.ExprInt_from(arg1, 1) << arg2
561  dst = arg3 if arg1 & bitmask else m2_expr.ExprId(
562  ir.get_next_label(instr), 64)
563  PC = dst
564  ir.IRDst = dst
565 
566 
@sbuild.parse
def miasm2.arch.aarch64.sem.tbz (   arg1,
  arg2,
  arg3 
)

Definition at line 549 of file sem.py.

550 def tbz(arg1, arg2, arg3):
551  bitmask = m2_expr.ExprInt_from(arg1, 1) << arg2
552  dst = m2_expr.ExprId(
553  ir.get_next_label(instr), 64) if arg1 & bitmask else arg3
554  PC = dst
555  ir.IRDst = dst
556 
557 
@sbuild.parse
def miasm2.arch.aarch64.sem.tst (   ir,
  instr,
  arg1,
  arg2 
)

Definition at line 243 of file sem.py.

244 def tst(ir, instr, arg1, arg2):
245  e = []
246  arg2 = extend_arg(arg1, arg2)
247  res = arg1 & arg2
248  e += update_flag_logic(res)
249  return e, []
250 
251 
@sbuild.parse

+ Here is the call graph for this function:

def miasm2.arch.aarch64.sem.ubfm (   ir,
  instr,
  arg1,
  arg2,
  arg3,
  arg4 
)

Definition at line 494 of file sem.py.

495 def ubfm(ir, instr, arg1, arg2, arg3, arg4):
496  e = []
497  rim, sim = int(arg3.arg), int(arg4.arg) + 1
498  if sim > rim:
499  res = arg2[rim:sim].zeroExtend(arg1.size)
500  else:
501  shift = m2_expr.ExprInt_from(arg2, arg2.size - rim)
502  res = (arg2[:sim].zeroExtend(arg1.size) << shift)
503  e.append(m2_expr.ExprAff(arg1, res))
504  return e, []
def miasm2.arch.aarch64.sem.udiv (   arg1,
  arg2,
  arg3 
)

Definition at line 530 of file sem.py.

531 def udiv(arg1, arg2, arg3):
532  arg1 = m2_expr.ExprOp('udiv', arg2, arg3)
533 
534 
@sbuild.parse
def miasm2.arch.aarch64.sem.update_flag_add (   x,
  y,
  z 
)

Definition at line 79 of file sem.py.

79 
80 def update_flag_add(x, y, z):
81  e = []
82  e.append(update_flag_add_cf(x, y, z))
83  e.append(update_flag_add_of(x, y, z))
84  return e
85 
86 # z = x-y (+cf?)
87 
def update_flag_add_of
Definition: sem.py:60
def update_flag_add_cf
Definition: sem.py:55

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

def miasm2.arch.aarch64.sem.update_flag_add_cf (   op1,
  op2,
  res 
)

Definition at line 55 of file sem.py.

55 
56 def update_flag_add_cf(op1, op2, res):
57  "Compute cf in @res = @op1 + @op2"
58  return m2_expr.ExprAff(cf, (((op1 ^ op2) ^ res) ^ ((op1 ^ res) & (~(op1 ^ op2)))).msb())
59 
def update_flag_add_cf
Definition: sem.py:55

+ Here is the caller graph for this function:

def miasm2.arch.aarch64.sem.update_flag_add_of (   op1,
  op2,
  res 
)

Definition at line 60 of file sem.py.

60 
61 def update_flag_add_of(op1, op2, res):
62  "Compute of in @res = @op1 + @op2"
63  return m2_expr.ExprAff(of, (((op1 ^ res) & (~(op1 ^ op2)))).msb())
64 
65 
# checked: ok for sbb add because b & c before +cf
def update_flag_add_of
Definition: sem.py:60

+ Here is the caller graph for this function:

def miasm2.arch.aarch64.sem.update_flag_arith (   a)

Definition at line 35 of file sem.py.

35 
36 def update_flag_arith(a):
37  e = []
38  e += update_flag_zn(a)
39  return e
40 

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

def miasm2.arch.aarch64.sem.update_flag_logic (   a)

Definition at line 27 of file sem.py.

27 
28 def update_flag_logic(a):
29  e = []
30  e += update_flag_zn(a)
31  # XXX TODO: set cf if ROT imm in argument
32  # e.append(m2_expr.ExprAff(cf, m2_expr.ExprInt1(0)))
33  return e
34 

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

def miasm2.arch.aarch64.sem.update_flag_nf (   a)

Definition at line 16 of file sem.py.

16 
17 def update_flag_nf(a):
18  return [m2_expr.ExprAff(nf, a.msb())]
19 

+ Here is the caller graph for this function:

def miasm2.arch.aarch64.sem.update_flag_sub (   x,
  y,
  z 
)

Definition at line 88 of file sem.py.

88 
89 def update_flag_sub(x, y, z):
90  e = []
91  e.append(update_flag_sub_cf(x, y, z))
92  e.append(update_flag_sub_of(x, y, z))
93  return e
94 
def update_flag_sub_of
Definition: sem.py:72
def update_flag_sub_cf
Definition: sem.py:66

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

def miasm2.arch.aarch64.sem.update_flag_sub_cf (   op1,
  op2,
  res 
)

Definition at line 66 of file sem.py.

66 
67 def update_flag_sub_cf(op1, op2, res):
68  "Compote CF in @res = @op1 - @op2"
69  return m2_expr.ExprAff(cf,
70  ((((op1 ^ op2) ^ res) ^ ((op1 ^ res) & (op1 ^ op2))).msb()) ^ m2_expr.ExprInt1(1))
71 
def update_flag_sub_cf
Definition: sem.py:66

+ Here is the caller graph for this function:

def miasm2.arch.aarch64.sem.update_flag_sub_of (   op1,
  op2,
  res 
)

Definition at line 72 of file sem.py.

72 
73 def update_flag_sub_of(op1, op2, res):
74  "Compote OF in @res = @op1 - @op2"
75  return m2_expr.ExprAff(of, (((op1 ^ res) & (op1 ^ op2))).msb())
76 
77 # z = x+y (+cf?)
78 
def update_flag_sub_of
Definition: sem.py:72

+ Here is the caller graph for this function:

def miasm2.arch.aarch64.sem.update_flag_zf (   a)

Definition at line 12 of file sem.py.

12 
13 def update_flag_zf(a):
14  return [m2_expr.ExprAff(zf, m2_expr.ExprCond(a, m2_expr.ExprInt1(0), m2_expr.ExprInt1(1)))]
15 

+ Here is the caller graph for this function:

def miasm2.arch.aarch64.sem.update_flag_zn (   a)

Definition at line 20 of file sem.py.

20 
21 def update_flag_zn(a):
22  e = []
23  e += update_flag_zf(a)
24  e += update_flag_nf(a)
25  return e
26 

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Variable Documentation

dictionary miasm2.arch.aarch64.sem.cond2expr
Initial value:
1 = {'EQ': zf,
2  'NE': zf ^ m2_expr.ExprInt1(1),
3  'CS': cf,
4  'CC': cf ^ m2_expr.ExprInt1(1),
5  'MI': nf,
6  'PL': nf ^ m2_expr.ExprInt1(1),
7  'VS': of,
8  'VC': of ^ m2_expr.ExprInt1(1),
9  'HI': cf & (zf ^ m2_expr.ExprInt1(1)),
10  'LS': (cf ^ m2_expr.ExprInt1(1)) | zf,
11  'GE': nf ^ of ^ m2_expr.ExprInt1(1),
12  'LT': nf ^ of,
13  'GT': ((zf ^ m2_expr.ExprInt1(1)) &
14  (nf ^ of ^ m2_expr.ExprInt1(1))),
15  'LE': zf | (nf ^ of),
16  'AL': m2_expr.ExprInt1(1),
17  'NV': m2_expr.ExprInt1(0)
18  }

Definition at line 95 of file sem.py.

dictionary miasm2.arch.aarch64.sem.ctx
Initial value:
1 = {"PC": PC,
2  "LR": LR,
3  "nf": nf,
4  "zf": zf,
5  "cf": cf,
6  "of": of,
7  "cond2expr": cond2expr,
8  "extend_arg": extend_arg,
9  "m2_expr":m2_expr
10  }

Definition at line 131 of file sem.py.

tuple miasm2.arch.aarch64.sem.EXCEPT_PRIV_INSN = (1 << 17)

Definition at line 7 of file sem.py.

miasm2.arch.aarch64.sem.mnemo_func = sbuild.functions

Definition at line 679 of file sem.py.

tuple miasm2.arch.aarch64.sem.sbuild = SemBuilder(ctx)

Definition at line 142 of file sem.py.