Miasm2
 All Classes Namespaces Files Functions Variables Typedefs Properties Macros
Public Member Functions | Static Public Member Functions | Public Attributes | Static Public Attributes | List of all members
miasm2.arch.aarch64.arch.instruction_aarch64 Class Reference
+ Inheritance diagram for miasm2.arch.aarch64.arch.instruction_aarch64:
+ Collaboration diagram for miasm2.arch.aarch64.arch.instruction_aarch64:

Public Member Functions

def __init__
 
def dstflow
 
def mnemo_flow_to_dst_index
 
def dstflow2label
 
def breakflow
 
def is_subcall
 
def getdstflow
 
def splitflow
 
def get_symbol_size
 
def fixDstOffset
 
def gen_args
 
def __str__
 
def get_asm_offset
 
def resolve_args_with_symbols
 
def get_info
 

Static Public Member Functions

def arg2str
 

Public Attributes

 name
 
 mode
 
 args
 
 additional_info
 

Static Public Attributes

int delayslot = 0
 

Detailed Description

Definition at line 327 of file arch.py.

Constructor & Destructor Documentation

def miasm2.arch.aarch64.arch.instruction_aarch64.__init__ (   self,
  args,
  kargs 
)

Definition at line 330 of file arch.py.

331  def __init__(self, *args, **kargs):
332  super(instruction_aarch64, self).__init__(*args, **kargs)

Member Function Documentation

def miasm2.core.cpu.instruction.__str__ (   self)
inherited

Definition at line 924 of file cpu.py.

925  def __str__(self):
926  o = "%-10s " % self.name
927  args = []
928  for i, arg in enumerate(self.args):
929  if not isinstance(arg, m2_expr.Expr):
930  raise ValueError('zarb arg type')
931  x = self.arg2str(arg, pos = i)
932  args.append(x)
933  o += self.gen_args(args)
934  return o

+ Here is the call graph for this function:

def miasm2.arch.aarch64.arch.instruction_aarch64.arg2str (   e,
  pos = None 
)
static

Definition at line 334 of file arch.py.

335  def arg2str(e, pos=None):
336  wb = False
337  if isinstance(e, m2_expr.ExprId) or isinstance(e, m2_expr.ExprInt):
338  return str(e)
339  elif isinstance(e, m2_expr.ExprOp) and e.op in shift_expr:
340  op_str = shift_str[shift_expr.index(e.op)]
341  return "%s %s %s" % (e.args[0], op_str, e.args[1])
342  elif isinstance(e, m2_expr.ExprOp) and e.op == "slice_at":
343  return "%s LSL %s" % (e.args[0], e.args[1])
344  elif isinstance(e, m2_expr.ExprOp) and e.op in extend_lst:
345  op_str = e.op
346  return "%s %s %s" % (e.args[0], op_str, e.args[1])
347  elif isinstance(e, m2_expr.ExprOp) and e.op == "postinc":
348  if e.args[1].arg != 0:
349  return "[%s], %s" % (e.args[0], e.args[1])
350  else:
351  return "[%s]" % (e.args[0])
352  elif isinstance(e, m2_expr.ExprOp) and e.op == "preinc_wb":
353  if e.args[1].arg != 0:
354  return "[%s, %s]!" % (e.args[0], e.args[1])
355  else:
356  return "[%s]" % (e.args[0])
357  elif isinstance(e, m2_expr.ExprOp) and e.op == "preinc":
358  if len(e.args) == 1:
359  return "[%s]" % (e.args[0])
360  elif not isinstance(e.args[1], m2_expr.ExprInt) or e.args[1].arg != 0:
361  return "[%s, %s]" % (e.args[0], e.args[1])
362  else:
363  return "[%s]" % (e.args[0])
364  elif isinstance(e, m2_expr.ExprOp) and e.op == 'segm':
365  arg = e.args[1]
366  if isinstance(arg, m2_expr.ExprId):
367  arg = str(arg)
368  elif arg.op == 'LSL' and arg.args[1].arg == 0:
369  arg = str(arg.args[0])
370  else:
371  arg = "%s %s %s" % (arg.args[0], arg.op, arg.args[1])
372  return '[%s, %s]' % (e.args[0], arg)
373 
374  else:
375  raise NotImplementedError("bad op")

+ Here is the caller graph for this function:

def miasm2.arch.aarch64.arch.instruction_aarch64.breakflow (   self)

Definition at line 397 of file arch.py.

398  def breakflow(self):
399  return self.name in BRCOND + ["BR", "BLR", "RET", "ERET", "DRPS", "B", "BL"]

+ Here is the caller graph for this function:

def miasm2.arch.aarch64.arch.instruction_aarch64.dstflow (   self)

Definition at line 376 of file arch.py.

377  def dstflow(self):
378  return self.name in self.name in BRCOND + ["B", "BL"]
def miasm2.arch.aarch64.arch.instruction_aarch64.dstflow2label (   self,
  symbol_pool 
)

Definition at line 387 of file arch.py.

