about summary refs log tree commit diff stats
path: root/miasm2/arch/arm/disasm.py
diff options
context:
space:
mode:
authorserpilliere <devnull@localhost>2014-06-03 10:27:56 +0200
committerserpilliere <devnull@localhost>2014-06-03 10:27:56 +0200
commited5c3668cc9f545b52674ad699fc2b0ed1ccb575 (patch)
tree07faf97d7e4d083173a1f7e1bfd249baed2d74f9 /miasm2/arch/arm/disasm.py
parenta183e1ebd525453710306695daa8c410fd0cb2af (diff)
downloadmiasm-ed5c3668cc9f545b52674ad699fc2b0ed1ccb575.tar.gz
miasm-ed5c3668cc9f545b52674ad699fc2b0ed1ccb575.zip
Miasm v2
* API has changed, so old scripts need updates
* See example for API usage
* Use tcc or llvm for jit emulation
* Go to test and run test_all.py to check install

Enjoy !
Diffstat (limited to 'miasm2/arch/arm/disasm.py')
-rw-r--r--miasm2/arch/arm/disasm.py51
1 files changed, 51 insertions, 0 deletions
diff --git a/miasm2/arch/arm/disasm.py b/miasm2/arch/arm/disasm.py
new file mode 100644
index 00000000..64e10eec
--- /dev/null
+++ b/miasm2/arch/arm/disasm.py
@@ -0,0 +1,51 @@
+from miasm2.core.asmbloc import asm_constraint, disasmEngine
+from arch import mn_arm, mn_armt
+
+
+def cb_arm_fix_call(
+    mn, attrib, pool_bin, cur_bloc, offsets_to_dis, symbol_pool):
+    """
+    for arm:
+    MOV        LR, PC
+    LDR        PC, [R5, 0x14]
+    * is a subcall *
+
+    """
+    if len(cur_bloc.lines) < 2:
+        return
+    l1 = cur_bloc.lines[-1]
+    l2 = cur_bloc.lines[-2]
+    if l1.name != "LDR":
+        return
+    if l2.name != "MOV":
+        return
+    # print cur_bloc
+    # print l1
+    if not l1.args[0] in mn.pc.values():
+        return
+    if not l2.args[1] in mn.pc.values():
+        return
+    cur_bloc.add_cst(l1.offset + 4, asm_constraint.c_next, symbol_pool)
+    offsets_to_dis.add(l1.offset + 4)
+
+cb_arm_funcs = [cb_arm_fix_call]
+
+
+def cb_arm_disasm(mn, attrib, pool_bin, cur_bloc, offsets_to_dis, symbol_pool):
+    for func in cb_arm_funcs:
+        func(mn, attrib, pool_bin, cur_bloc, offsets_to_dis, symbol_pool)
+
+
+class dis_arm(disasmEngine):
+    attrib = 'arm'
+
+    def __init__(self, bs=None, **kwargs):
+        super(dis_arm, self).__init__(mn_arm, self.attrib, bs, **kwargs)
+        self.dis_bloc_callback = cb_arm_disasm
+
+
+class dis_armt(disasmEngine):
+    attrib = 'armt'
+
+    def __init__(self, bs=None, **kwargs):
+        super(dis_armt, self).__init__(mn_armt, self.attrib, bs, **kwargs)