about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorCamille Mougey <camille.mougey@cea.fr>2015-01-23 12:39:48 +0100
committerCamille Mougey <camille.mougey@cea.fr>2015-01-23 17:24:43 +0100
commit29a65d37ba8cc3c1e4b06807d4dee3ef32bb2e8f (patch)
tree27b80e0e813e85dd0ff73586c74a9de90a7b4858
parenta5f035142ce772f7868c0a67cb60d876dedfc0dc (diff)
downloadmiasm-29a65d37ba8cc3c1e4b06807d4dee3ef32bb2e8f.tar.gz
miasm-29a65d37ba8cc3c1e4b06807d4dee3ef32bb2e8f.zip
Example/ASM: Test the second ARM (arm_sc.S) example
-rw-r--r--example/asm/arm_sc.py62
-rw-r--r--test/test_all.py8
2 files changed, 8 insertions, 62 deletions
diff --git a/example/asm/arm_sc.py b/example/asm/arm_sc.py
deleted file mode 100644
index 83787f02..00000000
--- a/example/asm/arm_sc.py
+++ /dev/null
@@ -1,62 +0,0 @@
-#! /usr/bin/env python
-
-from pdb import pm
-
-from elfesteem.strpatchwork import StrPatchwork
-
-from miasm2.core import asmbloc
-from miasm2.core.cpu import parse_ast
-from miasm2.arch.arm.arch import mn_arm, base_expr
-from miasm2.core import parse_asm
-import miasm2.expression.expression as m2_expr
-
-reg_and_id = dict(mn_arm.regs.all_regs_ids_byname)
-
-
-def my_ast_int2expr(a):
-    return m2_expr.ExprInt32(a)
-
-
-def my_ast_id2expr(t):
-    return reg_and_id.get(t, m2_expr.ExprId(t, size=32))
-
-my_var_parser = parse_ast(my_ast_id2expr, my_ast_int2expr)
-base_expr.setParseAction(my_var_parser)
-
-
-st = StrPatchwork()
-
-blocs, symbol_pool = parse_asm.parse_txt(mn_arm, 'l', '''
-main:
-    MOV R1, R0
-    MOV R2, 0x100
-    LDR R3, [PC, mykey1-$]
-loop:
-    ADD R2, R1, R2
-    ADD R1, R1, 1
-    LDR R3, [PC, mykey2-$]
-    CMP R1, R3
-    BEQ loop
-
-    ADD R0, R1, R2
-    BX LR
-mykey1:
-.long 0x1
-mykey2:
-.long 0x2
-''')
-
-# fix shellcode addr
-symbol_pool.set_offset(symbol_pool.getby_name("main"), 0)
-
-for b in blocs[0]:
-    print b
-
-resolved_b, patches = asmbloc.asm_resolve_final(
-    mn_arm, blocs[0], symbol_pool)
-print patches
-
-for offset, raw in patches.items():
-    st[offset] = raw
-
-open('arm_sc.bin', 'wb').write(str(st))
diff --git a/test/test_all.py b/test/test_all.py
index 86c8241a..cb0adf64 100644
--- a/test/test_all.py
+++ b/test/test_all.py
@@ -128,6 +128,8 @@ for source in test_box_names:
 
 test_armb = ExampleShellcode(["armb", "arm_simple.S", "demo_arm_b.bin"])
 test_arml = ExampleShellcode(["arml", "arm_simple.S", "demo_arm_l.bin"])
+test_armb_sc = ExampleShellcode(["armb", "arm_sc.S", "demo_arm2_b.bin"])
+test_arml_sc = ExampleShellcode(["arml", "arm_sc.S", "demo_arm2_l.bin"])
 test_armtb = ExampleShellcode(["armtb", "armt.S", "demo_armt_b.bin"])
 test_armtl = ExampleShellcode(["armtl", "armt.S", "demo_armt_l.bin"])
 test_msp430 = ExampleShellcode(["msp430", "msp430.S", "msp430_sc.bin"])
@@ -138,6 +140,8 @@ test_x86_64 = ExampleShellcode(["x86_64", "x86_64.S", "demo_x86_64.bin",
 
 testset += test_armb
 testset += test_arml
+testset += test_armb_sc
+testset += test_arml_sc
 testset += test_armtb
 testset += test_armtl
 testset += test_msp430
@@ -177,6 +181,10 @@ testset += ExampleDisasmFull(["arml", Example.get_sample("demo_arm_l.bin"),
                               "0"], depends=[test_arml])
 testset += ExampleDisasmFull(["armb", Example.get_sample("demo_arm_b.bin"),
                               "0"], depends=[test_armb])
+testset += ExampleDisasmFull(["arml", Example.get_sample("demo_arm2_l.bin"),
+                              "0"], depends=[test_arml_sc])
+testset += ExampleDisasmFull(["armb", Example.get_sample("demo_arm2_b.bin"),
+                              "0"], depends=[test_armb_sc])
 testset += ExampleDisasmFull(["armtl", Example.get_sample("demo_armt_l.bin"),
                               "0"], depends=[test_armtl])
 testset += ExampleDisasmFull(["armtb", Example.get_sample("demo_armt_b.bin"),