388  def dstflow2label(self, symbol_pool):
389  index = self.mnemo_flow_to_dst_index(self.name)
390  e = self.args[index]
391  if not isinstance(e, m2_expr.ExprInt):
392  return
393  ad = e.arg + self.offset
394  l = symbol_pool.getby_offset_create(ad)
395  s = m2_expr.ExprId(l, e.size)
396  self.args[index] = s

+ Here is the call graph for this function:

def miasm2.arch.aarch64.arch.instruction_aarch64.fixDstOffset (   self)

Definition at line 413 of file arch.py.

414  def fixDstOffset(self):
415  index = self.mnemo_flow_to_dst_index(self.name)
416  e = self.args[index]
417  if self.offset is None:
418  raise ValueError('symbol not resolved %s' % l)
419  if not isinstance(e, m2_expr.ExprInt):
420  log.debug('dyn dst %r', e)
421  return
422  off = e.arg - self.offset
423  if int(off % 4):
424  raise ValueError('strange offset! %r' % off)
425  self.args[index] = m2_expr.ExprInt64(off)
426 
427 

+ Here is the call graph for this function:

def miasm2.core.cpu.instruction.gen_args (   self,
  args 
)
inherited

Definition at line 920 of file cpu.py.

921  def gen_args(self, args):
922  out = ', '.join([str(x) for x in args])
923  return out

+ Here is the caller graph for this function:

def miasm2.core.cpu.instruction.get_asm_offset (   self,
  expr 
)
inherited

Definition at line 935 of file cpu.py.

936  def get_asm_offset(self, expr):
937  return m2_expr.ExprInt_from(expr, self.offset)

+ Here is the caller graph for this function:

def miasm2.core.cpu.instruction.get_info (   self,
  c 
)
inherited

Definition at line 975 of file cpu.py.

976  def get_info(self, c):
977  return
978 
def miasm2.arch.aarch64.arch.instruction_aarch64.get_symbol_size (   self,
  symbol,
  symbol_pool 
)

Definition at line 410 of file arch.py.

411  def get_symbol_size(self, symbol, symbol_pool):
412  return 64

+ Here is the caller graph for this function:

def miasm2.arch.aarch64.arch.instruction_aarch64.getdstflow (   self,
  symbol_pool 
)

Definition at line 403 of file arch.py.

404  def getdstflow(self, symbol_pool):
405  index = self.mnemo_flow_to_dst_index(self.name)
406  return [self.args[index]]

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

def miasm2.arch.aarch64.arch.instruction_aarch64.is_subcall (   self)

Definition at line 400 of file arch.py.

401  def is_subcall(self):
402  return self.name in ["BLR", "BL"]
def miasm2.arch.aarch64.arch.instruction_aarch64.mnemo_flow_to_dst_index (   self,
  name 
)

Definition at line 379 of file arch.py.

380  def mnemo_flow_to_dst_index(self, name):
381  if self.name in ['CBZ', 'CBNZ']:
382  return 1
383  elif self.name in ['TBZ', 'TBNZ']:
384  return 2
385  else:
386  return 0

+ Here is the caller graph for this function:

def miasm2.core.cpu.instruction.resolve_args_with_symbols (   self,
  symbols = None 
)
inherited

Definition at line 938 of file cpu.py.

939  def resolve_args_with_symbols(self, symbols=None):
940  if symbols is None:
941  symbols = {}
942  args_out = []
943  for a in self.args:
944  e = a
945  # try to resolve symbols using symbols (0 for default value)
946  ids = m2_expr.get_expr_ids(e)
947  fixed_ids = {}
948  for x in ids:
949  if isinstance(x.name, asmbloc.asm_label):
950  name = x.name.name
951  # special symbol $
952  if name == '$':
953  fixed_ids[x] = self.get_asm_offset(x)
954  continue
955  if not name in symbols:
956  raise ValueError('unresolved symbol! %r' % x)
957  else:
958  name = x.name
959  if not name in symbols:
960  continue
961  if symbols[name].offset is None:
962  raise ValueError('The offset of label "%s" cannot be '
963  'determined' % name)
964  else:
965  size = x.size
966  if size is None:
967  default_size = self.get_symbol_size(x, symbols)
968  size = default_size
969  value = m2_expr.ExprInt(symbols[name].offset, size)
970  fixed_ids[x] = value
971  e = e.replace_expr(fixed_ids)
972  e = expr_simp(e)
973  args_out.append(e)
974  return args_out

+ Here is the call graph for this function:

def miasm2.arch.aarch64.arch.instruction_aarch64.splitflow (   self)

Definition at line 407 of file arch.py.

408  def splitflow(self):
409  return self.name in BRCOND + ["BLR", "BL"]

Member Data Documentation

miasm2.core.cpu.instruction.additional_info
inherited

Definition at line 918 of file cpu.py.

miasm2.core.cpu.instruction.args
inherited

Definition at line 917 of file cpu.py.

int miasm2.arch.aarch64.arch.instruction_aarch64.delayslot = 0
static

Definition at line 328 of file arch.py.

miasm2.core.cpu.instruction.mode
inherited

Definition at line 916 of file cpu.py.

miasm2.core.cpu.instruction.name
inherited

Definition at line 915 of file cpu.py.


The documentation for this class was generated from the following file: