From 2c988d3ec52cc4c949a35aca7ef335dac773df92 Mon Sep 17 00:00:00 2001 From: Cyrille Bagard Date: Sat, 2 Dec 2017 12:04:35 +0100 Subject: Created a plugin for the ARM support. --- .gitignore | 2 +- ChangeLog | 330 ++++ autogen.sh | 2 +- configure.ac | 14 +- plugins/Makefile.am | 2 +- plugins/arm/Makefile.am | 32 + plugins/arm/cond.h | 64 + plugins/arm/context-int.h | 75 + plugins/arm/context.c | 447 +++++ plugins/arm/context.h | 85 + plugins/arm/core.c | 83 + plugins/arm/core.h | 41 + plugins/arm/instruction-int.h | 57 + plugins/arm/instruction.c | 274 +++ plugins/arm/instruction.h | 69 + plugins/arm/link.c | 67 + plugins/arm/link.h | 38 + plugins/arm/processor-int.h | 52 + plugins/arm/processor.c | 126 ++ plugins/arm/processor.h | 53 + plugins/arm/python/Makefile.am | 20 + plugins/arm/python/instruction.c | 111 ++ plugins/arm/python/instruction.h | 42 + plugins/arm/python/module.c | 105 ++ plugins/arm/python/module.h | 38 + plugins/arm/python/processor.c | 108 ++ plugins/arm/python/processor.h | 42 + plugins/arm/python/v7/Makefile.am | 16 + plugins/arm/python/v7/instruction.c | 109 ++ plugins/arm/python/v7/instruction.h | 42 + plugins/arm/python/v7/module.c | 93 + plugins/arm/python/v7/module.h | 39 + plugins/arm/python/v7/processor.c | 108 ++ plugins/arm/python/v7/processor.h | 42 + plugins/arm/register-int.h | 58 + plugins/arm/register.c | 202 +++ plugins/arm/register.h | 56 + plugins/arm/v7/Makefile.am | 33 + plugins/arm/v7/arm.c | 2271 ++++++++++++++++++++++++ plugins/arm/v7/arm.h | 37 + plugins/arm/v7/build_tmp_decl.sh | 39 + plugins/arm/v7/context.c | 305 ++++ plugins/arm/v7/context.h | 81 + plugins/arm/v7/core.c | 66 + plugins/arm/v7/core.h | 40 + plugins/arm/v7/cregister.c | 212 +++ plugins/arm/v7/cregister.h | 56 + plugins/arm/v7/fetch.c | 521 ++++++ plugins/arm/v7/fetch.h | 114 ++ plugins/arm/v7/helpers.c | 277 +++ plugins/arm/v7/helpers.h | 441 +++++ plugins/arm/v7/instruction.c | 284 +++ plugins/arm/v7/instruction.h | 69 + plugins/arm/v7/link.c | 114 ++ plugins/arm/v7/link.h | 43 + plugins/arm/v7/opcodes/Makefile.am | 26 + plugins/arm/v7/opcodes/opcodes_tmp_arm.h | 56 + plugins/arm/v7/opcodes/opcodes_tmp_simd.h | 138 ++ plugins/arm/v7/opcodes/opcodes_tmp_thumb_16.h | 10 + plugins/arm/v7/opcodes/opcodes_tmp_thumb_32.h | 59 + plugins/arm/v7/opdefs/Makefile.am | 302 ++++ plugins/arm/v7/opdefs/adc_A881.d | 74 + plugins/arm/v7/opdefs/adc_A882.d | 92 + plugins/arm/v7/opdefs/adc_A883.d | 52 + plugins/arm/v7/opdefs/add_A8810.d | 83 + plugins/arm/v7/opdefs/add_A8811.d | 52 + plugins/arm/v7/opdefs/add_A884.d | 98 + plugins/arm/v7/opdefs/add_A885.d | 51 + plugins/arm/v7/opdefs/add_A886.d | 83 + plugins/arm/v7/opdefs/add_A887.d | 52 + plugins/arm/v7/opdefs/add_A888.d | 52 + plugins/arm/v7/opdefs/add_A889.d | 123 ++ plugins/arm/v7/opdefs/adr_A8812.d | 114 ++ plugins/arm/v7/opdefs/and_A8813.d | 74 + plugins/arm/v7/opdefs/and_A8814.d | 92 + plugins/arm/v7/opdefs/and_A8815.d | 52 + plugins/arm/v7/opdefs/asr_A8816.d | 91 + plugins/arm/v7/opdefs/asr_A8817.d | 90 + plugins/arm/v7/opdefs/b_A8818.d | 157 ++ plugins/arm/v7/opdefs/bfc_A8819.d | 67 + plugins/arm/v7/opdefs/bfi_A8820.d | 69 + plugins/arm/v7/opdefs/bic_A8821.d | 74 + plugins/arm/v7/opdefs/bic_A8822.d | 92 + plugins/arm/v7/opdefs/bic_A8823.d | 52 + plugins/arm/v7/opdefs/bkpt_A8824.d | 55 + plugins/arm/v7/opdefs/bl_A8825.d | 125 ++ plugins/arm/v7/opdefs/blx_A8826.d | 61 + plugins/arm/v7/opdefs/bx_A8827.d | 75 + plugins/arm/v7/opdefs/bxj_A8828.d | 61 + plugins/arm/v7/opdefs/cb_A8829.d | 58 + plugins/arm/v7/opdefs/cdp_A8830.d | 109 ++ plugins/arm/v7/opdefs/clrex_A8832.d | 39 + plugins/arm/v7/opdefs/clz_A8833.d | 63 + plugins/arm/v7/opdefs/cmn_A8834.d | 63 + plugins/arm/v7/opdefs/cmn_A8835.d | 80 + plugins/arm/v7/opdefs/cmn_A8836.d | 49 + plugins/arm/v7/opdefs/cmp_A8837.d | 78 + plugins/arm/v7/opdefs/cmp_A8838.d | 95 + plugins/arm/v7/opdefs/cmp_A8839.d | 49 + plugins/arm/v7/opdefs/dbg_A8842.d | 61 + plugins/arm/v7/opdefs/dmb_A8843.d | 55 + plugins/arm/v7/opdefs/dsb_A8844.d | 55 + plugins/arm/v7/opdefs/eor_A8846.d | 74 + plugins/arm/v7/opdefs/eor_A8847.d | 92 + plugins/arm/v7/opdefs/eor_A8848.d | 52 + plugins/arm/v7/opdefs/ldr_A8862.d | 98 + plugins/arm/v7/opdefs/ldr_A8863.d | 53 + plugins/arm/v7/opdefs/ldr_A8864.d | 99 ++ plugins/arm/v7/opdefs/ldr_A8865.d | 62 + plugins/arm/v7/opdefs/ldr_A8866.d | 54 + plugins/arm/v7/opdefs/ldrb_A8867.d | 81 + plugins/arm/v7/opdefs/ldrb_A8868.d | 53 + plugins/arm/v7/opdefs/ldrb_A8869.d | 63 + plugins/arm/v7/opdefs/ldrb_A8870.d | 89 + plugins/arm/v7/opdefs/ldrbt_A8871.d | 93 + plugins/arm/v7/opdefs/ldrd_A8872.d | 75 + plugins/arm/v7/opdefs/ldrd_A8873.d | 65 + plugins/arm/v7/opdefs/ldrd_A8874.d | 54 + plugins/arm/v7/opdefs/ldrex_A8875.d | 66 + plugins/arm/v7/opdefs/ldrexb_A8876.d | 65 + plugins/arm/v7/opdefs/ldrexd_A8877.d | 67 + plugins/arm/v7/opdefs/ldrexh_A8878.d | 65 + plugins/arm/v7/opdefs/ldrh_A8879.d | 81 + plugins/arm/v7/opdefs/ldrh_A8880.d | 53 + plugins/arm/v7/opdefs/ldrh_A8881.d | 63 + plugins/arm/v7/opdefs/ldrh_A8882.d | 88 + plugins/arm/v7/opdefs/ldrht_A8883.d | 92 + plugins/arm/v7/opdefs/ldrsb_A8884.d | 90 + plugins/arm/v7/opdefs/ldrsb_A8885.d | 63 + plugins/arm/v7/opdefs/ldrsb_A8886.d | 88 + plugins/arm/v7/opdefs/ldrsbt_A8887.d | 92 + plugins/arm/v7/opdefs/ldrsh_A8888.d | 90 + plugins/arm/v7/opdefs/ldrsh_A8889.d | 63 + plugins/arm/v7/opdefs/ldrsh_A8890.d | 88 + plugins/arm/v7/opdefs/ldrsht_A8891.d | 92 + plugins/arm/v7/opdefs/ldrt_A8892.d | 93 + plugins/arm/v7/opdefs/lsl_A8894.d | 91 + plugins/arm/v7/opdefs/lsl_A8895.d | 90 + plugins/arm/v7/opdefs/lsr_A8896.d | 91 + plugins/arm/v7/opdefs/lsr_A8897.d | 90 + plugins/arm/v7/opdefs/mcr_A8898.d | 109 ++ plugins/arm/v7/opdefs/mcrr_A8899.d | 105 ++ plugins/arm/v7/opdefs/mla_A88100.d | 69 + plugins/arm/v7/opdefs/mls_A88101.d | 67 + plugins/arm/v7/opdefs/mov_A88102.d | 124 ++ plugins/arm/v7/opdefs/mov_A88103.d | 80 + plugins/arm/v7/opdefs/mov_A88104.d | 50 + plugins/arm/v7/opdefs/movt_A88106.d | 63 + plugins/arm/v7/opdefs/mrc_A88107.d | 109 ++ plugins/arm/v7/opdefs/mrrc_A88108.d | 105 ++ plugins/arm/v7/opdefs/mul_A88114.d | 83 + plugins/arm/v7/opdefs/mvn_A88115.d | 72 + plugins/arm/v7/opdefs/mvn_A88116.d | 90 + plugins/arm/v7/opdefs/mvn_A88117.d | 51 + plugins/arm/v7/opdefs/nop_A88119.d | 53 + plugins/arm/v7/opdefs/orn_A88120.d | 50 + plugins/arm/v7/opdefs/orn_A88121.d | 51 + plugins/arm/v7/opdefs/orr_A88122.d | 74 + plugins/arm/v7/opdefs/orr_A88123.d | 92 + plugins/arm/v7/opdefs/orr_A88124.d | 52 + plugins/arm/v7/opdefs/pop_A88131.d | 87 + plugins/arm/v7/opdefs/pop_A88132.d | 79 + plugins/arm/v7/opdefs/push_A88133.d | 109 ++ plugins/arm/v7/opdefs/qadd16_A88135.d | 65 + plugins/arm/v7/opdefs/qadd8_A88136.d | 65 + plugins/arm/v7/opdefs/qadd_A88134.d | 65 + plugins/arm/v7/opdefs/qasx_A88137.d | 65 + plugins/arm/v7/opdefs/qdadd_A88138.d | 65 + plugins/arm/v7/opdefs/qdsub_A88139.d | 65 + plugins/arm/v7/opdefs/qsax_A88140.d | 65 + plugins/arm/v7/opdefs/qsub16_A88142.d | 65 + plugins/arm/v7/opdefs/qsub8_A88143.d | 65 + plugins/arm/v7/opdefs/qsub_A88141.d | 65 + plugins/arm/v7/opdefs/rbit_A88144.d | 63 + plugins/arm/v7/opdefs/rev16_A88146.d | 78 + plugins/arm/v7/opdefs/rev_A88145.d | 78 + plugins/arm/v7/opdefs/revsh_A88147.d | 78 + plugins/arm/v7/opdefs/ror_A88149.d | 74 + plugins/arm/v7/opdefs/ror_A88150.d | 90 + plugins/arm/v7/opdefs/rrx_A88151.d | 72 + plugins/arm/v7/opdefs/rsb_A88152.d | 91 + plugins/arm/v7/opdefs/rsb_A88153.d | 76 + plugins/arm/v7/opdefs/rsb_A88154.d | 52 + plugins/arm/v7/opdefs/rsc_A88155.d | 51 + plugins/arm/v7/opdefs/rsc_A88156.d | 52 + plugins/arm/v7/opdefs/rsc_A88157.d | 52 + plugins/arm/v7/opdefs/sadd16_A88158.d | 65 + plugins/arm/v7/opdefs/sadd8_A88159.d | 65 + plugins/arm/v7/opdefs/sasx_A88160.d | 65 + plugins/arm/v7/opdefs/sbc_A88161.d | 74 + plugins/arm/v7/opdefs/sbc_A88162.d | 92 + plugins/arm/v7/opdefs/sbc_A88163.d | 52 + plugins/arm/v7/opdefs/sbfx_A88164.d | 67 + plugins/arm/v7/opdefs/sdiv_A88165.d | 65 + plugins/arm/v7/opdefs/sel_A88166.d | 65 + plugins/arm/v7/opdefs/setend_A88167.d | 55 + plugins/arm/v7/opdefs/sev_A88168.d | 53 + plugins/arm/v7/opdefs/shadd16_A88169.d | 65 + plugins/arm/v7/opdefs/shadd8_A88170.d | 65 + plugins/arm/v7/opdefs/shasx_A88171.d | 65 + plugins/arm/v7/opdefs/shsax_A88172.d | 65 + plugins/arm/v7/opdefs/shsub16_A88173.d | 65 + plugins/arm/v7/opdefs/shsub8_A88174.d | 65 + plugins/arm/v7/opdefs/smlad_A88177.d | 76 + plugins/arm/v7/opdefs/smlal_A88178.d | 69 + plugins/arm/v7/opdefs/smlald_A88180.d | 76 + plugins/arm/v7/opdefs/smlsd_A88182.d | 76 + plugins/arm/v7/opdefs/smlsld_A88183.d | 76 + plugins/arm/v7/opdefs/smmla_A88184.d | 76 + plugins/arm/v7/opdefs/smmls_A88185.d | 76 + plugins/arm/v7/opdefs/smmul_A88186.d | 74 + plugins/arm/v7/opdefs/smuad_A88187.d | 74 + plugins/arm/v7/opdefs/smull_A88189.d | 69 + plugins/arm/v7/opdefs/str_A88203.d | 98 + plugins/arm/v7/opdefs/str_A88204.d | 53 + plugins/arm/v7/opdefs/str_A88205.d | 89 + plugins/arm/v7/opdefs/strb_A88206.d | 81 + plugins/arm/v7/opdefs/strb_A88207.d | 53 + plugins/arm/v7/opdefs/strb_A88208.d | 89 + plugins/arm/v7/opdefs/strbt_A88209.d | 93 + plugins/arm/v7/opdefs/strd_A88210.d | 75 + plugins/arm/v7/opdefs/strd_A88211.d | 54 + plugins/arm/v7/opdefs/strex_A88212.d | 68 + plugins/arm/v7/opdefs/strexb_A88213.d | 67 + plugins/arm/v7/opdefs/strexd_A88214.d | 69 + plugins/arm/v7/opdefs/strexh_A88215.d | 67 + plugins/arm/v7/opdefs/strh_A88216.d | 81 + plugins/arm/v7/opdefs/strh_A88217.d | 53 + plugins/arm/v7/opdefs/strh_A88218.d | 88 + plugins/arm/v7/opdefs/strht_A88219.d | 92 + plugins/arm/v7/opdefs/strt_A88220.d | 93 + plugins/arm/v7/opdefs/sub_A88221.d | 98 + plugins/arm/v7/opdefs/sub_A88222.d | 51 + plugins/arm/v7/opdefs/sub_A88223.d | 93 + plugins/arm/v7/opdefs/sub_A88224.d | 52 + plugins/arm/v7/opdefs/sub_A88225.d | 107 ++ plugins/arm/v7/opdefs/sub_A88226.d | 76 + plugins/arm/v7/opdefs/subs_B9320.d | 44 + plugins/arm/v7/opdefs/svc_A88228.d | 61 + plugins/arm/v7/opdefs/swp_A88229.d | 52 + plugins/arm/v7/opdefs/teq_A88237.d | 63 + plugins/arm/v7/opdefs/teq_A88238.d | 65 + plugins/arm/v7/opdefs/teq_A88239.d | 49 + plugins/arm/v7/opdefs/tst_A88240.d | 63 + plugins/arm/v7/opdefs/tst_A88241.d | 80 + plugins/arm/v7/opdefs/tst_A88242.d | 49 + plugins/arm/v7/opdefs/uadd16_A88243.d | 65 + plugins/arm/v7/opdefs/uadd8_A88244.d | 65 + plugins/arm/v7/opdefs/uasx_A88245.d | 65 + plugins/arm/v7/opdefs/ubfx_A88246.d | 67 + plugins/arm/v7/opdefs/udf_A88247.d | 69 + plugins/arm/v7/opdefs/udiv_A88248.d | 65 + plugins/arm/v7/opdefs/uhadd16_A88249.d | 65 + plugins/arm/v7/opdefs/uhadd8_A88250.d | 65 + plugins/arm/v7/opdefs/uhasx_A88251.d | 65 + plugins/arm/v7/opdefs/uhsax_A88252.d | 65 + plugins/arm/v7/opdefs/uhsub16_A88253.d | 65 + plugins/arm/v7/opdefs/uhsub8_A88254.d | 65 + plugins/arm/v7/opdefs/umaal_A88255.d | 67 + plugins/arm/v7/opdefs/umlal_A88256.d | 69 + plugins/arm/v7/opdefs/umull_A88257.d | 69 + plugins/arm/v7/opdefs/uqadd16_A88258.d | 65 + plugins/arm/v7/opdefs/uqadd8_A88259.d | 65 + plugins/arm/v7/opdefs/uqasx_A88260.d | 65 + plugins/arm/v7/opdefs/uqsax_A88261.d | 65 + plugins/arm/v7/opdefs/uqsub16_A88262.d | 65 + plugins/arm/v7/opdefs/uqsub8_A88263.d | 65 + plugins/arm/v7/opdefs/usad8_A88264.d | 65 + plugins/arm/v7/opdefs/usada8_A88265.d | 67 + plugins/arm/v7/opdefs/usat16_A88267.d | 65 + plugins/arm/v7/opdefs/usat_A88266.d | 67 + plugins/arm/v7/opdefs/usax_A88268.d | 65 + plugins/arm/v7/opdefs/usub16_A88269.d | 65 + plugins/arm/v7/opdefs/usub8_A88270.d | 65 + plugins/arm/v7/opdefs/uxtab16_A88272.d | 67 + plugins/arm/v7/opdefs/uxtab_A88271.d | 67 + plugins/arm/v7/opdefs/uxtah_A88273.d | 67 + plugins/arm/v7/opdefs/uxtb16_A88275.d | 65 + plugins/arm/v7/opdefs/uxtb_A88274.d | 80 + plugins/arm/v7/opdefs/uxth_A88276.d | 80 + plugins/arm/v7/opdefs/wfi_A88425.d | 53 + plugins/arm/v7/opdefs/yield_A88426.d | 53 + plugins/arm/v7/operands/Makefile.am | 21 + plugins/arm/v7/operands/coproc.c | 250 +++ plugins/arm/v7/operands/coproc.h | 61 + plugins/arm/v7/operands/estate.c | 248 +++ plugins/arm/v7/operands/estate.h | 61 + plugins/arm/v7/operands/limitation.c | 287 +++ plugins/arm/v7/operands/limitation.h | 77 + plugins/arm/v7/operands/maccess.c | 385 ++++ plugins/arm/v7/operands/maccess.h | 77 + plugins/arm/v7/operands/offset.c | 283 +++ plugins/arm/v7/operands/offset.h | 68 + plugins/arm/v7/operands/reglist.c | 376 ++++ plugins/arm/v7/operands/reglist.h | 74 + plugins/arm/v7/operands/rotation.c | 256 +++ plugins/arm/v7/operands/rotation.h | 61 + plugins/arm/v7/operands/shift.c | 300 ++++ plugins/arm/v7/operands/shift.h | 67 + plugins/arm/v7/post.c | 99 ++ plugins/arm/v7/post.h | 57 + plugins/arm/v7/processor.c | 297 ++++ plugins/arm/v7/processor.h | 56 + plugins/arm/v7/pseudo.c | 683 +++++++ plugins/arm/v7/pseudo.h | 136 ++ plugins/arm/v7/register.c | 229 +++ plugins/arm/v7/register.h | 57 + plugins/arm/v7/simd.c | 1541 ++++++++++++++++ plugins/arm/v7/simd.h | 55 + plugins/arm/v7/thumb_16.c | 672 +++++++ plugins/arm/v7/thumb_16.h | 37 + plugins/arm/v7/thumb_32.c | 2270 +++++++++++++++++++++++ plugins/arm/v7/thumb_32.h | 37 + plugins/pychrysa/arch/Makefile.am | 5 +- plugins/pychrysa/arch/arm/Makefile.am | 20 - plugins/pychrysa/arch/arm/instruction.c | 111 -- plugins/pychrysa/arch/arm/instruction.h | 42 - plugins/pychrysa/arch/arm/module.c | 96 - plugins/pychrysa/arch/arm/module.h | 39 - plugins/pychrysa/arch/arm/processor.c | 108 -- plugins/pychrysa/arch/arm/processor.h | 42 - plugins/pychrysa/arch/arm/v7/Makefile.am | 16 - plugins/pychrysa/arch/arm/v7/instruction.c | 109 -- plugins/pychrysa/arch/arm/v7/instruction.h | 42 - plugins/pychrysa/arch/arm/v7/module.c | 93 - plugins/pychrysa/arch/arm/v7/module.h | 39 - plugins/pychrysa/arch/arm/v7/processor.c | 108 -- plugins/pychrysa/arch/arm/v7/processor.h | 42 - plugins/pychrysa/arch/module.c | 3 - plugins/ropgadgets/helper_arm.c | 2 +- plugins/ropgadgets/plugin.c | 4 +- src/arch/Makefile.am | 5 +- src/arch/arm/Makefile.am | 27 - src/arch/arm/cond.h | 64 - src/arch/arm/context-int.h | 75 - src/arch/arm/context.c | 447 ----- src/arch/arm/context.h | 85 - src/arch/arm/instruction-int.h | 55 - src/arch/arm/instruction.c | 272 --- src/arch/arm/instruction.h | 67 - src/arch/arm/link.c | 65 - src/arch/arm/link.h | 38 - src/arch/arm/processor-int.h | 50 - src/arch/arm/processor.c | 126 -- src/arch/arm/processor.h | 53 - src/arch/arm/register-int.h | 56 - src/arch/arm/register.c | 200 --- src/arch/arm/register.h | 56 - src/arch/arm/v7/Makefile.am | 33 - src/arch/arm/v7/arm.c | 2269 ----------------------- src/arch/arm/v7/arm.h | 37 - src/arch/arm/v7/build_tmp_decl.sh | 39 - src/arch/arm/v7/context.c | 305 ---- src/arch/arm/v7/context.h | 81 - src/arch/arm/v7/core.c | 66 - src/arch/arm/v7/core.h | 40 - src/arch/arm/v7/cregister.c | 212 --- src/arch/arm/v7/cregister.h | 56 - src/arch/arm/v7/fetch.c | 521 ------ src/arch/arm/v7/fetch.h | 112 -- src/arch/arm/v7/helpers.c | 275 --- src/arch/arm/v7/helpers.h | 439 ----- src/arch/arm/v7/instruction.c | 284 --- src/arch/arm/v7/instruction.h | 69 - src/arch/arm/v7/link.c | 114 -- src/arch/arm/v7/link.h | 41 - src/arch/arm/v7/opcodes/Makefile.am | 26 - src/arch/arm/v7/opcodes/opcodes_tmp_arm.h | 56 - src/arch/arm/v7/opcodes/opcodes_tmp_simd.h | 138 -- src/arch/arm/v7/opcodes/opcodes_tmp_thumb_16.h | 10 - src/arch/arm/v7/opcodes/opcodes_tmp_thumb_32.h | 59 - src/arch/arm/v7/opdefs/Makefile.am | 301 ---- src/arch/arm/v7/opdefs/adc_A881.d | 74 - src/arch/arm/v7/opdefs/adc_A882.d | 92 - src/arch/arm/v7/opdefs/adc_A883.d | 52 - src/arch/arm/v7/opdefs/add_A8810.d | 83 - src/arch/arm/v7/opdefs/add_A8811.d | 52 - src/arch/arm/v7/opdefs/add_A884.d | 98 - src/arch/arm/v7/opdefs/add_A885.d | 51 - src/arch/arm/v7/opdefs/add_A886.d | 83 - src/arch/arm/v7/opdefs/add_A887.d | 52 - src/arch/arm/v7/opdefs/add_A888.d | 52 - src/arch/arm/v7/opdefs/add_A889.d | 123 -- src/arch/arm/v7/opdefs/adr_A8812.d | 114 -- src/arch/arm/v7/opdefs/and_A8813.d | 74 - src/arch/arm/v7/opdefs/and_A8814.d | 92 - src/arch/arm/v7/opdefs/and_A8815.d | 52 - src/arch/arm/v7/opdefs/asr_A8816.d | 91 - src/arch/arm/v7/opdefs/asr_A8817.d | 90 - src/arch/arm/v7/opdefs/b_A8818.d | 157 -- src/arch/arm/v7/opdefs/bfc_A8819.d | 67 - src/arch/arm/v7/opdefs/bfi_A8820.d | 69 - src/arch/arm/v7/opdefs/bic_A8821.d | 74 - src/arch/arm/v7/opdefs/bic_A8822.d | 92 - src/arch/arm/v7/opdefs/bic_A8823.d | 52 - src/arch/arm/v7/opdefs/bkpt_A8824.d | 55 - src/arch/arm/v7/opdefs/bl_A8825.d | 125 -- src/arch/arm/v7/opdefs/blx_A8826.d | 61 - src/arch/arm/v7/opdefs/bx_A8827.d | 75 - src/arch/arm/v7/opdefs/bxj_A8828.d | 61 - src/arch/arm/v7/opdefs/cb_A8829.d | 58 - src/arch/arm/v7/opdefs/cdp_A8830.d | 109 -- src/arch/arm/v7/opdefs/clrex_A8832.d | 39 - src/arch/arm/v7/opdefs/clz_A8833.d | 63 - src/arch/arm/v7/opdefs/cmn_A8834.d | 63 - src/arch/arm/v7/opdefs/cmn_A8835.d | 80 - src/arch/arm/v7/opdefs/cmn_A8836.d | 49 - src/arch/arm/v7/opdefs/cmp_A8837.d | 78 - src/arch/arm/v7/opdefs/cmp_A8838.d | 95 - src/arch/arm/v7/opdefs/cmp_A8839.d | 49 - src/arch/arm/v7/opdefs/dbg_A8842.d | 61 - src/arch/arm/v7/opdefs/dmb_A8843.d | 55 - src/arch/arm/v7/opdefs/dsb_A8844.d | 55 - src/arch/arm/v7/opdefs/eor_A8846.d | 74 - src/arch/arm/v7/opdefs/eor_A8847.d | 92 - src/arch/arm/v7/opdefs/eor_A8848.d | 52 - src/arch/arm/v7/opdefs/ldr_A8862.d | 98 - src/arch/arm/v7/opdefs/ldr_A8863.d | 53 - src/arch/arm/v7/opdefs/ldr_A8864.d | 99 -- src/arch/arm/v7/opdefs/ldr_A8865.d | 62 - src/arch/arm/v7/opdefs/ldr_A8866.d | 54 - src/arch/arm/v7/opdefs/ldrb_A8867.d | 81 - src/arch/arm/v7/opdefs/ldrb_A8868.d | 53 - src/arch/arm/v7/opdefs/ldrb_A8869.d | 63 - src/arch/arm/v7/opdefs/ldrb_A8870.d | 89 - src/arch/arm/v7/opdefs/ldrbt_A8871.d | 93 - src/arch/arm/v7/opdefs/ldrd_A8872.d | 75 - src/arch/arm/v7/opdefs/ldrd_A8873.d | 65 - src/arch/arm/v7/opdefs/ldrd_A8874.d | 54 - src/arch/arm/v7/opdefs/ldrex_A8875.d | 66 - src/arch/arm/v7/opdefs/ldrexb_A8876.d | 65 - src/arch/arm/v7/opdefs/ldrexd_A8877.d | 67 - src/arch/arm/v7/opdefs/ldrexh_A8878.d | 65 - src/arch/arm/v7/opdefs/ldrh_A8879.d | 81 - src/arch/arm/v7/opdefs/ldrh_A8880.d | 53 - src/arch/arm/v7/opdefs/ldrh_A8881.d | 63 - src/arch/arm/v7/opdefs/ldrh_A8882.d | 88 - src/arch/arm/v7/opdefs/ldrht_A8883.d | 92 - src/arch/arm/v7/opdefs/ldrsb_A8884.d | 90 - src/arch/arm/v7/opdefs/ldrsb_A8885.d | 63 - src/arch/arm/v7/opdefs/ldrsb_A8886.d | 88 - src/arch/arm/v7/opdefs/ldrsbt_A8887.d | 92 - src/arch/arm/v7/opdefs/ldrsh_A8888.d | 90 - src/arch/arm/v7/opdefs/ldrsh_A8889.d | 63 - src/arch/arm/v7/opdefs/ldrsh_A8890.d | 88 - src/arch/arm/v7/opdefs/ldrsht_A8891.d | 92 - src/arch/arm/v7/opdefs/ldrt_A8892.d | 93 - src/arch/arm/v7/opdefs/lsl_A8894.d | 91 - src/arch/arm/v7/opdefs/lsl_A8895.d | 90 - src/arch/arm/v7/opdefs/lsr_A8896.d | 91 - src/arch/arm/v7/opdefs/lsr_A8897.d | 90 - src/arch/arm/v7/opdefs/mcr_A8898.d | 109 -- src/arch/arm/v7/opdefs/mcrr_A8899.d | 105 -- src/arch/arm/v7/opdefs/mla_A88100.d | 69 - src/arch/arm/v7/opdefs/mls_A88101.d | 67 - src/arch/arm/v7/opdefs/mov_A88102.d | 124 -- src/arch/arm/v7/opdefs/mov_A88103.d | 80 - src/arch/arm/v7/opdefs/mov_A88104.d | 50 - src/arch/arm/v7/opdefs/movt_A88106.d | 63 - src/arch/arm/v7/opdefs/mrc_A88107.d | 109 -- src/arch/arm/v7/opdefs/mrrc_A88108.d | 105 -- src/arch/arm/v7/opdefs/mul_A88114.d | 83 - src/arch/arm/v7/opdefs/mvn_A88115.d | 72 - src/arch/arm/v7/opdefs/mvn_A88116.d | 90 - src/arch/arm/v7/opdefs/mvn_A88117.d | 51 - src/arch/arm/v7/opdefs/nop_A88119.d | 53 - src/arch/arm/v7/opdefs/orn_A88120.d | 50 - src/arch/arm/v7/opdefs/orn_A88121.d | 51 - src/arch/arm/v7/opdefs/orr_A88122.d | 74 - src/arch/arm/v7/opdefs/orr_A88123.d | 92 - src/arch/arm/v7/opdefs/orr_A88124.d | 52 - src/arch/arm/v7/opdefs/pop_A88131.d | 87 - src/arch/arm/v7/opdefs/pop_A88132.d | 79 - src/arch/arm/v7/opdefs/push_A88133.d | 109 -- src/arch/arm/v7/opdefs/qadd16_A88135.d | 65 - src/arch/arm/v7/opdefs/qadd8_A88136.d | 65 - src/arch/arm/v7/opdefs/qadd_A88134.d | 65 - src/arch/arm/v7/opdefs/qasx_A88137.d | 65 - src/arch/arm/v7/opdefs/qdadd_A88138.d | 65 - src/arch/arm/v7/opdefs/qdsub_A88139.d | 65 - src/arch/arm/v7/opdefs/qsax_A88140.d | 65 - src/arch/arm/v7/opdefs/qsub16_A88142.d | 65 - src/arch/arm/v7/opdefs/qsub8_A88143.d | 65 - src/arch/arm/v7/opdefs/qsub_A88141.d | 65 - src/arch/arm/v7/opdefs/rbit_A88144.d | 63 - src/arch/arm/v7/opdefs/rev16_A88146.d | 78 - src/arch/arm/v7/opdefs/rev_A88145.d | 78 - src/arch/arm/v7/opdefs/revsh_A88147.d | 78 - src/arch/arm/v7/opdefs/ror_A88149.d | 74 - src/arch/arm/v7/opdefs/ror_A88150.d | 90 - src/arch/arm/v7/opdefs/rrx_A88151.d | 72 - src/arch/arm/v7/opdefs/rsb_A88152.d | 91 - src/arch/arm/v7/opdefs/rsb_A88153.d | 76 - src/arch/arm/v7/opdefs/rsb_A88154.d | 52 - src/arch/arm/v7/opdefs/rsc_A88155.d | 51 - src/arch/arm/v7/opdefs/rsc_A88156.d | 52 - src/arch/arm/v7/opdefs/rsc_A88157.d | 52 - src/arch/arm/v7/opdefs/sadd16_A88158.d | 65 - src/arch/arm/v7/opdefs/sadd8_A88159.d | 65 - src/arch/arm/v7/opdefs/sasx_A88160.d | 65 - src/arch/arm/v7/opdefs/sbc_A88161.d | 74 - src/arch/arm/v7/opdefs/sbc_A88162.d | 92 - src/arch/arm/v7/opdefs/sbc_A88163.d | 52 - src/arch/arm/v7/opdefs/sbfx_A88164.d | 67 - src/arch/arm/v7/opdefs/sdiv_A88165.d | 65 - src/arch/arm/v7/opdefs/sel_A88166.d | 65 - src/arch/arm/v7/opdefs/setend_A88167.d | 55 - src/arch/arm/v7/opdefs/sev_A88168.d | 53 - src/arch/arm/v7/opdefs/shadd16_A88169.d | 65 - src/arch/arm/v7/opdefs/shadd8_A88170.d | 65 - src/arch/arm/v7/opdefs/shasx_A88171.d | 65 - src/arch/arm/v7/opdefs/shsax_A88172.d | 65 - src/arch/arm/v7/opdefs/shsub16_A88173.d | 65 - src/arch/arm/v7/opdefs/shsub8_A88174.d | 65 - src/arch/arm/v7/opdefs/smlad_A88177.d | 76 - src/arch/arm/v7/opdefs/smlal_A88178.d | 69 - src/arch/arm/v7/opdefs/smlald_A88180.d | 76 - src/arch/arm/v7/opdefs/smlsd_A88182.d | 76 - src/arch/arm/v7/opdefs/smlsld_A88183.d | 76 - src/arch/arm/v7/opdefs/smmla_A88184.d | 76 - src/arch/arm/v7/opdefs/smmls_A88185.d | 76 - src/arch/arm/v7/opdefs/smmul_A88186.d | 74 - src/arch/arm/v7/opdefs/smuad_A88187.d | 74 - src/arch/arm/v7/opdefs/smull_A88189.d | 69 - src/arch/arm/v7/opdefs/str_A88203.d | 98 - src/arch/arm/v7/opdefs/str_A88204.d | 53 - src/arch/arm/v7/opdefs/str_A88205.d | 89 - src/arch/arm/v7/opdefs/strb_A88206.d | 81 - src/arch/arm/v7/opdefs/strb_A88207.d | 53 - src/arch/arm/v7/opdefs/strb_A88208.d | 89 - src/arch/arm/v7/opdefs/strbt_A88209.d | 93 - src/arch/arm/v7/opdefs/strd_A88210.d | 75 - src/arch/arm/v7/opdefs/strd_A88211.d | 54 - src/arch/arm/v7/opdefs/strex_A88212.d | 68 - src/arch/arm/v7/opdefs/strexb_A88213.d | 67 - src/arch/arm/v7/opdefs/strexd_A88214.d | 69 - src/arch/arm/v7/opdefs/strexh_A88215.d | 67 - src/arch/arm/v7/opdefs/strh_A88216.d | 81 - src/arch/arm/v7/opdefs/strh_A88217.d | 53 - src/arch/arm/v7/opdefs/strh_A88218.d | 88 - src/arch/arm/v7/opdefs/strht_A88219.d | 92 - src/arch/arm/v7/opdefs/strt_A88220.d | 93 - src/arch/arm/v7/opdefs/sub_A88221.d | 98 - src/arch/arm/v7/opdefs/sub_A88222.d | 51 - src/arch/arm/v7/opdefs/sub_A88223.d | 93 - src/arch/arm/v7/opdefs/sub_A88224.d | 52 - src/arch/arm/v7/opdefs/sub_A88225.d | 107 -- src/arch/arm/v7/opdefs/sub_A88226.d | 76 - src/arch/arm/v7/opdefs/subs_B9320.d | 44 - src/arch/arm/v7/opdefs/svc_A88228.d | 61 - src/arch/arm/v7/opdefs/swp_A88229.d | 52 - src/arch/arm/v7/opdefs/teq_A88237.d | 63 - src/arch/arm/v7/opdefs/teq_A88238.d | 65 - src/arch/arm/v7/opdefs/teq_A88239.d | 49 - src/arch/arm/v7/opdefs/tst_A88240.d | 63 - src/arch/arm/v7/opdefs/tst_A88241.d | 80 - src/arch/arm/v7/opdefs/tst_A88242.d | 49 - src/arch/arm/v7/opdefs/uadd16_A88243.d | 65 - src/arch/arm/v7/opdefs/uadd8_A88244.d | 65 - src/arch/arm/v7/opdefs/uasx_A88245.d | 65 - src/arch/arm/v7/opdefs/ubfx_A88246.d | 67 - src/arch/arm/v7/opdefs/udf_A88247.d | 69 - src/arch/arm/v7/opdefs/udiv_A88248.d | 65 - src/arch/arm/v7/opdefs/uhadd16_A88249.d | 65 - src/arch/arm/v7/opdefs/uhadd8_A88250.d | 65 - src/arch/arm/v7/opdefs/uhasx_A88251.d | 65 - src/arch/arm/v7/opdefs/uhsax_A88252.d | 65 - src/arch/arm/v7/opdefs/uhsub16_A88253.d | 65 - src/arch/arm/v7/opdefs/uhsub8_A88254.d | 65 - src/arch/arm/v7/opdefs/umaal_A88255.d | 67 - src/arch/arm/v7/opdefs/umlal_A88256.d | 69 - src/arch/arm/v7/opdefs/umull_A88257.d | 69 - src/arch/arm/v7/opdefs/uqadd16_A88258.d | 65 - src/arch/arm/v7/opdefs/uqadd8_A88259.d | 65 - src/arch/arm/v7/opdefs/uqasx_A88260.d | 65 - src/arch/arm/v7/opdefs/uqsax_A88261.d | 65 - src/arch/arm/v7/opdefs/uqsub16_A88262.d | 65 - src/arch/arm/v7/opdefs/uqsub8_A88263.d | 65 - src/arch/arm/v7/opdefs/usad8_A88264.d | 65 - src/arch/arm/v7/opdefs/usada8_A88265.d | 67 - src/arch/arm/v7/opdefs/usat16_A88267.d | 65 - src/arch/arm/v7/opdefs/usat_A88266.d | 67 - src/arch/arm/v7/opdefs/usax_A88268.d | 65 - src/arch/arm/v7/opdefs/usub16_A88269.d | 65 - src/arch/arm/v7/opdefs/usub8_A88270.d | 65 - src/arch/arm/v7/opdefs/uxtab16_A88272.d | 67 - src/arch/arm/v7/opdefs/uxtab_A88271.d | 67 - src/arch/arm/v7/opdefs/uxtah_A88273.d | 67 - src/arch/arm/v7/opdefs/uxtb16_A88275.d | 65 - src/arch/arm/v7/opdefs/uxtb_A88274.d | 80 - src/arch/arm/v7/opdefs/uxth_A88276.d | 80 - src/arch/arm/v7/opdefs/wfi_A88425.d | 53 - src/arch/arm/v7/opdefs/yield_A88426.d | 53 - src/arch/arm/v7/operands/Makefile.am | 21 - src/arch/arm/v7/operands/coproc.c | 250 --- src/arch/arm/v7/operands/coproc.h | 61 - src/arch/arm/v7/operands/estate.c | 248 --- src/arch/arm/v7/operands/estate.h | 61 - src/arch/arm/v7/operands/limitation.c | 287 --- src/arch/arm/v7/operands/limitation.h | 77 - src/arch/arm/v7/operands/maccess.c | 385 ---- src/arch/arm/v7/operands/maccess.h | 75 - src/arch/arm/v7/operands/offset.c | 283 --- src/arch/arm/v7/operands/offset.h | 66 - src/arch/arm/v7/operands/reglist.c | 376 ---- src/arch/arm/v7/operands/reglist.h | 72 - src/arch/arm/v7/operands/rotation.c | 256 --- src/arch/arm/v7/operands/rotation.h | 61 - src/arch/arm/v7/operands/shift.c | 300 ---- src/arch/arm/v7/operands/shift.h | 65 - src/arch/arm/v7/post.c | 99 -- src/arch/arm/v7/post.h | 57 - src/arch/arm/v7/processor.c | 295 --- src/arch/arm/v7/processor.h | 56 - src/arch/arm/v7/pseudo.c | 683 ------- src/arch/arm/v7/pseudo.h | 136 -- src/arch/arm/v7/register.c | 229 --- src/arch/arm/v7/register.h | 57 - src/arch/arm/v7/simd.c | 1539 ---------------- src/arch/arm/v7/simd.h | 55 - src/arch/arm/v7/thumb_16.c | 670 ------- src/arch/arm/v7/thumb_16.h | 37 - src/arch/arm/v7/thumb_32.c | 2268 ----------------------- src/arch/arm/v7/thumb_32.h | 37 - src/core/processors.c | 6 - src/plugins/plugin.c | 3 + 626 files changed, 33870 insertions(+), 33370 deletions(-) create mode 100644 plugins/arm/Makefile.am create mode 100644 plugins/arm/cond.h create mode 100644 plugins/arm/context-int.h create mode 100644 plugins/arm/context.c create mode 100644 plugins/arm/context.h create mode 100644 plugins/arm/core.c create mode 100644 plugins/arm/core.h create mode 100644 plugins/arm/instruction-int.h create mode 100644 plugins/arm/instruction.c create mode 100644 plugins/arm/instruction.h create mode 100644 plugins/arm/link.c create mode 100644 plugins/arm/link.h create mode 100644 plugins/arm/processor-int.h create mode 100644 plugins/arm/processor.c create mode 100644 plugins/arm/processor.h create mode 100644 plugins/arm/python/Makefile.am create mode 100644 plugins/arm/python/instruction.c create mode 100644 plugins/arm/python/instruction.h create mode 100644 plugins/arm/python/module.c create mode 100644 plugins/arm/python/module.h create mode 100644 plugins/arm/python/processor.c create mode 100644 plugins/arm/python/processor.h create mode 100644 plugins/arm/python/v7/Makefile.am create mode 100644 plugins/arm/python/v7/instruction.c create mode 100644 plugins/arm/python/v7/instruction.h create mode 100644 plugins/arm/python/v7/module.c create mode 100644 plugins/arm/python/v7/module.h create mode 100644 plugins/arm/python/v7/processor.c create mode 100644 plugins/arm/python/v7/processor.h create mode 100644 plugins/arm/register-int.h create mode 100644 plugins/arm/register.c create mode 100644 plugins/arm/register.h create mode 100644 plugins/arm/v7/Makefile.am create mode 100644 plugins/arm/v7/arm.c create mode 100644 plugins/arm/v7/arm.h create mode 100755 plugins/arm/v7/build_tmp_decl.sh create mode 100644 plugins/arm/v7/context.c create mode 100644 plugins/arm/v7/context.h create mode 100644 plugins/arm/v7/core.c create mode 100644 plugins/arm/v7/core.h create mode 100644 plugins/arm/v7/cregister.c create mode 100644 plugins/arm/v7/cregister.h create mode 100644 plugins/arm/v7/fetch.c create mode 100644 plugins/arm/v7/fetch.h create mode 100644 plugins/arm/v7/helpers.c create mode 100644 plugins/arm/v7/helpers.h create mode 100644 plugins/arm/v7/instruction.c create mode 100644 plugins/arm/v7/instruction.h create mode 100644 plugins/arm/v7/link.c create mode 100644 plugins/arm/v7/link.h create mode 100644 plugins/arm/v7/opcodes/Makefile.am create mode 100644 plugins/arm/v7/opcodes/opcodes_tmp_arm.h create mode 100644 plugins/arm/v7/opcodes/opcodes_tmp_simd.h create mode 100644 plugins/arm/v7/opcodes/opcodes_tmp_thumb_16.h create mode 100644 plugins/arm/v7/opcodes/opcodes_tmp_thumb_32.h create mode 100644 plugins/arm/v7/opdefs/Makefile.am create mode 100644 plugins/arm/v7/opdefs/adc_A881.d create mode 100644 plugins/arm/v7/opdefs/adc_A882.d create mode 100644 plugins/arm/v7/opdefs/adc_A883.d create mode 100644 plugins/arm/v7/opdefs/add_A8810.d create mode 100644 plugins/arm/v7/opdefs/add_A8811.d create mode 100644 plugins/arm/v7/opdefs/add_A884.d create mode 100644 plugins/arm/v7/opdefs/add_A885.d create mode 100644 plugins/arm/v7/opdefs/add_A886.d create mode 100644 plugins/arm/v7/opdefs/add_A887.d create mode 100644 plugins/arm/v7/opdefs/add_A888.d create mode 100644 plugins/arm/v7/opdefs/add_A889.d create mode 100644 plugins/arm/v7/opdefs/adr_A8812.d create mode 100644 plugins/arm/v7/opdefs/and_A8813.d create mode 100644 plugins/arm/v7/opdefs/and_A8814.d create mode 100644 plugins/arm/v7/opdefs/and_A8815.d create mode 100644 plugins/arm/v7/opdefs/asr_A8816.d create mode 100644 plugins/arm/v7/opdefs/asr_A8817.d create mode 100644 plugins/arm/v7/opdefs/b_A8818.d create mode 100644 plugins/arm/v7/opdefs/bfc_A8819.d create mode 100644 plugins/arm/v7/opdefs/bfi_A8820.d create mode 100644 plugins/arm/v7/opdefs/bic_A8821.d create mode 100644 plugins/arm/v7/opdefs/bic_A8822.d create mode 100644 plugins/arm/v7/opdefs/bic_A8823.d create mode 100644 plugins/arm/v7/opdefs/bkpt_A8824.d create mode 100644 plugins/arm/v7/opdefs/bl_A8825.d create mode 100644 plugins/arm/v7/opdefs/blx_A8826.d create mode 100644 plugins/arm/v7/opdefs/bx_A8827.d create mode 100644 plugins/arm/v7/opdefs/bxj_A8828.d create mode 100644 plugins/arm/v7/opdefs/cb_A8829.d create mode 100644 plugins/arm/v7/opdefs/cdp_A8830.d create mode 100644 plugins/arm/v7/opdefs/clrex_A8832.d create mode 100644 plugins/arm/v7/opdefs/clz_A8833.d create mode 100644 plugins/arm/v7/opdefs/cmn_A8834.d create mode 100644 plugins/arm/v7/opdefs/cmn_A8835.d create mode 100644 plugins/arm/v7/opdefs/cmn_A8836.d create mode 100644 plugins/arm/v7/opdefs/cmp_A8837.d create mode 100644 plugins/arm/v7/opdefs/cmp_A8838.d create mode 100644 plugins/arm/v7/opdefs/cmp_A8839.d create mode 100644 plugins/arm/v7/opdefs/dbg_A8842.d create mode 100644 plugins/arm/v7/opdefs/dmb_A8843.d create mode 100644 plugins/arm/v7/opdefs/dsb_A8844.d create mode 100644 plugins/arm/v7/opdefs/eor_A8846.d create mode 100644 plugins/arm/v7/opdefs/eor_A8847.d create mode 100644 plugins/arm/v7/opdefs/eor_A8848.d create mode 100644 plugins/arm/v7/opdefs/ldr_A8862.d create mode 100644 plugins/arm/v7/opdefs/ldr_A8863.d create mode 100644 plugins/arm/v7/opdefs/ldr_A8864.d create mode 100644 plugins/arm/v7/opdefs/ldr_A8865.d create mode 100644 plugins/arm/v7/opdefs/ldr_A8866.d create mode 100644 plugins/arm/v7/opdefs/ldrb_A8867.d create mode 100644 plugins/arm/v7/opdefs/ldrb_A8868.d create mode 100644 plugins/arm/v7/opdefs/ldrb_A8869.d create mode 100644 plugins/arm/v7/opdefs/ldrb_A8870.d create mode 100644 plugins/arm/v7/opdefs/ldrbt_A8871.d create mode 100644 plugins/arm/v7/opdefs/ldrd_A8872.d create mode 100644 plugins/arm/v7/opdefs/ldrd_A8873.d create mode 100644 plugins/arm/v7/opdefs/ldrd_A8874.d create mode 100644 plugins/arm/v7/opdefs/ldrex_A8875.d create mode 100644 plugins/arm/v7/opdefs/ldrexb_A8876.d create mode 100644 plugins/arm/v7/opdefs/ldrexd_A8877.d create mode 100644 plugins/arm/v7/opdefs/ldrexh_A8878.d create mode 100644 plugins/arm/v7/opdefs/ldrh_A8879.d create mode 100644 plugins/arm/v7/opdefs/ldrh_A8880.d create mode 100644 plugins/arm/v7/opdefs/ldrh_A8881.d create mode 100644 plugins/arm/v7/opdefs/ldrh_A8882.d create mode 100644 plugins/arm/v7/opdefs/ldrht_A8883.d create mode 100644 plugins/arm/v7/opdefs/ldrsb_A8884.d create mode 100644 plugins/arm/v7/opdefs/ldrsb_A8885.d create mode 100644 plugins/arm/v7/opdefs/ldrsb_A8886.d create mode 100644 plugins/arm/v7/opdefs/ldrsbt_A8887.d create mode 100644 plugins/arm/v7/opdefs/ldrsh_A8888.d create mode 100644 plugins/arm/v7/opdefs/ldrsh_A8889.d create mode 100644 plugins/arm/v7/opdefs/ldrsh_A8890.d create mode 100644 plugins/arm/v7/opdefs/ldrsht_A8891.d create mode 100644 plugins/arm/v7/opdefs/ldrt_A8892.d create mode 100644 plugins/arm/v7/opdefs/lsl_A8894.d create mode 100644 plugins/arm/v7/opdefs/lsl_A8895.d create mode 100644 plugins/arm/v7/opdefs/lsr_A8896.d create mode 100644 plugins/arm/v7/opdefs/lsr_A8897.d create mode 100644 plugins/arm/v7/opdefs/mcr_A8898.d create mode 100644 plugins/arm/v7/opdefs/mcrr_A8899.d create mode 100644 plugins/arm/v7/opdefs/mla_A88100.d create mode 100644 plugins/arm/v7/opdefs/mls_A88101.d create mode 100644 plugins/arm/v7/opdefs/mov_A88102.d create mode 100644 plugins/arm/v7/opdefs/mov_A88103.d create mode 100644 plugins/arm/v7/opdefs/mov_A88104.d create mode 100644 plugins/arm/v7/opdefs/movt_A88106.d create mode 100644 plugins/arm/v7/opdefs/mrc_A88107.d create mode 100644 plugins/arm/v7/opdefs/mrrc_A88108.d create mode 100644 plugins/arm/v7/opdefs/mul_A88114.d create mode 100644 plugins/arm/v7/opdefs/mvn_A88115.d create mode 100644 plugins/arm/v7/opdefs/mvn_A88116.d create mode 100644 plugins/arm/v7/opdefs/mvn_A88117.d create mode 100644 plugins/arm/v7/opdefs/nop_A88119.d create mode 100644 plugins/arm/v7/opdefs/orn_A88120.d create mode 100644 plugins/arm/v7/opdefs/orn_A88121.d create mode 100644 plugins/arm/v7/opdefs/orr_A88122.d create mode 100644 plugins/arm/v7/opdefs/orr_A88123.d create mode 100644 plugins/arm/v7/opdefs/orr_A88124.d create mode 100644 plugins/arm/v7/opdefs/pop_A88131.d create mode 100644 plugins/arm/v7/opdefs/pop_A88132.d create mode 100644 plugins/arm/v7/opdefs/push_A88133.d create mode 100644 plugins/arm/v7/opdefs/qadd16_A88135.d create mode 100644 plugins/arm/v7/opdefs/qadd8_A88136.d create mode 100644 plugins/arm/v7/opdefs/qadd_A88134.d create mode 100644 plugins/arm/v7/opdefs/qasx_A88137.d create mode 100644 plugins/arm/v7/opdefs/qdadd_A88138.d create mode 100644 plugins/arm/v7/opdefs/qdsub_A88139.d create mode 100644 plugins/arm/v7/opdefs/qsax_A88140.d create mode 100644 plugins/arm/v7/opdefs/qsub16_A88142.d create mode 100644 plugins/arm/v7/opdefs/qsub8_A88143.d create mode 100644 plugins/arm/v7/opdefs/qsub_A88141.d create mode 100644 plugins/arm/v7/opdefs/rbit_A88144.d create mode 100644 plugins/arm/v7/opdefs/rev16_A88146.d create mode 100644 plugins/arm/v7/opdefs/rev_A88145.d create mode 100644 plugins/arm/v7/opdefs/revsh_A88147.d create mode 100644 plugins/arm/v7/opdefs/ror_A88149.d create mode 100644 plugins/arm/v7/opdefs/ror_A88150.d create mode 100644 plugins/arm/v7/opdefs/rrx_A88151.d create mode 100644 plugins/arm/v7/opdefs/rsb_A88152.d create mode 100644 plugins/arm/v7/opdefs/rsb_A88153.d create mode 100644 plugins/arm/v7/opdefs/rsb_A88154.d create mode 100644 plugins/arm/v7/opdefs/rsc_A88155.d create mode 100644 plugins/arm/v7/opdefs/rsc_A88156.d create mode 100644 plugins/arm/v7/opdefs/rsc_A88157.d create mode 100644 plugins/arm/v7/opdefs/sadd16_A88158.d create mode 100644 plugins/arm/v7/opdefs/sadd8_A88159.d create mode 100644 plugins/arm/v7/opdefs/sasx_A88160.d create mode 100644 plugins/arm/v7/opdefs/sbc_A88161.d create mode 100644 plugins/arm/v7/opdefs/sbc_A88162.d create mode 100644 plugins/arm/v7/opdefs/sbc_A88163.d create mode 100644 plugins/arm/v7/opdefs/sbfx_A88164.d create mode 100644 plugins/arm/v7/opdefs/sdiv_A88165.d create mode 100644 plugins/arm/v7/opdefs/sel_A88166.d create mode 100644 plugins/arm/v7/opdefs/setend_A88167.d create mode 100644 plugins/arm/v7/opdefs/sev_A88168.d create mode 100644 plugins/arm/v7/opdefs/shadd16_A88169.d create mode 100644 plugins/arm/v7/opdefs/shadd8_A88170.d create mode 100644 plugins/arm/v7/opdefs/shasx_A88171.d create mode 100644 plugins/arm/v7/opdefs/shsax_A88172.d create mode 100644 plugins/arm/v7/opdefs/shsub16_A88173.d create mode 100644 plugins/arm/v7/opdefs/shsub8_A88174.d create mode 100644 plugins/arm/v7/opdefs/smlad_A88177.d create mode 100644 plugins/arm/v7/opdefs/smlal_A88178.d create mode 100644 plugins/arm/v7/opdefs/smlald_A88180.d create mode 100644 plugins/arm/v7/opdefs/smlsd_A88182.d create mode 100644 plugins/arm/v7/opdefs/smlsld_A88183.d create mode 100644 plugins/arm/v7/opdefs/smmla_A88184.d create mode 100644 plugins/arm/v7/opdefs/smmls_A88185.d create mode 100644 plugins/arm/v7/opdefs/smmul_A88186.d create mode 100644 plugins/arm/v7/opdefs/smuad_A88187.d create mode 100644 plugins/arm/v7/opdefs/smull_A88189.d create mode 100644 plugins/arm/v7/opdefs/str_A88203.d create mode 100644 plugins/arm/v7/opdefs/str_A88204.d create mode 100644 plugins/arm/v7/opdefs/str_A88205.d create mode 100644 plugins/arm/v7/opdefs/strb_A88206.d create mode 100644 plugins/arm/v7/opdefs/strb_A88207.d create mode 100644 plugins/arm/v7/opdefs/strb_A88208.d create mode 100644 plugins/arm/v7/opdefs/strbt_A88209.d create mode 100644 plugins/arm/v7/opdefs/strd_A88210.d create mode 100644 plugins/arm/v7/opdefs/strd_A88211.d create mode 100644 plugins/arm/v7/opdefs/strex_A88212.d create mode 100644 plugins/arm/v7/opdefs/strexb_A88213.d create mode 100644 plugins/arm/v7/opdefs/strexd_A88214.d create mode 100644 plugins/arm/v7/opdefs/strexh_A88215.d create mode 100644 plugins/arm/v7/opdefs/strh_A88216.d create mode 100644 plugins/arm/v7/opdefs/strh_A88217.d create mode 100644 plugins/arm/v7/opdefs/strh_A88218.d create mode 100644 plugins/arm/v7/opdefs/strht_A88219.d create mode 100644 plugins/arm/v7/opdefs/strt_A88220.d create mode 100644 plugins/arm/v7/opdefs/sub_A88221.d create mode 100644 plugins/arm/v7/opdefs/sub_A88222.d create mode 100644 plugins/arm/v7/opdefs/sub_A88223.d create mode 100644 plugins/arm/v7/opdefs/sub_A88224.d create mode 100644 plugins/arm/v7/opdefs/sub_A88225.d create mode 100644 plugins/arm/v7/opdefs/sub_A88226.d create mode 100644 plugins/arm/v7/opdefs/subs_B9320.d create mode 100644 plugins/arm/v7/opdefs/svc_A88228.d create mode 100644 plugins/arm/v7/opdefs/swp_A88229.d create mode 100644 plugins/arm/v7/opdefs/teq_A88237.d create mode 100644 plugins/arm/v7/opdefs/teq_A88238.d create mode 100644 plugins/arm/v7/opdefs/teq_A88239.d create mode 100644 plugins/arm/v7/opdefs/tst_A88240.d create mode 100644 plugins/arm/v7/opdefs/tst_A88241.d create mode 100644 plugins/arm/v7/opdefs/tst_A88242.d create mode 100644 plugins/arm/v7/opdefs/uadd16_A88243.d create mode 100644 plugins/arm/v7/opdefs/uadd8_A88244.d create mode 100644 plugins/arm/v7/opdefs/uasx_A88245.d create mode 100644 plugins/arm/v7/opdefs/ubfx_A88246.d create mode 100644 plugins/arm/v7/opdefs/udf_A88247.d create mode 100644 plugins/arm/v7/opdefs/udiv_A88248.d create mode 100644 plugins/arm/v7/opdefs/uhadd16_A88249.d create mode 100644 plugins/arm/v7/opdefs/uhadd8_A88250.d create mode 100644 plugins/arm/v7/opdefs/uhasx_A88251.d create mode 100644 plugins/arm/v7/opdefs/uhsax_A88252.d create mode 100644 plugins/arm/v7/opdefs/uhsub16_A88253.d create mode 100644 plugins/arm/v7/opdefs/uhsub8_A88254.d create mode 100644 plugins/arm/v7/opdefs/umaal_A88255.d create mode 100644 plugins/arm/v7/opdefs/umlal_A88256.d create mode 100644 plugins/arm/v7/opdefs/umull_A88257.d create mode 100644 plugins/arm/v7/opdefs/uqadd16_A88258.d create mode 100644 plugins/arm/v7/opdefs/uqadd8_A88259.d create mode 100644 plugins/arm/v7/opdefs/uqasx_A88260.d create mode 100644 plugins/arm/v7/opdefs/uqsax_A88261.d create mode 100644 plugins/arm/v7/opdefs/uqsub16_A88262.d create mode 100644 plugins/arm/v7/opdefs/uqsub8_A88263.d create mode 100644 plugins/arm/v7/opdefs/usad8_A88264.d create mode 100644 plugins/arm/v7/opdefs/usada8_A88265.d create mode 100644 plugins/arm/v7/opdefs/usat16_A88267.d create mode 100644 plugins/arm/v7/opdefs/usat_A88266.d create mode 100644 plugins/arm/v7/opdefs/usax_A88268.d create mode 100644 plugins/arm/v7/opdefs/usub16_A88269.d create mode 100644 plugins/arm/v7/opdefs/usub8_A88270.d create mode 100644 plugins/arm/v7/opdefs/uxtab16_A88272.d create mode 100644 plugins/arm/v7/opdefs/uxtab_A88271.d create mode 100644 plugins/arm/v7/opdefs/uxtah_A88273.d create mode 100644 plugins/arm/v7/opdefs/uxtb16_A88275.d create mode 100644 plugins/arm/v7/opdefs/uxtb_A88274.d create mode 100644 plugins/arm/v7/opdefs/uxth_A88276.d create mode 100644 plugins/arm/v7/opdefs/wfi_A88425.d create mode 100644 plugins/arm/v7/opdefs/yield_A88426.d create mode 100644 plugins/arm/v7/operands/Makefile.am create mode 100644 plugins/arm/v7/operands/coproc.c create mode 100644 plugins/arm/v7/operands/coproc.h create mode 100644 plugins/arm/v7/operands/estate.c create mode 100644 plugins/arm/v7/operands/estate.h create mode 100644 plugins/arm/v7/operands/limitation.c create mode 100644 plugins/arm/v7/operands/limitation.h create mode 100644 plugins/arm/v7/operands/maccess.c create mode 100644 plugins/arm/v7/operands/maccess.h create mode 100644 plugins/arm/v7/operands/offset.c create mode 100644 plugins/arm/v7/operands/offset.h create mode 100644 plugins/arm/v7/operands/reglist.c create mode 100644 plugins/arm/v7/operands/reglist.h create mode 100644 plugins/arm/v7/operands/rotation.c create mode 100644 plugins/arm/v7/operands/rotation.h create mode 100644 plugins/arm/v7/operands/shift.c create mode 100644 plugins/arm/v7/operands/shift.h create mode 100644 plugins/arm/v7/post.c create mode 100644 plugins/arm/v7/post.h create mode 100644 plugins/arm/v7/processor.c create mode 100644 plugins/arm/v7/processor.h create mode 100644 plugins/arm/v7/pseudo.c create mode 100644 plugins/arm/v7/pseudo.h create mode 100644 plugins/arm/v7/register.c create mode 100644 plugins/arm/v7/register.h create mode 100644 plugins/arm/v7/simd.c create mode 100644 plugins/arm/v7/simd.h create mode 100644 plugins/arm/v7/thumb_16.c create mode 100644 plugins/arm/v7/thumb_16.h create mode 100644 plugins/arm/v7/thumb_32.c create mode 100644 plugins/arm/v7/thumb_32.h delete mode 100644 plugins/pychrysa/arch/arm/Makefile.am delete mode 100644 plugins/pychrysa/arch/arm/instruction.c delete mode 100644 plugins/pychrysa/arch/arm/instruction.h delete mode 100644 plugins/pychrysa/arch/arm/module.c delete mode 100644 plugins/pychrysa/arch/arm/module.h delete mode 100644 plugins/pychrysa/arch/arm/processor.c delete mode 100644 plugins/pychrysa/arch/arm/processor.h delete mode 100644 plugins/pychrysa/arch/arm/v7/Makefile.am delete mode 100644 plugins/pychrysa/arch/arm/v7/instruction.c delete mode 100644 plugins/pychrysa/arch/arm/v7/instruction.h delete mode 100644 plugins/pychrysa/arch/arm/v7/module.c delete mode 100644 plugins/pychrysa/arch/arm/v7/module.h delete mode 100644 plugins/pychrysa/arch/arm/v7/processor.c delete mode 100644 plugins/pychrysa/arch/arm/v7/processor.h delete mode 100644 src/arch/arm/Makefile.am delete mode 100644 src/arch/arm/cond.h delete mode 100644 src/arch/arm/context-int.h delete mode 100644 src/arch/arm/context.c delete mode 100644 src/arch/arm/context.h delete mode 100644 src/arch/arm/instruction-int.h delete mode 100644 src/arch/arm/instruction.c delete mode 100644 src/arch/arm/instruction.h delete mode 100644 src/arch/arm/link.c delete mode 100644 src/arch/arm/link.h delete mode 100644 src/arch/arm/processor-int.h delete mode 100644 src/arch/arm/processor.c delete mode 100644 src/arch/arm/processor.h delete mode 100644 src/arch/arm/register-int.h delete mode 100644 src/arch/arm/register.c delete mode 100644 src/arch/arm/register.h delete mode 100644 src/arch/arm/v7/Makefile.am delete mode 100644 src/arch/arm/v7/arm.c delete mode 100644 src/arch/arm/v7/arm.h delete mode 100755 src/arch/arm/v7/build_tmp_decl.sh delete mode 100644 src/arch/arm/v7/context.c delete mode 100644 src/arch/arm/v7/context.h delete mode 100644 src/arch/arm/v7/core.c delete mode 100644 src/arch/arm/v7/core.h delete mode 100644 src/arch/arm/v7/cregister.c delete mode 100644 src/arch/arm/v7/cregister.h delete mode 100644 src/arch/arm/v7/fetch.c delete mode 100644 src/arch/arm/v7/fetch.h delete mode 100644 src/arch/arm/v7/helpers.c delete mode 100644 src/arch/arm/v7/helpers.h delete mode 100644 src/arch/arm/v7/instruction.c delete mode 100644 src/arch/arm/v7/instruction.h delete mode 100644 src/arch/arm/v7/link.c delete mode 100644 src/arch/arm/v7/link.h delete mode 100644 src/arch/arm/v7/opcodes/Makefile.am delete mode 100644 src/arch/arm/v7/opcodes/opcodes_tmp_arm.h delete mode 100644 src/arch/arm/v7/opcodes/opcodes_tmp_simd.h delete mode 100644 src/arch/arm/v7/opcodes/opcodes_tmp_thumb_16.h delete mode 100644 src/arch/arm/v7/opcodes/opcodes_tmp_thumb_32.h delete mode 100644 src/arch/arm/v7/opdefs/Makefile.am delete mode 100644 src/arch/arm/v7/opdefs/adc_A881.d delete mode 100644 src/arch/arm/v7/opdefs/adc_A882.d delete mode 100644 src/arch/arm/v7/opdefs/adc_A883.d delete mode 100644 src/arch/arm/v7/opdefs/add_A8810.d delete mode 100644 src/arch/arm/v7/opdefs/add_A8811.d delete mode 100644 src/arch/arm/v7/opdefs/add_A884.d delete mode 100644 src/arch/arm/v7/opdefs/add_A885.d delete mode 100644 src/arch/arm/v7/opdefs/add_A886.d delete mode 100644 src/arch/arm/v7/opdefs/add_A887.d delete mode 100644 src/arch/arm/v7/opdefs/add_A888.d delete mode 100644 src/arch/arm/v7/opdefs/add_A889.d delete mode 100644 src/arch/arm/v7/opdefs/adr_A8812.d delete mode 100644 src/arch/arm/v7/opdefs/and_A8813.d delete mode 100644 src/arch/arm/v7/opdefs/and_A8814.d delete mode 100644 src/arch/arm/v7/opdefs/and_A8815.d delete mode 100644 src/arch/arm/v7/opdefs/asr_A8816.d delete mode 100644 src/arch/arm/v7/opdefs/asr_A8817.d delete mode 100644 src/arch/arm/v7/opdefs/b_A8818.d delete mode 100644 src/arch/arm/v7/opdefs/bfc_A8819.d delete mode 100644 src/arch/arm/v7/opdefs/bfi_A8820.d delete mode 100644 src/arch/arm/v7/opdefs/bic_A8821.d delete mode 100644 src/arch/arm/v7/opdefs/bic_A8822.d delete mode 100644 src/arch/arm/v7/opdefs/bic_A8823.d delete mode 100644 src/arch/arm/v7/opdefs/bkpt_A8824.d delete mode 100644 src/arch/arm/v7/opdefs/bl_A8825.d delete mode 100644 src/arch/arm/v7/opdefs/blx_A8826.d delete mode 100644 src/arch/arm/v7/opdefs/bx_A8827.d delete mode 100644 src/arch/arm/v7/opdefs/bxj_A8828.d delete mode 100644 src/arch/arm/v7/opdefs/cb_A8829.d delete mode 100644 src/arch/arm/v7/opdefs/cdp_A8830.d delete mode 100644 src/arch/arm/v7/opdefs/clrex_A8832.d delete mode 100644 src/arch/arm/v7/opdefs/clz_A8833.d delete mode 100644 src/arch/arm/v7/opdefs/cmn_A8834.d delete mode 100644 src/arch/arm/v7/opdefs/cmn_A8835.d delete mode 100644 src/arch/arm/v7/opdefs/cmn_A8836.d delete mode 100644 src/arch/arm/v7/opdefs/cmp_A8837.d delete mode 100644 src/arch/arm/v7/opdefs/cmp_A8838.d delete mode 100644 src/arch/arm/v7/opdefs/cmp_A8839.d delete mode 100644 src/arch/arm/v7/opdefs/dbg_A8842.d delete mode 100644 src/arch/arm/v7/opdefs/dmb_A8843.d delete mode 100644 src/arch/arm/v7/opdefs/dsb_A8844.d delete mode 100644 src/arch/arm/v7/opdefs/eor_A8846.d delete mode 100644 src/arch/arm/v7/opdefs/eor_A8847.d delete mode 100644 src/arch/arm/v7/opdefs/eor_A8848.d delete mode 100644 src/arch/arm/v7/opdefs/ldr_A8862.d delete mode 100644 src/arch/arm/v7/opdefs/ldr_A8863.d delete mode 100644 src/arch/arm/v7/opdefs/ldr_A8864.d delete mode 100644 src/arch/arm/v7/opdefs/ldr_A8865.d delete mode 100644 src/arch/arm/v7/opdefs/ldr_A8866.d delete mode 100644 src/arch/arm/v7/opdefs/ldrb_A8867.d delete mode 100644 src/arch/arm/v7/opdefs/ldrb_A8868.d delete mode 100644 src/arch/arm/v7/opdefs/ldrb_A8869.d delete mode 100644 src/arch/arm/v7/opdefs/ldrb_A8870.d delete mode 100644 src/arch/arm/v7/opdefs/ldrbt_A8871.d delete mode 100644 src/arch/arm/v7/opdefs/ldrd_A8872.d delete mode 100644 src/arch/arm/v7/opdefs/ldrd_A8873.d delete mode 100644 src/arch/arm/v7/opdefs/ldrd_A8874.d delete mode 100644 src/arch/arm/v7/opdefs/ldrex_A8875.d delete mode 100644 src/arch/arm/v7/opdefs/ldrexb_A8876.d delete mode 100644 src/arch/arm/v7/opdefs/ldrexd_A8877.d delete mode 100644 src/arch/arm/v7/opdefs/ldrexh_A8878.d delete mode 100644 src/arch/arm/v7/opdefs/ldrh_A8879.d delete mode 100644 src/arch/arm/v7/opdefs/ldrh_A8880.d delete mode 100644 src/arch/arm/v7/opdefs/ldrh_A8881.d delete mode 100644 src/arch/arm/v7/opdefs/ldrh_A8882.d delete mode 100644 src/arch/arm/v7/opdefs/ldrht_A8883.d delete mode 100644 src/arch/arm/v7/opdefs/ldrsb_A8884.d delete mode 100644 src/arch/arm/v7/opdefs/ldrsb_A8885.d delete mode 100644 src/arch/arm/v7/opdefs/ldrsb_A8886.d delete mode 100644 src/arch/arm/v7/opdefs/ldrsbt_A8887.d delete mode 100644 src/arch/arm/v7/opdefs/ldrsh_A8888.d delete mode 100644 src/arch/arm/v7/opdefs/ldrsh_A8889.d delete mode 100644 src/arch/arm/v7/opdefs/ldrsh_A8890.d delete mode 100644 src/arch/arm/v7/opdefs/ldrsht_A8891.d delete mode 100644 src/arch/arm/v7/opdefs/ldrt_A8892.d delete mode 100644 src/arch/arm/v7/opdefs/lsl_A8894.d delete mode 100644 src/arch/arm/v7/opdefs/lsl_A8895.d delete mode 100644 src/arch/arm/v7/opdefs/lsr_A8896.d delete mode 100644 src/arch/arm/v7/opdefs/lsr_A8897.d delete mode 100644 src/arch/arm/v7/opdefs/mcr_A8898.d delete mode 100644 src/arch/arm/v7/opdefs/mcrr_A8899.d delete mode 100644 src/arch/arm/v7/opdefs/mla_A88100.d delete mode 100644 src/arch/arm/v7/opdefs/mls_A88101.d delete mode 100644 src/arch/arm/v7/opdefs/mov_A88102.d delete mode 100644 src/arch/arm/v7/opdefs/mov_A88103.d delete mode 100644 src/arch/arm/v7/opdefs/mov_A88104.d delete mode 100644 src/arch/arm/v7/opdefs/movt_A88106.d delete mode 100644 src/arch/arm/v7/opdefs/mrc_A88107.d delete mode 100644 src/arch/arm/v7/opdefs/mrrc_A88108.d delete mode 100644 src/arch/arm/v7/opdefs/mul_A88114.d delete mode 100644 src/arch/arm/v7/opdefs/mvn_A88115.d delete mode 100644 src/arch/arm/v7/opdefs/mvn_A88116.d delete mode 100644 src/arch/arm/v7/opdefs/mvn_A88117.d delete mode 100644 src/arch/arm/v7/opdefs/nop_A88119.d delete mode 100644 src/arch/arm/v7/opdefs/orn_A88120.d delete mode 100644 src/arch/arm/v7/opdefs/orn_A88121.d delete mode 100644 src/arch/arm/v7/opdefs/orr_A88122.d delete mode 100644 src/arch/arm/v7/opdefs/orr_A88123.d delete mode 100644 src/arch/arm/v7/opdefs/orr_A88124.d delete mode 100644 src/arch/arm/v7/opdefs/pop_A88131.d delete mode 100644 src/arch/arm/v7/opdefs/pop_A88132.d delete mode 100644 src/arch/arm/v7/opdefs/push_A88133.d delete mode 100644 src/arch/arm/v7/opdefs/qadd16_A88135.d delete mode 100644 src/arch/arm/v7/opdefs/qadd8_A88136.d delete mode 100644 src/arch/arm/v7/opdefs/qadd_A88134.d delete mode 100644 src/arch/arm/v7/opdefs/qasx_A88137.d delete mode 100644 src/arch/arm/v7/opdefs/qdadd_A88138.d delete mode 100644 src/arch/arm/v7/opdefs/qdsub_A88139.d delete mode 100644 src/arch/arm/v7/opdefs/qsax_A88140.d delete mode 100644 src/arch/arm/v7/opdefs/qsub16_A88142.d delete mode 100644 src/arch/arm/v7/opdefs/qsub8_A88143.d delete mode 100644 src/arch/arm/v7/opdefs/qsub_A88141.d delete mode 100644 src/arch/arm/v7/opdefs/rbit_A88144.d delete mode 100644 src/arch/arm/v7/opdefs/rev16_A88146.d delete mode 100644 src/arch/arm/v7/opdefs/rev_A88145.d delete mode 100644 src/arch/arm/v7/opdefs/revsh_A88147.d delete mode 100644 src/arch/arm/v7/opdefs/ror_A88149.d delete mode 100644 src/arch/arm/v7/opdefs/ror_A88150.d delete mode 100644 src/arch/arm/v7/opdefs/rrx_A88151.d delete mode 100644 src/arch/arm/v7/opdefs/rsb_A88152.d delete mode 100644 src/arch/arm/v7/opdefs/rsb_A88153.d delete mode 100644 src/arch/arm/v7/opdefs/rsb_A88154.d delete mode 100644 src/arch/arm/v7/opdefs/rsc_A88155.d delete mode 100644 src/arch/arm/v7/opdefs/rsc_A88156.d delete mode 100644 src/arch/arm/v7/opdefs/rsc_A88157.d delete mode 100644 src/arch/arm/v7/opdefs/sadd16_A88158.d delete mode 100644 src/arch/arm/v7/opdefs/sadd8_A88159.d delete mode 100644 src/arch/arm/v7/opdefs/sasx_A88160.d delete mode 100644 src/arch/arm/v7/opdefs/sbc_A88161.d delete mode 100644 src/arch/arm/v7/opdefs/sbc_A88162.d delete mode 100644 src/arch/arm/v7/opdefs/sbc_A88163.d delete mode 100644 src/arch/arm/v7/opdefs/sbfx_A88164.d delete mode 100644 src/arch/arm/v7/opdefs/sdiv_A88165.d delete mode 100644 src/arch/arm/v7/opdefs/sel_A88166.d delete mode 100644 src/arch/arm/v7/opdefs/setend_A88167.d delete mode 100644 src/arch/arm/v7/opdefs/sev_A88168.d delete mode 100644 src/arch/arm/v7/opdefs/shadd16_A88169.d delete mode 100644 src/arch/arm/v7/opdefs/shadd8_A88170.d delete mode 100644 src/arch/arm/v7/opdefs/shasx_A88171.d delete mode 100644 src/arch/arm/v7/opdefs/shsax_A88172.d delete mode 100644 src/arch/arm/v7/opdefs/shsub16_A88173.d delete mode 100644 src/arch/arm/v7/opdefs/shsub8_A88174.d delete mode 100644 src/arch/arm/v7/opdefs/smlad_A88177.d delete mode 100644 src/arch/arm/v7/opdefs/smlal_A88178.d delete mode 100644 src/arch/arm/v7/opdefs/smlald_A88180.d delete mode 100644 src/arch/arm/v7/opdefs/smlsd_A88182.d delete mode 100644 src/arch/arm/v7/opdefs/smlsld_A88183.d delete mode 100644 src/arch/arm/v7/opdefs/smmla_A88184.d delete mode 100644 src/arch/arm/v7/opdefs/smmls_A88185.d delete mode 100644 src/arch/arm/v7/opdefs/smmul_A88186.d delete mode 100644 src/arch/arm/v7/opdefs/smuad_A88187.d delete mode 100644 src/arch/arm/v7/opdefs/smull_A88189.d delete mode 100644 src/arch/arm/v7/opdefs/str_A88203.d delete mode 100644 src/arch/arm/v7/opdefs/str_A88204.d delete mode 100644 src/arch/arm/v7/opdefs/str_A88205.d delete mode 100644 src/arch/arm/v7/opdefs/strb_A88206.d delete mode 100644 src/arch/arm/v7/opdefs/strb_A88207.d delete mode 100644 src/arch/arm/v7/opdefs/strb_A88208.d delete mode 100644 src/arch/arm/v7/opdefs/strbt_A88209.d delete mode 100644 src/arch/arm/v7/opdefs/strd_A88210.d delete mode 100644 src/arch/arm/v7/opdefs/strd_A88211.d delete mode 100644 src/arch/arm/v7/opdefs/strex_A88212.d delete mode 100644 src/arch/arm/v7/opdefs/strexb_A88213.d delete mode 100644 src/arch/arm/v7/opdefs/strexd_A88214.d delete mode 100644 src/arch/arm/v7/opdefs/strexh_A88215.d delete mode 100644 src/arch/arm/v7/opdefs/strh_A88216.d delete mode 100644 src/arch/arm/v7/opdefs/strh_A88217.d delete mode 100644 src/arch/arm/v7/opdefs/strh_A88218.d delete mode 100644 src/arch/arm/v7/opdefs/strht_A88219.d delete mode 100644 src/arch/arm/v7/opdefs/strt_A88220.d delete mode 100644 src/arch/arm/v7/opdefs/sub_A88221.d delete mode 100644 src/arch/arm/v7/opdefs/sub_A88222.d delete mode 100644 src/arch/arm/v7/opdefs/sub_A88223.d delete mode 100644 src/arch/arm/v7/opdefs/sub_A88224.d delete mode 100644 src/arch/arm/v7/opdefs/sub_A88225.d delete mode 100644 src/arch/arm/v7/opdefs/sub_A88226.d delete mode 100644 src/arch/arm/v7/opdefs/subs_B9320.d delete mode 100644 src/arch/arm/v7/opdefs/svc_A88228.d delete mode 100644 src/arch/arm/v7/opdefs/swp_A88229.d delete mode 100644 src/arch/arm/v7/opdefs/teq_A88237.d delete mode 100644 src/arch/arm/v7/opdefs/teq_A88238.d delete mode 100644 src/arch/arm/v7/opdefs/teq_A88239.d delete mode 100644 src/arch/arm/v7/opdefs/tst_A88240.d delete mode 100644 src/arch/arm/v7/opdefs/tst_A88241.d delete mode 100644 src/arch/arm/v7/opdefs/tst_A88242.d delete mode 100644 src/arch/arm/v7/opdefs/uadd16_A88243.d delete mode 100644 src/arch/arm/v7/opdefs/uadd8_A88244.d delete mode 100644 src/arch/arm/v7/opdefs/uasx_A88245.d delete mode 100644 src/arch/arm/v7/opdefs/ubfx_A88246.d delete mode 100644 src/arch/arm/v7/opdefs/udf_A88247.d delete mode 100644 src/arch/arm/v7/opdefs/udiv_A88248.d delete mode 100644 src/arch/arm/v7/opdefs/uhadd16_A88249.d delete mode 100644 src/arch/arm/v7/opdefs/uhadd8_A88250.d delete mode 100644 src/arch/arm/v7/opdefs/uhasx_A88251.d delete mode 100644 src/arch/arm/v7/opdefs/uhsax_A88252.d delete mode 100644 src/arch/arm/v7/opdefs/uhsub16_A88253.d delete mode 100644 src/arch/arm/v7/opdefs/uhsub8_A88254.d delete mode 100644 src/arch/arm/v7/opdefs/umaal_A88255.d delete mode 100644 src/arch/arm/v7/opdefs/umlal_A88256.d delete mode 100644 src/arch/arm/v7/opdefs/umull_A88257.d delete mode 100644 src/arch/arm/v7/opdefs/uqadd16_A88258.d delete mode 100644 src/arch/arm/v7/opdefs/uqadd8_A88259.d delete mode 100644 src/arch/arm/v7/opdefs/uqasx_A88260.d delete mode 100644 src/arch/arm/v7/opdefs/uqsax_A88261.d delete mode 100644 src/arch/arm/v7/opdefs/uqsub16_A88262.d delete mode 100644 src/arch/arm/v7/opdefs/uqsub8_A88263.d delete mode 100644 src/arch/arm/v7/opdefs/usad8_A88264.d delete mode 100644 src/arch/arm/v7/opdefs/usada8_A88265.d delete mode 100644 src/arch/arm/v7/opdefs/usat16_A88267.d delete mode 100644 src/arch/arm/v7/opdefs/usat_A88266.d delete mode 100644 src/arch/arm/v7/opdefs/usax_A88268.d delete mode 100644 src/arch/arm/v7/opdefs/usub16_A88269.d delete mode 100644 src/arch/arm/v7/opdefs/usub8_A88270.d delete mode 100644 src/arch/arm/v7/opdefs/uxtab16_A88272.d delete mode 100644 src/arch/arm/v7/opdefs/uxtab_A88271.d delete mode 100644 src/arch/arm/v7/opdefs/uxtah_A88273.d delete mode 100644 src/arch/arm/v7/opdefs/uxtb16_A88275.d delete mode 100644 src/arch/arm/v7/opdefs/uxtb_A88274.d delete mode 100644 src/arch/arm/v7/opdefs/uxth_A88276.d delete mode 100644 src/arch/arm/v7/opdefs/wfi_A88425.d delete mode 100644 src/arch/arm/v7/opdefs/yield_A88426.d delete mode 100644 src/arch/arm/v7/operands/Makefile.am delete mode 100644 src/arch/arm/v7/operands/coproc.c delete mode 100644 src/arch/arm/v7/operands/coproc.h delete mode 100644 src/arch/arm/v7/operands/estate.c delete mode 100644 src/arch/arm/v7/operands/estate.h delete mode 100644 src/arch/arm/v7/operands/limitation.c delete mode 100644 src/arch/arm/v7/operands/limitation.h delete mode 100644 src/arch/arm/v7/operands/maccess.c delete mode 100644 src/arch/arm/v7/operands/maccess.h delete mode 100644 src/arch/arm/v7/operands/offset.c delete mode 100644 src/arch/arm/v7/operands/offset.h delete mode 100644 src/arch/arm/v7/operands/reglist.c delete mode 100644 src/arch/arm/v7/operands/reglist.h delete mode 100644 src/arch/arm/v7/operands/rotation.c delete mode 100644 src/arch/arm/v7/operands/rotation.h delete mode 100644 src/arch/arm/v7/operands/shift.c delete mode 100644 src/arch/arm/v7/operands/shift.h delete mode 100644 src/arch/arm/v7/post.c delete mode 100644 src/arch/arm/v7/post.h delete mode 100644 src/arch/arm/v7/processor.c delete mode 100644 src/arch/arm/v7/processor.h delete mode 100644 src/arch/arm/v7/pseudo.c delete mode 100644 src/arch/arm/v7/pseudo.h delete mode 100644 src/arch/arm/v7/register.c delete mode 100644 src/arch/arm/v7/register.h delete mode 100644 src/arch/arm/v7/simd.c delete mode 100644 src/arch/arm/v7/simd.h delete mode 100644 src/arch/arm/v7/thumb_16.c delete mode 100644 src/arch/arm/v7/thumb_16.h delete mode 100644 src/arch/arm/v7/thumb_32.c delete mode 100644 src/arch/arm/v7/thumb_32.h diff --git a/.gitignore b/.gitignore index c609e23..822478f 100644 --- a/.gitignore +++ b/.gitignore @@ -58,7 +58,7 @@ __pycache__ *.g .gen/ fmk.done -src/arch/arm/v7/opcodes/ +plugins/arm/v7/opcodes/ plugins/dalvik/opcodes/ # GLib diff --git a/ChangeLog b/ChangeLog index 07fc007..28ec9d5 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,333 @@ +17-12-02 Cyrille Bagard + + * .gitignore: + * autogen.sh: + * configure.ac: + * plugins/Makefile.am: + Update files and code. + + * plugins/arm/Makefile.am: + * plugins/arm/cond.h: + * plugins/arm/context-int.h: + * plugins/arm/context.c: + * plugins/arm/context.h: + * plugins/arm/core.c: + * plugins/arm/core.h: + * plugins/arm/instruction-int.h: + * plugins/arm/instruction.c: + * plugins/arm/instruction.h: + * plugins/arm/link.c: + * plugins/arm/link.h: + * plugins/arm/processor-int.h: + * plugins/arm/processor.c: + * plugins/arm/processor.h: + * plugins/arm/python/Makefile.am: + * plugins/arm/python/instruction.c: + * plugins/arm/python/instruction.h: + * plugins/arm/python/module.c: + * plugins/arm/python/module.h: + * plugins/arm/python/processor.c: + * plugins/arm/python/processor.h: + * plugins/arm/python/v7/Makefile.am: + * plugins/arm/python/v7/instruction.c: + * plugins/arm/python/v7/instruction.h: + * plugins/arm/python/v7/module.c: + * plugins/arm/python/v7/module.h: + * plugins/arm/python/v7/processor.c: + * plugins/arm/python/v7/processor.h: + * plugins/arm/register-int.h: + * plugins/arm/register.c: + * plugins/arm/register.h: + * plugins/arm/v7/Makefile.am: + * plugins/arm/v7/arm.c: + * plugins/arm/v7/arm.h: + * plugins/arm/v7/build_tmp_decl.sh: + * plugins/arm/v7/context.c: + * plugins/arm/v7/context.h: + * plugins/arm/v7/core.c: + * plugins/arm/v7/core.h: + * plugins/arm/v7/cregister.c: + * plugins/arm/v7/cregister.h: + * plugins/arm/v7/fetch.c: + * plugins/arm/v7/fetch.h: + * plugins/arm/v7/helpers.c: + * plugins/arm/v7/helpers.h: + * plugins/arm/v7/instruction.c: + * plugins/arm/v7/instruction.h: + * plugins/arm/v7/link.c: + * plugins/arm/v7/link.h: + * plugins/arm/v7/opcodes/Makefile.am: + * plugins/arm/v7/opcodes/opcodes_tmp_arm.h: + * plugins/arm/v7/opcodes/opcodes_tmp_simd.h: + * plugins/arm/v7/opcodes/opcodes_tmp_thumb_16.h: + * plugins/arm/v7/opcodes/opcodes_tmp_thumb_32.h: + * plugins/arm/v7/opdefs/Makefile.am: + * plugins/arm/v7/opdefs/adc_A881.d: + * plugins/arm/v7/opdefs/adc_A882.d: + * plugins/arm/v7/opdefs/adc_A883.d: + * plugins/arm/v7/opdefs/add_A8810.d: + * plugins/arm/v7/opdefs/add_A8811.d: + * plugins/arm/v7/opdefs/add_A884.d: + * plugins/arm/v7/opdefs/add_A885.d: + * plugins/arm/v7/opdefs/add_A886.d: + * plugins/arm/v7/opdefs/add_A887.d: + * plugins/arm/v7/opdefs/add_A888.d: + * plugins/arm/v7/opdefs/add_A889.d: + * plugins/arm/v7/opdefs/adr_A8812.d: + * plugins/arm/v7/opdefs/and_A8813.d: + * plugins/arm/v7/opdefs/and_A8814.d: + * plugins/arm/v7/opdefs/and_A8815.d: + * plugins/arm/v7/opdefs/asr_A8816.d: + * plugins/arm/v7/opdefs/asr_A8817.d: + * plugins/arm/v7/opdefs/b_A8818.d: + * plugins/arm/v7/opdefs/bfc_A8819.d: + * plugins/arm/v7/opdefs/bfi_A8820.d: + * plugins/arm/v7/opdefs/bic_A8821.d: + * plugins/arm/v7/opdefs/bic_A8822.d: + * plugins/arm/v7/opdefs/bic_A8823.d: + * plugins/arm/v7/opdefs/bkpt_A8824.d: + * plugins/arm/v7/opdefs/bl_A8825.d: + * plugins/arm/v7/opdefs/blx_A8826.d: + * plugins/arm/v7/opdefs/bx_A8827.d: + * plugins/arm/v7/opdefs/bxj_A8828.d: + * plugins/arm/v7/opdefs/cb_A8829.d: + * plugins/arm/v7/opdefs/cdp_A8830.d: + * plugins/arm/v7/opdefs/clrex_A8832.d: + * plugins/arm/v7/opdefs/clz_A8833.d: + * plugins/arm/v7/opdefs/cmn_A8834.d: + * plugins/arm/v7/opdefs/cmn_A8835.d: + * plugins/arm/v7/opdefs/cmn_A8836.d: + * plugins/arm/v7/opdefs/cmp_A8837.d: + * plugins/arm/v7/opdefs/cmp_A8838.d: + * plugins/arm/v7/opdefs/cmp_A8839.d: + * plugins/arm/v7/opdefs/dbg_A8842.d: + * plugins/arm/v7/opdefs/dmb_A8843.d: + * plugins/arm/v7/opdefs/dsb_A8844.d: + * plugins/arm/v7/opdefs/eor_A8846.d: + * plugins/arm/v7/opdefs/eor_A8847.d: + * plugins/arm/v7/opdefs/eor_A8848.d: + * plugins/arm/v7/opdefs/ldr_A8862.d: + * plugins/arm/v7/opdefs/ldr_A8863.d: + * plugins/arm/v7/opdefs/ldr_A8864.d: + * plugins/arm/v7/opdefs/ldr_A8865.d: + * plugins/arm/v7/opdefs/ldr_A8866.d: + * plugins/arm/v7/opdefs/ldrb_A8867.d: + * plugins/arm/v7/opdefs/ldrb_A8868.d: + * plugins/arm/v7/opdefs/ldrb_A8869.d: + * plugins/arm/v7/opdefs/ldrb_A8870.d: + * plugins/arm/v7/opdefs/ldrbt_A8871.d: + * plugins/arm/v7/opdefs/ldrd_A8872.d: + * plugins/arm/v7/opdefs/ldrd_A8873.d: + * plugins/arm/v7/opdefs/ldrd_A8874.d: + * plugins/arm/v7/opdefs/ldrex_A8875.d: + * plugins/arm/v7/opdefs/ldrexb_A8876.d: + * plugins/arm/v7/opdefs/ldrexd_A8877.d: + * plugins/arm/v7/opdefs/ldrexh_A8878.d: + * plugins/arm/v7/opdefs/ldrh_A8879.d: + * plugins/arm/v7/opdefs/ldrh_A8880.d: + * plugins/arm/v7/opdefs/ldrh_A8881.d: + * plugins/arm/v7/opdefs/ldrh_A8882.d: + * plugins/arm/v7/opdefs/ldrht_A8883.d: + * plugins/arm/v7/opdefs/ldrsb_A8884.d: + * plugins/arm/v7/opdefs/ldrsb_A8885.d: + * plugins/arm/v7/opdefs/ldrsb_A8886.d: + * plugins/arm/v7/opdefs/ldrsbt_A8887.d: + * plugins/arm/v7/opdefs/ldrsh_A8888.d: + * plugins/arm/v7/opdefs/ldrsh_A8889.d: + * plugins/arm/v7/opdefs/ldrsh_A8890.d: + * plugins/arm/v7/opdefs/ldrsht_A8891.d: + * plugins/arm/v7/opdefs/ldrt_A8892.d: + * plugins/arm/v7/opdefs/lsl_A8894.d: + * plugins/arm/v7/opdefs/lsl_A8895.d: + * plugins/arm/v7/opdefs/lsr_A8896.d: + * plugins/arm/v7/opdefs/lsr_A8897.d: + * plugins/arm/v7/opdefs/mcr_A8898.d: + * plugins/arm/v7/opdefs/mcrr_A8899.d: + * plugins/arm/v7/opdefs/mla_A88100.d: + * plugins/arm/v7/opdefs/mls_A88101.d: + * plugins/arm/v7/opdefs/mov_A88102.d: + * plugins/arm/v7/opdefs/mov_A88103.d: + * plugins/arm/v7/opdefs/mov_A88104.d: + * plugins/arm/v7/opdefs/movt_A88106.d: + * plugins/arm/v7/opdefs/mrc_A88107.d: + * plugins/arm/v7/opdefs/mrrc_A88108.d: + * plugins/arm/v7/opdefs/mul_A88114.d: + * plugins/arm/v7/opdefs/mvn_A88115.d: + * plugins/arm/v7/opdefs/mvn_A88116.d: + * plugins/arm/v7/opdefs/mvn_A88117.d: + * plugins/arm/v7/opdefs/nop_A88119.d: + * plugins/arm/v7/opdefs/orn_A88120.d: + * plugins/arm/v7/opdefs/orn_A88121.d: + * plugins/arm/v7/opdefs/orr_A88122.d: + * plugins/arm/v7/opdefs/orr_A88123.d: + * plugins/arm/v7/opdefs/orr_A88124.d: + * plugins/arm/v7/opdefs/pop_A88131.d: + * plugins/arm/v7/opdefs/pop_A88132.d: + * plugins/arm/v7/opdefs/push_A88133.d: + * plugins/arm/v7/opdefs/qadd16_A88135.d: + * plugins/arm/v7/opdefs/qadd8_A88136.d: + * plugins/arm/v7/opdefs/qadd_A88134.d: + * plugins/arm/v7/opdefs/qasx_A88137.d: + * plugins/arm/v7/opdefs/qdadd_A88138.d: + * plugins/arm/v7/opdefs/qdsub_A88139.d: + * plugins/arm/v7/opdefs/qsax_A88140.d: + * plugins/arm/v7/opdefs/qsub16_A88142.d: + * plugins/arm/v7/opdefs/qsub8_A88143.d: + * plugins/arm/v7/opdefs/qsub_A88141.d: + * plugins/arm/v7/opdefs/rbit_A88144.d: + * plugins/arm/v7/opdefs/rev16_A88146.d: + * plugins/arm/v7/opdefs/rev_A88145.d: + * plugins/arm/v7/opdefs/revsh_A88147.d: + * plugins/arm/v7/opdefs/ror_A88149.d: + * plugins/arm/v7/opdefs/ror_A88150.d: + * plugins/arm/v7/opdefs/rrx_A88151.d: + * plugins/arm/v7/opdefs/rsb_A88152.d: + * plugins/arm/v7/opdefs/rsb_A88153.d: + * plugins/arm/v7/opdefs/rsb_A88154.d: + * plugins/arm/v7/opdefs/rsc_A88155.d: + * plugins/arm/v7/opdefs/rsc_A88156.d: + * plugins/arm/v7/opdefs/rsc_A88157.d: + * plugins/arm/v7/opdefs/sadd16_A88158.d: + * plugins/arm/v7/opdefs/sadd8_A88159.d: + * plugins/arm/v7/opdefs/sasx_A88160.d: + * plugins/arm/v7/opdefs/sbc_A88161.d: + * plugins/arm/v7/opdefs/sbc_A88162.d: + * plugins/arm/v7/opdefs/sbc_A88163.d: + * plugins/arm/v7/opdefs/sbfx_A88164.d: + * plugins/arm/v7/opdefs/sdiv_A88165.d: + * plugins/arm/v7/opdefs/sel_A88166.d: + * plugins/arm/v7/opdefs/setend_A88167.d: + * plugins/arm/v7/opdefs/sev_A88168.d: + * plugins/arm/v7/opdefs/shadd16_A88169.d: + * plugins/arm/v7/opdefs/shadd8_A88170.d: + * plugins/arm/v7/opdefs/shasx_A88171.d: + * plugins/arm/v7/opdefs/shsax_A88172.d: + * plugins/arm/v7/opdefs/shsub16_A88173.d: + * plugins/arm/v7/opdefs/shsub8_A88174.d: + * plugins/arm/v7/opdefs/smlad_A88177.d: + * plugins/arm/v7/opdefs/smlal_A88178.d: + * plugins/arm/v7/opdefs/smlald_A88180.d: + * plugins/arm/v7/opdefs/smlsd_A88182.d: + * plugins/arm/v7/opdefs/smlsld_A88183.d: + * plugins/arm/v7/opdefs/smmla_A88184.d: + * plugins/arm/v7/opdefs/smmls_A88185.d: + * plugins/arm/v7/opdefs/smmul_A88186.d: + * plugins/arm/v7/opdefs/smuad_A88187.d: + * plugins/arm/v7/opdefs/smull_A88189.d: + * plugins/arm/v7/opdefs/str_A88203.d: + * plugins/arm/v7/opdefs/str_A88204.d: + * plugins/arm/v7/opdefs/str_A88205.d: + * plugins/arm/v7/opdefs/strb_A88206.d: + * plugins/arm/v7/opdefs/strb_A88207.d: + * plugins/arm/v7/opdefs/strb_A88208.d: + * plugins/arm/v7/opdefs/strbt_A88209.d: + * plugins/arm/v7/opdefs/strd_A88210.d: + * plugins/arm/v7/opdefs/strd_A88211.d: + * plugins/arm/v7/opdefs/strex_A88212.d: + * plugins/arm/v7/opdefs/strexb_A88213.d: + * plugins/arm/v7/opdefs/strexd_A88214.d: + * plugins/arm/v7/opdefs/strexh_A88215.d: + * plugins/arm/v7/opdefs/strh_A88216.d: + * plugins/arm/v7/opdefs/strh_A88217.d: + * plugins/arm/v7/opdefs/strh_A88218.d: + * plugins/arm/v7/opdefs/strht_A88219.d: + * plugins/arm/v7/opdefs/strt_A88220.d: + * plugins/arm/v7/opdefs/sub_A88221.d: + * plugins/arm/v7/opdefs/sub_A88222.d: + * plugins/arm/v7/opdefs/sub_A88223.d: + * plugins/arm/v7/opdefs/sub_A88224.d: + * plugins/arm/v7/opdefs/sub_A88225.d: + * plugins/arm/v7/opdefs/sub_A88226.d: + * plugins/arm/v7/opdefs/subs_B9320.d: + * plugins/arm/v7/opdefs/svc_A88228.d: + * plugins/arm/v7/opdefs/swp_A88229.d: + * plugins/arm/v7/opdefs/teq_A88237.d: + * plugins/arm/v7/opdefs/teq_A88238.d: + * plugins/arm/v7/opdefs/teq_A88239.d: + * plugins/arm/v7/opdefs/tst_A88240.d: + * plugins/arm/v7/opdefs/tst_A88241.d: + * plugins/arm/v7/opdefs/tst_A88242.d: + * plugins/arm/v7/opdefs/uadd16_A88243.d: + * plugins/arm/v7/opdefs/uadd8_A88244.d: + * plugins/arm/v7/opdefs/uasx_A88245.d: + * plugins/arm/v7/opdefs/ubfx_A88246.d: + * plugins/arm/v7/opdefs/udf_A88247.d: + * plugins/arm/v7/opdefs/udiv_A88248.d: + * plugins/arm/v7/opdefs/uhadd16_A88249.d: + * plugins/arm/v7/opdefs/uhadd8_A88250.d: + * plugins/arm/v7/opdefs/uhasx_A88251.d: + * plugins/arm/v7/opdefs/uhsax_A88252.d: + * plugins/arm/v7/opdefs/uhsub16_A88253.d: + * plugins/arm/v7/opdefs/uhsub8_A88254.d: + * plugins/arm/v7/opdefs/umaal_A88255.d: + * plugins/arm/v7/opdefs/umlal_A88256.d: + * plugins/arm/v7/opdefs/umull_A88257.d: + * plugins/arm/v7/opdefs/uqadd16_A88258.d: + * plugins/arm/v7/opdefs/uqadd8_A88259.d: + * plugins/arm/v7/opdefs/uqasx_A88260.d: + * plugins/arm/v7/opdefs/uqsax_A88261.d: + * plugins/arm/v7/opdefs/uqsub16_A88262.d: + * plugins/arm/v7/opdefs/uqsub8_A88263.d: + * plugins/arm/v7/opdefs/usad8_A88264.d: + * plugins/arm/v7/opdefs/usada8_A88265.d: + * plugins/arm/v7/opdefs/usat16_A88267.d: + * plugins/arm/v7/opdefs/usat_A88266.d: + * plugins/arm/v7/opdefs/usax_A88268.d: + * plugins/arm/v7/opdefs/usub16_A88269.d: + * plugins/arm/v7/opdefs/usub8_A88270.d: + * plugins/arm/v7/opdefs/uxtab16_A88272.d: + * plugins/arm/v7/opdefs/uxtab_A88271.d: + * plugins/arm/v7/opdefs/uxtah_A88273.d: + * plugins/arm/v7/opdefs/uxtb16_A88275.d: + * plugins/arm/v7/opdefs/uxtb_A88274.d: + * plugins/arm/v7/opdefs/uxth_A88276.d: + * plugins/arm/v7/opdefs/wfi_A88425.d: + * plugins/arm/v7/opdefs/yield_A88426.d: + * plugins/arm/v7/operands/Makefile.am: + * plugins/arm/v7/operands/coproc.c: + * plugins/arm/v7/operands/coproc.h: + * plugins/arm/v7/operands/estate.c: + * plugins/arm/v7/operands/estate.h: + * plugins/arm/v7/operands/limitation.c: + * plugins/arm/v7/operands/limitation.h: + * plugins/arm/v7/operands/maccess.c: + * plugins/arm/v7/operands/maccess.h: + * plugins/arm/v7/operands/offset.c: + * plugins/arm/v7/operands/offset.h: + * plugins/arm/v7/operands/reglist.c: + * plugins/arm/v7/operands/reglist.h: + * plugins/arm/v7/operands/rotation.c: + * plugins/arm/v7/operands/rotation.h: + * plugins/arm/v7/operands/shift.c: + * plugins/arm/v7/operands/shift.h: + * plugins/arm/v7/post.c: + * plugins/arm/v7/post.h: + * plugins/arm/v7/processor.c: + * plugins/arm/v7/processor.h: + * plugins/arm/v7/pseudo.c: + * plugins/arm/v7/pseudo.h: + * plugins/arm/v7/register.c: + * plugins/arm/v7/register.h: + * plugins/arm/v7/simd.c: + * plugins/arm/v7/simd.h: + * plugins/arm/v7/thumb_16.c: + * plugins/arm/v7/thumb_16.h: + * plugins/arm/v7/thumb_32.c: + * plugins/arm/v7/thumb_32.h: + Moved entries: create a plugin for the ARM support. + + * plugins/pychrysa/arch/Makefile.am: + * plugins/pychrysa/arch/module.c: + * plugins/ropgadgets/helper_arm.c: + * plugins/ropgadgets/plugin.c: + * src/arch/Makefile.am: + * src/arch/arm/Makefile.am: + * src/core/processors.c: + Update files and code. + + * src/plugins/plugin.c: + Fix a bug in the dependency tracking. + 17-11-30 Cyrille Bagard * plugins/dex/python/format.c: diff --git a/autogen.sh b/autogen.sh index 68fbb58..01eadf0 100755 --- a/autogen.sh +++ b/autogen.sh @@ -18,7 +18,7 @@ cp /usr/share/gettext/gettext.h . echo "timestamp" > stamp-h.in # As some Makefiles expect an external fragment built dynamically, ensure these files exist -touch src/arch/arm/v7/opcodes/gencode.mk +touch plugins/arm/v7/opcodes/gencode.mk touch plugins/dalvik/opcodes/gencode.mk # Run the GNU tools diff --git a/configure.ac b/configure.ac index 7f572e8..902a5a0 100644 --- a/configure.ac +++ b/configure.ac @@ -319,6 +319,13 @@ AC_CONFIG_COMMANDS([marshal], [echo -e "VOID:UINT64\nVOID:INT,UINT64,INT\nVOID:O AC_CONFIG_FILES([Makefile pixmaps/Makefile plugins/Makefile + plugins/arm/Makefile + plugins/arm/python/Makefile + plugins/arm/python/v7/Makefile + plugins/arm/v7/Makefile + plugins/arm/v7/opdefs/Makefile + plugins/arm/v7/opcodes/Makefile + plugins/arm/v7/operands/Makefile plugins/dalvik/Makefile plugins/dalvik/opdefs/Makefile plugins/dalvik/opcodes/Makefile @@ -338,8 +345,6 @@ AC_CONFIG_FILES([Makefile plugins/pychrysa/analysis/db/Makefile plugins/pychrysa/analysis/db/items/Makefile plugins/pychrysa/arch/Makefile - plugins/pychrysa/arch/arm/Makefile - plugins/pychrysa/arch/arm/v7/Makefile plugins/pychrysa/common/Makefile plugins/pychrysa/core/Makefile plugins/pychrysa/debug/Makefile @@ -367,11 +372,6 @@ AC_CONFIG_FILES([Makefile src/analysis/human/asm/Makefile src/analysis/types/Makefile src/arch/Makefile - src/arch/arm/Makefile - src/arch/arm/v7/Makefile - src/arch/arm/v7/opdefs/Makefile - src/arch/arm/v7/opcodes/Makefile - src/arch/arm/v7/operands/Makefile src/common/Makefile src/core/Makefile src/debug/Makefile diff --git a/plugins/Makefile.am b/plugins/Makefile.am index 1070742..9f26d8f 100644 --- a/plugins/Makefile.am +++ b/plugins/Makefile.am @@ -4,4 +4,4 @@ if HAVE_PYTHON3_CONFIG endif # androhelpers -SUBDIRS = dalvik devdbg dex elf fmtp libcsem mobicore $(PYTHON3_SUBDIRS) readdex readelf readmc ropgadgets +SUBDIRS = arm dalvik devdbg dex elf fmtp libcsem mobicore $(PYTHON3_SUBDIRS) readdex readelf readmc ropgadgets diff --git a/plugins/arm/Makefile.am b/plugins/arm/Makefile.am new file mode 100644 index 0000000..3e691f4 --- /dev/null +++ b/plugins/arm/Makefile.am @@ -0,0 +1,32 @@ + +lib_LTLIBRARIES = libarm.la + +libarm_la_SOURCES = \ + cond.h \ + context-int.h \ + context.h context.c \ + core.h core.c \ + instruction-int.h \ + instruction.h instruction.c \ + link.h link.c \ + processor-int.h \ + processor.h processor.c \ + register-int.h \ + register.h register.c + +libarm_la_LIBADD = \ + python/libarmpython.la \ + v7/libarmv7.la + +libarm_la_CFLAGS = $(AM_CFLAGS) + +libarm_la_LDFLAGS = \ + $(LIBPYTHON_LIBS) $(LIBPYGOBJECT_LIBS) + + +AM_CPPFLAGS = $(LIBGTK_CFLAGS) $(LIBPYTHON_CFLAGS) $(LIBPYGOBJECT_CFLAGS) $(LIBXML_CFLAGS) -I$(top_srcdir)/src + +AM_CFLAGS = $(DEBUG_CFLAGS) $(WARNING_FLAGS) $(COMPLIANCE_FLAGS) + + +SUBDIRS = python v7 diff --git a/plugins/arm/cond.h b/plugins/arm/cond.h new file mode 100644 index 0000000..a4c6db0 --- /dev/null +++ b/plugins/arm/cond.h @@ -0,0 +1,64 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * encoding.h - prototypes pour le décodage des conditions d'exécution ARM + * + * Copyright (C) 2014-2017 Cyrille Bagard + * + * This file is part of Chrysalide. + * + * Chrysalide is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Chrysalide is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Foobar. If not, see . + */ + + +#ifndef _PLUGINS_ARM_ENCODING_H +#define _PLUGINS_ARM_ENCODING_H + + + +/** + * Les conditions d'exécutions sont partagées par les architectures ARM : + * + * ARMv7 Instruction Details + * § A8.3 Conditional execution + * + * ARMv8 Instruction Set Overview. + * § 4.3 Condition Codes. + * + */ + +/* Liste des conditions possibles */ +typedef enum _ArmCondCode +{ + ACC_EQ = 0x0, /* Equal */ + ACC_NE = 0x1, /* Not equal */ + ACC_HS = 0x2, /* Unsigned higher or same */ + ACC_LO = 0x3, /* Unsigned lower */ + ACC_MI = 0x4, /* Minus */ + ACC_PL = 0x5, /* Plus or zero */ + ACC_VS = 0x6, /* Overflow set */ + ACC_VC = 0x7, /* Overflow clear */ + ACC_HI = 0x8, /* Unsigned higher */ + ACC_LS = 0x9, /* Unsigned lower or same */ + ACC_GE = 0xa, /* Signed greater than or equal*/ + ACC_LT = 0xb, /* Signed less than */ + ACC_GT = 0xc, /* Signed greater than */ + ACC_LE = 0xd, /* Signed less than or equal */ + ACC_AL = 0xe, /* Always */ + ACC_NV = 0xf, /* (Never) */ + +} ArmCondCode; + + + +#endif /* _PLUGINS_ARM_ENCODING_H */ diff --git a/plugins/arm/context-int.h b/plugins/arm/context-int.h new file mode 100644 index 0000000..1ebe0a8 --- /dev/null +++ b/plugins/arm/context-int.h @@ -0,0 +1,75 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * context-int.h - prototypes internes pour le contexte lié à l'exécution d'un processeur + * + * Copyright (C) 2015-2017 Cyrille Bagard + * + * This file is part of Chrysalide. + * + * Chrysalide is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Chrysalide is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Foobar. If not, see . + */ + + +#ifndef _PLUGINS_ARM_CONTEXT_INT_H +#define _PLUGINS_ARM_CONTEXT_INT_H + + +#include + + +#include "context.h" + + + +/* Découpage de la zone de désassemblage */ +typedef struct _disass_arm_area +{ + virt_t start; /* Début de la zone */ + virt_t end; /* Fin de la zone */ + + unsigned int marker; /* Type de décodage associé */ + +} disass_arm_area; + + +/* Définition d'un contexte pour processeur ARM (instance) */ +struct _GArmContext +{ + GProcContext parent; /* A laisser en premier */ + + disass_arm_area *areas; /* Désassemblage découpé */ + size_t acount; /* Nombre de zones définies */ + GMutex areas_access; /* Accès aux découpes de zones */ + +}; + + +/* Définition d'un contexte pour processeur ARM (classe) */ +struct _GArmContextClass +{ + GProcContextClass parent; /* A laisser en premier */ + +}; + + + +/* Enregistre l'encodage (générique) utilisé à une adresse. */ +void _g_arm_context_define_encoding(GArmContext *, virt_t, unsigned int); + +/* Indique l'encodage (générique) utilisé à une adresse donnée. */ +unsigned int _g_arm_context_find_encoding(GArmContext *, virt_t); + + + +#endif /* _PLUGINS_ARM_CONTEXT_INT_H */ diff --git a/plugins/arm/context.c b/plugins/arm/context.c new file mode 100644 index 0000000..15c7bf5 --- /dev/null +++ b/plugins/arm/context.c @@ -0,0 +1,447 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * context.c - contexte lié à l'exécution d'un processeur + * + * Copyright (C) 2014-2017 Cyrille Bagard + * + * This file is part of Chrysalide. + * + * Chrysalide is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Chrysalide is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Foobar. If not, see . + */ + + +#include "context.h" + + +#include +#include +#include + + +#include "context-int.h" + + + +/* ------------------------ MANIPULATION GLOBALE DU CONTEXTE ------------------------ */ + + +/* Initialise la classe des contextes de processeur ARM. */ +static void g_arm_context_class_init(GArmContextClass *); + +/* Initialise une instance de contexte de processeur ARM. */ +static void g_arm_context_init(GArmContext *); + +/* Supprime toutes les références externes. */ +static void g_arm_context_dispose(GArmContext *); + +/* Procède à la libération totale de la mémoire. */ +static void g_arm_context_finalize(GArmContext *); + +/* Indique l'encodage (générique) utilisé à une adresse donnée. */ +static size_t find_disass_arm_area(disass_arm_area *, virt_t, size_t, size_t); + + + +/* ------------------------- CONTEXTE POUR LA DECOMPILATION ------------------------- */ + +#if 0 +/* Définition d'un contexte pour décompilation ARM (instance) */ +struct _GArmDContext +{ + GDecContext parent; /* A laisser en premier */ + + GDecInstruction *this; /* Représentation de la classe */ + GHashTable *args; /* Correspondance arg./pseudo */ + GHashTable *locals; /* Correspondance var./pseudo */ + size_t locals_count; /* Quantité de var. locales */ + +}; + + +/* Définition d'un contexte pour décompilation ARM (classe) */ +struct _GArmDContextClass +{ + GDecContextClass parent; /* A laisser en premier */ + +}; + + +/* Initialise la classe des contextes de décompilation ARM. */ +static void g_arm_dcontext_class_init(GArmDContextClass *); + +/* Initialise une instance de contexte de décompilation ARM. */ +static void g_arm_dcontext_init(GArmDContext *); + +/* Supprime toutes les références externes. */ +static void g_arm_dcontext_dispose(GArmDContext *); + +/* Procède à la libération totale de la mémoire. */ +static void g_arm_dcontext_finalize(GArmDContext *); +#endif + + + +/* ---------------------------------------------------------------------------------- */ +/* MANIPULATION GLOBALE DU CONTEXTE */ +/* ---------------------------------------------------------------------------------- */ + + +/* Indique le type définit par la GLib pour le contexte de processeur ARM. */ +G_DEFINE_TYPE(GArmContext, g_arm_context, G_TYPE_PROC_CONTEXT); + + +/****************************************************************************** +* * +* Paramètres : klass = classe à initialiser. * +* * +* Description : Initialise la classe des contextes de processeur ARM. * +* * +* Retour : - * +* * +* Remarques : - * +* * +******************************************************************************/ + +static void g_arm_context_class_init(GArmContextClass *klass) +{ + GObjectClass *object; /* Autre version de la classe */ + + object = G_OBJECT_CLASS(klass); + + object->dispose = (GObjectFinalizeFunc/* ! */)g_arm_context_dispose; + object->finalize = (GObjectFinalizeFunc)g_arm_context_finalize; + +} + + +/****************************************************************************** +* * +* Paramètres : ctx = instance à initialiser. * +* * +* Description : Initialise une instance de contexte de processeur ARM. * +* * +* Retour : - * +* * +* Remarques : - * +* * +******************************************************************************/ + +static void g_arm_context_init(GArmContext *ctx) +{ + g_mutex_init(&ctx->areas_access); + +} + + +/****************************************************************************** +* * +* Paramètres : ctx = instance d'objet GLib à traiter. * +* * +* Description : Supprime toutes les références externes. * +* * +* Retour : - * +* * +* Remarques : - * +* * +******************************************************************************/ + +static void g_arm_context_dispose(GArmContext *ctx) +{ + g_mutex_clear(&ctx->areas_access); + + G_OBJECT_CLASS(g_arm_context_parent_class)->dispose(G_OBJECT(ctx)); + +} + + +/****************************************************************************** +* * +* Paramètres : ctx = instance d'objet GLib à traiter. * +* * +* Description : Procède à la libération totale de la mémoire. * +* * +* Retour : - * +* * +* Remarques : - * +* * +******************************************************************************/ + +static void g_arm_context_finalize(GArmContext *ctx) +{ + G_OBJECT_CLASS(g_arm_context_parent_class)->finalize(G_OBJECT(ctx)); + +} + + +/****************************************************************************** +* * +* Paramètres : - * +* * +* Description : Crée un contexte pour l'exécution du processeur ARM. * +* * +* Retour : Contexte mis en place. * +* * +* Remarques : - * +* * +******************************************************************************/ + +GArmContext *g_arm_context_new(void) +{ + GArmContext *result; /* Structure à retourner */ + + result = g_object_new(G_TYPE_ARM_CONTEXT, NULL); + + return result; + +} + + +/****************************************************************************** +* * +* Paramètres : areas = ensemble des découpages du désassemblage. * +* addr = adresse d'un nouveau point de départ à retrouver. * +* first = indice de la première zone à considérer. * +* last = indice de la dernière zone à considérer. * +* * +* Description : Indique l'encodage (générique) utilisé à une adresse donnée. * +* * +* Retour : Marqueur à priori toujours valide. * +* * +* Remarques : - * +* * +******************************************************************************/ + +static size_t find_disass_arm_area(disass_arm_area *areas, virt_t addr, size_t first, size_t last) +{ + size_t index; /* Indice de cellule idéale */ + size_t mid; /* Division de l'espace */ + + if (first == last) + index = first; + + else + { + mid = first + (last - first + 1) / 2; + + if (areas[mid].start <= addr) + index = find_disass_arm_area(areas, addr, mid, last); + else + index = find_disass_arm_area(areas, addr, first, mid - 1); + + } + + assert(areas[index].start <= addr && addr <= areas[index].end); + + return index; + +} + + +/****************************************************************************** +* * +* Paramètres : ctx = contexte de désassemblage à compléter. * +* addr = adresse d'un nouveau point de départ à créer. * +* marker = forme générique d'un encodage à mémoriser. * +* * +* Description : Enregistre l'encodage (générique) utilisé à une adresse. * +* * +* Retour : - * +* * +* Remarques : - * +* * +******************************************************************************/ + +void _g_arm_context_define_encoding(GArmContext *ctx, virt_t addr, unsigned int marker) +{ + size_t selected; /* Zone associée à une adresse */ + + g_mutex_lock(&ctx->areas_access); + + selected = find_disass_arm_area(ctx->areas, addr, 0, ctx->acount - 1); + + //assert(ctx->areas[selected].start != addr || ctx->areas[selected].marker == marker); + + /* S'agit-il d'une redéfinition ? */ + if (ctx->areas[selected].start == addr) + ctx->areas[selected].marker = marker; + + /* Sinon on redivise... */ + else + { + ctx->areas = (disass_arm_area *)realloc(ctx->areas, ++ctx->acount * sizeof(disass_arm_area)); + + memmove(&ctx->areas[selected + 1], &ctx->areas[selected], + (ctx->acount - selected - 1) * sizeof(disass_arm_area)); + + ctx->areas[selected].start = ctx->areas[selected + 1].start; + ctx->areas[selected].end = addr - 1; + ctx->areas[selected].marker = ctx->areas[selected + 1].marker; + + ctx->areas[selected + 1].start = addr; + ctx->areas[selected + 1].marker = marker; + + } + + g_mutex_unlock(&ctx->areas_access); + +} + + +/****************************************************************************** +* * +* Paramètres : ctx = contexte de désassemblage à consulter. * +* addr = adresse d'un nouveau point de départ à retrouver. * +* * +* Description : Indique l'encodage (générique) utilisé à une adresse donnée. * +* * +* Retour : Marqueur à priori toujours valide. * +* * +* Remarques : - * +* * +******************************************************************************/ + +unsigned int _g_arm_context_find_encoding(GArmContext *ctx, virt_t addr) +{ + unsigned int result; /* Identifiant à retourner */ + size_t selected; /* Zone associée à une adresse */ + + g_mutex_lock(&ctx->areas_access); + + selected = find_disass_arm_area(ctx->areas, addr, 0, ctx->acount - 1); + + result = ctx->areas[selected].marker; + + g_mutex_unlock(&ctx->areas_access); + + return result; + +} + + + + + + + +/* ---------------------------------------------------------------------------------- */ +/* CONTEXTE POUR LA DECOMPILATION */ +/* ---------------------------------------------------------------------------------- */ + +#if 0 +/* Indique le type définit par la GLib pour le contexte de décompilation ARM. */ +G_DEFINE_TYPE(GArmDContext, g_arm_dcontext, G_TYPE_DEC_CONTEXT); + + +/****************************************************************************** +* * +* Paramètres : class = classe à initialiser. * +* * +* Description : Initialise la classe des contextes de décompilation ARM. * +* * +* Retour : - * +* * +* Remarques : - * +* * +******************************************************************************/ + +static void g_arm_dcontext_class_init(GArmDContextClass *class) +{ + GObjectClass *object; /* Autre version de la classe */ + + object = G_OBJECT_CLASS(class); + + object->dispose = (GObjectFinalizeFunc/* ! */)g_arm_dcontext_dispose; + object->finalize = (GObjectFinalizeFunc)g_arm_dcontext_finalize; + +} + + +/****************************************************************************** +* * +* Paramètres : ctx = instance à initialiser. * +* * +* Description : Initialise une instance de contexte de décompilation ARM. * +* * +* Retour : - * +* * +* Remarques : - * +* * +******************************************************************************/ + +static void g_arm_dcontext_init(GArmDContext *ctx) +{ + +} + + +/****************************************************************************** +* * +* Paramètres : ctx = instance d'objet GLib à traiter. * +* * +* Description : Supprime toutes les références externes. * +* * +* Retour : - * +* * +* Remarques : - * +* * +******************************************************************************/ + +static void g_arm_dcontext_dispose(GArmDContext *ctx) +{ + G_OBJECT_CLASS(g_arm_dcontext_parent_class)->dispose(G_OBJECT(ctx)); + +} + + +/****************************************************************************** +* * +* Paramètres : ctx = instance d'objet GLib à traiter. * +* * +* Description : Procède à la libération totale de la mémoire. * +* * +* Retour : - * +* * +* Remarques : - * +* * +******************************************************************************/ + +static void g_arm_dcontext_finalize(GArmDContext *ctx) +{ + G_OBJECT_CLASS(g_arm_dcontext_parent_class)->finalize(G_OBJECT(ctx)); + +} + + +/****************************************************************************** +* * +* Paramètres : - * +* * +* Description : Crée un contexte pour la décompilation ARM. * +* * +* Retour : Contexte mis en place. * +* * +* Remarques : - * +* * +******************************************************************************/ + +GArmDContext *g_arm_dcontext_new(void) +{ + GArmDContext *result; /* Structure à retourner */ + + result = g_object_new(G_TYPE_ARM_DCONTEXT, NULL); + + return result; + +} +#endif diff --git a/plugins/arm/context.h b/plugins/arm/context.h new file mode 100644 index 0000000..8adf7d8 --- /dev/null +++ b/plugins/arm/context.h @@ -0,0 +1,85 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * context.h - prototypes pour le contexte lié à l'exécution d'un processeur + * + * Copyright (C) 2014-2017 Cyrille Bagard + * + * This file is part of Chrysalide. + * + * Chrysalide is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Chrysalide is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Foobar. If not, see . + */ + + +#ifndef _PLUGINS_ARM_CONTEXT_H +#define _PLUGINS_ARM_CONTEXT_H + + +#include + + + +/* ------------------------ MANIPULATION GLOBALE DU CONTEXTE ------------------------ */ + + +#define G_TYPE_ARM_CONTEXT g_arm_context_get_type() +#define G_ARM_CONTEXT(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), g_arm_context_get_type(), GArmContext)) +#define G_IS_ARM_CONTEXT(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), g_arm_context_get_type())) +#define G_ARM_CONTEXT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), G_TYPE_ARM_CONTEXT, GGArmContextClass)) +#define G_IS_ARM_CONTEXT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), G_TYPE_ARM_CONTEXT)) +#define G_ARM_CONTEXT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), G_TYPE_ARM_CONTEXT, GGArmContextClass)) + + +/* Définition d'un contexte pour processeur ARM (instance) */ +typedef struct _GArmContext GArmContext; + +/* Définition d'un contexte pour processeur ARM (classe) */ +typedef struct _GArmContextClass GArmContextClass; + + +/* Indique le type définit par la GLib pour le contexte de processeur ARM. */ +GType g_arm_context_get_type(void); + +/* Crée un contexte pour l'exécution du processeur ARM. */ +GArmContext *g_arm_context_new(void); + + + +/* ------------------------- CONTEXTE POUR LA DECOMPILATION ------------------------- */ + +#if 0 +#define G_TYPE_ARM_DCONTEXT g_arm_dcontext_get_type() +#define G_ARM_DCONTEXT(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), g_arm_dcontext_get_type(), GArmDContext)) +#define G_IS_ARM_DCONTEXT(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), g_arm_dcontext_get_type())) +#define G_ARM_DCONTEXT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), G_TYPE_ARM_DCONTEXT, GGArmDContextClass)) +#define G_IS_ARM_DCONTEXT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), G_TYPE_ARM_DCONTEXT)) +#define G_ARM_DCONTEXT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), G_TYPE_ARM_DCONTEXT, GGArmDContextClass)) + + +/* Définition d'un contexte pour décompilation ARM (instance) */ +typedef struct _GArmDContext GArmDContext; + +/* Définition d'un contexte pour décompilation ARM (classe) */ +typedef struct _GArmDContextClass GArmDContextClass; + + +/* Indique le type définit par la GLib pour le contexte de décompilation ARM. */ +GType g_arm_dcontext_get_type(void); + +/* Crée un contexte pour la décompilation ARM. */ +GArmDContext *g_arm_dcontext_new(void); +#endif + + + +#endif /* _PLUGINS_ARM_CONTEXT_H */ diff --git a/plugins/arm/core.c b/plugins/arm/core.c new file mode 100644 index 0000000..6dd95d1 --- /dev/null +++ b/plugins/arm/core.c @@ -0,0 +1,83 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * core.c - intégration du support de l'architecture ARM + * + * Copyright (C) 2017 Cyrille Bagard + * + * This file is part of Chrysalide. + * + * Chrysalide is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Chrysalide is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Foobar. If not, see . + */ + + +#include "core.h" + + +#include +#include + + +#include "python/module.h" +#include "v7/core.h" +#include "v7/processor.h" + + + +DEFINE_CHRYSALIDE_PLUGIN("arm", "Add suport for the ARM architecture", "0.1.0", + RL("PyChrysalide"), AL(PGA_PLUGIN_INIT)); + + + +/****************************************************************************** +* * +* Paramètres : plugin = greffon à manipuler. * +* * +* Description : Prend acte du chargement du greffon. * +* * +* Retour : - * +* * +* Remarques : - * +* * +******************************************************************************/ + +G_MODULE_EXPORT bool chrysalide_plugin_init(GPluginModule *plugin) +{ + bool result; /* Bilan à retourner */ + + result = register_processor_type("armv7", "ARM v7", G_TYPE_ARMV7_PROCESSOR, + init_armv7_core, exit_armv7_core); + + if (result) + result = add_arch_arm_module_to_python_module(); + + return result; + +} + +/****************************************************************************** +* * +* Paramètres : plugin = greffon à manipuler. * +* * +* Description : Prend acte du déchargement du greffon. * +* * +* Retour : - * +* * +* Remarques : - * +* * +******************************************************************************/ + +G_MODULE_EXPORT void chrysalide_plugin_exit(GPluginModule *plugin) +{ + +} diff --git a/plugins/arm/core.h b/plugins/arm/core.h new file mode 100644 index 0000000..9461b5e --- /dev/null +++ b/plugins/arm/core.h @@ -0,0 +1,41 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * core.h - prototypes pour l'intégration du support de l'architecture ARM + * + * Copyright (C) 2017 Cyrille Bagard + * + * This file is part of Chrysalide. + * + * Chrysalide is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Chrysalide is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Foobar. If not, see . + */ + + +#ifndef _PLUGINS_ARM_CORE_H +#define _PLUGINS_ARM_CORE_H + + +#include +#include + + + +/* Prend acte du chargement du greffon. */ +G_MODULE_EXPORT bool chrysalide_plugin_init(GPluginModule *); + +/* Prend acte du déchargement du greffon. */ +G_MODULE_EXPORT void chrysalide_plugin_exit(GPluginModule *); + + + +#endif /* _PLUGINS_ARM_CORE_H */ diff --git a/plugins/arm/instruction-int.h b/plugins/arm/instruction-int.h new file mode 100644 index 0000000..87ddc60 --- /dev/null +++ b/plugins/arm/instruction-int.h @@ -0,0 +1,57 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * instruction-int.h - prototypes pour la définition générique interne des instructions ARM + * + * Copyright (C) 2013-2017 Cyrille Bagard + * + * This file is part of Chrysalide. + * + * Chrysalide is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Chrysalide is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Foobar. If not, see . + */ + + +#ifndef _PLUGINS_ARM_INSTRUCTION_INT_H +#define _PLUGINS_ARM_INSTRUCTION_INT_H + + +#include + + +#include "instruction.h" + + + +/* Définition générique d'une instruction d'architecture ARM (instance) */ +struct _GArmInstruction +{ + GArchInstruction parent; /* A laisser en premier */ + + const char *keyword; /* Nom clef de l'instruction */ + char *suffix; /* Complément au nom affiché */ + char *cached_keyword; /* Désignation complète */ + + ArmCondCode cond; /* Condition d'exécution */ + +}; + +/* Définition générique d'une instruction d'architecture ARM (classe) */ +struct _GArmInstructionClass +{ + GArchInstructionClass parent; /* A laisser en premier */ + +}; + + + +#endif /* _PLUGINS_ARM_INSTRUCTION_INT_H */ diff --git a/plugins/arm/instruction.c b/plugins/arm/instruction.c new file mode 100644 index 0000000..3a7af7f --- /dev/null +++ b/plugins/arm/instruction.c @@ -0,0 +1,274 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * instruction.c - gestion des instructions de la ARM + * + * Copyright (C) 2013-2017 Cyrille Bagard + * + * This file is part of Chrysalide. + * + * Chrysalide is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Chrysalide is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Foobar. If not, see . + */ + + +#include "instruction.h" + + +#include +#include + + +#include + + +#include "instruction-int.h" + + + +/* Initialise la classe des instructions ARM. */ +static void g_arm_instruction_class_init(GArmInstructionClass *); + +/* Initialise une instance de instruction ARM. */ +static void g_arm_instruction_init(GArmInstruction *); + +/* Supprime toutes les références externes. */ +static void g_arm_instruction_dispose(GArmInstruction *); + +/* Procède à la libération totale de la mémoire. */ +static void g_arm_instruction_finalize(GArmInstruction *); + +/* Fournit le nom humain de l'instruction manipulée. */ +static const char *g_arm_instruction_get_keyword(GArmInstruction *, AsmSyntax); + + + +/* Indique le type défini pour une représentation d'une instruction ARM. */ +G_DEFINE_TYPE(GArmInstruction, g_arm_instruction, G_TYPE_ARCH_INSTRUCTION); + + +/****************************************************************************** +* * +* Paramètres : klass = classe à initialiser. * +* * +* Description : Initialise la classe des instructions ARM. * +* * +* Retour : - * +* * +* Remarques : - * +* * +******************************************************************************/ + +static void g_arm_instruction_class_init(GArmInstructionClass *klass) +{ + GObjectClass *object_class; /* Autre version de la classe */ + GArchInstructionClass *instr; /* Encore une autre vision... */ + + object_class = G_OBJECT_CLASS(klass); + instr = G_ARCH_INSTRUCTION_CLASS(klass); + + object_class->dispose = (GObjectFinalizeFunc/* ! */)g_arm_instruction_dispose; + object_class->finalize = (GObjectFinalizeFunc)g_arm_instruction_finalize; + + instr->get_keyword = (get_instruction_keyword_fc)g_arm_instruction_get_keyword; + +} + + +/****************************************************************************** +* * +* Paramètres : instr = instance à initialiser. * +* * +* Description : Initialise une instance d'instruction ARM. * +* * +* Retour : - * +* * +* Remarques : - * +* * +******************************************************************************/ + +static void g_arm_instruction_init(GArmInstruction *instr) +{ + instr->cond = ACC_AL; + +} + + +/****************************************************************************** +* * +* Paramètres : instr = instance d'objet GLib à traiter. * +* * +* Description : Supprime toutes les références externes. * +* * +* Retour : - * +* * +* Remarques : - * +* * +******************************************************************************/ + +static void g_arm_instruction_dispose(GArmInstruction *instr) +{ + G_OBJECT_CLASS(g_arm_instruction_parent_class)->dispose(G_OBJECT(instr)); + +} + + +/****************************************************************************** +* * +* Paramètres : instr = instance d'objet GLib à traiter. * +* * +* Description : Procède à la libération totale de la mémoire. * +* * +* Retour : - * +* * +* Remarques : - * +* * +******************************************************************************/ + +static void g_arm_instruction_finalize(GArmInstruction *instr) +{ + if (instr->suffix != NULL) + free(instr->suffix); + + if (instr->cached_keyword != NULL) + free(instr->cached_keyword); + + G_OBJECT_CLASS(g_arm_instruction_parent_class)->finalize(G_OBJECT(instr)); + +} + + +/****************************************************************************** +* * +* Paramètres : instr = instruction quelconque à modifier. * +* suffix = chaîne de caractères fournie en complément. * +* * +* Description : Etend la désignation d'un nom d'instruction. * +* * +* Retour : true. * +* * +* Remarques : - * +* * +******************************************************************************/ + +bool g_arm_instruction_extend_keyword(GArmInstruction *instr, const char *suffix) +{ + instr->suffix = stradd(instr->suffix, suffix); + + if (instr->cached_keyword != NULL) + { + free(instr->cached_keyword); + instr->cached_keyword = NULL; + } + + return true; + +} + + +/****************************************************************************** +* * +* Paramètres : instr = instruction d'assemblage à consulter. * +* syntax = type de représentation demandée. * +* * +* Description : Fournit le nom humain de l'instruction manipulée. * +* * +* Retour : Mot clef de bas niveau. * +* * +* Remarques : - * +* * +******************************************************************************/ + +static const char *g_arm_instruction_get_keyword(GArmInstruction *instr, AsmSyntax syntax) +{ + if (instr->cached_keyword == NULL) + { + instr->cached_keyword = strdup(instr->keyword); + + if (instr->suffix != NULL) + instr->cached_keyword = stradd(instr->cached_keyword, instr->suffix); + + } + + return instr->cached_keyword; + +} + + +/****************************************************************************** +* * +* Paramètres : instr = instruction ARM à mettre à jour. * +* cond = condition d'exécution de l'instruction. * +* * +* Description : Définit les conditions d'exécution d'une instruction ARM. * +* * +* Retour : Bilan de l'opération. * +* * +* Remarques : - * +* * +******************************************************************************/ + +bool g_arm_instruction_set_cond(GArmInstruction *instr, ArmCondCode cond) +{ + bool result; /* Bilan à retourner */ + const char *suffix; /* Eventuelle marque à ajouter */ + + instr->cond = cond; + + switch (cond) + { + case ACC_EQ: suffix = "eq"; break; + case ACC_NE: suffix = "ne"; break; + case ACC_HS: suffix = "hs"; break; + case ACC_LO: suffix = "lo"; break; + case ACC_MI: suffix = "mi"; break; + case ACC_PL: suffix = "pl"; break; + case ACC_VS: suffix = "vs"; break; + case ACC_VC: suffix = "vc"; break; + case ACC_HI: suffix = "hi"; break; + case ACC_LS: suffix = "ls"; break; + case ACC_GE: suffix = "ge"; break; + case ACC_LT: suffix = "lt"; break; + case ACC_GT: suffix = "gt"; break; + case ACC_LE: suffix = "le"; break; + case ACC_AL: suffix = NULL; break; + case ACC_NV: suffix = "nv"; break; + } + + if (suffix != NULL) + result = g_arm_instruction_extend_keyword(instr, suffix); + + else + result = true; + + return result; + +} + + +/****************************************************************************** +* * +* Paramètres : instr = instruction ARM à consulter. * +* * +* Description : Indique les conditions d'exécution d'une instruction ARM. * +* * +* Retour : Condition d'exécution de l'instruction. * +* * +* Remarques : - * +* * +******************************************************************************/ + +ArmCondCode g_arm_instruction_get_cond(const GArmInstruction *instr) +{ + return instr->cond; + +} diff --git a/plugins/arm/instruction.h b/plugins/arm/instruction.h new file mode 100644 index 0000000..cebb69c --- /dev/null +++ b/plugins/arm/instruction.h @@ -0,0 +1,69 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * instruction.h - prototypes pour la gestion des instructions ARM + * + * Copyright (C) 2013-2017 Cyrille Bagard + * + * This file is part of Chrysalide. + * + * Chrysalide is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Chrysalide is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Foobar. If not, see . + */ + + +#ifndef _PLUGINS_ARM_INSTRUCTION_H +#define _PLUGINS_ARM_INSTRUCTION_H + + +#include +#include +#include + + +#include + + +#include "cond.h" + + + +#define G_TYPE_ARM_INSTRUCTION g_arm_instruction_get_type() +#define G_ARM_INSTRUCTION(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), g_arm_instruction_get_type(), GArmInstruction)) +#define G_IS_ARM_INSTRUCTION(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), g_arm_instruction_get_type())) +#define G_ARM_INSTRUCTION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), G_TYPE_ARM_INSTRUCTION, GArmInstructionClass)) +#define G_IS_ARM_INSTRUCTION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), G_TYPE_ARM_INSTRUCTION)) +#define G_ARM_INSTRUCTION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), G_TYPE_ARM_INSTRUCTION, GArmInstructionClass)) + + +/* Définition d'une instruction d'architecture ARM (instance) */ +typedef struct _GArmInstruction GArmInstruction; + +/* Définition d'une instruction d'architecture ARM (classe) */ +typedef struct _GArmInstructionClass GArmInstructionClass; + + +/* Indique le type défini pour une représentation d'une instruction ARM. */ +GType g_arm_instruction_get_type(void); + +/* Etend la désignation d'un nom d'instruction. */ +bool g_arm_instruction_extend_keyword(GArmInstruction *, const char *); + +/* Définit les conditions d'exécution d'une instruction ARM. */ +bool g_arm_instruction_set_cond(GArmInstruction *, ArmCondCode); + +/* Indique les conditions d'exécution d'une instruction ARM. */ +ArmCondCode g_arm_instruction_get_cond(const GArmInstruction *); + + + +#endif /* _PLUGINS_ARM_INSTRUCTION_H */ diff --git a/plugins/arm/link.c b/plugins/arm/link.c new file mode 100644 index 0000000..c29a646 --- /dev/null +++ b/plugins/arm/link.c @@ -0,0 +1,67 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * link.c - édition des liens après la phase de désassemblage ARM + * + * Copyright (C) 2015-2017 Cyrille Bagard + * + * This file is part of Chrysalide. + * + * Chrysalide is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Chrysalide is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Foobar. If not, see . + */ + + +#include "link.h" + + +#include + + +#include "cond.h" +#include "instruction.h" + + + +/****************************************************************************** +* * +* Paramètres : instr = instruction ARM à traiter. * +* proc = représentation de l'architecture utilisée. * +* context = contexte associé à la phase de désassemblage. * +* format = acès aux données du binaire d'origine. * +* * +* Description : Etablit un lien conditionnel selon une instruction donnée. * +* * +* Retour : - * +* * +* Remarques : - * +* * +******************************************************************************/ + +void handle_arm_conditional_branch_as_link(GArchInstruction *instr, GArchProcessor *proc, GProcContext *context, GExeFormat *format) +{ + switch (g_arm_instruction_get_cond(G_ARM_INSTRUCTION(instr))) + { + case ACC_AL: + handle_jump_as_link(instr, proc, context, format); + break; + + case ACC_NV: + break; + + default: + handle_branch_if_true_as_link(instr, proc, context, format); + break; + + } + +} diff --git a/plugins/arm/link.h b/plugins/arm/link.h new file mode 100644 index 0000000..de74d8f --- /dev/null +++ b/plugins/arm/link.h @@ -0,0 +1,38 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * link.h - prototypes pour l'édition des liens après la phase de désassemblage ARM + * + * Copyright (C) 2015-2017 Cyrille Bagard + * + * This file is part of Chrysalide. + * + * Chrysalide is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Chrysalide is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Foobar. If not, see . + */ + + +#ifndef _PLUGINS_ARM_LINK_H +#define _PLUGINS_ARM_LINK_H + + +#include +#include + + + +/* Etablit un lien conditionnel selon une instruction donnée. */ +void handle_arm_conditional_branch_as_link(GArchInstruction *, GArchProcessor *, GProcContext *, GExeFormat *); + + + +#endif /* _PLUGINS_ARM_LINK_H */ diff --git a/plugins/arm/processor-int.h b/plugins/arm/processor-int.h new file mode 100644 index 0000000..032ba66 --- /dev/null +++ b/plugins/arm/processor-int.h @@ -0,0 +1,52 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * instruction-int.h - prototypes pour la définition générique interne des processeurs ARM + * + * Copyright (C) 2014-2017 Cyrille Bagard + * + * This file is part of Chrysalide. + * + * Chrysalide is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Chrysalide is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Foobar. If not, see . + */ + + +#ifndef _PLUGINS_ARM_PROCESSOR_INT_H +#define _PLUGINS_ARM_PROCESSOR_INT_H + + +#include + + +#include "processor.h" + + + +/* Définition du processeur ARM (instance) */ +struct _GArmProcessor +{ + GArchProcessor parent; /* Instance parente */ + +}; + + +/* Définition du processeur ARM (classe) */ +struct _GArmProcessorClass +{ + GArchProcessorClass parent; /* Classe parente */ + +}; + + + +#endif /* _PLUGINS_ARM_PROCESSOR_INT_H */ diff --git a/plugins/arm/processor.c b/plugins/arm/processor.c new file mode 100644 index 0000000..4906799 --- /dev/null +++ b/plugins/arm/processor.c @@ -0,0 +1,126 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * processor.c - manipulation du processeur ARM + * + * Copyright (C) 2010-2017 Cyrille Bagard + * + * This file is part of Chrysalide. + * + * Chrysalide is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Chrysalide is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Foobar. If not, see . + */ + + +#include "processor.h" + + +#include "processor-int.h" + + + +/* Initialise la classe des registres ARM. */ +static void g_arm_processor_class_init(GArmProcessorClass *); + +/* Initialise une instance de registre ARM. */ +static void g_arm_processor_init(GArmProcessor *); + +/* Supprime toutes les références externes. */ +static void g_arm_processor_dispose(GArmProcessor *); + +/* Procède à la libération totale de la mémoire. */ +static void g_arm_processor_finalize(GArmProcessor *); + + + +/* Indique le type défini par la GLib pour le processeur ARM. */ +G_DEFINE_TYPE(GArmProcessor, g_arm_processor, G_TYPE_ARCH_PROCESSOR); + + +/****************************************************************************** +* * +* Paramètres : klass = classe à initialiser. * +* * +* Description : Initialise la classe des processeurs ARM. * +* * +* Retour : - * +* * +* Remarques : - * +* * +******************************************************************************/ + +static void g_arm_processor_class_init(GArmProcessorClass *klass) +{ + GObjectClass *object_class; /* Autre version de la classe */ + + object_class = G_OBJECT_CLASS(klass); + + object_class->dispose = (GObjectFinalizeFunc/* ! */)g_arm_processor_dispose; + object_class->finalize = (GObjectFinalizeFunc)g_arm_processor_finalize; + +} + + +/****************************************************************************** +* * +* Paramètres : proc = instance à initialiser. * +* * +* Description : Initialise une instance de processeur ARM. * +* * +* Retour : - * +* * +* Remarques : - * +* * +******************************************************************************/ + +static void g_arm_processor_init(GArmProcessor *proc) +{ + +} + + +/****************************************************************************** +* * +* Paramètres : proc = instance d'objet GLib à traiter. * +* * +* Description : Supprime toutes les références externes. * +* * +* Retour : - * +* * +* Remarques : - * +* * +******************************************************************************/ + +static void g_arm_processor_dispose(GArmProcessor *proc) +{ + G_OBJECT_CLASS(g_arm_processor_parent_class)->dispose(G_OBJECT(proc)); + +} + + +/****************************************************************************** +* * +* Paramètres : proc = instance d'objet GLib à traiter. * +* * +* Description : Procède à la libération totale de la mémoire. * +* * +* Retour : - * +* * +* Remarques : - * +* * +******************************************************************************/ + +static void g_arm_processor_finalize(GArmProcessor *proc) +{ + G_OBJECT_CLASS(g_arm_processor_parent_class)->finalize(G_OBJECT(proc)); + +} diff --git a/plugins/arm/processor.h b/plugins/arm/processor.h new file mode 100644 index 0000000..bebbde4 --- /dev/null +++ b/plugins/arm/processor.h @@ -0,0 +1,53 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * processor.h - prototypes pour la manipulation du processeur ARM + * + * Copyright (C) 2010-2017 Cyrille Bagard + * + * This file is part of Chrysalide. + * + * Chrysalide is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Chrysalide is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Foobar. If not, see . + */ + + +#ifndef _PLUGINS_ARM_PROCESSOR_H +#define _PLUGINS_ARM_PROCESSOR_H + + +#include +#include + + + +#define G_TYPE_ARM_PROCESSOR g_arm_processor_get_type() +#define G_ARM_PROCESSOR(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), g_arm_processor_get_type(), GArmProcessor)) +#define G_IS_ARM_PROCESSOR(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), g_arm_processor_get_type())) +#define G_ARM_PROCESSOR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), G_TYPE_ARM_PROCESSOR, GArmProcessorClass)) +#define G_IS_ARM_PROCESSOR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), G_TYPE_ARM_PROCESSOR)) +#define G_ARM_PROCESSOR_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), G_TYPE_ARM_PROCESSOR, GArmProcessorClass)) + + +/* Définition du processeur ARM (instance) */ +typedef struct _GArmProcessor GArmProcessor; + +/* Définition du processeur ARM (classe) */ +typedef struct _GArmProcessorClass GArmProcessorClass; + + +/* Indique le type défini par la GLib pour le processeur ARM. */ +GType g_arm_processor_get_type(void); + + + +#endif /* _PLUGINS_ARM_PROCESSOR_H */ diff --git a/plugins/arm/python/Makefile.am b/plugins/arm/python/Makefile.am new file mode 100644 index 0000000..63bc7be --- /dev/null +++ b/plugins/arm/python/Makefile.am @@ -0,0 +1,20 @@ + +noinst_LTLIBRARIES = libarmpython.la + +libarmpython_la_SOURCES = \ + instruction.h instruction.c \ + module.h module.c \ + processor.h processor.c + +libarmpython_la_LIBADD = \ + v7/libarmpythonv7.la + +libarmpython_la_LDFLAGS = + + +AM_CPPFLAGS = $(LIBGTK_CFLAGS) $(LIBXML_CFLAGS) $(LIBPYTHON_CFLAGS) $(LIBPYGOBJECT_CFLAGS) \ + -I$(top_srcdir)/src + +AM_CFLAGS = $(DEBUG_CFLAGS) $(WARNING_FLAGS) $(COMPLIANCE_FLAGS) + +SUBDIRS = v7 diff --git a/plugins/arm/python/instruction.c b/plugins/arm/python/instruction.c new file mode 100644 index 0000000..bbcde50 --- /dev/null +++ b/plugins/arm/python/instruction.c @@ -0,0 +1,111 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * instruction.c - équivalent Python du fichier "arch/arm/instruction.c" + * + * Copyright (C) 2015-2017 Cyrille Bagard + * + * This file is part of Chrysalide. + * + * Chrysalide is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Chrysalide is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + + +#include "instruction.h" + + +#include + + +#include +#include + + +#include "../instruction.h" + + + +/****************************************************************************** +* * +* Paramètres : - * +* * +* Description : Fournit un accès à une définition de type à diffuser. * +* * +* Retour : Définition d'objet pour Python. * +* * +* Remarques : - * +* * +******************************************************************************/ + +PyTypeObject *get_python_arm_instruction_type(void) +{ + static PyMethodDef py_arm_instruction_methods[] = { + { NULL } + }; + + static PyGetSetDef py_arm_instruction_getseters[] = { + { NULL } + }; + + static PyTypeObject py_arm_instruction_type = { + + PyVarObject_HEAD_INIT(NULL, 0) + + .tp_name = "pychrysalide.arch.arm.ArmInstruction", + .tp_basicsize = sizeof(PyGObject), + + .tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, + + .tp_doc = "PyChrysalide instruction for an ARM architecture.", + + .tp_methods = py_arm_instruction_methods, + .tp_getset = py_arm_instruction_getseters, + + }; + + return &py_arm_instruction_type; + +} + + +/****************************************************************************** +* * +* Paramètres : module = module dont la définition est à compléter. * +* * +* Description : Prend en charge l'objet 'pychrysalide....arm.ArmInstruction'.* +* * +* Retour : Bilan de l'opération. * +* * +* Remarques : - * +* * +******************************************************************************/ + +bool register_python_arm_instruction(PyObject *module) +{ + PyTypeObject *py_arm_instruction_type; /* Type Python 'BinContent' */ + PyObject *dict; /* Dictionnaire du module */ + + py_arm_instruction_type = get_python_arm_instruction_type(); + + APPLY_ABSTRACT_FLAG(py_arm_instruction_type); + + dict = PyModule_GetDict(module); + + if (!register_class_for_pygobject(dict, G_TYPE_ARM_INSTRUCTION, + py_arm_instruction_type, get_python_arch_instruction_type())) + return false; + + return true; + +} diff --git a/plugins/arm/python/instruction.h b/plugins/arm/python/instruction.h new file mode 100644 index 0000000..fec82bb --- /dev/null +++ b/plugins/arm/python/instruction.h @@ -0,0 +1,42 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * instruction.h - prototypes pour l'équivalent Python du fichier "arch/arm/instruction.h" + * + * Copyright (C) 2015-2017 Cyrille Bagard + * + * This file is part of Chrysalide. + * + * Chrysalide is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Chrysalide is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + + +#ifndef _PLUGINS_ARM_PYTHON_INSTRUCTION_H +#define _PLUGINS_ARM_PYTHON_INSTRUCTION_H + + +#include +#include + + + +/* Fournit un accès à une définition de type à diffuser. */ +PyTypeObject *get_python_arm_instruction_type(void); + +/* Prend en charge l'objet 'pychrysalide.arch.arm.ArmInstruction'. */ +bool register_python_arm_instruction(PyObject *); + + + +#endif /* _PLUGINS_ARM_PYTHON_INSTRUCTION_H */ diff --git a/plugins/arm/python/module.c b/plugins/arm/python/module.c new file mode 100644 index 0000000..6d71afe --- /dev/null +++ b/plugins/arm/python/module.c @@ -0,0 +1,105 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * module.c - intégration du répertoire arm en tant que module + * + * Copyright (C) 2015-2017 Cyrille Bagard + * + * This file is part of Chrysalide. + * + * Chrysalide is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Chrysalide is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + + +#include "module.h" + + +#include + + +#include + + +#include "instruction.h" +#include "processor.h" +#include "v7/module.h" + + + +/****************************************************************************** +* * +* Paramètres : - * +* * +* Description : Ajoute le module 'arm' au module Python. * +* * +* Retour : - * +* * +* Remarques : - * +* * +******************************************************************************/ + +bool add_arch_arm_module_to_python_module(void) +{ + bool result; /* Bilan à retourner */ + PyObject *super; /* Module à compléter */ + PyObject *module; /* Sous-module mis en place */ + int ret; /* Bilan d'un appel */ + + static PyModuleDef py_chrysalide_arm_module = { + + .m_base = PyModuleDef_HEAD_INIT, + + .m_name = "pychrysalide.arch.arm", + .m_doc = "Python module for Chrysalide.arch.arm", + + .m_size = -1, + + }; + + result = false; + + super = get_access_to_python_module("pychrysalide.arch"); + + module = PyModule_Create(&py_chrysalide_arm_module); + if (module == NULL) return false; + + ret = PyState_AddModule(super, &py_chrysalide_arm_module); + if (ret != 0) goto aaamtpm_exit; + + ret = _PyImport_FixupBuiltin(module, "pychrysalide.arch.arm"); + if (ret != 0) goto aaamtpm_exit; + + Py_INCREF(module); + ret = PyModule_AddObject(super, "arm", module); + if (ret != 0) goto aaamtpm_exit; + + result = true; + + result &= register_python_arm_instruction(module); + result &= register_python_arm_processor(module); + + result &= add_arch_arm_v7_module_to_python_module(module); + + aaamtpm_exit: + + if (!result) + { + printf("something went wrong in %s...\n", __FUNCTION__); + /* ... */ + + } + + return result; + +} diff --git a/plugins/arm/python/module.h b/plugins/arm/python/module.h new file mode 100644 index 0000000..aeacd3d --- /dev/null +++ b/plugins/arm/python/module.h @@ -0,0 +1,38 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * module.h - prototypes pour l'intégration du répertoire arm en tant que module + * + * Copyright (C) 2015-2017 Cyrille Bagard + * + * This file is part of Chrysalide. + * + * Chrysalide is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Chrysalide is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + + +#ifndef _PLUGINS_ARM_PYTHON_MODULE_H +#define _PLUGINS_ARM_PYTHON_MODULE_H + + +#include + + + +/* Ajoute le module 'arm' au module Python. */ +bool add_arch_arm_module_to_python_module(void); + + + +#endif /* _PLUGINS_ARM_PYTHON_MODULE_H */ diff --git a/plugins/arm/python/processor.c b/plugins/arm/python/processor.c new file mode 100644 index 0000000..818809d --- /dev/null +++ b/plugins/arm/python/processor.c @@ -0,0 +1,108 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * processor.c - équivalent Python du fichier "arch/arm/processor.c" + * + * Copyright (C) 2015-2017 Cyrille Bagard + * + * This file is part of Chrysalide. + * + * Chrysalide is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Chrysalide is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + + +#include "processor.h" + + +#include + + +#include +#include + + +#include "../processor.h" + + + +/****************************************************************************** +* * +* Paramètres : - * +* * +* Description : Fournit un accès à une définition de type à diffuser. * +* * +* Retour : Définition d'objet pour Python. * +* * +* Remarques : - * +* * +******************************************************************************/ + +PyTypeObject *get_python_arm_processor_type(void) +{ + static PyMethodDef py_arm_processor_methods[] = { + { NULL } + }; + + static PyGetSetDef py_arm_processor_getseters[] = { + { NULL } + }; + + static PyTypeObject py_arm_processor_type = { + + PyVarObject_HEAD_INIT(NULL, 0) + + .tp_name = "pychrysalide.arch.arm.ArmProcessor", + .tp_basicsize = sizeof(PyGObject), + + .tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, + + .tp_doc = "PyChrysalide processor for an ARM architecture.", + + .tp_methods = py_arm_processor_methods, + .tp_getset = py_arm_processor_getseters, + + }; + + return &py_arm_processor_type; + +} + + +/****************************************************************************** +* * +* Paramètres : module = module dont la définition est à compléter. * +* * +* Description : Prend en charge l'objet 'pychrysalide.arch.arm.ArmProcessor'.* +* * +* Retour : Bilan de l'opération. * +* * +* Remarques : - * +* * +******************************************************************************/ + +bool register_python_arm_processor(PyObject *module) +{ + PyTypeObject *py_arm_processor_type; /* Type Python 'BinContent' */ + PyObject *dict; /* Dictionnaire du module */ + + py_arm_processor_type = get_python_arm_processor_type(); + + dict = PyModule_GetDict(module); + + if (!register_class_for_pygobject(dict, G_TYPE_ARM_PROCESSOR, py_arm_processor_type, get_python_arch_processor_type())) + return false; + + return true; + +} diff --git a/plugins/arm/python/processor.h b/plugins/arm/python/processor.h new file mode 100644 index 0000000..36512ff --- /dev/null +++ b/plugins/arm/python/processor.h @@ -0,0 +1,42 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * processor.h - prototypes pour l'équivalent Python du fichier "arch/arm/processor.h" + * + * Copyright (C) 2015-2017 Cyrille Bagard + * + * This file is part of Chrysalide. + * + * Chrysalide is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Chrysalide is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + + +#ifndef _PLUGINS_ARM_PYTHON_PROCESSOR_H +#define _PLUGINS_ARM_PYTHON_PROCESSOR_H + + +#include +#include + + + +/* Fournit un accès à une définition de type à diffuser. */ +PyTypeObject *get_python_arm_processor_type(void); + +/* Prend en charge l'objet 'pychrysalide.arch.arm.ArmProcessor'. */ +bool register_python_arm_processor(PyObject *); + + + +#endif /* _PLUGINS_ARM_PYTHON_PROCESSOR_H */ diff --git a/plugins/arm/python/v7/Makefile.am b/plugins/arm/python/v7/Makefile.am new file mode 100644 index 0000000..f4f6df4 --- /dev/null +++ b/plugins/arm/python/v7/Makefile.am @@ -0,0 +1,16 @@ + +noinst_LTLIBRARIES = libarmpythonv7.la + +libarmpythonv7_la_SOURCES = \ + instruction.h instruction.c \ + module.h module.c \ + processor.h processor.c + + +libarmpythonv7_la_LDFLAGS = + + +AM_CPPFLAGS = $(LIBGTK_CFLAGS) $(LIBXML_CFLAGS) $(LIBPYTHON_CFLAGS) $(LIBPYGOBJECT_CFLAGS) \ + -I$(top_srcdir)/src + +AM_CFLAGS = $(DEBUG_CFLAGS) $(WARNING_FLAGS) $(COMPLIANCE_FLAGS) diff --git a/plugins/arm/python/v7/instruction.c b/plugins/arm/python/v7/instruction.c new file mode 100644 index 0000000..25a49bb --- /dev/null +++ b/plugins/arm/python/v7/instruction.c @@ -0,0 +1,109 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * instruction.c - équivalent Python du fichier "arch/arm/v7/instruction.c" + * + * Copyright (C) 2015-2017 Cyrille Bagard + * + * This file is part of Chrysalide. + * + * Chrysalide is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Chrysalide is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + + +#include "instruction.h" + + +#include + + +#include + + +#include "../instruction.h" +#include "../../v7/instruction.h" + + + +/****************************************************************************** +* * +* Paramètres : - * +* * +* Description : Fournit un accès à une définition de type à diffuser. * +* * +* Retour : Définition d'objet pour Python. * +* * +* Remarques : - * +* * +******************************************************************************/ + +PyTypeObject *get_python_armv7_instruction_type(void) +{ + static PyMethodDef py_armv7_instruction_methods[] = { + { NULL } + }; + + static PyGetSetDef py_armv7_instruction_getseters[] = { + { NULL } + }; + + static PyTypeObject py_armv7_instruction_type = { + + PyVarObject_HEAD_INIT(NULL, 0) + + .tp_name = "pychrysalide.arch.arm.v7.ArmV7Instruction", + .tp_basicsize = sizeof(PyGObject), + + .tp_flags = Py_TPFLAGS_DEFAULT, + + .tp_doc = "PyChrysalide instruction for an ARMv7 architecture.", + + .tp_methods = py_armv7_instruction_methods, + .tp_getset = py_armv7_instruction_getseters, + + }; + + return &py_armv7_instruction_type; + +} + + +/****************************************************************************** +* * +* Paramètres : module = module dont la définition est à compléter. * +* * +* Description : Prend en charge l'objet 'pychrysalide....arm.ArmInstruction'.* +* * +* Retour : Bilan de l'opération. * +* * +* Remarques : - * +* * +******************************************************************************/ + +bool register_python_armv7_instruction(PyObject *module) +{ + PyTypeObject *py_armv7_instruction_type;/* Type Python 'BinContent' */ + PyObject *dict; /* Dictionnaire du module */ + + py_armv7_instruction_type = get_python_armv7_instruction_type(); + + dict = PyModule_GetDict(module); + + if (!register_class_for_pygobject(dict, G_TYPE_ARMV7_INSTRUCTION, + py_armv7_instruction_type, get_python_arm_instruction_type())) + return false; + + return true; + +} diff --git a/plugins/arm/python/v7/instruction.h b/plugins/arm/python/v7/instruction.h new file mode 100644 index 0000000..a1a04be --- /dev/null +++ b/plugins/arm/python/v7/instruction.h @@ -0,0 +1,42 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * instruction.h - prototypes pour l'équivalent Python du fichier "arch/arm/v7/instruction.h" + * + * Copyright (C) 2015-2017 Cyrille Bagard + * + * This file is part of Chrysalide. + * + * Chrysalide is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Chrysalide is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + + +#ifndef _PLUGINS_ARM_PYTHON_V7_INSTRUCTION_H +#define _PLUGINS_ARM_PYTHON_V7_INSTRUCTION_H + + +#include +#include + + + +/* Fournit un accès à une définition de type à diffuser. */ +PyTypeObject *get_python_armv7_instruction_type(void); + +/* Prend en charge l'objet 'pychrysalide.arch.arm.v7.ArmV7Instruction'. */ +bool register_python_armv7_instruction(PyObject *); + + + +#endif /* _PLUGINS_ARM_PYTHON_V7_INSTRUCTION_H */ diff --git a/plugins/arm/python/v7/module.c b/plugins/arm/python/v7/module.c new file mode 100644 index 0000000..9188ae4 --- /dev/null +++ b/plugins/arm/python/v7/module.c @@ -0,0 +1,93 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * module.c - intégration du répertoire v7 en tant que module + * + * Copyright (C) 2015-2017 Cyrille Bagard + * + * This file is part of Chrysalide. + * + * Chrysalide is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Chrysalide is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + + +#include "module.h" + + +#include "instruction.h" +#include "processor.h" + + + +/****************************************************************************** +* * +* Paramètres : module = module dont la définition est à compléter. * +* * +* Description : Ajoute le module 'arm' au module Python. * +* * +* Retour : - * +* * +* Remarques : - * +* * +******************************************************************************/ + +bool add_arch_arm_v7_module_to_python_module(PyObject *super) +{ + bool result; /* Bilan à retourner */ + PyObject *module; /* Sous-module mis en place */ + int ret; /* Bilan d'un appel */ + + static PyModuleDef py_chrysalide_v7_module = { + + .m_base = PyModuleDef_HEAD_INIT, + + .m_name = "pychrysalide.arch.arm.v7", + .m_doc = "Python module for Chrysalide.arch.arm.v7", + + .m_size = -1, + + }; + + result = false; + + module = PyModule_Create(&py_chrysalide_v7_module); + if (module == NULL) return false; + + ret = PyState_AddModule(super, &py_chrysalide_v7_module); + if (ret != 0) goto aaamtpm_exit; + + ret = _PyImport_FixupBuiltin(module, "pychrysalide.arch.arm.v7"); + if (ret != 0) goto aaamtpm_exit; + + Py_INCREF(module); + ret = PyModule_AddObject(super, "v7", module); + if (ret != 0) goto aaamtpm_exit; + + result = true; + + result &= register_python_armv7_instruction(module); + result &= register_python_armv7_processor(module); + + aaamtpm_exit: + + if (!result) + { + printf("something went wrong in %s...\n", __FUNCTION__); + /* ... */ + + } + + return result; + +} diff --git a/plugins/arm/python/v7/module.h b/plugins/arm/python/v7/module.h new file mode 100644 index 0000000..fc5ba8c --- /dev/null +++ b/plugins/arm/python/v7/module.h @@ -0,0 +1,39 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * module.h - prototypes pour l'intégration du répertoire v7 en tant que module + * + * Copyright (C) 2015-2017 Cyrille Bagard + * + * This file is part of Chrysalide. + * + * Chrysalide is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Chrysalide is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + + +#ifndef _PLUGINS_ARM_PYTHON_V7_MODULE_H +#define _PLUGINS_ARM_PYTHON_V7_MODULE_H + + +#include +#include + + + +/* Ajoute le module 'arm' au module Python. */ +bool add_arch_arm_v7_module_to_python_module(PyObject *); + + + +#endif /* _PLUGINS_ARM_PYTHON_V7_MODULE_H */ diff --git a/plugins/arm/python/v7/processor.c b/plugins/arm/python/v7/processor.c new file mode 100644 index 0000000..9a0911c --- /dev/null +++ b/plugins/arm/python/v7/processor.c @@ -0,0 +1,108 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * processor.c - équivalent Python du fichier "arch/arm/v7/processor.c" + * + * Copyright (C) 2015-2017 Cyrille Bagard + * + * This file is part of Chrysalide. + * + * Chrysalide is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Chrysalide is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + + +#include "processor.h" + + +#include + + +#include + + +#include "../processor.h" +#include "../../v7/processor.h" + + + +/****************************************************************************** +* * +* Paramètres : - * +* * +* Description : Fournit un accès à une définition de type à diffuser. * +* * +* Retour : Définition d'objet pour Python. * +* * +* Remarques : - * +* * +******************************************************************************/ + +PyTypeObject *get_python_armv7_processor_type(void) +{ + static PyMethodDef py_armv7_processor_methods[] = { + { NULL } + }; + + static PyGetSetDef py_armv7_processor_getseters[] = { + { NULL } + }; + + static PyTypeObject py_armv7_processor_type = { + + PyVarObject_HEAD_INIT(NULL, 0) + + .tp_name = "pychrysalide.arch.arm.v7.ArmV7Processor", + .tp_basicsize = sizeof(PyGObject), + + .tp_flags = Py_TPFLAGS_DEFAULT, + + .tp_doc = "PyChrysalide processor for an ARMv7 architecture.", + + .tp_methods = py_armv7_processor_methods, + .tp_getset = py_armv7_processor_getseters, + + }; + + return &py_armv7_processor_type; + +} + + +/****************************************************************************** +* * +* Paramètres : module = module dont la définition est à compléter. * +* * +* Description : Prend en charge l'objet 'pychrysalide.arch.arm.ArmProcessor'.* +* * +* Retour : Bilan de l'opération. * +* * +* Remarques : - * +* * +******************************************************************************/ + +bool register_python_armv7_processor(PyObject *module) +{ + PyTypeObject *py_armv7_processor_type; /* Type Python 'BinContent' */ + PyObject *dict; /* Dictionnaire du module */ + + py_armv7_processor_type = get_python_armv7_processor_type(); + + dict = PyModule_GetDict(module); + + if (!register_class_for_pygobject(dict, G_TYPE_ARMV7_PROCESSOR, py_armv7_processor_type, get_python_arm_processor_type())) + return false; + + return true; + +} diff --git a/plugins/arm/python/v7/processor.h b/plugins/arm/python/v7/processor.h new file mode 100644 index 0000000..3226abd --- /dev/null +++ b/plugins/arm/python/v7/processor.h @@ -0,0 +1,42 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * processor.h - prototypes pour l'équivalent Python du fichier "arch/arm/v7/processor.h" + * + * Copyright (C) 2015-2017 Cyrille Bagard + * + * This file is part of Chrysalide. + * + * Chrysalide is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Chrysalide is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + + +#ifndef _PLUGINS_ARM_PYTHON_V7_PROCESSOR_H +#define _PLUGINS_ARM_PYTHON_V7_PROCESSOR_H + + +#include +#include + + + +/* Fournit un accès à une définition de type à diffuser. */ +PyTypeObject *get_python_armv7_processor_type(void); + +/* Prend en charge l'objet 'pychrysalide.arch.arm.v7.ArmV7Processor'. */ +bool register_python_armv7_processor(PyObject *); + + + +#endif /* _PLUGINS_ARM_PYTHON_V7_PROCESSOR_H */ diff --git a/plugins/arm/register-int.h b/plugins/arm/register-int.h new file mode 100644 index 0000000..9032d0f --- /dev/null +++ b/plugins/arm/register-int.h @@ -0,0 +1,58 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * register-int.h - définitions internes pour la représentation d'un registre ARM + * + * Copyright (C) 2014-2017 Cyrille Bagard + * + * This file is part of Chrysalide. + * + * Chrysalide is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Chrysalide is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Foobar. If not, see . + */ + + +#ifndef _PLUGINS_ARM_REGISTER_INT_H +#define _PLUGINS_ARM_REGISTER_INT_H + + + +#include + + +#include "register.h" + + + +#define MAX_REGNAME_LEN 8 + + +/* Représentation d'un registre ARM (instance) */ +struct _GArmRegister +{ + GArchRegister parent; /* A laisser en premier */ + + uint8_t index; /* Indice du registre */ + +}; + + +/* Représentation d'un registre ARM (classe) */ +struct _GArmRegisterClass +{ + GArchRegisterClass parent; /* A laisser en premier */ + +}; + + + +#endif /* _PLUGINS_ARM_REGISTER_INT_H */ diff --git a/plugins/arm/register.c b/plugins/arm/register.c new file mode 100644 index 0000000..8e1d741 --- /dev/null +++ b/plugins/arm/register.c @@ -0,0 +1,202 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * registers.c - aides auxiliaires relatives aux registres ARM + * + * Copyright (C) 2014-2017 Cyrille Bagard + * + * This file is part of Chrysalide. + * + * Chrysalide is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Chrysalide is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Foobar. If not, see . + */ + + +#include "register.h" + + +#include + + +#include "register-int.h" + + + +/* Initialise la classe des registres ARM. */ +static void g_arm_register_class_init(GArmRegisterClass *); + +/* Initialise une instance de registre ARM. */ +static void g_arm_register_init(GArmRegister *); + +/* Supprime toutes les références externes. */ +static void g_arm_register_dispose(GArmRegister *); + +/* Procède à la libération totale de la mémoire. */ +static void g_arm_register_finalize(GArmRegister *); + +/* Produit une empreinte à partir d'un registre. */ +static guint g_arm_register_hash(const GArmRegister *); + +/* Compare un registre avec un autre. */ +static int g_arm_register_compare(const GArmRegister *, const GArmRegister *); + + + +/* Indique le type défini pour une représentation d'un registre ARM. */ +G_DEFINE_TYPE(GArmRegister, g_arm_register, G_TYPE_ARCH_REGISTER); + + +/****************************************************************************** +* * +* Paramètres : klass = classe à initialiser. * +* * +* Description : Initialise la classe des registres Arm. * +* * +* Retour : - * +* * +* Remarques : - * +* * +******************************************************************************/ + +static void g_arm_register_class_init(GArmRegisterClass *klass) +{ + GObjectClass *object_class; /* Autre version de la classe */ + GArchRegisterClass *register_class; /* Classe de haut niveau */ + + object_class = G_OBJECT_CLASS(klass); + register_class = G_ARCH_REGISTER_CLASS(klass); + + object_class->dispose = (GObjectFinalizeFunc/* ! */)g_arm_register_dispose; + object_class->finalize = (GObjectFinalizeFunc)g_arm_register_finalize; + + register_class->hash = (reg_hash_fc)g_arm_register_hash; + register_class->compare = (reg_compare_fc)g_arm_register_compare; + +} + + +/****************************************************************************** +* * +* Paramètres : reg = instance à initialiser. * +* * +* Description : Initialise une instance de registre ARM. * +* * +* Retour : - * +* * +* Remarques : - * +* * +******************************************************************************/ + +static void g_arm_register_init(GArmRegister *reg) +{ + +} + + +/****************************************************************************** +* * +* Paramètres : reg = instance d'objet GLib à traiter. * +* * +* Description : Supprime toutes les références externes. * +* * +* Retour : - * +* * +* Remarques : - * +* * +******************************************************************************/ + +static void g_arm_register_dispose(GArmRegister *reg) +{ + G_OBJECT_CLASS(g_arm_register_parent_class)->dispose(G_OBJECT(reg)); + +} + + +/****************************************************************************** +* * +* Paramètres : reg = instance d'objet GLib à traiter. * +* * +* Description : Procède à la libération totale de la mémoire. * +* * +* Retour : - * +* * +* Remarques : - * +* * +******************************************************************************/ + +static void g_arm_register_finalize(GArmRegister *reg) +{ + G_OBJECT_CLASS(g_arm_register_parent_class)->finalize(G_OBJECT(reg)); + +} + + +/****************************************************************************** +* * +* Paramètres : reg = registre à consulter. * +* * +* Description : Fournit l'indice d'un registre ARM. * +* * +* Retour : Inditifiant représentant le registre. * +* * +* Remarques : - * +* * +******************************************************************************/ + +uint8_t g_arm_register_get_index(const GArmRegister *reg) +{ + return reg->index; + +} + + +/****************************************************************************** +* * +* Paramètres : reg = opérande à consulter pour le calcul. * +* * +* Description : Produit une empreinte à partir d'un registre. * +* * +* Retour : Bilan de l'opération. * +* * +* Remarques : - * +* * +******************************************************************************/ + +static guint g_arm_register_hash(const GArmRegister *reg) +{ + return reg->index; + +} + + +/****************************************************************************** +* * +* Paramètres : a = premier opérande à consulter. * +* b = second opérande à consulter. * +* * +* Description : Compare un registre avec un autre. * +* * +* Retour : Bilan de la comparaison. * +* * +* Remarques : - * +* * +******************************************************************************/ + +static int g_arm_register_compare(const GArmRegister *a, const GArmRegister *b) +{ + int result; /* Bilan à retourner */ + + result = sort_unsigned_long(b->index, b->index); + + return result; + +} diff --git a/plugins/arm/register.h b/plugins/arm/register.h new file mode 100644 index 0000000..e9994a7 --- /dev/null +++ b/plugins/arm/register.h @@ -0,0 +1,56 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * registers.h - prototypes pour les aides auxiliaires relatives aux registres ARM + * + * Copyright (C) 2014-2017 Cyrille Bagard + * + * This file is part of Chrysalide. + * + * Chrysalide is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Chrysalide is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Foobar. If not, see . + */ + + +#ifndef _PLUGINS_ARM_REGISTER_H +#define _PLUGINS_ARM_REGISTER_H + + +#include +#include + + + +#define G_TYPE_ARM_REGISTER g_arm_register_get_type() +#define G_ARM_REGISTER(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), g_arm_register_get_type(), GArmRegister)) +#define G_IS_ARM_REGISTER(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), g_arm_register_get_type())) +#define G_ARM_REGISTER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), G_TYPE_ARM_REGISTER, GArmRegisterClass)) +#define G_IS_ARM_REGISTER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), G_TYPE_ARM_REGISTER)) +#define G_ARM_REGISTER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), G_TYPE_ARM_REGISTER, GArmRegisterClass)) + + +/* Représentation d'un registre ARM (instance) */ +typedef struct _GArmRegister GArmRegister; + +/* Représentation d'un registre ARM (classe) */ +typedef struct _GArmRegisterClass GArmRegisterClass; + + +/* Indique le type défini pour une représentation d'un registre ARM. */ +GType g_arm_register_get_type(void); + +/* Fournit l'indice d'un registre ARM. */ +uint8_t g_arm_register_get_index(const GArmRegister *); + + + +#endif /* _PLUGINS_ARM_REGISTER_H */ diff --git a/plugins/arm/v7/Makefile.am b/plugins/arm/v7/Makefile.am new file mode 100644 index 0000000..e2fc96c --- /dev/null +++ b/plugins/arm/v7/Makefile.am @@ -0,0 +1,33 @@ + +noinst_LTLIBRARIES = libarmv7.la + +libarmv7_la_SOURCES = \ + arm.h arm.c \ + context.h context.c \ + core.h core.c \ + cregister.h cregister.c \ + fetch.h fetch.c \ + helpers.h helpers.c \ + instruction.h instruction.c \ + link.h link.c \ + post.h post.c \ + processor.h processor.c \ + pseudo.h pseudo.c \ + register.h register.c \ + simd.h simd.c \ + thumb_16.h thumb_16.c \ + thumb_32.h thumb_32.c + +libarmv7_la_LIBADD = \ + opcodes/libarmv7opcodes.la \ + operands/libarmv7operands.la + +libarmv7_la_CFLAGS = $(AM_CFLAGS) + + +AM_CPPFLAGS = $(LIBGTK_CFLAGS) $(LIBXML_CFLAGS) -I$(top_srcdir)/src + +AM_CFLAGS = $(DEBUG_CFLAGS) $(WARNING_FLAGS) $(COMPLIANCE_FLAGS) + + +SUBDIRS = opdefs opcodes operands diff --git a/plugins/arm/v7/arm.c b/plugins/arm/v7/arm.c new file mode 100644 index 0000000..89a17b6 --- /dev/null +++ b/plugins/arm/v7/arm.c @@ -0,0 +1,2271 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * arm.c - désassemblage des instructions ARMv7 + * + * Copyright (C) 2014-2017 Cyrille Bagard + * + * This file is part of Chrysalide. + * + * Chrysalide is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Chrysalide is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Foobar. If not, see . + */ + + +#include "arm.h" + + +#include + + +#include +#include + + +#include "simd.h" +#include "opcodes/arm_opcodes.h" +#include "opcodes/opcodes_tmp_arm.h" + + + +/* Désassemble une instruction ARMv7 de données ou autre. */ +static GArchInstruction *process_armv7_arm_data_processing_and_miscellaneous_instructions(uint32_t); + +/* Désassemble une instruction ARMv7 liées au chapitre A5.2.1. */ +static GArchInstruction *process_armv7_arm_data_processing_register(uint32_t); + +/* Désassemble une instruction ARMv7 liées au chapitre A5.2.2. */ +static GArchInstruction *process_armv7_arm_data_processing_register_shifted_register(uint32_t); + +/* Désassemble une instruction ARMv7 liées au chapitre A5.2.3. */ +static GArchInstruction *process_armv7_arm_data_processing_immediate(uint32_t); + +/* Désassemble une instruction ARMv7 liées au chapitre A5.2.5. */ +static GArchInstruction *process_armv7_arm_multiply_and_multiply_accumulate(uint32_t); + +/* Désassemble une instruction ARMv7 liées au chapitre A5.2.6. */ +static GArchInstruction *process_armv7_arm_saturating_addition_and_subtraction(uint32_t); + +/* Désassemble une instruction ARMv7 liées au chapitre A5.2.7. */ +static GArchInstruction *process_armv7_arm_halfword_multiply_and_multiply_accumulate(uint32_t); + +/* Désassemble une instruction ARMv7 liées au chapitre A5.2.8. */ +static GArchInstruction *process_armv7_arm_extra_load_store_instructions(uint32_t); + +/* Désassemble une instruction ARMv7 liées au chapitre A5.2.9. */ +static GArchInstruction *process_armv7_arm_extra_load_store_instructions_unprivileged(uint32_t); + +/* Désassemble une instruction ARMv7 liées au chapitre A5.2.10. */ +static GArchInstruction *process_armv7_arm_synchronization_primitives(uint32_t); + +/* Désassemble une instruction ARMv7 liées au chapitre A5.2.11. */ +static GArchInstruction *process_armv7_arm_msr_immediate_and_hints(uint32_t); + +/* Désassemble une instruction ARMv7 liées au chapitre A5.2.12. */ +static GArchInstruction *process_armv7_arm_miscellaneous_instructions(uint32_t); + +/* Désassemble une instruction ARMv7 liées au chapitre A5.3. */ +static GArchInstruction *process_armv7_arm_load_store_word_and_unsigned_byte(uint32_t); + +/* Désassemble une instruction ARMv7 liées au chapitre A5.4. */ +static GArchInstruction *process_armv7_arm_media_instructions(uint32_t); + +/* Désassemble une instruction ARMv7 liées au chapitre A5.4.1. */ +static GArchInstruction *process_armv7_arm_parallel_addition_and_subtraction_signed(uint32_t); + +/* Désassemble une instruction ARMv7 liées au chapitre A5.4.2. */ +static GArchInstruction *process_armv7_arm_parallel_addition_and_subtraction_unsigned(uint32_t); + +/* Désassemble une instruction ARMv7 liées au chapitre A5.4.3. */ +static GArchInstruction *process_armv7_arm_packing_unpacking_saturation_and_reversal(uint32_t); + +/* Désassemble une instruction ARMv7 liées au chapitre A5.4.4. */ +static GArchInstruction *process_armv7_arm_signed_multiply_signed_and_unsigned_divide(uint32_t); + +/* Désassemble une instruction ARMv7 liées au chapitre A5.5. */ +static GArchInstruction *process_armv7_arm_branch_branch_with_link_and_block_data_transfer(uint32_t); + +/* Désassemble une instruction ARMv7 liées au chapitre A5.6. */ +static GArchInstruction *process_armv7_arm_coprocessor_instructions_and_supervisor_call(uint32_t); + +/* Désassemble une instruction ARMv7 liées au chapitre A5.7. */ +static GArchInstruction *process_armv7_arm_unconditional_instructions(uint32_t); + +/* Désassemble une instruction ARMv7 liées au chapitre A5.7.1. */ +static GArchInstruction *process_armv7_arm_memory_hints_advanced_simd_instructions_and_miscellaneous_instructions(uint32_t); + + + +/****************************************************************************** +* * +* Paramètres : raw = donnée brute de 32 bits à désassembler. * +* * +* Description : Désassemble une instruction ARMv7 liées au chapitre A5.1. * +* * +* Retour : Instruction mise en place ou NULL en cas d'échec. * +* * +* Remarques : - * +* * +******************************************************************************/ + +GArchInstruction *process_armv7_arm_instruction_set_encoding(uint32_t raw) +{ + GArchInstruction *result; /* Instruction à renvoyer */ + uint32_t cond; /* Champ 'cond' à retrouver */ + uint32_t op1; /* Champ 'op1' à retrouver */ + uint32_t op; /* Champ 'op' à retrouver */ + + /** + * Suit les directives de : + * § A5.1 ARM instruction set encoding + */ + + result = NULL; + + cond = (raw >> 28) & 0xf; + op1 = (raw >> 25) & 0x7; + op = (raw >> 4) & 0x1; + + if (cond != b1111) + { + if ((op1 & b110) == b000) + result = process_armv7_arm_data_processing_and_miscellaneous_instructions(raw); + + else if (op1 == b010) + result = process_armv7_arm_load_store_word_and_unsigned_byte(raw); + + else if (op1 == b011) + { + if (op == b0) + result = process_armv7_arm_load_store_word_and_unsigned_byte(raw); + + else/* if (op == b1)*/ + result = process_armv7_arm_media_instructions(raw); + + } + + else if ((op1 & b110) == b100) + result = process_armv7_arm_branch_branch_with_link_and_block_data_transfer(raw); + + else if ((op1 & b110) == b110) + result = process_armv7_arm_coprocessor_instructions_and_supervisor_call(raw); + + } + + else /* if (cond == b1111) */ + result = process_armv7_arm_unconditional_instructions(raw); + + return result; + +} + + +/****************************************************************************** +* * +* Paramètres : raw = donnée brute de 32 bits à désassembler. * +* * +* Description : Désassemble une instruction ARMv7 de données ou autre. * +* * +* Retour : Instruction mise en place ou NULL en cas d'échec. * +* * +* Remarques : - * +* * +******************************************************************************/ + +static GArchInstruction *process_armv7_arm_data_processing_and_miscellaneous_instructions(uint32_t raw) +{ + GArchInstruction *result; /* Instruction à retourner */ + uint32_t op; /* Champ 'op' à retrouver */ + uint32_t op1; /* Champ 'op1' à retrouver */ + uint32_t op2; /* Champ 'op2' à retrouver */ + + /** + * Suit les directives de : + * § A5.2 Data-processing and miscellaneous instructions + */ + + result = NULL; + + op = (raw >> 25) & 0x1; + op1 = (raw >> 20) & 0x1f; + op2 = (raw >> 4) & 0xf; + + if (op == b0) + { + if ((op1 & b11001) != b10000) + { + if ((op2 & b0001) == b0000) + result = process_armv7_arm_data_processing_register(raw); + + else if ((op2 & b1001) == b0001) + result = process_armv7_arm_data_processing_register_shifted_register(raw); + + if (result != NULL) goto padpami_found; + + } + + else /* if ((op1 & b11001) == b10000) */ + { + if ((op2 & b1000) == b0000) + result = process_armv7_arm_miscellaneous_instructions(raw); + + else if ((op2 & b1001) == b1000) + result = process_armv7_arm_halfword_multiply_and_multiply_accumulate(raw); + + if (result != NULL) goto padpami_found; + + } + + if ((op1 & b10000) == b00000) + { + if (op2 == b1001) + result = process_armv7_arm_multiply_and_multiply_accumulate(raw); + + if (result != NULL) goto padpami_found; + + } + + if ((op1 & b10000) == b10000) + { + if (op2 == b1001) + result = process_armv7_arm_synchronization_primitives(raw); + + if (result != NULL) goto padpami_found; + + } + + if ((op1 & b10010) != b00010) + { + if (op2 == b1011) + result = process_armv7_arm_extra_load_store_instructions(raw); + + else if ((op2 & b1101) == b1101) + result = process_armv7_arm_extra_load_store_instructions(raw); + + if (result != NULL) goto padpami_found; + + } + + else /* if ((op1 & b10010) != b00010) */ + { + if (op2 == b1011) + result = process_armv7_arm_extra_load_store_instructions_unprivileged(raw); + + else if ((op2 & b1101) == b1101) + result = process_armv7_arm_extra_load_store_instructions(raw); + + if (result != NULL) goto padpami_found; + + } + + } + + else + { + if ((op1 & b11001) != b10000) + result = process_armv7_arm_data_processing_immediate(raw); + + else if (op1 == b10000) + result = armv7_read_arm_instr_mov_immediate(raw); + + else if (op1 == b10100) + result = armv7_read_arm_instr_movt(raw); + + else if ((op1 & b11011) == b10010) + result = process_armv7_arm_msr_immediate_and_hints(raw); + + } + + padpami_found: + + return result; + +} + + +/****************************************************************************** +* * +* Paramètres : raw = donnée brute de 32 bits à désassembler. * +* * +* Description : Désassemble une instruction ARMv7 liées au chapitre A5.2.1. * +* * +* Retour : Instruction mise en place ou NULL en cas d'échec. * +* * +* Remarques : - * +* * +******************************************************************************/ + +static GArchInstruction *process_armv7_arm_data_processing_register(uint32_t raw) +{ + GArchInstruction *result; /* Instruction à retourner */ + uint32_t op; /* Champ 'op' à retrouver */ + uint32_t imm5; /* Champ 'imm5' à retrouver */ + uint32_t op2; /* Champ 'op2' à retrouver */ + + /** + * Suit les directives de : + * § A5.2.1 Data-processing (register) + */ + + if ((raw & 0x0e000010) != 0x00000000) return NULL; + + result = NULL; + + op = (raw >> 20) & 0x1f; + imm5 = (raw >> 7) & 0x1f; + op2 = (raw >> 5) & 0x3; + + if ((op & b11110) == b00000) + result = armv7_read_arm_instr_and_register(raw); + + else if ((op & b11110) == b00010) + result = armv7_read_arm_instr_eor_register(raw); + + else if ((op & b11110) == b00100) + result = armv7_read_arm_instr_sub_register(raw); + + else if ((op & b11110) == b00110) + result = armv7_read_arm_instr_rsb_register(raw); + + else if ((op & b11110) == b01000) + result = armv7_read_arm_instr_add_register_arm(raw); + + else if ((op & b11110) == b01010) + result = armv7_read_arm_instr_adc_register(raw); + + else if ((op & b11110) == b01100) + result = armv7_read_arm_instr_sbc_register(raw); + + else if ((op & b11110) == b01110) + result = armv7_read_arm_instr_rsc_register(raw); + + /* + else if ((op & b11001) == b10000) + result = process_armv7_arm_data_processing_and_miscellaneous_instructions(raw); + */ + + else if (op == b10001) + result = armv7_read_arm_instr_tst_register(raw); + + else if (op == b10011) + result = armv7_read_arm_instr_teq_register(raw); + + else if (op == b10101) + result = armv7_read_arm_instr_cmp_register(raw); + + else if (op == b10111) + result = armv7_read_arm_instr_cmn_register(raw); + + else if ((op & b11110) == b11000) + result = armv7_read_arm_instr_orr_register(raw); + + else if ((op & b11110) == b11010) + { + if (op2 == b00) + { + if (imm5 == b00000) + result = armv7_read_arm_instr_mov_register_arm(raw); + + else + result = armv7_read_arm_instr_lsl_immediate(raw); + + } + + else if (op2 == b01) + result = armv7_read_arm_instr_lsr_immediate(raw); + + else if (op2 == b10) + result = armv7_read_arm_instr_asr_immediate(raw); + + else if (op2 == b11) + { + if (imm5 == b00000) + result = armv7_read_arm_instr_rrx(raw); + + else + result = armv7_read_arm_instr_ror_immediate(raw); + + } + + } + + else if ((op & b11110) == b11100) + result = armv7_read_arm_instr_bic_register(raw); + + else if ((op & b11110) == b11110) + result = armv7_read_arm_instr_mvn_register(raw); + + return result; + +} + + +/****************************************************************************** +* * +* Paramètres : raw = donnée brute de 32 bits à désassembler. * +* * +* Description : Désassemble une instruction ARMv7 liées au chapitre A5.2.2. * +* * +* Retour : Instruction mise en place ou NULL en cas d'échec. * +* * +* Remarques : - * +* * +******************************************************************************/ + +static GArchInstruction *process_armv7_arm_data_processing_register_shifted_register(uint32_t raw) +{ + GArchInstruction *result; /* Instruction à retourner */ + uint32_t op1; /* Champ 'op1' à retrouver */ + uint32_t op2; /* Champ 'op2' à retrouver */ + + /** + * Suit les directives de : + * § A5.2.2 Data-processing (register-shifted register) + */ + + if ((raw & 0x0e000090) != 0x00000010) return NULL; + + result = NULL; + + op1 = (raw >> 20) & 0x1f; + op2 = (raw >> 5) & 0x3; + + if ((op1 & b11110) == b00000) + result = armv7_read_arm_instr_and_register_shifted_register(raw); + + else if ((op1 & b11110) == b00010) + result = armv7_read_arm_instr_eor_register_shifted_register(raw); + + else if ((op1 & b11110) == b00100) + result = armv7_read_arm_instr_sub_register_shifted_register(raw); + + else if ((op1 & b11110) == b00110) + result = armv7_read_arm_instr_rsb_register_shifted_register(raw); + + else if ((op1 & b11110) == b01000) + result = armv7_read_arm_instr_add_register_shifted_register(raw); + + else if ((op1 & b11110) == b01010) + result = armv7_read_arm_instr_adc_register_shifted_register(raw); + + else if ((op1 & b11110) == b01100) + result = armv7_read_arm_instr_sbc_register_shifted_register(raw); + + else if ((op1 & b11110) == b01110) + result = armv7_read_arm_instr_rsc_register_shifted_register(raw); + +#if 0 + else if ((op1 & b11001) == b10000) + /* See Data-processing and miscellaneous instructions on page A5-196 */ +#endif + + else if (op1 == b10001) + result = armv7_read_arm_instr_tst_register_shifted_register(raw); + + else if (op1 == b10011) + result = armv7_read_arm_instr_teq_register_shifted_register(raw); + + else if (op1 == b10101) + result = armv7_read_arm_instr_cmp_register_shifted_register(raw); + + else if (op1 == b10111) + result = armv7_read_arm_instr_cmn_register_shifted_register(raw); + + else if ((op1 & b11110) == b11000) + result = armv7_read_arm_instr_orr_register_shifted_register(raw); + + else if ((op1 & b11110) == b11010) + { + if (op2 == b00) + result = armv7_read_arm_instr_lsl_register(raw); + + else if (op2 == b01) + result = armv7_read_arm_instr_lsr_register(raw); + + else if (op2 == b10) + result = armv7_read_arm_instr_asr_register(raw); + + else if (op2 == b11) + result = armv7_read_arm_instr_ror_register(raw); + + } + + else if ((op1 & b11110) == b11100) + result = armv7_read_arm_instr_bic_register_shifted_register(raw); + + else if ((op1 & b11110) == b11110) + result = armv7_read_arm_instr_mvn_register_shifted_register(raw); + + return result; + +} + + +/****************************************************************************** +* * +* Paramètres : raw = donnée brute de 32 bits à désassembler. * +* * +* Description : Désassemble une instruction ARMv7 liées au chapitre A5.2.3. * +* * +* Retour : Instruction mise en place ou NULL en cas d'échec. * +* * +* Remarques : - * +* * +******************************************************************************/ + +static GArchInstruction *process_armv7_arm_data_processing_immediate(uint32_t raw) +{ + GArchInstruction *result; /* Instruction à retourner */ + uint32_t op; /* Champ 'op' à retrouver */ + uint32_t rn; /* Champ 'rn' à retrouver */ + + /** + * Suit les directives de : + * § A5.2.3 Data-processing (immediate) + */ + + if ((raw & 0x0e000000) != 0x02000000) return NULL; + + result = NULL; + + op = (raw >> 20) & 0x1f; + rn = (raw >> 16) & 0xf; + + if ((op & b11110) == b00000) + result = armv7_read_arm_instr_and_immediate(raw); + + else if ((op & b11110) == b00010) + result = armv7_read_arm_instr_eor_immediate(raw); + + else if ((op & b11110) == b00100) + { + if (rn == b1111) + result = armv7_read_arm_instr_adr(raw); + + else + result = armv7_read_arm_instr_sub_immediate_arm(raw); + + } + + else if ((op & b11110) == b00110) + result = armv7_read_arm_instr_rsb_immediate(raw); + + else if ((op & b11110) == b01000) + { + if (rn == b1111) + result = armv7_read_arm_instr_adr(raw); + + else + result = armv7_read_arm_instr_add_immediate_arm(raw); + + } + + else if ((op & b11110) == b01010) + result = armv7_read_arm_instr_adc_immediate(raw); + + else if ((op & b11110) == b01100) + result = armv7_read_arm_instr_sbc_immediate(raw); + + else if ((op & b11110) == b01110) + result = armv7_read_arm_instr_rsc_immediate(raw); + + /* + else if ((op & b11110) == b10000) + result = process_armv7_arm_data_processing_and_miscellaneous_instructions(raw); + */ + + else if (op == b10001) + result = armv7_read_arm_instr_tst_immediate(raw); + + else if (op == b10011) + result = armv7_read_arm_instr_teq_immediate(raw); + + else if (op == b10101) + result = armv7_read_arm_instr_cmp_immediate(raw); + + else if (op == b10111) + result = armv7_read_arm_instr_cmn_immediate(raw); + + else if ((op & b11110) == b11000) + result = armv7_read_arm_instr_orr_immediate(raw); + + else if ((op & b11110) == b11010) + result = armv7_read_arm_instr_mov_immediate(raw); + + else if ((op & b11110) == b11100) + result = armv7_read_arm_instr_bic_immediate(raw); + + else if ((op & b11110) == b11110) + result = armv7_read_arm_instr_mvn_immediate(raw); + + return result; + +} + + +/****************************************************************************** +* * +* Paramètres : raw = donnée brute de 32 bits à désassembler. * +* * +* Description : Désassemble une instruction ARMv7 liées au chapitre A5.2.5. * +* * +* Retour : Instruction mise en place ou NULL en cas d'échec. * +* * +* Remarques : - * +* * +******************************************************************************/ + +static GArchInstruction *process_armv7_arm_multiply_and_multiply_accumulate(uint32_t raw) +{ + GArchInstruction *result; /* Instruction à retourner */ + uint32_t op; /* Champ 'op' à retrouver */ + + /** + * Suit les directives de : + * § A5.2.5 Multiply and multiply accumulate + */ + + if ((raw & 0x0f0000f0) != 0x00000090) return NULL; + + result = NULL; + + op = (raw >> 20) & 0xf; + + if ((op & b1110) == b0000) + result = armv7_read_arm_instr_mul(raw); + + else if ((op & b1110) == b0010) + result = armv7_read_arm_instr_mla(raw); + + else if (op == b0100) + result = armv7_read_arm_instr_umaal(raw); + + else if (op == b0101) + result = NULL; /* Non défini */ + + else if (op == b0110) + result = armv7_read_arm_instr_mls(raw); + + else if (op == b0111) + result = NULL; /* Non défini */ + + else if ((op & b1110) == b1000) + result = armv7_read_arm_instr_umull(raw); + + else if ((op & b1110) == b1010) + result = armv7_read_arm_instr_umlal(raw); + + else if ((op & b1110) == b1100) + result = armv7_read_arm_instr_smull(raw); + + else if ((op & b1110) == b1110) + result = armv7_read_arm_instr_smlal(raw); + + return result; + +} + + +/****************************************************************************** +* * +* Paramètres : raw = donnée brute de 32 bits à désassembler. * +* * +* Description : Désassemble une instruction ARMv7 liées au chapitre A5.2.6. * +* * +* Retour : Instruction mise en place ou NULL en cas d'échec. * +* * +* Remarques : - * +* * +******************************************************************************/ + +static GArchInstruction *process_armv7_arm_saturating_addition_and_subtraction(uint32_t raw) +{ + GArchInstruction *result; /* Instruction à retourner */ + uint32_t op; /* Champ 'op' à retrouver */ + + /** + * Suit les directives de : + * § A5.2.6 Saturating addition and subtraction + */ + + if ((raw & 0x0f9000f0) != 0x01000050) return NULL; + + result = NULL; + + op = (raw >> 21) & 0x3; + + if (op == b00) + result = armv7_read_arm_instr_qadd(raw); + + else if (op == b01) + result = armv7_read_arm_instr_qsub(raw); + + else if (op == b10) + result = armv7_read_arm_instr_qdadd(raw); + + else if (op == b11) + result = armv7_read_arm_instr_qdsub(raw); + + return result; + +} + + +/****************************************************************************** +* * +* Paramètres : raw = donnée brute de 32 bits à désassembler. * +* * +* Description : Désassemble une instruction ARMv7 liées au chapitre A5.2.7. * +* * +* Retour : Instruction mise en place ou NULL en cas d'échec. * +* * +* Remarques : - * +* * +******************************************************************************/ + +static GArchInstruction *process_armv7_arm_halfword_multiply_and_multiply_accumulate(uint32_t raw) +{ + GArchInstruction *result; /* Instruction à retourner */ + uint32_t op1; /* Champ 'op1' à retrouver */ + uint32_t op; /* Champ 'op' à retrouver */ + + /** + * Suit les directives de : + * § A5.2.7 Halfword multiply and multiply accumulate + */ + + if ((raw & 0x0f900090) != 0x01000080) return NULL; + + result = NULL; + + op1 = (raw >> 21) & 0x3; + op = (raw >> 5) & 0x1; + + if (op1 == b00) + result = armv7_read_arm_instr_smlabb_smlabt_smlatb_smlatt(raw); + + else if (op1 == b01) + { + if (op == b0) + result = armv7_read_arm_instr_smlawb_smlawt(raw); + + else/* if (op == b1)*/ + result = armv7_read_arm_instr_smulwb_smulwt(raw); + + } + + else if (op1 == b10) + result = armv7_read_arm_instr_smlalbb_smlalbt_smlaltb_smlaltt(raw); + + else if (op1 == b11) + result = armv7_read_arm_instr_smulbb_smulbt_smultb_smultt(raw); + + return result; + +} + + +/****************************************************************************** +* * +* Paramètres : raw = donnée brute de 32 bits à désassembler. * +* * +* Description : Désassemble une instruction ARMv7 liées au chapitre A5.2.8. * +* * +* Retour : Instruction mise en place ou NULL en cas d'échec. * +* * +* Remarques : - * +* * +******************************************************************************/ + +static GArchInstruction *process_armv7_arm_extra_load_store_instructions(uint32_t raw) +{ + GArchInstruction *result; /* Instruction à retourner */ + uint32_t op1; /* Champ 'op1' à retrouver */ + uint32_t rn; /* Champ 'rn' à retrouver */ + uint32_t op2; /* Champ 'op2' à retrouver */ + + /** + * Suit les directives de : + * § A5.2.8 Extra load/store instructions + */ + + if ((raw & 0x0e000090) != 0x00000090) return NULL; + + result = NULL; + + op1 = (raw >> 20) & 0x1f; + rn = (raw >> 16) & 0xf; + op2 = (raw >> 5) & 0x3; + + if (op2 == b01) + { + if ((op1 & b00101) == b00000) + result = armv7_read_arm_instr_strh_register(raw); + + else if ((op1 & b00101) == b00001) + result = armv7_read_arm_instr_ldrh_register(raw); + + else if ((op1 & b00101) == b00100) + result = armv7_read_arm_instr_strh_immediate_arm(raw); + + else/* if ((op1 & b00101) == b00101)*/ + { + if (rn == b1111) + result = armv7_read_arm_instr_ldrh_literal(raw); + + else + result = armv7_read_arm_instr_ldrh_immediate_arm(raw); + + } + + } + + else if (op2 == b10) + { + if ((op1 & b00101) == b00000) + result = armv7_read_arm_instr_ldrd_register(raw); + + else if ((op1 & b00101) == b00001) + result = armv7_read_arm_instr_ldrsb_register(raw); + + else if ((op1 & b00101) == b00100) + { + if (rn == b1111) + result = armv7_read_arm_instr_ldrd_literal(raw); + + else + result = armv7_read_arm_instr_ldrd_immediate(raw); + + } + + else/* if ((op1 & b00101) == b00101)*/ + { + if (rn == b1111) + result = armv7_read_arm_instr_ldrsb_literal(raw); + + else + result = armv7_read_arm_instr_ldrsb_immediate(raw); + + } + + } + + else if (op2 == b11) + { + if ((op1 & b00101) == b00000) + result = armv7_read_arm_instr_strd_register(raw); + + else if ((op1 & b00101) == b00001) + result = armv7_read_arm_instr_ldrsh_register(raw); + + else if ((op1 & b00101) == b00100) + result = armv7_read_arm_instr_strd_immediate(raw); + + else/* if ((op1 & b00101) == b00101)*/ + { + if (rn == b1111) + result = armv7_read_arm_instr_ldrsh_literal(raw); + + else + result = armv7_read_arm_instr_ldrsh_immediate(raw); + + } + + } + + return result; + +} + + +/****************************************************************************** +* * +* Paramètres : raw = donnée brute de 32 bits à désassembler. * +* * +* Description : Désassemble une instruction ARMv7 liées au chapitre A5.2.9. * +* * +* Retour : Instruction mise en place ou NULL en cas d'échec. * +* * +* Remarques : - * +* * +******************************************************************************/ + +static GArchInstruction *process_armv7_arm_extra_load_store_instructions_unprivileged(uint32_t raw) +{ + GArchInstruction *result; /* Instruction à retourner */ + uint32_t op; /* Champ 'op' à retrouver */ + uint32_t op2; /* Champ 'op2' à retrouver */ + + /** + * Suit les directives de : + * § A5.2.9 Extra load/store instructions, unprivileged + */ + + if ((raw & 0x0f200090) != 0x00200090) return NULL; + + result = NULL; + + op = (raw >> 20) & 0x1; + op2 = (raw >> 5) & 0x3; + + if (op2 == b01) + { + if (op == b0) + result = armv7_read_arm_instr_strht(raw); + + else/* if (op == b1)*/ + result = armv7_read_arm_instr_ldrht(raw); + + } + + else if (op2 == b10) + { + if (op == b1) + result = armv7_read_arm_instr_ldrsbt(raw); + + } + + else if (op2 == b11) + { + if (op == b1) + result = armv7_read_arm_instr_ldrsht(raw); + + } + + return result; + +} + + +/****************************************************************************** +* * +* Paramètres : raw = donnée brute de 32 bits à désassembler. * +* * +* Description : Désassemble une instruction ARMv7 liées au chapitre A5.2.10. * +* * +* Retour : Instruction mise en place ou NULL en cas d'échec. * +* * +* Remarques : - * +* * +******************************************************************************/ + +static GArchInstruction *process_armv7_arm_synchronization_primitives(uint32_t raw) +{ + GArchInstruction *result; /* Instruction à retourner */ + uint32_t op; /* Champ 'op' à retrouver */ + + /** + * Suit les directives de : + * § A5.2.10 Synchronization primitives + */ + + if ((raw & 0x0f0000f0) != 0x01000090) return NULL; + + result = NULL; + + op = (raw >> 20) & 0xf; + + if ((op & b1011) == b0000) + result = armv7_read_arm_instr_swp_swpb(raw); + + else if (op == b1000) + result = armv7_read_arm_instr_strex(raw); + + else if (op == b1001) + result = armv7_read_arm_instr_ldrex(raw); + + else if (op == b1010) + result = armv7_read_arm_instr_strexd(raw); + + else if (op == b1011) + result = armv7_read_arm_instr_ldrexd(raw); + + else if (op == b1100) + result = armv7_read_arm_instr_strexb(raw); + + else if (op == b1101) + result = armv7_read_arm_instr_ldrexb(raw); + + else if (op == b1110) + result = armv7_read_arm_instr_strexh(raw); + + else if (op == b1111) + result = armv7_read_arm_instr_ldrexh(raw); + + return result; + +} + + +/****************************************************************************** +* * +* Paramètres : raw = donnée brute de 32 bits à désassembler. * +* * +* Description : Désassemble une instruction ARMv7 liées au chapitre A5.2.11. * +* * +* Retour : Instruction mise en place ou NULL en cas d'échec. * +* * +* Remarques : - * +* * +******************************************************************************/ + +static GArchInstruction *process_armv7_arm_msr_immediate_and_hints(uint32_t raw) +{ + GArchInstruction *result; /* Instruction à retourner */ + uint32_t op; /* Champ 'op' à retrouver */ + uint32_t op1; /* Champ 'op1' à retrouver */ + uint32_t op2; /* Champ 'op2' à retrouver */ + + /** + * Suit les directives de : + * § A5.2.11 MSR (immediate), and hints + */ + + if ((raw & 0x0fb00000) != 0x03200000) return NULL; + + result = NULL; + + op = (raw >> 22) & 0x1; + op1 = (raw >> 16) & 0xf; + op2 = (raw >> 0) & 0x1; + + if (op == b0) + { + if (op1 == b0000) + { + if (op2 == b00000000) + result = armv7_read_arm_instr_nop(raw); + + else if (op2 == b00000001) + result = armv7_read_arm_instr_yield(raw); + + else if (op2 == b00000010) + result = armv7_read_arm_instr_wfe(raw); + + else if (op2 == b00000011) + result = armv7_read_arm_instr_wfi(raw); + + else if (op2 == b00000100) + result = armv7_read_arm_instr_sev(raw); + + else if ((op2 & b11110000) == b11110000) + result = armv7_read_arm_instr_dbg(raw); + + } + + else if (op1 == b0100 || (op1 & b1011) == b1000) + result = armv7_read_arm_instr_msr_immediate_a8(raw); + + else if ((op1 & b0011) == b0001 || (op1 & b0010) == b0010) + result = armv7_read_arm_instr_msr_immediate_b9(raw); + + } + + else/* if (op == b1)*/ + result = armv7_read_arm_instr_msr_immediate_b9(raw); + + return result; + +} + + +/****************************************************************************** +* * +* Paramètres : raw = donnée brute de 32 bits à désassembler. * +* * +* Description : Désassemble une instruction ARMv7 liées au chapitre A5.2.12. * +* * +* Retour : Instruction mise en place ou NULL en cas d'échec. * +* * +* Remarques : - * +* * +******************************************************************************/ + +static GArchInstruction *process_armv7_arm_miscellaneous_instructions(uint32_t raw) +{ + GArchInstruction *result; /* Instruction à retourner */ + uint32_t op; /* Champ 'op' à retrouver */ + uint32_t op1; /* Champ 'op1' à retrouver */ + uint32_t b; /* Champ 'b' à retrouver */ + uint32_t op2; /* Champ 'op2' à retrouver */ + + /** + * Suit les directives de : + * § A5.2.12 Miscellaneous instructions + */ + + if ((raw & 0x0f900080) != 0x01000000) return NULL; + + result = NULL; + + op = (raw >> 21) & 0x3; + op1 = (raw >> 16) & 0xf; + b = (raw >> 9) & 0x1; + op2 = (raw >> 4) & 0x7; + + if (op2 == b000) + { + if (b == b1) + { + if ((op & b01) == b00) + result = armv7_read_arm_instr_mrs_banked_register(raw); + + else/* if ((op & b01) == b01)*/ + result = armv7_read_arm_instr_msr_banked_register(raw); + + } + else/* if (b == b0)*/ + { + if ((op & b01) == b00) + result = armv7_read_arm_instr_mrs(raw); + + else if (op == b01) + { + if ((op1 & b0011) == b0000) + result = armv7_read_arm_instr_msr_register_a8(raw); + + else if ((op1 & b0011) == b0001 || (op1 & b0010) == b0010) + result = armv7_read_arm_instr_msr_register_b9(raw); + + } + + else if (op == b11) + result = armv7_read_arm_instr_msr_register_b9(raw); + + } + + } + + else if (op2 == b001) + { + if (op == b01) + result = armv7_read_arm_instr_bx(raw); + + else if (op == b11) + result = armv7_read_arm_instr_clz(raw); + + } + + else if (op2 == b010) + { + if (op == b01) + result = armv7_read_arm_instr_bxj(raw); + + } + + else if (op2 == b011) + { + if (op == b01) + result = armv7_read_arm_instr_blx_register(raw); + + } + + else if (op2 == b101) + result = process_armv7_arm_saturating_addition_and_subtraction(raw); + + else if (op2 == b110) + { + if (op == b11) + result = armv7_read_arm_instr_eret(raw); + + } + + else if (op2 == b111) + { + if (op == b) + result = armv7_read_arm_instr_bkpt(raw); + + else if (op == b) + result = armv7_read_arm_instr_hvc(raw); + + else if (op == b) + result = armv7_read_arm_instr_smc_previously_smi(raw); + + } + + return result; + +} + + +/****************************************************************************** +* * +* Paramètres : raw = donnée brute de 32 bits à désassembler. * +* * +* Description : Désassemble une instruction ARMv7 liées au chapitre A5.3. * +* * +* Retour : Instruction mise en place ou NULL en cas d'échec. * +* * +* Remarques : - * +* * +******************************************************************************/ + +static GArchInstruction *process_armv7_arm_load_store_word_and_unsigned_byte(uint32_t raw) +{ + GArchInstruction *result; /* Instruction à retourner */ + uint32_t a; /* Champ 'a' à retrouver */ + uint32_t op1; /* Champ 'op1' à retrouver */ + uint32_t rn; /* Champ 'rn' à retrouver */ + uint32_t b; /* Champ 'b' à retrouver */ + + /** + * Suit les directives de : + * § A5.3 Load/store word and unsigned byte + */ + + if ((raw & 0x0c000000) != 0x04000000) return NULL; + + result = NULL; + + a = (raw >> 25) & 0x1; + op1 = (raw >> 20) & 0x1f; + rn = (raw >> 16) & 0xf; + b = (raw >> 4) & 0x1; + + if (a == b0) + { + if ((op1 & b00101) == b00000 && (op1 & b10111) != b00010) + result = armv7_read_arm_instr_str_immediate_arm(raw); + + else if ((op1 & b10111) == b00010) + result = armv7_read_arm_instr_strt(raw); + + else if ((op1 & b00101) == b00001 && (op1 & b10111) != b00011) + { + if (rn != b1111) + result = armv7_read_arm_instr_ldr_immediate_arm(raw); + else + result = armv7_read_arm_instr_ldr_literal(raw); + } + + else if ((op1 & b10111) == b00011) + result = armv7_read_arm_instr_ldrt(raw); + + else if ((op1 & b00101) == b00100 && (op1 & b10110) != b00110) + result = armv7_read_arm_instr_strb_immediate_arm(raw); + + else if ((op1 & b10110) == b00110) + result = armv7_read_arm_instr_strbt(raw); + + else if ((op1 & b00101) == b00101 && (op1 & b10111) != b00111) + { + if (rn != b1111) + result = armv7_read_arm_instr_ldrb_immediate_arm(raw); + else + result = armv7_read_arm_instr_ldrb_literal(raw); + } + + else if ((op1 & b10111) == b00111) + result = armv7_read_arm_instr_ldrbt(raw); + + } + else /*if (a == b1)*/ + { + if ((op1 & b00101) == b00000 && (op1 & b10111) != b00010 && b == b0) + result = armv7_read_arm_instr_str_register(raw); + + else if ((op1 & b10111) == b00010 && b == b0) + result = armv7_read_arm_instr_strt(raw); + + else if ((op1 & b00101) == b00001 && (op1 & b10111) != b00011 && b == b0) + result = armv7_read_arm_instr_ldr_register_arm(raw); + + else if ((op1 & b10111) == b00011 && b == b0) + result = armv7_read_arm_instr_ldrt(raw); + + else if ((op1 & b00101) == b00100 && (op1 & b10110) != b00110 && b == b0) + result = armv7_read_arm_instr_strb_register(raw); + + else if ((op1 & b10110) == b00110 && b == b0) + result = armv7_read_arm_instr_strbt(raw); + + else if ((op1 & b00101) == b00101 && (op1 & b10111) != b00111 && b == b0) + result = armv7_read_arm_instr_ldrb_register(raw); + + else if ((op1 & b10111) == b00111 && b == b0) + result = armv7_read_arm_instr_ldrbt(raw); + + } + + return result; + +} + + +/****************************************************************************** +* * +* Paramètres : raw = donnée brute de 32 bits à désassembler. * +* * +* Description : Désassemble une instruction ARMv7 liées au chapitre A5.4. * +* * +* Retour : Instruction mise en place ou NULL en cas d'échec. * +* * +* Remarques : - * +* * +******************************************************************************/ + +static GArchInstruction *process_armv7_arm_media_instructions(uint32_t raw) +{ + GArchInstruction *result; /* Instruction à retourner */ + uint32_t cond; /* Champ 'cond' à retrouver */ + uint32_t op1; /* Champ 'op1' à retrouver */ + uint32_t rd; /* Champ 'rd' à retrouver */ + uint32_t op2; /* Champ 'op2' à retrouver */ + uint32_t rn; /* Champ 'rn' à retrouver */ + + /** + * Suit les directives de : + * § A5.4 Media instructions + */ + + if ((raw & 0x0e000010) != 0x06000010) return NULL; + + result = NULL; + + cond = (raw >> 28) & 0xf; + op1 = (raw >> 20) & 0x1f; + rd = (raw >> 12) & 0xf; + op2 = (raw >> 5) & 0x7; + rn = (raw >> 0) & 0xf; + + if ((op1 & b11100) == b00000) + result = process_armv7_arm_parallel_addition_and_subtraction_signed(raw); + + else if ((op1 & b11100) == b00100) + result = process_armv7_arm_parallel_addition_and_subtraction_unsigned(raw); + + else if ((op1 & b11000) == b01000) + result = process_armv7_arm_packing_unpacking_saturation_and_reversal(raw); + + else if ((op1 & b11000) == b10000) + result = process_armv7_arm_signed_multiply_signed_and_unsigned_divide(raw); + + else if (op1 == b11000) + { + if (op2 == b000) + { + if (rd == b1111) + result = armv7_read_arm_instr_usad8(raw); + else + result = armv7_read_arm_instr_usada8(raw); + } + + goto a54_done; + + } + + else if ((op1 & b11110) == b11010) + { + if ((op2 & b011) == b010) + result = armv7_read_arm_instr_sbfx(raw); + + goto a54_done; + + } + + else if ((op1 & b11110) == b11100) + { + if ((op2 & b011) == b000) + { + if (rn == b1111) + result = armv7_read_arm_instr_bfc(raw); + else + result = armv7_read_arm_instr_bfi(raw); + } + + goto a54_done; + + } + + else if ((op1 & b11110) == b11110) + { + if ((op2 & b011) == b010) + result = armv7_read_arm_instr_ubfx(raw); + + goto a54_done; + + } + + else if (op1 == b11111 && op2 == b111 && cond == b1110) + result = armv7_read_arm_instr_ubfx(raw); + + a54_done: + + return result; + +} + + +/****************************************************************************** +* * +* Paramètres : raw = donnée brute de 32 bits à désassembler. * +* * +* Description : Désassemble une instruction ARMv7 liées au chapitre A5.4.1. * +* * +* Retour : Instruction mise en place ou NULL en cas d'échec. * +* * +* Remarques : - * +* * +******************************************************************************/ + +static GArchInstruction *process_armv7_arm_parallel_addition_and_subtraction_signed(uint32_t raw) +{ + GArchInstruction *result; /* Instruction à retourner */ + uint32_t op1; /* Champ 'op1' à retrouver */ + uint32_t op2; /* Champ 'op2' à retrouver */ + + /** + * Suit les directives de : + * § A5.4.1 Parallel addition and subtraction, signed + */ + + if ((raw & 0x0fc00010) != 0x06000010) return NULL; + + result = NULL; + + op1 = (raw >> 20) & 0x3; + op2 = (raw >> 5) & 0x7; + + if (op1 == b01) + { + if (op2 == b000) + result = armv7_read_arm_instr_sadd16(raw); + + else if (op2 == b001) + result = armv7_read_arm_instr_sasx(raw); + + else if (op2 == b010) + result = armv7_read_arm_instr_ssax(raw); + + else if (op2 == b011) + result = armv7_read_arm_instr_ssub16(raw); + + else if (op2 == b100) + result = armv7_read_arm_instr_sadd8(raw); + + else if (op2 == b111) + result = armv7_read_arm_instr_ssub8(raw); + + } + + else if (op1 == b10) + { + if (op2 == b000) + result = armv7_read_arm_instr_qadd16(raw); + + else if (op2 == b001) + result = armv7_read_arm_instr_qasx(raw); + + else if (op2 == b010) + result = armv7_read_arm_instr_qsax(raw); + + else if (op2 == b011) + result = armv7_read_arm_instr_qsub16(raw); + + else if (op2 == b100) + result = armv7_read_arm_instr_qadd8(raw); + + else if (op2 == b111) + result = armv7_read_arm_instr_qsub8(raw); + + } + + else if (op1 == b11) + { + if (op2 == b000) + result = armv7_read_arm_instr_shadd16(raw); + + else if (op2 == b001) + result = armv7_read_arm_instr_shasx(raw); + + else if (op2 == b010) + result = armv7_read_arm_instr_shsax(raw); + + else if (op2 == b011) + result = armv7_read_arm_instr_shsub16(raw); + + else if (op2 == b100) + result = armv7_read_arm_instr_shadd8(raw); + + else if (op2 == b111) + result = armv7_read_arm_instr_shsub8(raw); + + } + + return result; + +} + + +/****************************************************************************** +* * +* Paramètres : raw = donnée brute de 32 bits à désassembler. * +* * +* Description : Désassemble une instruction ARMv7 liées au chapitre A5.4.2. * +* * +* Retour : Instruction mise en place ou NULL en cas d'échec. * +* * +* Remarques : - * +* * +******************************************************************************/ + +static GArchInstruction *process_armv7_arm_parallel_addition_and_subtraction_unsigned(uint32_t raw) +{ + GArchInstruction *result; /* Instruction à retourner */ + uint32_t op1; /* Champ 'op1' à retrouver */ + uint32_t op2; /* Champ 'op2' à retrouver */ + + /** + * Suit les directives de : + * § A5.4.2 Parallel addition and subtraction, unsigned + */ + + if ((raw & 0x0fc00010) != 0x06400010) return NULL; + + result = NULL; + + op1 = (raw >> 20) & 0x3; + op2 = (raw >> 5) & 0x7; + + if (op1 == b01) + { + if (op2 == b000) + result = armv7_read_arm_instr_uadd16(raw); + + else if (op2 == b001) + result = armv7_read_arm_instr_uasx(raw); + + else if (op2 == b010) + result = armv7_read_arm_instr_usax(raw); + + else if (op2 == b011) + result = armv7_read_arm_instr_usub16(raw); + + else if (op2 == b100) + result = armv7_read_arm_instr_uadd8(raw); + + else if (op2 == b111) + result = armv7_read_arm_instr_usub8(raw); + + } + + else if (op1 == b10) + { + if (op2 == b000) + result = armv7_read_arm_instr_uqadd16(raw); + + else if (op2 == b001) + result = armv7_read_arm_instr_uqasx(raw); + + else if (op2 == b010) + result = armv7_read_arm_instr_uqsax(raw); + + else if (op2 == b011) + result = armv7_read_arm_instr_uqsub16(raw); + + else if (op2 == b100) + result = armv7_read_arm_instr_uqadd8(raw); + + else if (op2 == b111) + result = armv7_read_arm_instr_uqsub8(raw); + + } + + else if (op1 == b11) + { + if (op2 == b000) + result = armv7_read_arm_instr_uhadd16(raw); + + else if (op2 == b001) + result = armv7_read_arm_instr_uhasx(raw); + + else if (op2 == b010) + result = armv7_read_arm_instr_uhsax(raw); + + else if (op2 == b011) + result = armv7_read_arm_instr_uhsub16(raw); + + else if (op2 == b100) + result = armv7_read_arm_instr_uhadd8(raw); + + else if (op2 == b111) + result = armv7_read_arm_instr_uhsub8(raw); + + } + + return result; + +} + + +/****************************************************************************** +* * +* Paramètres : raw = donnée brute de 32 bits à désassembler. * +* * +* Description : Désassemble une instruction ARMv7 liées au chapitre A5.4.3. * +* * +* Retour : Instruction mise en place ou NULL en cas d'échec. * +* * +* Remarques : - * +* * +******************************************************************************/ + +static GArchInstruction *process_armv7_arm_packing_unpacking_saturation_and_reversal(uint32_t raw) +{ + GArchInstruction *result; /* Instruction à retourner */ + uint32_t op1; /* Champ 'op1' à retrouver */ + uint32_t a; /* Champ 'a' à retrouver */ + uint32_t op2; /* Champ 'op2' à retrouver */ + + /** + * Suit les directives de : + * § A5.4.3 Packing, unpacking, saturation, and reversal + */ + + if ((raw & 0x0f800010) != 0x06800010) return NULL; + + result = NULL; + + op1 = (raw >> 20) & 0x7; + a = (raw >> 16) & 0xf; + op2 = (raw >> 5) & 0x7; + + if ((op1 & b111) == b000) + { + if ((op2 & b001) == b000) + { + result = armv7_read_arm_instr_pkh(raw); + goto a543_done; + } + else if (op2 == b011) + { + if (a == b1111) + { + result = armv7_read_arm_instr_sxtb16(raw); + goto a543_done; + } + else + { + result = armv7_read_arm_instr_sxtab16(raw); + goto a543_done; + } + } + else if (op2 == b101) + { + result = armv7_read_arm_instr_sel(raw); + goto a543_done; + } + } + + else if ((op1 & b110) == b010 && (op2 & b001) == b000) + { + result = armv7_read_arm_instr_ssat(raw); + goto a543_done; + } + + else if (op1 == b010) + { + if (op2 == b001) + { + result = armv7_read_arm_instr_ssat16(raw); + goto a543_done; + } + else if (op2 == b011) + { + if (a == b1111) + { + result = armv7_read_arm_instr_sxtb(raw); + goto a543_done; + } + else + { + result = armv7_read_arm_instr_sxtab(raw); + goto a543_done; + } + } + } + + else if (op1 == b011) + { + if (op2 == b001) + { + result = armv7_read_arm_instr_rev(raw); + goto a543_done; + } + else if (op2 == b011) + { + if (a == b1111) + { + result = armv7_read_arm_instr_sxth(raw); + goto a543_done; + } + else + { + result = armv7_read_arm_instr_sxtah(raw); + goto a543_done; + } + } + else if (op2 == b101) + { + result = armv7_read_arm_instr_rev16(raw); + goto a543_done; + } + } + + else if (op1 == b100 && op2 == b011) + { + if (a == b1111) + { + result = armv7_read_arm_instr_uxtb16(raw); + goto a543_done; + } + else + { + result = armv7_read_arm_instr_uxtab16(raw); + goto a543_done; + } + } + + else if ((op1 & b110) == b110 && (op2 & b001) == b000) + { + result = armv7_read_arm_instr_usat(raw); + goto a543_done; + } + + else if (op1 == b110) + { + if (op2 == b001) + { + result = armv7_read_arm_instr_usat16(raw); + goto a543_done; + } + else if (op2 == b011) + { + if (a == b1111) + { + result = armv7_read_arm_instr_uxtb(raw); + goto a543_done; + } + else + { + result = armv7_read_arm_instr_uxtab(raw); + goto a543_done; + } + } + } + + else if (op1 == b111) + { + if (op2 == b001) + { + result = armv7_read_arm_instr_rbit(raw); + goto a543_done; + } + else if (op2 == b011) + { + if (a == b1111) + { + result = armv7_read_arm_instr_uxth(raw); + goto a543_done; + } + else + { + result = armv7_read_arm_instr_uxtah(raw); + goto a543_done; + } + } + else if (op2 == b101) + { + result = armv7_read_arm_instr_revsh(raw); + goto a543_done; + } + } + + a543_done: + + return result; + +} + + +/****************************************************************************** +* * +* Paramètres : raw = donnée brute de 32 bits à désassembler. * +* * +* Description : Désassemble une instruction ARMv7 liées au chapitre A5.4.4. * +* * +* Retour : Instruction mise en place ou NULL en cas d'échec. * +* * +* Remarques : - * +* * +******************************************************************************/ + +static GArchInstruction *process_armv7_arm_signed_multiply_signed_and_unsigned_divide(uint32_t raw) +{ + GArchInstruction *result; /* Instruction à retourner */ + uint32_t op1; /* Champ 'op1' à retrouver */ + uint32_t a; /* Champ 'a' à retrouver */ + uint32_t op2; /* Champ 'op2' à retrouver */ + + /** + * Suit les directives de : + * § A5.4.4 Signed multiply, signed and unsigned divide + */ + + if ((raw & 0x0f800010) != 0x07000010) return NULL; + + result = NULL; + + op1 = (raw >> 20) & 0x7; + a = (raw >> 12) & 0xf; + op2 = (raw >> 5) & 0x7; + + if (op1 == b000) + { + if ((op2 & b110) == b000) + { + if (a != b1111) + result = armv7_read_arm_instr_smlad(raw); + else/* if (a == b1111)*/ + result = armv7_read_arm_instr_smuad(raw); + + } + + else if ((op2 & b110) == b010) + { + if (a != b1111) + result = armv7_read_arm_instr_smlsd(raw); + else/* if (a == b1111)*/ + result = armv7_read_arm_instr_smusd(raw); + + } + + } + + else if (op1 == b001) + { + if (op2 == b000) + result = armv7_read_arm_instr_sdiv(raw); + + } + + else if (op1 == b011) + { + if (op2 == b000) + result = armv7_read_arm_instr_udiv(raw); + + } + + else if (op1 == b100) + { + if ((op2 & b110) == b000) + result = armv7_read_arm_instr_smlald(raw); + + else if ((op2 & b110) == b010) + result = armv7_read_arm_instr_smlsld(raw); + + } + + else if (op1 == b101) + { + if ((op2 & b110) == b000) + { + if (a != b1111) + result = armv7_read_arm_instr_smmla(raw); + else/* if (a == b1111)*/ + result = armv7_read_arm_instr_smmul(raw); + + } + + else if ((op2 & b110) == b110) + result = armv7_read_arm_instr_smmls(raw); + + } + + return result; + +} + + +/****************************************************************************** +* * +* Paramètres : raw = donnée brute de 32 bits à désassembler. * +* * +* Description : Désassemble une instruction ARMv7 liées au chapitre A5.5. * +* * +* Retour : Instruction mise en place ou NULL en cas d'échec. * +* * +* Remarques : - * +* * +******************************************************************************/ + +static GArchInstruction *process_armv7_arm_branch_branch_with_link_and_block_data_transfer(uint32_t raw) +{ + GArchInstruction *result; /* Instruction à retourner */ + uint32_t op; /* Champ 'op' à retrouver */ + uint32_t rn; /* Champ 'rn' à retrouver */ + uint32_t r; /* Champ 'r' à retrouver */ + + /** + * Suit les directives de : + * § A5.5 Branch, branch with link, and block data transferr + */ + + if ((raw & 0x0c000000) != 0x08000000) return NULL; + + result = NULL; + + op = (raw >> 20) & 0x3f; + rn = (raw >> 16) & 0xf; + r = (raw >> 15) & 0x1; + + if ((op & b111101) == b000000) + result = armv7_read_arm_instr_stmda_stmed(raw); + + else if ((op & b111101) == b000001) + result = armv7_read_arm_instr_ldmda_ldmfa(raw); + + else if ((op & b111101) == b001000) + result = armv7_read_arm_instr_stm_stmia_stmea(raw); + + else if (op == b001001) + result = armv7_read_arm_instr_ldm_ldmia_ldmfd_arm(raw); + + else if (op == b001011) + { + if (rn != b1101) + result = armv7_read_arm_instr_ldm_ldmia_ldmfd_arm(raw); + else /* if (rn == b1101) */ + result = armv7_read_arm_instr_pop_arm(raw); + } + + else if (op == b010000) + result = armv7_read_arm_instr_stmdb_stmfd(raw); + + else if (op == b010010) + { + if (rn != b1101) + result = armv7_read_arm_instr_stmdb_stmfd(raw); + else /* if (rn == b1101) */ + result = armv7_read_arm_instr_push(raw); + } + + else if ((op & b111101) == b010001) + result = armv7_read_arm_instr_ldmdb_ldmea(raw); + + else if ((op & b111101) == b011000) + result = armv7_read_arm_instr_stmib_stmfa(raw); + + else if ((op & b111101) == b011001) + result = armv7_read_arm_instr_ldmib_ldmed(raw); + + else if ((op & b100101) == b000100) + result = armv7_read_arm_instr_stm_user_registers(raw); + + else if ((op & b100101) == b000101) + { + if (r == b0) + result = armv7_read_arm_instr_ldm_user_registers(raw); + else /* if (r == b1) */ + result = armv7_read_arm_instr_ldm_exception_return(raw); + } + + else if ((op & b110000) == b100000) + result = armv7_read_arm_instr_b(raw); + + else if ((op & b110000) == b110000) + result = armv7_read_arm_instr_bl_blx_immediate(raw); + + return result; + +} + + +/****************************************************************************** +* * +* Paramètres : raw = donnée brute de 32 bits à désassembler. * +* * +* Description : Désassemble une instruction ARMv7 liées au chapitre A5.6. * +* * +* Retour : Instruction mise en place ou NULL en cas d'échec. * +* * +* Remarques : - * +* * +******************************************************************************/ + +static GArchInstruction *process_armv7_arm_coprocessor_instructions_and_supervisor_call(uint32_t raw) +{ + GArchInstruction *result; /* Instruction à retourner */ + uint32_t op1; /* Champ 'op1' à retrouver */ + uint32_t rn; /* Champ 'rn' à retrouver */ + uint32_t coproc; /* Champ 'coproc' à retrouver */ + uint32_t op; /* Champ 'op' à retrouver */ + + /** + * Suit les directives de : + * § A5.6 Coprocessor instructions, and Supervisor Call + */ + + if ((raw & 0x0c000000) != 0x0c000000) return NULL; + + result = NULL; + + op1 = (raw >> 20) & 0x3f; + rn = (raw >> 16) & 0xf; + coproc = (raw >> 8) & 0xf; + op = (raw >> 4) & 0x1; + + if ((op1 & b111110) == b000000) + result = g_undef_instruction_new(IBS_UNDEFINED); + + else if ((op1 & b110000) == b110000) + result = armv7_read_arm_instr_svc_previously_swi(raw); + + else if ((coproc & b1110) != b1010) + { + if ((op1 & b100001) == b000000 && (op1 & b111011) != b000000) + result = armv7_read_arm_instr_stc_stc2(raw); + + else if ((op1 & b100001) == b000001 && (op1 & b111011) != b000001) + { + if (rn != b1111) + result = armv7_read_arm_instr_ldc_ldc2_immediate(raw); + else + result = armv7_read_arm_instr_ldc_ldc2_literal(raw); + + } + + else if (op1 == b000100) + result = armv7_read_arm_instr_mcrr_mcrr2(raw); + + else if (op1 == b000101) + result = armv7_read_arm_instr_mrrc_mrrc2(raw); + + + else if ((op1 & b110000) == b100000 && op == b0) + result = armv7_read_arm_instr_cdp_cdp2(raw); + + else if ((op1 & b110001) == b100000 && op == b1) + result = armv7_read_arm_instr_mcr_mcr2(raw); + + else if ((op1 & b110001) == b100001 && op == b1) + result = armv7_read_arm_instr_mrc_mrc2(raw); + + } + + else if ((coproc & b1110) == b1010) + { + /* TODO */ + + } + + return result; + +} + + +/****************************************************************************** +* * +* Paramètres : raw = donnée brute de 32 bits à désassembler. * +* * +* Description : Désassemble une instruction ARMv7 liées au chapitre A5.7. * +* * +* Retour : Instruction mise en place ou NULL en cas d'échec. * +* * +* Remarques : - * +* * +******************************************************************************/ + +static GArchInstruction *process_armv7_arm_unconditional_instructions(uint32_t raw) +{ + GArchInstruction *result; /* Instruction à retourner */ + uint32_t op1; /* Champ 'op1' à retrouver */ + uint32_t rn; /* Champ 'rn' à retrouver */ + uint32_t op; /* Champ 'op' à retrouver */ + + /** + * Suit les directives de : + * § A5.7 Unconditional instructions + */ + + if ((raw & 0xf0000000) != 0xf0000000) return NULL; + + result = NULL; + + op1 = (raw >> 20) & 0xff; + rn = (raw >> 16) & 0xf; + op = (raw >> 4) & 0x1; + + if ((op1 & b10000000) == b00000000) + result = process_armv7_arm_memory_hints_advanced_simd_instructions_and_miscellaneous_instructions(raw); + + else if ((op1 & b11100101) == b10000100) + result = armv7_read_arm_instr_srs_arm(raw); + + else if ((op1 & b11100101) == b10000001) + result = armv7_read_arm_instr_rfe(raw); + + else if ((op1 & b11100000) == b10100000) + result = armv7_read_arm_instr_bl_blx_immediate(raw); + + else if ((op1 & b11100001) == b11000000 && (op1 & b11111011) != b11000000) + result = armv7_read_arm_instr_stc_stc2(raw); + + else if ((op1 & b11100001) == b11000001 && (op1 & b11111011) != b11000001) + { + if (rn != b1111) + result = armv7_read_arm_instr_ldc_ldc2_immediate(raw); + else/* if (rn == b1111)*/ + result = armv7_read_arm_instr_ldc_ldc2_literal(raw); + } + + else if (op1 == b11000100) + result = armv7_read_arm_instr_mcrr_mcrr2(raw); + + else if (op1 == b11000101) + result = armv7_read_arm_instr_mrrc_mrrc2(raw); + + else if ((op1 & b11110000) == b11100000 && op == b0) + result = armv7_read_arm_instr_cdp_cdp2(raw); + + else if ((op1 & b11110001) == b11100000 && op == b1) + result = armv7_read_arm_instr_mcr_mcr2(raw); + + else if ((op1 & b11110001) == b11100001 && op == b1) + result = armv7_read_arm_instr_mrc_mrc2(raw); + + return result; + +} + + +/****************************************************************************** +* * +* Paramètres : raw = donnée brute de 32 bits à désassembler. * +* * +* Description : Désassemble une instruction ARMv7 liées au chapitre A5.7.1. * +* * +* Retour : Instruction mise en place ou NULL en cas d'échec. * +* * +* Remarques : - * +* * +******************************************************************************/ + +static GArchInstruction *process_armv7_arm_memory_hints_advanced_simd_instructions_and_miscellaneous_instructions(uint32_t raw) +{ + GArchInstruction *result; /* Instruction à retourner */ + uint32_t op1; /* Champ 'op1' à retrouver */ + uint32_t rn; /* Champ 'rn' à retrouver */ + uint32_t op2; /* Champ 'op2' à retrouver */ + + /** + * Suit les directives de : + * § A5.7.1 Memory hints, Advanced SIMD instructions, and miscellaneous instructions + */ + + if ((raw & 0xf8000000) != 0xf0000000) return NULL; + + result = NULL; + + op1 = (raw >> 20) & 0x7f; + rn = (raw >> 16) & 0xf; + op2 = (raw >> 4) & 0xf; + + if (op1 == b0010000) + { + if ((op2 & b0010) == b0000 && (rn & b0001) == b0000) + result = armv7_read_arm_instr_cps_arm(raw); + + else if (op2 == b0000 && (rn & b0001) == b0001) + result = armv7_read_arm_instr_cps_arm(raw); + + } + + else if ((op1 & b1100000) == b0100000) + result = process_armv7_simd_advanced_simd_data_processing_instructions(raw, true); + + else if ((op1 & b1110001) == b1000000) + result = process_armv7_simd_advanced_simd_element_or_structure_load_store_instructions(raw, true); + + else if ((op1 & b1110111) == b1000001) + result = g_undef_instruction_new(IBS_NOP); + + else if ((op1 & b1110111) == b1000101) + result = armv7_read_arm_instr_pli_immediate_literal(raw); + + else if ((op1 & b1110011) == b1000011) + result = g_undef_instruction_new(IBS_UNPREDICTABLE); + + else if ((op1 & b1110111) == b1010101) + { + if (rn != b1111) + result = armv7_read_arm_instr_pld_pldw_immediate(raw); + else + result = g_undef_instruction_new(IBS_UNPREDICTABLE); + + } + + else if ((op1 & b1110111) == b1010101) + { + if (rn != b1111) + result = armv7_read_arm_instr_pld_pldw_immediate(raw); + else + result = armv7_read_arm_instr_pld_literal(raw); + + } + + else if (op1 == b1010011) + result = g_undef_instruction_new(IBS_UNPREDICTABLE); + + else if (op1 == b1010111) + { + if (op2 == b0000) + result = g_undef_instruction_new(IBS_UNPREDICTABLE); + + else if (op2 == b0001) + result = armv7_read_arm_instr_clrex(raw); + + else if ((op2 & b1110) == b0010) + result = g_undef_instruction_new(IBS_UNPREDICTABLE); + + else if (op2 == b0100) + result = armv7_read_arm_instr_dsb(raw); + + else if (op2 == b0101) + result = armv7_read_arm_instr_dmb(raw); + + else if (op2 == b0110) + result = armv7_read_arm_instr_isb(raw); + + else if (op2 == b0111) + result = g_undef_instruction_new(IBS_UNPREDICTABLE); + + else if ((op2 & b1000) == b1000) + result = g_undef_instruction_new(IBS_UNPREDICTABLE); + + } + + else if ((op1 & b1111011) == b1011011) + result = g_undef_instruction_new(IBS_UNPREDICTABLE); + + else if ((op1 & b1110111) == b1100001 && (op2 & b0001) == b0000) + result = g_undef_instruction_new(IBS_NOP); + + else if ((op1 & b1110111) == b1100101 && (op2 & b0001) == b0000) + result = armv7_read_arm_instr_pli_register(raw); + + else if ((op1 & b1110111) == b1110001 && (op2 & b0001) == b0000) + result = armv7_read_arm_instr_pld_pldw_register(raw); + + return result; + +} diff --git a/plugins/arm/v7/arm.h b/plugins/arm/v7/arm.h new file mode 100644 index 0000000..015f1d4 --- /dev/null +++ b/plugins/arm/v7/arm.h @@ -0,0 +1,37 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * arm.h - prototypes pour le désassemblage des instructions ARMv7 + * + * Copyright (C) 2014-2017 Cyrille Bagard + * + * This file is part of Chrysalide. + * + * Chrysalide is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Chrysalide is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Foobar. If not, see . + */ + + +#ifndef _PLUGINS_ARM_V7_ARM_H +#define _PLUGINS_ARM_V7_ARM_H + + +#include + + + +/* Désassemble une instruction ARMv7 liées au chapitre A5.1. */ +GArchInstruction *process_armv7_arm_instruction_set_encoding(uint32_t raw); + + + +#endif /* _PLUGINS_ARM_V7_ARM_H */ diff --git a/plugins/arm/v7/build_tmp_decl.sh b/plugins/arm/v7/build_tmp_decl.sh new file mode 100755 index 0000000..0d0feee --- /dev/null +++ b/plugins/arm/v7/build_tmp_decl.sh @@ -0,0 +1,39 @@ +#!/bin/sh + + +arch=$1 +header="opcodes/${arch}_opcodes.h" +headertmp="opcodes/opcodes_tmp_$arch.h" + +echo "#ifndef ${arch}_def_tmp_h" > $headertmp +echo "#define ${arch}_def_tmp_h" >> $headertmp + +target=armv7_read_${arch}_instr + +needed=`grep $target $arch.c | sed "s/.*\(${target}_[^(]*\).*/\1/" | sort | uniq` + +for n in $needed; do + + echo " $n..." + + test -f $header && grep -q "$n(" $header + if [ $? -ne 0 ]; then + + if [ $arch = "simd" ]; then + echo "#define $n(r, a) NULL" >> $headertmp + else + echo "#define $n(r) NULL" >> $headertmp + fi + + else + + echo "$n found in $header" + + fi + +done + +echo "#endif" >> $headertmp + + + diff --git a/plugins/arm/v7/context.c b/plugins/arm/v7/context.c new file mode 100644 index 0000000..8fc7fc1 --- /dev/null +++ b/plugins/arm/v7/context.c @@ -0,0 +1,305 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * context.c - contexte lié à l'exécution d'un processeur + * + * Copyright (C) 2015-2017 Cyrille Bagard + * + * This file is part of Chrysalide. + * + * Chrysalide is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Chrysalide is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Foobar. If not, see . + */ + + +#include "context.h" + + +#include + + +#include "../context-int.h" + + + +/* ------------------------ MANIPULATION GLOBALE DU CONTEXTE ------------------------ */ + + +/* Définition d'un contexte pour processeur ARM (instance) */ +struct _GArmV7Context +{ + GArmContext parent; /* A laisser en premier */ + +}; + + +/* Définition d'un contexte pour processeur ARM (classe) */ +struct _GArmV7ContextClass +{ + GArmContextClass parent; /* A laisser en premier */ + +}; + + +/* Initialise la classe des contextes de processeur ARM. */ +static void g_armv7_context_class_init(GArmV7ContextClass *); + +/* Initialise une instance de contexte de processeur ARM. */ +static void g_armv7_context_init(GArmV7Context *); + +/* Supprime toutes les références externes. */ +static void g_armv7_context_dispose(GArmV7Context *); + +/* Procède à la libération totale de la mémoire. */ +static void g_armv7_context_finalize(GArmV7Context *); + +/* Ajoute une adresse virtuelle comme point de départ de code. */ +static void g_armv7_context_push_drop_point(GArmV7Context *, DisassPriorityLevel, virt_t, va_list); + + + +/* ---------------------------------------------------------------------------------- */ +/* MANIPULATION GLOBALE DU CONTEXTE */ +/* ---------------------------------------------------------------------------------- */ + + +/* Indique le type définit par la GLib pour le contexte de processeur ARM. */ +G_DEFINE_TYPE(GArmV7Context, g_armv7_context, G_TYPE_ARM_CONTEXT); + + +/****************************************************************************** +* * +* Paramètres : klass = classe à initialiser. * +* * +* Description : Initialise la classe des contextes de processeur ARM. * +* * +* Retour : - * +* * +* Remarques : - * +* * +******************************************************************************/ + +static void g_armv7_context_class_init(GArmV7ContextClass *klass) +{ + GObjectClass *object; /* Autre version de la classe */ + GProcContextClass *proc; /* Version parente de la classe*/ + + object = G_OBJECT_CLASS(klass); + + object->dispose = (GObjectFinalizeFunc/* ! */)g_armv7_context_dispose; + object->finalize = (GObjectFinalizeFunc)g_armv7_context_finalize; + + proc = G_PROC_CONTEXT_CLASS(klass); + + proc->push_point = (push_drop_point_fc)g_armv7_context_push_drop_point; + +} + + +/****************************************************************************** +* * +* Paramètres : ctx = instance à initialiser. * +* * +* Description : Initialise une instance de contexte de processeur ARM. * +* * +* Retour : - * +* * +* Remarques : - * +* * +******************************************************************************/ + +static void g_armv7_context_init(GArmV7Context *ctx) +{ + GArmContext *base; /* Autre version du contexte */ + + base = G_ARM_CONTEXT(ctx); + + base->areas = (disass_arm_area *)calloc(1, sizeof(disass_arm_area)); + base->acount = 1; + + base->areas[0].start = 0; + base->areas[0].end = (virt_t)-1; + base->areas[0].marker = AV7IS_ARM; + +} + + +/****************************************************************************** +* * +* Paramètres : ctx = instance d'objet GLib à traiter. * +* * +* Description : Supprime toutes les références externes. * +* * +* Retour : - * +* * +* Remarques : - * +* * +******************************************************************************/ + +static void g_armv7_context_dispose(GArmV7Context *ctx) +{ + G_OBJECT_CLASS(g_armv7_context_parent_class)->dispose(G_OBJECT(ctx)); + +} + + +/****************************************************************************** +* * +* Paramètres : ctx = instance d'objet GLib à traiter. * +* * +* Description : Procède à la libération totale de la mémoire. * +* * +* Retour : - * +* * +* Remarques : - * +* * +******************************************************************************/ + +static void g_armv7_context_finalize(GArmV7Context *ctx) +{ + G_OBJECT_CLASS(g_armv7_context_parent_class)->finalize(G_OBJECT(ctx)); + +} + + +/****************************************************************************** +* * +* Paramètres : - * +* * +* Description : Crée un contexte pour l'exécution du processeur ARM. * +* * +* Retour : Contexte mis en place. * +* * +* Remarques : - * +* * +******************************************************************************/ + +GArmV7Context *g_armv7_context_new(void) +{ + GArmV7Context *result; /* Structure à retourner */ + + result = g_object_new(G_TYPE_ARMV7_CONTEXT, NULL); + + return result; + +} + + +/****************************************************************************** +* * +* Paramètres : ctx = contexte de désassemblage à compléter. * +* level = indication de priorité et d'origine de l'adresse. * +* addr = adresse d'un nouveau point de départ à traiter. * +* ap = forme générique d'un encodage à mémoriser. * +* * +* Description : Ajoute une adresse virtuelle comme point de départ de code. * +* * +* Retour : - * +* * +* Remarques : - * +* * +******************************************************************************/ + +static void g_armv7_context_push_drop_point(GArmV7Context *ctx, DisassPriorityLevel level, virt_t addr, va_list ap) +{ + ArmV7InstrSet marker; /* Type de jeu d'instructions */ + + switch (level) + { + case DPL_ENTRY_POINT: + case DPL_SYMBOL: + + if (addr & 0x1) + { + addr -= 0x1; + marker = AV7IS_THUMB; + } + else + marker = AV7IS_ARM; + + break; + + default: + + /** + * Les messages de GCC annoncent parfois les choses très clairement : + * + * context.c:233:33: warning: 'ArmV7InstrSet' is promoted to 'int' when passed through '...' + * marker = va_arg(ap, ArmV7InstrSet); + * ^ + * context.c:233:33: note: (so you should pass 'int' not 'ArmV7InstrSet' to 'va_arg') + * context.c:233:33: note: if this code is reached, the program will abort + * + */ + + marker = (ArmV7InstrSet)va_arg(ap, unsigned int); + + /** + * Attention : toute adresse impaire est destinée à du mode Thumb. + * + * Mais la réciproque n'est pas vraie : le mode Thumb peut aussi + * manipuler des adresses paires. + */ + assert(((addr & 0x1) && marker == AV7IS_THUMB) || (addr & 0x1) == 0); + + addr &= ~0x1; + + break; + + } + + g_armv7_context_define_encoding(ctx, addr, marker); + + G_PROC_CONTEXT_CLASS(g_armv7_context_parent_class)->push_point(G_PROC_CONTEXT(ctx), level, addr, ap); + +} + + +/****************************************************************************** +* * +* Paramètres : ctx = contexte de désassemblage à compléter. * +* addr = adresse d'un nouveau point de départ à créer. * +* marker = forme générique d'un encodage à mémoriser. * +* * +* Description : Enregistre l'encodage (générique) utilisé à une adresse. * +* * +* Retour : - * +* * +* Remarques : - * +* * +******************************************************************************/ + +void g_armv7_context_define_encoding(GArmV7Context *ctx, virt_t addr, ArmV7InstrSet marker) +{ + _g_arm_context_define_encoding(G_ARM_CONTEXT(ctx), addr, marker); + +} + + +/****************************************************************************** +* * +* Paramètres : ctx = contexte de désassemblage à consulter. * +* addr = adresse d'un nouveau point de départ à retrouver. * +* * +* Description : Indique l'encodage (générique) utilisé à une adresse donnée. * +* * +* Retour : Marqueur à priori toujours valide. * +* * +* Remarques : - * +* * +******************************************************************************/ + +ArmV7InstrSet g_armv7_context_find_encoding(GArmV7Context *ctx, virt_t addr) +{ + return (ArmV7InstrSet)_g_arm_context_find_encoding(G_ARM_CONTEXT(ctx), addr); + +} diff --git a/plugins/arm/v7/context.h b/plugins/arm/v7/context.h new file mode 100644 index 0000000..4a4612d --- /dev/null +++ b/plugins/arm/v7/context.h @@ -0,0 +1,81 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * context.h - prototypes pour le contexte lié à l'exécution d'un processeur + * + * Copyright (C) 2015-2017 Cyrille Bagard + * + * This file is part of Chrysalide. + * + * Chrysalide is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Chrysalide is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Foobar. If not, see . + */ + + +#ifndef _PLUGINS_ARM_V7_CONTEXT_H +#define _PLUGINS_ARM_V7_CONTEXT_H + + +#include + + +#include + + + +/* ------------------------ MANIPULATION GLOBALE DU CONTEXTE ------------------------ */ + + +#define G_TYPE_ARMV7_CONTEXT g_armv7_context_get_type() +#define G_ARMV7_CONTEXT(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), g_armv7_context_get_type(), GArmV7Context)) +#define G_IS_ARMV7_CONTEXT(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), g_armv7_context_get_type())) +#define G_ARMV7_CONTEXT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), G_TYPE_ARMV7_CONTEXT, GGArmV7ContextClass)) +#define G_IS_ARMV7_CONTEXT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), G_TYPE_ARMV7_CONTEXT)) +#define G_ARMV7_CONTEXT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), G_TYPE_ARMV7_CONTEXT, GGArmV7ContextClass)) + + +/* Définition d'un contexte pour processeur ARM (instance) */ +typedef struct _GArmV7Context GArmV7Context; + +/* Définition d'un contexte pour processeur ARM (classe) */ +typedef struct _GArmV7ContextClass GArmV7ContextClass; + + +/* Indique le type définit par la GLib pour le contexte de processeur ARM. */ +GType g_armv7_context_get_type(void); + +/* Crée un contexte pour l'exécution du processeur ARM. */ +GArmV7Context *g_armv7_context_new(void); + + +/* Jeux d'instructions possibles avec ARM v7 */ +typedef enum _ArmV7InstrSet +{ + AV7IS_ARM, /* Encodage classique */ + AV7IS_THUMB, /* Encodage compressé */ + AV7IS_JAZELLE, /* Encodage JVM */ + AV7IS_THUMBEE, /* Encodage dense + JIT/AOT */ + + AV7IS_COUNT + +} ArmV7InstrSet; + + +/* Enregistre l'encodage (générique) utilisé à une adresse. */ +void g_armv7_context_define_encoding(GArmV7Context *, virt_t, ArmV7InstrSet); + +/* Indique l'encodage (générique) utilisé à une adresse donnée. */ +ArmV7InstrSet g_armv7_context_find_encoding(GArmV7Context *, virt_t); + + + +#endif /* _PLUGINS_ARM_V7_CONTEXT_H */ diff --git a/plugins/arm/v7/core.c b/plugins/arm/v7/core.c new file mode 100644 index 0000000..a2d0e45 --- /dev/null +++ b/plugins/arm/v7/core.c @@ -0,0 +1,66 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * core.c - chargement et déchargement des mécanismes internes de l'architecture ARMv7 + * + * Copyright (C) 2016-2017 Cyrille Bagard + * + * This file is part of Chrysalide. + * + * Chrysalide is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Chrysalide is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Foobar. If not, see . + */ + + +#include "core.h" + + + +/****************************************************************************** +* * +* Paramètres : - * +* * +* Description : Met en place les mécanismes internes de l'architecture ARMv7.* +* * +* Retour : Bilan de l'opération. * +* * +* Remarques : - * +* * +******************************************************************************/ + +bool init_armv7_core(void) +{ + bool result; /* Bilan à renvoyer */ + + result = true; + + return result; + +} + + +/****************************************************************************** +* * +* Paramètres : - * +* * +* Description : Supprime les mécanismes internes de l'architecture ARMv7. * +* * +* Retour : - * +* * +* Remarques : - * +* * +******************************************************************************/ + +void exit_armv7_core(void) +{ + +} diff --git a/plugins/arm/v7/core.h b/plugins/arm/v7/core.h new file mode 100644 index 0000000..0a67baf --- /dev/null +++ b/plugins/arm/v7/core.h @@ -0,0 +1,40 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * core.h - prototypes pour le chargement et le déchargement des mécanismes internes de l'architecture ARMv7 + * + * Copyright (C) 2016-2017 Cyrille Bagard + * + * This file is part of Chrysalide. + * + * Chrysalide is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Chrysalide is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Foobar. If not, see . + */ + + +#ifndef _PLUGINS_ARM_V7_CORE_H +#define _PLUGINS_ARM_V7_CORE_H + + +#include + + + +/* Met en place les mécanismes internes de l'architecture ARMv7. */ +bool init_armv7_core(void); + +/* Supprime les mécanismes internes de l'architecture ARMv7. */ +void exit_armv7_core(void); + + + +#endif /* _PLUGINS_ARM_V7_CORE_H */ diff --git a/plugins/arm/v7/cregister.c b/plugins/arm/v7/cregister.c new file mode 100644 index 0000000..33564f0 --- /dev/null +++ b/plugins/arm/v7/cregister.c @@ -0,0 +1,212 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * cregisters.c - aides auxiliaires relatives aux registres de co-processeur ARMv7 + * + * Copyright (C) 2016-2017 Cyrille Bagard + * + * This file is part of Chrysalide. + * + * Chrysalide is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Chrysalide is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Foobar. If not, see . + */ + + +#include "cregister.h" + + +#include + + +#include "../register-int.h" + + + +/* Représentation d'un registre de co-processeur ARMv7 (instance) */ +struct _GArmV7CRegister +{ + GArmRegister parent; /* Instance parente */ + +}; + + +/* Représentation d'un registre de co-processeur ARMv7 (classe) */ +struct _GArmV7CRegisterClass +{ + GArmRegisterClass parent; /* Classe parente */ + +}; + + + +/* Initialise la classe des registres de co-processeur ARMv7. */ +static void g_armv7_cregister_class_init(GArmV7CRegisterClass *); + +/* Initialise une instance de registre de co-processeur ARMv7. */ +static void g_armv7_cregister_init(GArmV7CRegister *); + +/* Supprime toutes les références externes. */ +static void g_armv7_cregister_dispose(GArmV7CRegister *); + +/* Procède à la libération totale de la mémoire. */ +static void g_armv7_cregister_finalize(GArmV7CRegister *); + +/* Traduit un registre en version humainement lisible. */ +static void g_armv7_cregister_print(const GArmV7CRegister *, GBufferLine *, AsmSyntax); + + + +/* Indique le type défini pour une représentation d'un registre de co-processeur ARMv7. */ +G_DEFINE_TYPE(GArmV7CRegister, g_armv7_cregister, G_TYPE_ARM_REGISTER); + + +/****************************************************************************** +* * +* Paramètres : klass = classe à initialiser. * +* * +* Description : Initialise la classe des registres de co-processeur ARMv7. * +* * +* Retour : - * +* * +* Remarques : - * +* * +******************************************************************************/ + +static void g_armv7_cregister_class_init(GArmV7CRegisterClass *klass) +{ + GObjectClass *object_class; /* Autre version de la classe */ + GArchRegisterClass *reg_class; /* Classe de haut niveau */ + + object_class = G_OBJECT_CLASS(klass); + reg_class = G_ARCH_REGISTER_CLASS(klass); + + object_class->dispose = (GObjectFinalizeFunc/* ! */)g_armv7_cregister_dispose; + object_class->finalize = (GObjectFinalizeFunc)g_armv7_cregister_finalize; + + reg_class->print = (reg_print_fc)g_armv7_cregister_print; + +} + + +/****************************************************************************** +* * +* Paramètres : reg = instance à initialiser. * +* * +* Description : Initialise une instance de registre de co-processeur ARMv7. * +* * +* Retour : - * +* * +* Remarques : - * +* * +******************************************************************************/ + +static void g_armv7_cregister_init(GArmV7CRegister *reg) +{ + +} + + +/****************************************************************************** +* * +* Paramètres : reg = instance d'objet GLib à traiter. * +* * +* Description : Supprime toutes les références externes. * +* * +* Retour : - * +* * +* Remarques : - * +* * +******************************************************************************/ + +static void g_armv7_cregister_dispose(GArmV7CRegister *reg) +{ + G_OBJECT_CLASS(g_armv7_cregister_parent_class)->dispose(G_OBJECT(reg)); + +} + + +/****************************************************************************** +* * +* Paramètres : reg = instance d'objet GLib à traiter. * +* * +* Description : Procède à la libération totale de la mémoire. * +* * +* Retour : - * +* * +* Remarques : - * +* * +******************************************************************************/ + +static void g_armv7_cregister_finalize(GArmV7CRegister *reg) +{ + G_OBJECT_CLASS(g_armv7_cregister_parent_class)->finalize(G_OBJECT(reg)); + +} + + +/****************************************************************************** +* * +* Paramètres : index = indice du registre correspondant. * +* * +* Description : Crée une réprésentation de registre de co-processeur ARMv7. * +* * +* Retour : Adresse de la structure mise en place. * +* * +* Remarques : - * +* * +******************************************************************************/ + +GArmV7CRegister *g_armv7_cregister_new(uint8_t index) +{ + GArmV7CRegister *result; /* Structure à retourner */ + + result = g_object_new(G_TYPE_ARMV7_CREGISTER, NULL); + + G_ARM_REGISTER(result)->index = index; + + return result; + +} + + +/****************************************************************************** +* * +* Paramètres : reg = registre à transcrire. * +* line = ligne tampon où imprimer l'opérande donné. * +* syntax = type de représentation demandée. * +* * +* Description : Traduit un registre en version humainement lisible. * +* * +* Retour : - * +* * +* Remarques : - * +* * +******************************************************************************/ + +static void g_armv7_cregister_print(const GArmV7CRegister *reg, GBufferLine *line, AsmSyntax syntax) +{ + char key[MAX_REGNAME_LEN]; /* Mot clef principal */ + size_t klen; /* Taille de ce mot clef */ + + switch (G_ARM_REGISTER(reg)->index) + { + case 0 ... 15: + klen = snprintf(key, MAX_REGNAME_LEN, "c%hhu", G_ARM_REGISTER(reg)->index); + break; + default: + klen = snprintf(key, MAX_REGNAME_LEN, "c??"); + break; + } + + g_buffer_line_append_text(line, BLC_ASSEMBLY, key, klen, RTT_REGISTER, NULL); + +} diff --git a/plugins/arm/v7/cregister.h b/plugins/arm/v7/cregister.h new file mode 100644 index 0000000..d6c2c63 --- /dev/null +++ b/plugins/arm/v7/cregister.h @@ -0,0 +1,56 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * cregisters.h - prototypes pour les aides auxiliaires relatives aux registres de co-processeur ARMv7 + * + * Copyright (C) 2016-2017 Cyrille Bagard + * + * This file is part of Chrysalide. + * + * Chrysalide is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Chrysalide is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Foobar. If not, see . + */ + + +#ifndef _PLUGINS_ARM_V7_CREGISTER_H +#define _PLUGINS_ARM_V7_CREGISTER_H + + +#include +#include + + + +#define G_TYPE_ARMV7_CREGISTER g_armv7_cregister_get_type() +#define G_ARMV7_CREGISTER(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), g_armv7_cregister_get_type(), GArmV7CRegister)) +#define G_IS_ARMV7_CREGISTER(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), g_armv7_cregister_get_type())) +#define G_ARMV7_CREGISTER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), G_TYPE_ARMV7_CREGISTER, GArmV7CRegisterClass)) +#define G_IS_ARMV7_CREGISTER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), G_TYPE_ARMV7_CREGISTER)) +#define G_ARMV7_CREGISTER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), G_TYPE_ARMV7_CREGISTER, GArmV7CRegisterClass)) + + +/* Représentation d'un registre de co-processeur ARMv7 (instance) */ +typedef struct _GArmV7CRegister GArmV7CRegister; + +/* Représentation d'un registre de co-processeur ARMv7 (classe) */ +typedef struct _GArmV7CRegisterClass GArmV7CRegisterClass; + + +/* Indique le type défini pour une représentation d'un registre de co-processeur ARMv7. */ +GType g_armv7_cregister_get_type(void); + +/* Crée une réprésentation de registre de co-processeur ARMv7. */ +GArmV7CRegister *g_armv7_cregister_new(uint8_t); + + + +#endif /* _PLUGINS_ARM_V7_CREGISTER_H */ diff --git a/plugins/arm/v7/fetch.c b/plugins/arm/v7/fetch.c new file mode 100644 index 0000000..005a48d --- /dev/null +++ b/plugins/arm/v7/fetch.c @@ -0,0 +1,521 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * fetch.c - ajouts de sauts à traiter durant la phase de désassemblage + * + * Copyright (C) 2015-2017 Cyrille Bagard + * + * This file is part of Chrysalide. + * + * Chrysalide is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Chrysalide is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Foobar. If not, see . + */ + + +#include "fetch.h" + + +#include +#include + + +#include +#include +#include +#include + + +#include "operands/offset.h" +#include "../register.h" + + + +/****************************************************************************** +* * +* Paramètres : instr = instruction ARMv7 à traiter. * +* proc = représentation de l'architecture utilisée. * +* context = contexte associé à la phase de désassemblage. * +* format = acès aux données du binaire d'origine. * +* iset = type de jeu d'instructions courant à faire suivre. * +* * +* Description : Complète un désassemblage accompli pour une instruction. * +* * +* Retour : - * +* * +* Remarques : - * +* * +******************************************************************************/ + +void help_fetching_with_instruction_b_with_orig(GArchInstruction *instr, GArchProcessor *proc, GArmV7Context *context, GExeFormat *format, ArmV7InstrSet iset) +{ + const mrange_t *range; /* Emplacementt d'instruction */ + virt_t pc; /* Position dans l'exécution */ + GImmOperand *op; /* Opérande numérique en place */ + int32_t offset; /* Décallage encodé en dur */ + virt_t target; /* Adresse virtuelle visée */ + + range = g_arch_instruction_get_range(instr); + + pc = get_virt_addr(get_mrange_addr(range)); + + + + + switch (iset) + { + case AV7IS_ARM: + pc += 8; + break; + case AV7IS_THUMB: + pc += 4; + break; + default: + assert(0); + break; + } + + + + //pc += get_mrange_length(range); + + op = G_IMM_OPERAND(g_arch_instruction_get_operand(instr, 0)); + + if (g_imm_operand_get_value(op, MDS_32_BITS_SIGNED, &offset)) + g_imm_operand_set_value(op, MDS_32_BITS_UNSIGNED, pc + offset); + + else assert(0); + + g_object_unref(G_OBJECT(op)); + + target = pc + offset; + + //g_armv7_context_define_encoding(context, target, iset); + g_proc_context_push_drop_point(G_PROC_CONTEXT(context), DPL_OTHER, target, iset); + +} + + +/****************************************************************************** +* * +* Paramètres : instr = instruction ARMv7 à traiter. * +* proc = représentation de l'architecture utilisée. * +* context = contexte associé à la phase de désassemblage. * +* format = acès aux données du binaire d'origine. * +* iset = type de jeu d'instructions courant à faire suivre. * +* * +* Description : Complète un désassemblage accompli pour une instruction. * +* * +* Retour : - * +* * +* Remarques : - * +* * +******************************************************************************/ + +void help_fetching_with_instruction_bl_with_orig(GArchInstruction *instr, GArchProcessor *proc, GArmV7Context *context, GExeFormat *format, ArmV7InstrSet iset) +{ + const mrange_t *range; /* Emplacementt d'instruction */ + virt_t pc; /* Position dans l'exécution */ + GImmOperand *op; /* Opérande numérique en place */ + int32_t offset; /* Décallage encodé en dur */ + virt_t target; /* Adresse virtuelle visée */ + + range = g_arch_instruction_get_range(instr); + + pc = get_virt_addr(get_mrange_addr(range)); + + /** + * Qu'on se trouve en mode Thumb ou ARM, l'instruction + * ne peut qu'être encodée sur 4 octets. + */ + + assert(get_mrange_length(range) == 4); + + switch (iset) + { + case AV7IS_ARM: + pc += 8; + break; + case AV7IS_THUMB: + pc += 4; + break; + default: + assert(0); + break; + } + + op = G_IMM_OPERAND(g_arch_instruction_get_operand(instr, 0)); + + if (g_imm_operand_get_value(op, MDS_32_BITS_SIGNED, &offset)) + g_imm_operand_set_value(op, MDS_32_BITS_UNSIGNED, pc + offset); + + else assert(0); + + g_object_unref(G_OBJECT(op)); + + target = pc + offset; + + //g_armv7_context_define_encoding(context, target, iset); + g_proc_context_push_drop_point(G_PROC_CONTEXT(context), DPL_OTHER, target, iset); + +} + + +/****************************************************************************** +* * +* Paramètres : instr = instruction ARMv7 à traiter. * +* proc = représentation de l'architecture utilisée. * +* context = contexte associé à la phase de désassemblage. * +* format = acès aux données du binaire d'origine. * +* iset = type de jeu d'instructions courant à inverser. * +* * +* Description : Complète un désassemblage accompli pour une instruction. * +* * +* Retour : - * +* * +* Remarques : - * +* * +******************************************************************************/ + +void help_fetching_with_instruction_blx_with_dest(GArchInstruction *instr, GArchProcessor *proc, GArmV7Context *context, GExeFormat *format, ArmV7InstrSet iset) +{ + const mrange_t *range; /* Emplacementt d'instruction */ + virt_t pc; /* Position dans l'exécution */ + GImmOperand *op; /* Opérande numérique en place */ + int32_t offset; /* Décallage encodé en dur */ + virt_t target; /* Adresse virtuelle visée */ + + range = g_arch_instruction_get_range(instr); + + pc = get_virt_addr(get_mrange_addr(range)); + + /** + * Qu'on se trouve en mode Thumb ou ARM, l'instruction + * ne peut qu'être encodée sur 4 octets. + */ + + assert(get_mrange_length(range) == 4); + + pc += 4; + pc -= pc % 4; + + op = G_IMM_OPERAND(g_arch_instruction_get_operand(instr, 0)); + + if (g_imm_operand_get_value(op, MDS_32_BITS_SIGNED, &offset)) + g_imm_operand_set_value(op, MDS_32_BITS_UNSIGNED, pc + offset); + + else assert(0); + + g_object_unref(G_OBJECT(op)); + + target = pc + offset; + + //g_armv7_context_define_encoding(context, target, iset); + g_proc_context_push_drop_point(G_PROC_CONTEXT(context), DPL_OTHER, target, iset); + +} + + +/****************************************************************************** +* * +* Paramètres : instr = instruction ARMv7 à traiter. * +* proc = représentation de l'architecture utilisée. * +* context = contexte associé à la phase de désassemblage. * +* format = acès aux données du binaire d'origine. * +* iset = type de jeu d'instructions courant à faire suivre. * +* * +* Description : Complète un désassemblage accompli pour une instruction. * +* * +* Retour : - * +* * +* Remarques : - * +* * +******************************************************************************/ + +void help_fetching_with_instruction_bx_with_orig(GArchInstruction *instr, GArchProcessor *proc, GArmV7Context *context, GExeFormat *format, ArmV7InstrSet iset) +{ + GArchOperand *op; /* Opérande numérique en place */ + GArmRegister *reg; /* Registre matériel manipulé */ + bool is_pc; /* Nature de ce même registre */ + const mrange_t *range; /* Emplacementt d'instruction */ + virt_t pc; /* Position dans l'exécution */ + + op = g_arch_instruction_get_operand(instr, 0); + assert(G_IS_REGISTER_OPERAND(op)); + + /** + * On ne sait agir qu'avec le seul contenu facilement prédictible : pc ! + */ + + reg = G_ARM_REGISTER(g_register_operand_get_register(G_REGISTER_OPERAND(op))); + + is_pc = (g_arm_register_get_index(reg) == 15 /* pc */); + + g_object_unref(G_OBJECT(reg)); + + if (!is_pc) goto hfwibwo_no_pc; + + /** + * On bascule alors le mode de décodage à cette adresse... + */ + + range = g_arch_instruction_get_range(instr); + + pc = get_virt_addr(get_mrange_addr(range)); + + switch (iset) + { + case AV7IS_ARM: + pc += 8; + //g_armv7_context_define_encoding(context, + g_proc_context_push_drop_point(G_PROC_CONTEXT(context), DPL_OTHER, pc, AV7IS_THUMB); + break; + case AV7IS_THUMB: + pc += 4; + //g_armv7_context_define_encoding(context, + g_proc_context_push_drop_point(G_PROC_CONTEXT(context), DPL_OTHER, pc, AV7IS_ARM); + break; + default: + assert(0); + break; + } + + hfwibwo_no_pc: + + g_object_unref(G_OBJECT(op)); + +} + + +/****************************************************************************** +* * +* Paramètres : instr = instruction ARMv7 à traiter. * +* proc = représentation de l'architecture utilisée. * +* context = contexte associé à la phase de désassemblage. * +* format = acès aux données du binaire d'origine. * +* * +* Description : Complète un désassemblage accompli pour une instruction. * +* * +* Retour : - * +* * +* Remarques : - * +* * +******************************************************************************/ + +void help_fetching_with_instruction_cb_n_z(GArchInstruction *instr, GArchProcessor *proc, GArmV7Context *context, GExeFormat *format) +{ + const mrange_t *range; /* Emplacementt d'instruction */ + virt_t pc; /* Position dans l'exécution */ + GImmOperand *op; /* Opérande numérique en place */ + uint32_t offset; /* Décallage encodé en dur */ + virt_t target; /* Adresse virtuelle visée */ + + range = g_arch_instruction_get_range(instr); + + pc = get_virt_addr(get_mrange_addr(range)); + + /** + * En mode Thumb, pc a pour valeur l'adresse courante plus 4. + */ + + pc += 4; + + op = G_IMM_OPERAND(g_arch_instruction_get_operand(instr, 1)); + + if (g_imm_operand_get_value(op, MDS_32_BITS_UNSIGNED, &offset)) + g_imm_operand_set_value(op, MDS_32_BITS_UNSIGNED, pc + offset); + + else assert(0); + + g_object_unref(G_OBJECT(op)); + + target = pc + offset; + + //g_armv7_context_define_encoding(context, target, AV7IS_THUMB); + g_proc_context_push_drop_point(G_PROC_CONTEXT(context), DPL_OTHER, target, AV7IS_THUMB); + +} + + +/****************************************************************************** +* * +* Paramètres : instr = instruction ARMv7 à traiter. * +* proc = représentation de l'architecture utilisée. * +* context = contexte associé à la phase de désassemblage. * +* format = acès aux données du binaire d'origine. * +* iset = type de jeu d'instructions courant. * +* * +* Description : Complète un désassemblage accompli pour une instruction. * +* * +* Retour : - * +* * +* Remarques : - * +* * +******************************************************************************/ + +void help_fetching_with_instruction_ldr_literal_with_orig(GArchInstruction *instr, GArchProcessor *proc, GArmV7Context *context, GExeFormat *format, ArmV7InstrSet iset) +{ + const mrange_t *range; /* Emplacementt d'instruction */ + phys_t phys_pc; /* Position dans l'exécution */ + GArchOperand *op; /* Opérande de surcouche */ + uint32_t offset; /* Décallage encodé en dur */ + bool ret; /* Bilan d'une récupération */ + off_t val_offset; /* Position de valeur à lire */ + vmpa2t loaded_addr; /* Adresse de valeur chargée */ + mrange_t loaded_range; /* Espace de chargement */ + GBinContent *content; /* Contenu binaire à relire */ + uint32_t target; /* Adresse virtuelle visée */ + vmpa2t pos; /* Tête de lecture de valeur */ + VMPA_BUFFER(loc); /* Adresse au format texte */ + GPreloadInfo *info; /* Informations préchargées */ + GArchInstruction *loaded; /* Instruction de valeur */ + bool inserted; /* Bilan d'une insertion */ + char *desc; /* Description d'accompagnement*/ + GDbComment *comment; /* Définition de commentaire */ + GArchOperand *new; /* Instruction de ciblage */ + + /* Récupération de l'adresse visée par le chargement */ + + range = g_arch_instruction_get_range(instr); + + phys_pc = get_phy_addr(get_mrange_addr(range)); + + phys_pc &= ~3; + //phys_pc = (phys_pc + 3) & ~3; + + switch (iset) + { + case AV7IS_ARM: + phys_pc += 8; + break; + case AV7IS_THUMB: + phys_pc += 4; + break; + default: + assert(0); + break; + } + + g_arch_instruction_lock_operands(instr); + + op = _g_arch_instruction_get_operand(instr, 1); + assert(G_IS_IMM_OPERAND(op)); + + ret = g_imm_operand_get_value(G_IMM_OPERAND(op), MDS_32_BITS_UNSIGNED, &offset); + if (!ret) + { + assert(0); + g_object_unref(G_OBJECT(op)); + g_arch_instruction_unlock_operands(instr); + return; + } + + /* Transformations et conservation d'une position de chargement */ + + val_offset = phys_pc + offset; + + if (!g_exe_format_translate_offset_into_vmpa(format, val_offset, &loaded_addr)) + { + assert(0); + g_object_unref(G_OBJECT(op)); + g_arch_instruction_unlock_operands(instr); + return; + } + + init_mrange(&loaded_range, &loaded_addr, 4); + + /* Lecture de la valeur vers laquelle renvoyer */ + + content = g_binary_format_get_content(G_BIN_FORMAT(format)); + + copy_vmpa(&pos, &loaded_addr); + + ret = g_binary_content_read_u32(content, &pos, SRE_LITTLE /* FIXME */, &target); + g_object_unref(G_OBJECT(content)); + + if (!ret) + { + g_object_unref(G_OBJECT(op)); + g_arch_instruction_unlock_operands(instr); + return; + } + + /* Réalise l'intégration de la valeur chargée */ + + copy_vmpa(&pos, &loaded_addr); + + info = G_PRELOAD_INFO(context); + + loaded = g_raw_instruction_new_from_value(&pos, MDS_32_BITS_UNSIGNED, target); + + inserted = g_preload_info_add_instruction(info, loaded); + + if (inserted) + { + /* Commentaire associé */ + + vmpa2_virt_to_string(get_mrange_addr(range), MDS_32_BITS, loc, NULL); + asprintf(&desc, _("Value used @ %s"), loc); + + g_preload_info_lock_comments(info); + + comment = _g_preload_info_find_comment_at(info, &loaded_addr); + + if (comment != NULL) + { + g_db_comment_add_static_text(comment, "\n"); + g_db_comment_add_dynamic_text(comment, desc); + } + + else + { + comment = g_db_comment_new_inlined(&loaded_addr, BLF_HAS_CODE, false); + g_db_item_set_volatile(G_DB_ITEM(comment), true); + + g_db_comment_add_dynamic_text(comment, desc); + + _g_preload_info_add_comment(info, comment); + + } + + g_preload_info_unlock_comments(info); + + } + + /* Mise à jour de l'affichage et conclusion */ + + new = g_imm_operand_new_from_value(MDS_32_BITS_UNSIGNED, target); + _g_arch_instruction_replace_operand(instr, op, new); + + g_object_unref(G_OBJECT(op)); + g_arch_instruction_unlock_operands(instr); + + + + //exit(0); + + + + //target = pc + offset; + + + if (target & 0x1) + iset = AV7IS_THUMB; + //else + // iset = AV7IS_ARM; + + //g_armv7_context_define_encoding(context, target, AV7IS_THUMB); + g_proc_context_push_drop_point(G_PROC_CONTEXT(context), DPL_OTHER, target, iset); + + + //exit(0); + +} diff --git a/plugins/arm/v7/fetch.h b/plugins/arm/v7/fetch.h new file mode 100644 index 0000000..52777d7 --- /dev/null +++ b/plugins/arm/v7/fetch.h @@ -0,0 +1,114 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * fetch.h - prototypes pour les ajouts de sauts à traiter durant la phase de désassemblage + * + * Copyright (C) 2015-2017 Cyrille Bagard + * + * This file is part of Chrysalide. + * + * Chrysalide is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Chrysalide is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Foobar. If not, see . + */ + + +#ifndef _PLUGINS_ARM_V7_FETCH_H +#define _PLUGINS_ARM_V7_FETCH_H + + +#include + + +#include "context.h" + + + +/* Complète un désassemblage accompli pour une instruction. */ +void help_fetching_with_instruction_b_with_orig(GArchInstruction *, GArchProcessor *, GArmV7Context *, GExeFormat *, ArmV7InstrSet); + + +static inline void help_fetching_with_instruction_b_from_arm(GArchInstruction *ins, GArchProcessor *proc, GArmV7Context *ctx, GExeFormat *fmt) +{ + help_fetching_with_instruction_b_with_orig(ins, proc, ctx, fmt, AV7IS_ARM); +} + +static inline void help_fetching_with_instruction_b_from_thumb(GArchInstruction *ins, GArchProcessor *proc, GArmV7Context *ctx, GExeFormat *fmt) +{ + help_fetching_with_instruction_b_with_orig(ins, proc, ctx, fmt, AV7IS_THUMB); +} + + +/* Complète un désassemblage accompli pour une instruction. */ +void help_fetching_with_instruction_bl_with_orig(GArchInstruction *, GArchProcessor *, GArmV7Context *, GExeFormat *, ArmV7InstrSet); + + +static inline void help_fetching_with_instruction_bl_from_arm(GArchInstruction *ins, GArchProcessor *proc, GArmV7Context *ctx, GExeFormat *fmt) +{ + help_fetching_with_instruction_bl_with_orig(ins, proc, ctx, fmt, AV7IS_ARM); +} + +static inline void help_fetching_with_instruction_bl_from_thumb(GArchInstruction *ins, GArchProcessor *proc, GArmV7Context *ctx, GExeFormat *fmt) +{ + help_fetching_with_instruction_bl_with_orig(ins, proc, ctx, fmt, AV7IS_THUMB); +} + + +/* Complète un désassemblage accompli pour une instruction. */ +void help_fetching_with_instruction_blx_with_dest(GArchInstruction *, GArchProcessor *, GArmV7Context *, GExeFormat *, ArmV7InstrSet); + + +static inline void help_fetching_with_instruction_blx_from_arm(GArchInstruction *ins, GArchProcessor *proc, GArmV7Context *ctx, GExeFormat *fmt) +{ + help_fetching_with_instruction_blx_with_dest(ins, proc, ctx, fmt, AV7IS_THUMB); +} + +static inline void help_fetching_with_instruction_blx_from_thumb(GArchInstruction *ins, GArchProcessor *proc, GArmV7Context *ctx, GExeFormat *fmt) +{ + help_fetching_with_instruction_blx_with_dest(ins, proc, ctx, fmt, AV7IS_ARM); +} + + +/* Complète un désassemblage accompli pour une instruction. */ +void help_fetching_with_instruction_bx_with_orig(GArchInstruction *, GArchProcessor *, GArmV7Context *, GExeFormat *, ArmV7InstrSet); + + +static inline void help_fetching_with_instruction_bx_from_arm(GArchInstruction *ins, GArchProcessor *proc, GArmV7Context *ctx, GExeFormat *fmt) +{ + help_fetching_with_instruction_bx_with_orig(ins, proc, ctx, fmt, AV7IS_ARM); +} + +static inline void help_fetching_with_instruction_bx_from_thumb(GArchInstruction *ins, GArchProcessor *proc, GArmV7Context *ctx, GExeFormat *fmt) +{ + help_fetching_with_instruction_bx_with_orig(ins, proc, ctx, fmt, AV7IS_THUMB); +} + + +/* Complète un désassemblage accompli pour une instruction. */ +void help_fetching_with_instruction_cb_n_z(GArchInstruction *, GArchProcessor *, GArmV7Context *, GExeFormat *); + +/* Complète un désassemblage accompli pour une instruction. */ +void help_fetching_with_instruction_ldr_literal_with_orig(GArchInstruction *, GArchProcessor *, GArmV7Context *, GExeFormat *, ArmV7InstrSet); + + +static inline void help_fetching_with_instruction_ldr_literal_from_arm(GArchInstruction *ins, GArchProcessor *proc, GArmV7Context *ctx, GExeFormat *fmt) +{ + help_fetching_with_instruction_ldr_literal_with_orig(ins, proc, ctx, fmt, AV7IS_ARM); +} + +static inline void help_fetching_with_instruction_ldr_literal_from_thumb(GArchInstruction *ins, GArchProcessor *proc, GArmV7Context *ctx, GExeFormat *fmt) +{ + help_fetching_with_instruction_ldr_literal_with_orig(ins, proc, ctx, fmt, AV7IS_THUMB); +} + + + +#endif /* _PLUGINS_ARM_V7_FETCH_H */ diff --git a/plugins/arm/v7/helpers.c b/plugins/arm/v7/helpers.c new file mode 100644 index 0000000..03786c0 --- /dev/null +++ b/plugins/arm/v7/helpers.c @@ -0,0 +1,277 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * helpers.c - aide à la mise en place des opérandes ARMv7 + * + * Copyright (C) 2014-2017 Cyrille Bagard + * + * This file is part of Chrysalide. + * + * Chrysalide is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Chrysalide is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Foobar. If not, see . + */ + + +#include "helpers.h" + + +#include +#include +#include +#include + + +#include "register.h" + + + +/****************************************************************************** +* * +* Paramètres : x = valeur sur 32 bits maximum à traiter. * +* shift = nombre de décallages visés. * +* * +* Description : Effectue une rotation vers la droit d'une valeur. * +* * +* Retour : Adresse de la structure mise en place. * +* * +* Remarques : Correspond à la pseudo fonction 'ROR_C'. * +* * +******************************************************************************/ + +GArchOperand *ror_armv7_imm(uint32_t x, unsigned int shift) +{ + GArchOperand *result; /* Opérande à faire remonter */ + uint32_t val32; /* Valeur sur 32 bits */ + + shift %= 32; + + val32 = (x >> shift) | (x << (32 - shift)); + + result = g_imm_operand_new_from_value(MDS_32_BITS_UNSIGNED, val32); + + return result; + +} + + + + + + + + + + + + +#if 0 + +// Shift_C() +// ========= +(bits(N), bit) Shift_C(bits(N) value, SRType type, integer amount, bit carry_in) +assert !(type == SRType_RRX && amount != 1); +if amount == 0 then +(result, carry_out) = (value, carry_in); +else +case type of + +when SRType_LSL +(result, carry_out) = LSL_C(value, amount); + +when SRType_LSR +(result, carry_out) + +when SRType_ASR +(result, carry_out) + +when SRType_ROR +(result, carry_out) + +when SRType_RRX +(result, carry_out) += LSR_C(value, amount); += ASR_C(value, amount); += ROR_C(value, amount); += RRX_C(value, carry_in); + +#endif + + + + + + +/****************************************************************************** +* * +* Paramètres : value = valeur sur 32 bits maximum à traiter. * +* topbit = valeur du bit de poids fort manipulé. * +* size = taille de la valeur finale à constituer. * +* * +* Description : Crée un opérande de valeur immédiate avec extension de signe.* +* * +* Retour : Adresse de la structure mise en place. * +* * +* Remarques : - * +* * +******************************************************************************/ + +GArchOperand *sign_extend_armv7_imm(uint32_t value, bool topbit, unsigned int size) +{ + GArchOperand *result; /* Opérande à faire remonter */ + unsigned int msb; /* Position du premier bit à 1 */ + MemoryDataSize mds; /* Conversion de la taille */ + uint32_t val4; /* Valeur sur 4 bits */ + uint32_t val8; /* Valeur sur 8 bits */ + uint32_t val16; /* Valeur sur 16 bits */ + uint32_t val32; /* Valeur sur 32 bits */ + unsigned int i; /* Boucle de parcours */ + + result = NULL; + + topbit &= msb_32(value, &msb); + + switch (size) + { + +#define SIGN_EXTEND_CASE(sz) \ + case sz: \ + mds = MDS_ ## sz ## _BITS_SIGNED; \ + val ## sz = value; \ + if (topbit) \ + for (i = msb; i < sz; i++) \ + val ## sz |= (1 << i); \ + result = g_imm_operand_new_from_value(mds, val ## sz); \ + break; + + SIGN_EXTEND_CASE(4); + SIGN_EXTEND_CASE(8); + SIGN_EXTEND_CASE(16); + SIGN_EXTEND_CASE(32); + + } + + return result; + +} + + +/****************************************************************************** +* * +* Paramètres : value = valeur sur 32 bits maximum à traiter. * +* * +* Description : Etend une valeur immédiate en mode 'Thumb' ARMv7. * +* * +* Retour : Adresse de la structure mise en place. * +* * +* Remarques : - * +* * +******************************************************************************/ + +GArchOperand *thumb_expand_armv7_imm(uint32_t value) +{ + GArchOperand *result; /* Opérande à faire remonter */ + uint8_t byte; /* Octet à reproduire */ + uint32_t val32; /* Valeur sur 32 bits */ + uint32_t unrotated; /* Transformation à décaller */ + + result = NULL; + + if (((value >> 10) & b11) == b00) + { + byte = value & 0xff; + + switch ((value >> 8) & b11) + { + case b00: + result = zero_extend_armv7_imm(byte, 32); + break; + + case b01: + if (byte == 0) return NULL; + val32 = byte << 16 | byte; + result = g_imm_operand_new_from_value(MDS_32_BITS_UNSIGNED, val32); + break; + + case b10: + if (byte == 0) return NULL; + val32 = byte << 24 | byte << 8; + result = g_imm_operand_new_from_value(MDS_32_BITS_UNSIGNED, val32); + break; + + case b11: + if (byte == 0) return NULL; + val32 = byte << 24 | byte << 16 | byte << 8 | byte; + result = g_imm_operand_new_from_value(MDS_32_BITS_UNSIGNED, val32); + break; + + } + + } + else + { + unrotated = 1 << 7 | (value & 0x3f); + result = ror_armv7_imm(unrotated, (value >> 7) & 0x1f); + } + + return result; + +} + + + + + + +/****************************************************************************** +* * +* Paramètres : value = valeur sur 32 bits maximum à traiter. * +* size = taille de la valeur finale à constituer. * +* * +* Description : Réalise un simple transtypage de valeur entière. * +* * +* Retour : Adresse de la structure mise en place. * +* * +* Remarques : Correspond à la pseudo fonction 'ZeroExtend'. * +* * +******************************************************************************/ + +GArchOperand *zero_extend_armv7_imm(uint32_t value, unsigned int size) +{ + GArchOperand *result; /* Opérande à faire remonter */ + MemoryDataSize mds; /* Conversion de la taille */ + uint32_t val4; /* Valeur sur 4 bits */ + uint32_t val8; /* Valeur sur 8 bits */ + uint32_t val16; /* Valeur sur 16 bits */ + uint32_t val32; /* Valeur sur 32 bits */ + + result = NULL; + + switch (size) + { + +#define ZERO_EXTEND_CASE(sz) \ + case sz: \ + mds = MDS_ ## sz ## _BITS_UNSIGNED; \ + val ## sz = value; \ + result = g_imm_operand_new_from_value(mds, val ## sz); \ + break; + + ZERO_EXTEND_CASE(4); + ZERO_EXTEND_CASE(8); + ZERO_EXTEND_CASE(16); + ZERO_EXTEND_CASE(32); + + } + + return result; + +} diff --git a/plugins/arm/v7/helpers.h b/plugins/arm/v7/helpers.h new file mode 100644 index 0000000..94b85f9 --- /dev/null +++ b/plugins/arm/v7/helpers.h @@ -0,0 +1,441 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * helpers.h - prototypes pour l'aide à la mise en place des opérandes ARMv7 + * + * Copyright (C) 2014-2017 Cyrille Bagard + * + * This file is part of Chrysalide. + * + * Chrysalide is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Chrysalide is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Foobar. If not, see . + */ + + +#ifndef _PLUGINS_ARM_V7_HELPERS_H +#define _PLUGINS_ARM_V7_HELPERS_H + + +#include + + +#include "cregister.h" +#include "pseudo.h" +#include "operands/coproc.h" +#include "operands/estate.h" +#include "operands/limitation.h" +#include "operands/maccess.h" +#include "operands/offset.h" +#include "operands/reglist.h" +#include "operands/rotation.h" +#include "operands/shift.h" +#include "../register.h" + + + + + +#define BarrierLimitation(opt) \ + ({ \ + GArchOperand *__result; \ + __result = g_armv7_limitation_operand_new(opt); \ + __result; \ + }) + + +#define BitDiff(msb, lsb) \ + ({ \ + GArchOperand *__result; \ + uint32_t __width; \ + __width = g_imm_operand_get_raw_value(G_IMM_OPERAND(msb)); \ + __width -= g_imm_operand_get_raw_value(G_IMM_OPERAND(lsb)); \ + __width += 1; \ + __result = g_imm_operand_new_from_value(MDS_32_BITS_UNSIGNED, __width); \ + __result; \ + }) + + +#define BuildImm8(val) \ + ({ \ + GArchOperand *__result; \ + __result = g_imm_operand_new_from_value(MDS_8_BITS_UNSIGNED, (uint8_t)val); \ + __result; \ + }) + + +#define BuildImm16(val) \ + ({ \ + GArchOperand *__result; \ + __result = g_imm_operand_new_from_value(MDS_16_BITS_UNSIGNED, (uint16_t)val); \ + __result; \ + }) + + +#define CoProcessor(idx) \ + ({ \ + GArchOperand *__result; \ + __result = g_armv7_coproc_operand_new(idx); \ + __result; \ + }) + + +#define CRegister(idx) \ + ({ \ + GArchOperand *__result; \ + GArmV7CRegister *__reg; \ + __reg = g_armv7_cregister_new(idx); \ + if (__reg == NULL) \ + __result = NULL; \ + else \ + __result = g_register_operand_new(G_ARCH_REGISTER(__reg)); \ + __result; \ + }) + + +#define IncWidth(widthm1) \ + ({ \ + GArchOperand *__result; \ + uint32_t __width; \ + __width = widthm1 + 1; \ + __result = g_imm_operand_new_from_value(MDS_32_BITS_UNSIGNED, __width); \ + __result; \ + }) + + +#define DecodeImmShift(type, imm5) \ + ({ \ + GArchOperand *__result; \ + SRType __shift_t; \ + uint32_t __shift_n; \ + GArchOperand *__op_n; \ + if (!armv7_decode_imm_shift(type, imm5, &__shift_t, &__shift_n)) \ + __result = NULL; \ + else \ + { \ + __op_n = g_imm_operand_new_from_value(MDS_32_BITS_UNSIGNED, __shift_n); \ + __result = g_armv7_shift_operand_new(__shift_t, __op_n); \ + } \ + __result; \ + }) + + +#define EndianState(big) \ + ({ \ + GArchOperand *__result; \ + __result = g_armv7_endian_operand_new(big); \ + __result; \ + }) + + +#define MakeMemoryAccess(base, off, shift, index, add, wback) \ + ({ \ + GArchOperand *__result; \ + GArchOperand *__offset; \ + if (off != NULL) \ + __offset = g_armv7_offset_operand_new(add, off); \ + else \ + __offset = NULL; \ + __result = g_armv7_maccess_operand_new(base, __offset, shift, index, wback); \ + __result; \ + }) + + +#define NextRegister(prev) \ + ({ \ + GRegisterOperand *__prev_op; \ + GArchRegister *__reg; \ + uint8_t __id; \ + __prev_op = G_REGISTER_OPERAND(prev); \ + __reg = g_register_operand_get_register(__prev_op); \ + __id = g_arm_register_get_index(G_ARM_REGISTER(__reg)); \ + Register(__id + 1); \ + }) + + +#define RawValue(val) \ + ({ \ + GArchOperand *__result; \ + __result = g_imm_operand_new_from_value(MDS_32_BITS_UNSIGNED, (uint32_t)val); \ + __result; \ + }) + + +#define Register(idx) \ + ({ \ + GArchOperand *__result; \ + GArmV7Register *__reg; \ + __reg = g_armv7_register_new(idx); \ + if (__reg == NULL) \ + __result = NULL; \ + else \ + __result = g_register_operand_new(G_ARCH_REGISTER(__reg)); \ + __result; \ + }) + + +#define RegisterShift(shift_t, rs) \ + ({ \ + GArchOperand *__result; \ + GArchOperand *__reg; \ + __reg = Register(rs); \ + if (__reg == NULL) \ + __result = NULL; \ + else \ + __result = g_armv7_shift_operand_new(shift_t, __reg); \ + __result; \ + }) + + +#define Rotation(val5) \ + ({ \ + GArchOperand *__result; \ + uint8_t __rot; \ + GArchOperand *__rot_op; \ + __rot = val5; \ + __rot_op = g_imm_operand_new_from_value(MDS_8_BITS_UNSIGNED, __rot); \ + __result = g_armv7_rotation_operand_new(__rot_op); \ + if (__result == NULL) \ + g_object_unref(G_OBJECT(__rot_op)); \ + __result; \ + }) + + +#define UInt(val) \ + ({ \ + GArchOperand *__result; \ + __result = g_imm_operand_new_from_value(MDS_8_BITS_UNSIGNED, (uint8_t)val); \ + __result; \ + }) + + + + +//#define DecodeImmShift(raw_type, raw_imm5); +//g_armv7_shift_operand_new(SRType type, GArchOperand *value) + + + +//#define MakeMemoryAccess(base, off, shift, index, add, wback) NULL + +//g_armv7_maccess_operand_new(GArchOperand *base, GArchOperand *offset, GArchOperand *shift, bool indexed, bool writeb) + +//g_armv7_offset_operand_new(add, off) + + + + +//////////////////// + +#define Imm16(imm16) \ + ({ \ + GArchOperand *__result; \ + __result = g_imm_operand_new_from_value(MDS_16_BITS_UNSIGNED, (uint16_t)imm16); \ + __result; \ + }) + +#define ARMExpandImm_C(imm12, c) \ + ({ \ + GArchOperand *__result; \ + uint32_t __val; \ + if (armv7_arm_expand_imm_c(imm12, (bool []) { c }, &__val)) \ + __result = g_imm_operand_new_from_value(MDS_32_BITS_UNSIGNED, __val); \ + else \ + __result = NULL; \ + __result; \ + }) + +#define ARMExpandImm(imm12) \ + ({ \ + GArchOperand *__result; \ + uint32_t __val; \ + if (armv7_arm_expand_imm(imm12, &__val)) \ + __result = g_imm_operand_new_from_value(MDS_32_BITS_UNSIGNED, __val); \ + else \ + __result = NULL; \ + __result; \ + }) + +#define ThumbExpandImm_C(imm12, c) \ + ({ \ + GArchOperand *__result; \ + uint32_t __val; \ + if (armv7_thumb_expand_imm_c(imm12, (bool []) { c }, &__val)) \ + __result = g_imm_operand_new_from_value(MDS_32_BITS_UNSIGNED, __val); \ + else \ + __result = NULL; \ + __result; \ + }) + +#define ThumbExpandImm(imm12) \ + ({ \ + GArchOperand *__result; \ + uint32_t __val; \ + if (armv7_thumb_expand_imm(imm12, &__val)) \ + __result = g_imm_operand_new_from_value(MDS_32_BITS_UNSIGNED, __val); \ + else \ + __result = NULL; \ + __result; \ + }) + + + + + + + +#define DecodeImmShiftValue(imm5) \ + ({ \ + GArchOperand *__result; \ + uint32_t __shift_n; \ + if (!armv7_decode_imm_shift(0, imm5, (SRType []) { 0 }, &__shift_n)) \ + __result = NULL; \ + else \ + __result = g_imm_operand_new_from_value(MDS_32_BITS_UNSIGNED, __shift_n); \ + __result; \ + }) + + +#if 0 +// DecodeRegShift() +// ================ +SRType DecodeRegShift(bits(2) type) +case type of +when '00' shift_t = SRType_LSL; +when '01' shift_t = SRType_LSR; +when '10' shift_t = SRType_ASR; +when '11' shift_t = SRType_ROR; +return shift_t; +#endif + + + +#define ZeroExtend(x, i) \ + ({ \ + MemoryDataSize __mds; \ + uint ## i ## _t __val; \ + __mds = MDS_ ## i ## _BITS_UNSIGNED; \ + __val = armv7_zero_extend(x, 0/**/, i); \ + g_imm_operand_new_from_value(__mds, __val); \ + }) + + + +#define Zeros(i) \ + ({ \ + MemoryDataSize __mds; \ + uint ## i ## _t __val; \ + __mds = MDS_ ## i ## _BITS_UNSIGNED; \ + __val = 0; \ + g_imm_operand_new_from_value(__mds, __val); \ + }) + + + + + + + + +/** + * Glue purement interne. + */ + + +#define MakeAccessOffset(add, off) \ + g_armv7_offset_operand_new(add, off) + + +#define MakeShiftedMemoryAccess(base, off, shift, wr) \ + g_armv7_maccess_operand_new(base, off, shift, wr) + + +#define _MakeMemoryAccess(base, off, wr) \ + MakeShiftedMemoryAccess(base, off, NULL, wr) + +/* +#define MakeMemoryAccess(base, off, add, wr) \ + ({ \ + GArchOperand *__off; \ + __off = MakeAccessOffset(add, off); \ + _MakeMemoryAccess(base, __off, wr); \ + }) +*/ + +#define MakeMemoryNotIndexed(base, wr) \ + _MakeMemoryAccess(base, NULL, wr) + + + + + + + + +// type == '10', pas 2 ! (FIXME) +#define FixedShift(type, imm5) \ + ({ \ + GArchOperand *__result; \ + uint32_t __shift_n; \ + __shift_n = imm5; \ + __result = g_imm_operand_new_from_value(MDS_32_BITS_UNSIGNED, __shift_n); \ + __result; \ + }) + + + + + +/** + * Glue purement interne pour les listes de registres. + */ + +#define RegistersList(mask) \ + ({ \ + GArchOperand *__result; \ + __result = g_armv7_reglist_operand_new(); \ + if (!g_armv7_reglist_load_registers(G_ARMV7_REGLIST_OPERAND(__result), mask)) \ + { \ + g_object_unref(G_OBJECT(__result)); \ + __result = NULL; \ + } \ + __result; \ + }) + + +#define ListFromRegister(regop) \ + ({ \ + GArchOperand *__result; \ + GArmV7Register *__reg; \ + __result = g_armv7_reglist_operand_new(); \ + __reg = G_ARMV7_REGISTER(regop); \ + g_armv7_reglist_add_register(G_ARMV7_REGLIST_OPERAND(__result), __reg); \ + __result; \ + }) + + + + +/* Effectue une rotation vers la droit d'une valeur. */ +GArchOperand *ror_armv7_imm(uint32_t, unsigned int); + +/* Crée un opérande de valeur immédiate avec extension de signe. */ +GArchOperand *sign_extend_armv7_imm(uint32_t, bool, unsigned int); + +/* Etend une valeur immédiate en mode 'Thumb' ARMv7. */ +GArchOperand *thumb_expand_armv7_imm(uint32_t); + +/* Réalise un simple transtypage de valeur entière. */ +GArchOperand *zero_extend_armv7_imm(uint32_t, unsigned int); + + + +#endif /* _PLUGINS_ARM_V7_HELPERS_H */ diff --git a/plugins/arm/v7/instruction.c b/plugins/arm/v7/instruction.c new file mode 100644 index 0000000..d9e4275 --- /dev/null +++ b/plugins/arm/v7/instruction.c @@ -0,0 +1,284 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * instruction.c - gestion des instructions ARMv7 + * + * Copyright (C) 2014-2017 Cyrille Bagard + * + * This file is part of Chrysalide. + * + * Chrysalide is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Chrysalide is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Foobar. If not, see . + */ + + +#include "instruction.h" + + +#include +#ifndef NDEBUG +# include +#endif + + +#include "../instruction-int.h" + + + +/* Définition d'une instruction d'architecture ARMv7 (instance) */ +struct _GArmV7Instruction +{ + GArmInstruction parent; /* Instance parente */ + + char encoding; /* Encodage de l'instruction */ + + bool setflags; /* Mise à jour des drapeaux */ + +}; + + +/* Définition d'une instruction d'architecture ARMv7 (classe) */ +struct _GArmV7InstructionClass +{ + GArmInstructionClass parent; /* Classe parente */ + +}; + + +/* Initialise la classe des instructions ARMv7. */ +static void g_armv7_instruction_class_init(GArmV7InstructionClass *); + +/* Initialise une instance d'instruction ARMv7. */ +static void g_armv7_instruction_init(GArmV7Instruction *); + +/* Supprime toutes les références externes. */ +static void g_armv7_instruction_dispose(GArmV7Instruction *); + +/* Procède à la libération totale de la mémoire. */ +static void g_armv7_instruction_finalize(GArmV7Instruction *); + +/* Indique l'encodage d'une instruction de façon détaillée. */ +static const char *g_armv7_instruction_get_encoding(const GArmV7Instruction *); + + +/* Indique le type défini pour une représentation d'une instruction ARMv7. */ +G_DEFINE_TYPE(GArmV7Instruction, g_armv7_instruction, G_TYPE_ARM_INSTRUCTION); + + +/****************************************************************************** +* * +* Paramètres : klass = classe à initialiser. * +* * +* Description : Initialise la classe des instructions ARMv7. * +* * +* Retour : - * +* * +* Remarques : - * +* * +******************************************************************************/ + +static void g_armv7_instruction_class_init(GArmV7InstructionClass *klass) +{ + GObjectClass *object_class; /* Autre version de la classe */ + GArchInstructionClass *instr; /* Encore une autre vision... */ + + object_class = G_OBJECT_CLASS(klass); + instr = G_ARCH_INSTRUCTION_CLASS(klass); + + object_class->dispose = (GObjectFinalizeFunc/* ! */)g_armv7_instruction_dispose; + object_class->finalize = (GObjectFinalizeFunc)g_armv7_instruction_finalize; + + instr->get_encoding = (get_instruction_encoding_fc)g_armv7_instruction_get_encoding; + +} + + +/****************************************************************************** +* * +* Paramètres : instr = instance à initialiser. * +* * +* Description : Initialise une instance d'instruction ARMv7. * +* * +* Retour : - * +* * +* Remarques : - * +* * +******************************************************************************/ + +static void g_armv7_instruction_init(GArmV7Instruction *instr) +{ + +} + + +/****************************************************************************** +* * +* Paramètres : instr = instance d'objet GLib à traiter. * +* * +* Description : Supprime toutes les références externes. * +* * +* Retour : - * +* * +* Remarques : - * +* * +******************************************************************************/ + +static void g_armv7_instruction_dispose(GArmV7Instruction *instr) +{ + G_OBJECT_CLASS(g_armv7_instruction_parent_class)->dispose(G_OBJECT(instr)); + +} + + +/****************************************************************************** +* * +* Paramètres : instr = instance d'objet GLib à traiter. * +* * +* Description : Procède à la libération totale de la mémoire. * +* * +* Retour : - * +* * +* Remarques : - * +* * +******************************************************************************/ + +static void g_armv7_instruction_finalize(GArmV7Instruction *instr) +{ + G_OBJECT_CLASS(g_armv7_instruction_parent_class)->finalize(G_OBJECT(instr)); + +} + + +/****************************************************************************** +* * +* Paramètres : keyword = définition du nom humaine de l'instruction. * +* * +* Description : Crée une instruction pour l'architecture ARMv7. * +* * +* Retour : Adresse de la structure mise en place. * +* * +* Remarques : - * +* * +******************************************************************************/ + +GArchInstruction *g_armv7_instruction_new(const char *keyword) +{ + GArchInstruction *result; /* Structure à retourner */ + + result = g_object_new(G_TYPE_ARMV7_INSTRUCTION, NULL); + + G_ARM_INSTRUCTION(result)->keyword = keyword; + + return result; + +} + + +/****************************************************************************** +* * +* Paramètres : instr = instruction quelconque à consulter. * +* * +* Description : Indique l'encodage d'une instruction de façon détaillée. * +* * +* Retour : Description humaine de l'encodage utilisé. * +* * +* Remarques : - * +* * +******************************************************************************/ + +static const char *g_armv7_instruction_get_encoding(const GArmV7Instruction *instr) +{ + const char *result; /* Description à retourner */ + + switch (instr->encoding) + { + case 't': + result = "Thumb/16"; + break; + + case 'T': + result = "Thumb/32"; + break; + + default: + result = "ARM"; + break; + + } + + return result; + +} + + +/****************************************************************************** +* * +* Paramètres : instr = instruction quelconque à modifier. * +* encoding = encodage de l'instruction. * +* * +* Description : Précise l'encodage d'une instruction ARMv7 dans le détail. * +* * +* Retour : - * +* * +* Remarques : - * +* * +******************************************************************************/ + +void g_armv7_instruction_set_encoding(GArmV7Instruction *instr, const char *encoding) +{ + assert(strlen(encoding) == 1); + assert(encoding[0] == 'A' || encoding[0] == 'T' || encoding[0] == 't'); + + instr->encoding = encoding[0]; + +} + + +/****************************************************************************** +* * +* Paramètres : instr = instruction ARMv7 à mettre à jour. * +* set = statut à enregistrer. * +* * +* Description : Définit si une instruction ARMv7 met à jour les drapeaux. * +* * +* Retour : Bilan de l'opération. * +* * +* Remarques : - * +* * +******************************************************************************/ + +bool g_armv7_instruction_define_setflags(GArmV7Instruction *instr, bool set) +{ + instr->setflags = set; + + return true; + +} + + +/****************************************************************************** +* * +* Paramètres : instr = instruction ARMv7 à consulter. * +* * +* Description : Indique si une instruction ARMv7 met à jour les drapeaux. * +* * +* Retour : Statut des incidences de l'instruction. * +* * +* Remarques : - * +* * +******************************************************************************/ + +bool g_armv7_instruction_get_setflags(const GArmV7Instruction *instr) +{ + return instr->setflags; + +} diff --git a/plugins/arm/v7/instruction.h b/plugins/arm/v7/instruction.h new file mode 100644 index 0000000..2a1ff67 --- /dev/null +++ b/plugins/arm/v7/instruction.h @@ -0,0 +1,69 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * instruction.h - prototypes pour la gestion des instructions ARMv7 + * + * Copyright (C) 2014-2017 Cyrille Bagard + * + * This file is part of Chrysalide. + * + * Chrysalide is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Chrysalide is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Foobar. If not, see . + */ + + +#ifndef _PLUGINS_ARM_V7_INSTRUCTION_H +#define _PLUGINS_ARM_V7_INSTRUCTION_H + + +#include +#include +#include + + +#include + + + +#define G_TYPE_ARMV7_INSTRUCTION g_armv7_instruction_get_type() +#define G_ARMV7_INSTRUCTION(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), g_armv7_instruction_get_type(), GArmV7Instruction)) +#define G_IS_ARMV7_INSTRUCTION(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), g_armv7_instruction_get_type())) +#define G_ARMV7_INSTRUCTION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), G_TYPE_ARMV7_INSTRUCTION, GArmV7InstructionClass)) +#define G_IS_ARMV7_INSTRUCTION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), G_TYPE_ARMV7_INSTRUCTION)) +#define G_ARMV7_INSTRUCTION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), G_TYPE_ARMV7_INSTRUCTION, GArmV7InstructionClass)) + + +/* Définition d'une instruction d'architecture ARMv7 (instance) */ +typedef struct _GArmV7Instruction GArmV7Instruction; + +/* Définition d'une instruction d'architecture ARMv7 (classe) */ +typedef struct _GArmV7InstructionClass GArmV7InstructionClass; + + +/* Indique le type défini pour une représentation d'une instruction ARMv7. */ +GType g_armv7_instruction_get_type(void); + +/* Crée une instruction pour l'architecture ARMv7. */ +GArchInstruction *g_armv7_instruction_new(const char *); + +/* Précise l'encodage d'une instruction ARMv7 dans le détail. */ +void g_armv7_instruction_set_encoding(GArmV7Instruction *, const char *); + +/* Définit si une instruction ARMv7 met à jour les drapeaux. */ +bool g_armv7_instruction_define_setflags(GArmV7Instruction *, bool); + +/* Indique si une instruction ARMv7 met à jour les drapeaux. */ +bool g_armv7_instruction_get_setflags(const GArmV7Instruction *); + + + +#endif /* _PLUGINS_ARM_V7_INSTRUCTION_H */ diff --git a/plugins/arm/v7/link.c b/plugins/arm/v7/link.c new file mode 100644 index 0000000..68cde7b --- /dev/null +++ b/plugins/arm/v7/link.c @@ -0,0 +1,114 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * link.c - édition des liens après la phase de désassemblage ARM v7 + * + * Copyright (C) 2014-2017 Cyrille Bagard + * + * This file is part of Chrysalide. + * + * Chrysalide is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Chrysalide is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Foobar. If not, see . + */ + + +#include "link.h" + + +#include + + +#include "operands/reglist.h" +#include "../register.h" + + + +/****************************************************************************** +* * +* Paramètres : instr = instruction ARM à traiter. * +* proc = représentation de l'architecture utilisée. * +* context = contexte associé à la phase de désassemblage. * +* format = acès aux données du binaire d'origine. * +* * +* Description : Encadre les sauts à partir de registres ARMv7. * +* * +* Retour : - * +* * +* Remarques : - * +* * +******************************************************************************/ + +void handle_armv7_conditional_branch_from_register(GArchInstruction *instr, GArchProcessor *proc, GProcContext *context, GExeFormat *format) +{ + GArchOperand *op; /* Opérande numérique en place */ + GArmRegister *reg; /* Registre matériel manipulé */ + + op = g_arch_instruction_get_operand(instr, 0); + assert(G_IS_REGISTER_OPERAND(op)); + + reg = G_ARM_REGISTER(g_register_operand_get_register(G_REGISTER_OPERAND(op))); + + if (g_arm_register_get_index(reg) == 14 /* lr */) + g_arch_instruction_set_flag(instr, AIF_RETURN_POINT); + + else + g_arch_instruction_set_flag(instr, AIF_RETURN_POINT); /* FIXME : jump inconnu ! */ + + g_object_unref(G_OBJECT(reg)); + + g_object_unref(G_OBJECT(op)); + +} + + +/****************************************************************************** +* * +* Paramètres : instr = instruction ARM à traiter. * +* proc = représentation de l'architecture utilisée. * +* context = contexte associé à la phase de désassemblage. * +* format = acès aux données du binaire d'origine. * +* * +* Description : Détecte les fins de procédures à base d'instructions 'pop'. * +* * +* Retour : - * +* * +* Remarques : - * +* * +******************************************************************************/ + +void handle_armv7_return_from_pop(GArchInstruction *instr, GArchProcessor *proc, GProcContext *context, GExeFormat *format) +{ + GArchOperand *op; /* Opérande numérique en place */ + GArmV7RegListOperand *reglist; /* Autre version de l'instance */ + size_t count; /* Nombre de registres présents*/ + size_t i; /* Boucle de parcours */ + GArmRegister *reg; /* Registre matériel manipulé */ + + op = g_arch_instruction_get_operand(instr, 0); + assert(G_IS_ARMV7_REGLIST_OPERAND(op)); + + reglist = G_ARMV7_REGLIST_OPERAND(op); + + count = g_armv7_reglist_count_registers(reglist); + + for (i = 0; i < count; i++) + { + reg = G_ARM_REGISTER(g_armv7_reglist_operand_get_register(reglist, i)); + + if (g_arm_register_get_index(reg) == 15 /* pc */) + g_arch_instruction_set_flag(instr, AIF_RETURN_POINT); + + } + + g_object_unref(G_OBJECT(op)); + +} diff --git a/plugins/arm/v7/link.h b/plugins/arm/v7/link.h new file mode 100644 index 0000000..636e2b3 --- /dev/null +++ b/plugins/arm/v7/link.h @@ -0,0 +1,43 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * link.h - prototypes pour l'édition des liens après la phase de désassemblage ARM v7 + * + * Copyright (C) 2014-2017 Cyrille Bagard + * + * This file is part of Chrysalide. + * + * Chrysalide is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Chrysalide is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Foobar. If not, see . + */ + + +#ifndef _PLUGINS_ARM_V7_LINK_H +#define _PLUGINS_ARM_V7_LINK_H + + +#include + + +#include "context.h" + + + +/* Encadre les sauts à partir de registres ARMv7. */ +void handle_armv7_conditional_branch_from_register(GArchInstruction *, GArchProcessor *, GProcContext *, GExeFormat *); + +/* Détecte les fins de procédures à base d'instructions 'pop'. */ +void handle_armv7_return_from_pop(GArchInstruction *, GArchProcessor *, GProcContext *, GExeFormat *); + + + +#endif /* _PLUGINS_ARM_V7_LINK_H */ diff --git a/plugins/arm/v7/opcodes/Makefile.am b/plugins/arm/v7/opcodes/Makefile.am new file mode 100644 index 0000000..a169c2b --- /dev/null +++ b/plugins/arm/v7/opcodes/Makefile.am @@ -0,0 +1,26 @@ + +# Initialement, ce Makefile est conçu sans définition de am__depfiles_maybe. +# Est-ce parce que GENERATED_FILES est vide et qu'il n'y a donc pas de code +# source ? En tout cas, au premier écrasement de gencode.mk, tous les fichiers +# sont regénérés, et am__depfiles_maybe apparaît enfin. Mais trop tard : +# des fichiers .Plo sont attendus mais non créés par l'ancien Makefile. +# On force les choses ici. +am__depfiles_maybe = depfiles + +include gencode.mk + +noinst_LTLIBRARIES = libarmv7opcodes.la + +libarmv7opcodes_la_SOURCES = $(GENERATED_FILES) + +libarmv7opcodes_la_LIBADD = + +libarmv7opcodes_la_CFLAGS = $(AM_CFLAGS) + + +AM_CPPFLAGS = $(LIBGTK_CFLAGS) $(LIBXML_CFLAGS) + +AM_CFLAGS = $(DEBUG_CFLAGS) $(WARNING_FLAGS) $(COMPLIANCE_FLAGS) -I$(top_srcdir)/src + + +EXTRA_DIST = opcodes_tmp_arm.h opcodes_tmp_simd.h opcodes_tmp_thumb_16.h opcodes_tmp_thumb_32.h diff --git a/plugins/arm/v7/opcodes/opcodes_tmp_arm.h b/plugins/arm/v7/opcodes/opcodes_tmp_arm.h new file mode 100644 index 0000000..4106cbd --- /dev/null +++ b/plugins/arm/v7/opcodes/opcodes_tmp_arm.h @@ -0,0 +1,56 @@ +#ifndef arm_def_tmp_h +#define arm_def_tmp_h +#define armv7_read_arm_instr_cps_arm(r) NULL +#define armv7_read_arm_instr_eret(r) NULL +#define armv7_read_arm_instr_hvc(r) NULL +#define armv7_read_arm_instr_isb(r) NULL +#define armv7_read_arm_instr_ldc_ldc2_immediate(r) NULL +#define armv7_read_arm_instr_ldc_ldc2_literal(r) NULL +#define armv7_read_arm_instr_ldmda_ldmfa(r) NULL +#define armv7_read_arm_instr_ldmdb_ldmea(r) NULL +#define armv7_read_arm_instr_ldm_exception_return(r) NULL +#define armv7_read_arm_instr_ldmib_ldmed(r) NULL +#define armv7_read_arm_instr_ldm_ldmia_ldmfd_arm(r) NULL +#define armv7_read_arm_instr_ldm_user_registers(r) NULL +#define armv7_read_arm_instr_mrs(r) NULL +#define armv7_read_arm_instr_mrs_banked_register(r) NULL +#define armv7_read_arm_instr_msr_banked_register(r) NULL +#define armv7_read_arm_instr_msr_immediate_a8(r) NULL +#define armv7_read_arm_instr_msr_immediate_b9(r) NULL +#define armv7_read_arm_instr_msr_register_a8(r) NULL +#define armv7_read_arm_instr_msr_register_b9(r) NULL +#define armv7_read_arm_instr_pkh(r) NULL +#define armv7_read_arm_instr_pld_literal(r) NULL +#define armv7_read_arm_instr_pld_pldw_immediate(r) NULL +#define armv7_read_arm_instr_pld_pldw_register(r) NULL +#define armv7_read_arm_instr_pli_immediate_literal(r) NULL +#define armv7_read_arm_instr_pli_register(r) NULL +#define armv7_read_arm_instr_rfe(r) NULL +#define armv7_read_arm_instr_smc_previously_smi(r) NULL +#define armv7_read_arm_instr_smlabb_smlabt_smlatb_smlatt(r) NULL +#define armv7_read_arm_instr_smlalbb_smlalbt_smlaltb_smlaltt(r) NULL +#define armv7_read_arm_instr_smlawb_smlawt(r) NULL +#define armv7_read_arm_instr_smulbb_smulbt_smultb_smultt(r) NULL +#define armv7_read_arm_instr_smulwb_smulwt(r) NULL +#define armv7_read_arm_instr_smusd(r) NULL +#define armv7_read_arm_instr_srs_arm(r) NULL +#define armv7_read_arm_instr_ssat(r) NULL +#define armv7_read_arm_instr_ssat16(r) NULL +#define armv7_read_arm_instr_ssax(r) NULL +#define armv7_read_arm_instr_ssub16(r) NULL +#define armv7_read_arm_instr_ssub8(r) NULL +#define armv7_read_arm_instr_stc_stc2(r) NULL +#define armv7_read_arm_instr_stmda_stmed(r) NULL +#define armv7_read_arm_instr_stmdb_stmfd(r) NULL +#define armv7_read_arm_instr_stmib_stmfa(r) NULL +#define armv7_read_arm_instr_stm_stmia_stmea(r) NULL +#define armv7_read_arm_instr_stm_user_registers(r) NULL +#define armv7_read_arm_instr_sub_register_shifted_register(r) NULL +#define armv7_read_arm_instr_sxtab(r) NULL +#define armv7_read_arm_instr_sxtab16(r) NULL +#define armv7_read_arm_instr_sxtah(r) NULL +#define armv7_read_arm_instr_sxtb(r) NULL +#define armv7_read_arm_instr_sxtb16(r) NULL +#define armv7_read_arm_instr_sxth(r) NULL +#define armv7_read_arm_instr_wfe(r) NULL +#endif diff --git a/plugins/arm/v7/opcodes/opcodes_tmp_simd.h b/plugins/arm/v7/opcodes/opcodes_tmp_simd.h new file mode 100644 index 0000000..1d7023e --- /dev/null +++ b/plugins/arm/v7/opcodes/opcodes_tmp_simd.h @@ -0,0 +1,138 @@ +#ifndef simd_def_tmp_h +#define simd_def_tmp_h +#define armv7_read_simd_instr_vaba_vabal(r, a) NULL +#define armv7_read_simd_instr_vabd_floating_point(r, a) NULL +#define armv7_read_simd_instr_vabd_vabdl_integer(r, a) NULL +#define armv7_read_simd_instr_vabs(r, a) NULL +#define armv7_read_simd_instr_vacge_vacgt_vacle_vaclt(r, a) NULL +#define armv7_read_simd_instr_vadd_floating_point(r, a) NULL +#define armv7_read_simd_instr_vaddhn(r, a) NULL +#define armv7_read_simd_instr_vadd_integer(r, a) NULL +#define armv7_read_simd_instr_vaddl_vaddw(r, a) NULL +#define armv7_read_simd_instr_vand_register(r, a) NULL +#define armv7_read_simd_instr_vbic_immediate(r, a) NULL +#define armv7_read_simd_instr_vbic_register(r, a) NULL +#define armv7_read_simd_instr_vbif_vbit_vbsl(r, a) NULL +#define armv7_read_simd_instr_vceq_immediate_0(r, a) NULL +#define armv7_read_simd_instr_vceq_register(r, a) NULL +#define armv7_read_simd_instr_vcge_immediate_0(r, a) NULL +#define armv7_read_simd_instr_vcge_register(r, a) NULL +#define armv7_read_simd_instr_vcgt_immediate_0(r, a) NULL +#define armv7_read_simd_instr_vcgt_register(r, a) NULL +#define armv7_read_simd_instr_vcle_immediate_0(r, a) NULL +#define armv7_read_simd_instr_vcls(r, a) NULL +#define armv7_read_simd_instr_vclt_immediate_0(r, a) NULL +#define armv7_read_simd_instr_vclz(r, a) NULL +#define armv7_read_simd_instr_vcmp_vcmpe(r, a) NULL +#define armv7_read_simd_instr_vcnt(r, a) NULL +#define armv7_read_simd_instr_vcvt_between_double_precision_and_single_precision(r, a) NULL +#define armv7_read_simd_instr_vcvt_between_floating_point_and_fixed_point_advanced_simd(r, a) NULL +#define armv7_read_simd_instr_vcvt_between_floating_point_and_fixed_point_floating_point(r, a) NULL +#define armv7_read_simd_instr_vcvtb_vcvtt(r, a) NULL +#define armv7_read_simd_instr_vcvt_vcvtr_between_floating_point_and_integer_floating_point(r, a) NULL +#define armv7_read_simd_instr_vdiv(r, a) NULL +#define armv7_read_simd_instr_vdup_arm_core_register(r, a) NULL +#define armv7_read_simd_instr_vdup_scalar(r, a) NULL +#define armv7_read_simd_instr_veor(r, a) NULL +#define armv7_read_simd_instr_vext(r, a) NULL +#define armv7_read_simd_instr_vfma_vfms(r, a) NULL +#define armv7_read_simd_instr_vfnma_vfnms(r, a) NULL +#define armv7_read_simd_instr_vhadd_vhsub(r, a) NULL +#define armv7_read_simd_instr_vld1_multiple_single_elements(r, a) NULL +#define armv7_read_simd_instr_vld1_single_element_to_all_lanes(r, a) NULL +#define armv7_read_simd_instr_vld1_single_element_to_one_lane(r, a) NULL +#define armv7_read_simd_instr_vld2_multiple_2_element_structures(r, a) NULL +#define armv7_read_simd_instr_vld2_single_2_element_structure_to_all_lanes(r, a) NULL +#define armv7_read_simd_instr_vld2_single_2_element_structure_to_one_lane(r, a) NULL +#define armv7_read_simd_instr_vld3_multiple_3_element_structures(r, a) NULL +#define armv7_read_simd_instr_vld3_single_3_element_structure_to_all_lanes(r, a) NULL +#define armv7_read_simd_instr_vld3_single_3_element_structure_to_one_lane(r, a) NULL +#define armv7_read_simd_instr_vld4_multiple_4_element_structures(r, a) NULL +#define armv7_read_simd_instr_vld4_single_4_element_structure_to_all_lanes(r, a) NULL +#define armv7_read_simd_instr_vld4_single_4_element_structure_to_one_lane(r, a) NULL +#define armv7_read_simd_instr_vldm(r, a) NULL +#define armv7_read_simd_instr_vldr(r, a) NULL +#define armv7_read_simd_instr_vmax_vmin_floating_point(r, a) NULL +#define armv7_read_simd_instr_vmax_vmin_integer(r, a) NULL +#define armv7_read_simd_instr_vmla_vmlal_vmls_vmlsl_by_scalar(r, a) NULL +#define armv7_read_simd_instr_vmla_vmlal_vmls_vmlsl_integer(r, a) NULL +#define armv7_read_simd_instr_vmla_vmls_floating_point(r, a) NULL +#define armv7_read_simd_instr_vmov_arm_core_register_to_scalar(r, a) NULL +#define armv7_read_simd_instr_vmov_between_arm_core_register_and_single_precision_register(r, a) NULL +#define armv7_read_simd_instr_vmov_between_two_arm_core_registers_and_a_doubleword_extension_register(r, a) NULL +#define armv7_read_simd_instr_vmov_between_two_arm_core_registers_and_two_single_precision_registers(r, a) NULL +#define armv7_read_simd_instr_vmov_immediate(r, a) NULL +#define armv7_read_simd_instr_vmovl(r, a) NULL +#define armv7_read_simd_instr_vmov_register(r, a) NULL +#define armv7_read_simd_instr_vmov_scalar_to_arm_core_register(r, a) NULL +#define armv7_read_simd_instr_vmrs(r, a) NULL +#define armv7_read_simd_instr_vmrs_b9(r, a) NULL +#define armv7_read_simd_instr_vmsr(r, a) NULL +#define armv7_read_simd_instr_vmsr_b9(r, a) NULL +#define armv7_read_simd_instr_vmul_floating_point(r, a) NULL +#define armv7_read_simd_instr_vmul_vmull_by_scalar(r, a) NULL +#define armv7_read_simd_instr_vmul_vmull_integer_and_polynomial(r, a) NULL +#define armv7_read_simd_instr_vmvn_immediate(r, a) NULL +#define armv7_read_simd_instr_vmvn_register(r, a) NULL +#define armv7_read_simd_instr_vneg(r, a) NULL +#define armv7_read_simd_instr_vnmla_vnmls_vnmul(r, a) NULL +#define armv7_read_simd_instr_vorn_register(r, a) NULL +#define armv7_read_simd_instr_vorr_immediate(r, a) NULL +#define armv7_read_simd_instr_vorr_register(r, a) NULL +#define armv7_read_simd_instr_vpadal(r, a) NULL +#define armv7_read_simd_instr_vpadd_floating_point(r, a) NULL +#define armv7_read_simd_instr_vpadd_integer(r, a) NULL +#define armv7_read_simd_instr_vpaddl(r, a) NULL +#define armv7_read_simd_instr_vpmax_vpmin_floating_point(r, a) NULL +#define armv7_read_simd_instr_vpmax_vpmin_integer(r, a) NULL +#define armv7_read_simd_instr_vpop(r, a) NULL +#define armv7_read_simd_instr_vpush(r, a) NULL +#define armv7_read_simd_instr_vqabs(r, a) NULL +#define armv7_read_simd_instr_vqadd(r, a) NULL +#define armv7_read_simd_instr_vqdmlal_vqdmlsl(r, a) NULL +#define armv7_read_simd_instr_vqdmulh(r, a) NULL +#define armv7_read_simd_instr_vqdmull(r, a) NULL +#define armv7_read_simd_instr_vqneg(r, a) NULL +#define armv7_read_simd_instr_vqrdmulh(r, a) NULL +#define armv7_read_simd_instr_vqrshl(r, a) NULL +#define armv7_read_simd_instr_vqrshrn_vqrshrun(r, a) NULL +#define armv7_read_simd_instr_vqshl_register(r, a) NULL +#define armv7_read_simd_instr_vqshl_vqshlu_immediate(r, a) NULL +#define armv7_read_simd_instr_vqshrn_vqshrun(r, a) NULL +#define armv7_read_simd_instr_vqsub(r, a) NULL +#define armv7_read_simd_instr_vraddhn(r, a) NULL +#define armv7_read_simd_instr_vrecps(r, a) NULL +#define armv7_read_simd_instr_vrev16_vrev32_vrev64(r, a) NULL +#define armv7_read_simd_instr_vrhadd(r, a) NULL +#define armv7_read_simd_instr_vrshl(r, a) NULL +#define armv7_read_simd_instr_vrshr(r, a) NULL +#define armv7_read_simd_instr_vrshrn(r, a) NULL +#define armv7_read_simd_instr_vrsqrts(r, a) NULL +#define armv7_read_simd_instr_vrsra(r, a) NULL +#define armv7_read_simd_instr_vrsubhn(r, a) NULL +#define armv7_read_simd_instr_vshl_immediate(r, a) NULL +#define armv7_read_simd_instr_vshll(r, a) NULL +#define armv7_read_simd_instr_vshl_register(r, a) NULL +#define armv7_read_simd_instr_vshr(r, a) NULL +#define armv7_read_simd_instr_vshrn(r, a) NULL +#define armv7_read_simd_instr_vsli(r, a) NULL +#define armv7_read_simd_instr_vsqrt(r, a) NULL +#define armv7_read_simd_instr_vsra(r, a) NULL +#define armv7_read_simd_instr_vsri(r, a) NULL +#define armv7_read_simd_instr_vst1_multiple_single_elements(r, a) NULL +#define armv7_read_simd_instr_vst1_single_element_from_one_lane(r, a) NULL +#define armv7_read_simd_instr_vst2_multiple_2_element_structures(r, a) NULL +#define armv7_read_simd_instr_vst2_single_2_element_structure_from_one_lane(r, a) NULL +#define armv7_read_simd_instr_vst3_multiple_3_element_structures(r, a) NULL +#define armv7_read_simd_instr_vst3_single_3_element_structure_from_one_lane(r, a) NULL +#define armv7_read_simd_instr_vst4_multiple_4_element_structures(r, a) NULL +#define armv7_read_simd_instr_vst4_single_4_element_structure_from_one_lane(r, a) NULL +#define armv7_read_simd_instr_vstm(r, a) NULL +#define armv7_read_simd_instr_vstr(r, a) NULL +#define armv7_read_simd_instr_vsub_floating_point(r, a) NULL +#define armv7_read_simd_instr_vsubhn(r, a) NULL +#define armv7_read_simd_instr_vsub_integer(r, a) NULL +#define armv7_read_simd_instr_vsubl_vsubw(r, a) NULL +#define armv7_read_simd_instr_vtbl_vtbx(r, a) NULL +#define armv7_read_simd_instr_vtst(r, a) NULL +#endif diff --git a/plugins/arm/v7/opcodes/opcodes_tmp_thumb_16.h b/plugins/arm/v7/opcodes/opcodes_tmp_thumb_16.h new file mode 100644 index 0000000..1968037 --- /dev/null +++ b/plugins/arm/v7/opcodes/opcodes_tmp_thumb_16.h @@ -0,0 +1,10 @@ +#ifndef thumb_16_def_tmp_h +#define thumb_16_def_tmp_h +#define armv7_read_thumb_16_instr_cps_thumb(r) NULL +#define armv7_read_thumb_16_instr_it(r) NULL +#define armv7_read_thumb_16_instr_ldm_ldmia_ldmfd_thumb(r) NULL +#define armv7_read_thumb_16_instr_stm_stmia_stmea(r) NULL +#define armv7_read_thumb_16_instr_sxtb(r) NULL +#define armv7_read_thumb_16_instr_sxth(r) NULL +#define armv7_read_thumb_16_instr_wfe(r) NULL +#endif diff --git a/plugins/arm/v7/opcodes/opcodes_tmp_thumb_32.h b/plugins/arm/v7/opcodes/opcodes_tmp_thumb_32.h new file mode 100644 index 0000000..1ed547c --- /dev/null +++ b/plugins/arm/v7/opcodes/opcodes_tmp_thumb_32.h @@ -0,0 +1,59 @@ +#ifndef thumb_32_def_tmp_h +#define thumb_32_def_tmp_h +#define armv7_read_thumb_32_instr_b_mrs(r) NULL +#define armv7_read_thumb_32_instr_b_msr_register(r) NULL +#define armv7_read_thumb_32_instr_cps_thumb(r) NULL +#define armv7_read_thumb_32_instr_enterx_leavex(r) NULL +#define armv7_read_thumb_32_instr_eret(r) NULL +#define armv7_read_thumb_32_instr_hvc(r) NULL +#define armv7_read_thumb_32_instr_isb(r) NULL +#define armv7_read_thumb_32_instr_ldc_ldc2_immediate(r) NULL +#define armv7_read_thumb_32_instr_ldc_ldc2_literal(r) NULL +#define armv7_read_thumb_32_instr_ldmdb_ldmea(r) NULL +#define armv7_read_thumb_32_instr_ldm_ldmia_ldmfd_thumb(r) NULL +#define armv7_read_thumb_32_instr_mrs(r) NULL +#define armv7_read_thumb_32_instr_mrs_banked_register(r) NULL +#define armv7_read_thumb_32_instr_msr_banked_register(r) NULL +#define armv7_read_thumb_32_instr_msr_register(r) NULL +#define armv7_read_thumb_32_instr_pkh(r) NULL +#define armv7_read_thumb_32_instr_pld_immediate(r) NULL +#define armv7_read_thumb_32_instr_pld_literal(r) NULL +#define armv7_read_thumb_32_instr_pld_pldw_immediate(r) NULL +#define armv7_read_thumb_32_instr_pld_pldw_register(r) NULL +#define armv7_read_thumb_32_instr_pld_register(r) NULL +#define armv7_read_thumb_32_instr_pli_immediate_literal(r) NULL +#define armv7_read_thumb_32_instr_pli_register(r) NULL +#define armv7_read_thumb_32_instr_rfe(r) NULL +#define armv7_read_thumb_32_instr_smc_previously_smi(r) NULL +#define armv7_read_thumb_32_instr_smlabb_smlabt_smlatb_smlatt(r) NULL +#define armv7_read_thumb_32_instr_smlalbb_smlalbt_smlaltb_smlaltt(r) NULL +#define armv7_read_thumb_32_instr_smlawb_smlawt(r) NULL +#define armv7_read_thumb_32_instr_smulbb_smulbt_smultb_smultt(r) NULL +#define armv7_read_thumb_32_instr_smulwb_smulwt(r) NULL +#define armv7_read_thumb_32_instr_smusd(r) NULL +#define armv7_read_thumb_32_instr_sqadd16(r) NULL +#define armv7_read_thumb_32_instr_sqadd8(r) NULL +#define armv7_read_thumb_32_instr_sqasx(r) NULL +#define armv7_read_thumb_32_instr_sqsax(r) NULL +#define armv7_read_thumb_32_instr_sqsub16(r) NULL +#define armv7_read_thumb_32_instr_sqsub8(r) NULL +#define armv7_read_thumb_32_instr_srs_thumb(r) NULL +#define armv7_read_thumb_32_instr_ssat(r) NULL +#define armv7_read_thumb_32_instr_ssat16(r) NULL +#define armv7_read_thumb_32_instr_ssax(r) NULL +#define armv7_read_thumb_32_instr_ssub16(r) NULL +#define armv7_read_thumb_32_instr_ssub8(r) NULL +#define armv7_read_thumb_32_instr_stc_stc2(r) NULL +#define armv7_read_thumb_32_instr_stmdb_stmfd(r) NULL +#define armv7_read_thumb_32_instr_stm_stmia_stmea(r) NULL +#define armv7_read_thumb_32_instr_sub_register_thumb(r) NULL +#define armv7_read_thumb_32_instr_subs_pc_lr_thumb(r) NULL +#define armv7_read_thumb_32_instr_sxtab(r) NULL +#define armv7_read_thumb_32_instr_sxtab16(r) NULL +#define armv7_read_thumb_32_instr_sxtah(r) NULL +#define armv7_read_thumb_32_instr_sxtb(r) NULL +#define armv7_read_thumb_32_instr_sxtb16(r) NULL +#define armv7_read_thumb_32_instr_sxth(r) NULL +#define armv7_read_thumb_32_instr_tbb_tbh(r) NULL +#define armv7_read_thumb_32_instr_wfe(r) NULL +#endif diff --git a/plugins/arm/v7/opdefs/Makefile.am b/plugins/arm/v7/opdefs/Makefile.am new file mode 100644 index 0000000..3f69a3f --- /dev/null +++ b/plugins/arm/v7/opdefs/Makefile.am @@ -0,0 +1,302 @@ + +include ../../../../tools/d2c/d2c.mk + + +D2C_BIN = ../../../../tools/d2c/d2c +GEN_BIN = ../../../../tools/d2c/d2c_genmakefile.sh + +D2C_TYPE = raw + +D2C_OUTDIR = $(PWD)/.. + +D2C_ARCH = armv7 +D2C_HEADER = _ARCH_ARM_V7 + +D2C_ENCODINGS = \ + -e A=arm_ \ + -e t=thumb_16_ \ + -e T=thumb_32_ + +D2C_MACROS = \ + -M SetFlags=g_armv7_instruction_define_setflags \ + -M Condition=g_arm_instruction_set_cond \ + -M "ExpandImmC32=g_imm_operand_new_from_value(MDS_32_BITS_UNSIGNED, " \ + -M SignExtend=sign_extend_armv7_imm \ + -M SetInsFlag=g_arch_instruction_set_flag \ + -M StoreCondition=g_arm_instruction_set_cond \ + -M ExtendKeyword=g_arm_instruction_extend_keyword + +D2C_OPERANDS = \ + -n BarrierLimitation \ + -n BitDiff \ + -n IncWidth \ + -n DecodeImmShift \ + -n MakeMemoryAccess \ + -n Register \ + -n RegisterShift \ + -n UInt \ + -n ZeroExtend + +FIXED_C_INCLUDES = \ + \n\#include \ + \n\#include \ + \n \ + \n\#include \"../helpers.h\" \ + \n\#include \"../instruction.h\" \ + \n\#include \"../fetch.h\" \ + \n\#include \"../link.h\" \ + \n\#include \"../post.h\" \ + \n\#include \"../../instruction.h\" \ + \n\#include \"../../link.h\" \ + \n\n + +FIXED_H_INCLUDES = \ + \n\#include \ + \n \ + \n\#include \ + \n\n + + +# for i in $(seq 1 426); do test -f *A88$i.d && (ls *A88$i.d | sed 's/^/\t/' | sed 's/$/\t\t\t\t\t\t\\/') ; done +ARMV7_DEFS = \ + adc_A881.d \ + adc_A882.d \ + adc_A883.d \ + add_A884.d \ + add_A885.d \ + add_A886.d \ + add_A887.d \ + add_A888.d \ + add_A889.d \ + add_A8810.d \ + add_A8811.d \ + adr_A8812.d \ + and_A8813.d \ + and_A8814.d \ + and_A8815.d \ + asr_A8816.d \ + asr_A8817.d \ + b_A8818.d \ + bfc_A8819.d \ + bfi_A8820.d \ + bic_A8821.d \ + bic_A8822.d \ + bic_A8823.d \ + bkpt_A8824.d \ + bl_A8825.d \ + blx_A8826.d \ + bx_A8827.d \ + bxj_A8828.d \ + cb_A8829.d \ + cdp_A8830.d \ + clrex_A8832.d \ + clz_A8833.d \ + cmn_A8834.d \ + cmn_A8835.d \ + cmn_A8836.d \ + cmp_A8837.d \ + cmp_A8838.d \ + cmp_A8839.d \ + dbg_A8842.d \ + dmb_A8843.d \ + dsb_A8844.d \ + eor_A8846.d \ + eor_A8847.d \ + eor_A8848.d \ + ldr_A8862.d \ + ldr_A8863.d \ + ldr_A8864.d \ + ldr_A8865.d \ + ldr_A8866.d \ + ldrb_A8867.d \ + ldrb_A8868.d \ + ldrb_A8869.d \ + ldrb_A8870.d \ + ldrbt_A8871.d \ + ldrd_A8872.d \ + ldrd_A8873.d \ + ldrd_A8874.d \ + ldrex_A8875.d \ + ldrexb_A8876.d \ + ldrexd_A8877.d \ + ldrexh_A8878.d \ + ldrh_A8879.d \ + ldrh_A8880.d \ + ldrh_A8881.d \ + ldrh_A8882.d \ + ldrht_A8883.d \ + ldrsb_A8884.d \ + ldrsb_A8885.d \ + ldrsb_A8886.d \ + ldrsbt_A8887.d \ + ldrsh_A8888.d \ + ldrsh_A8889.d \ + ldrsh_A8890.d \ + ldrsht_A8891.d \ + ldrt_A8892.d \ + lsl_A8894.d \ + lsl_A8895.d \ + lsr_A8896.d \ + lsr_A8897.d \ + mcr_A8898.d \ + mcrr_A8899.d \ + mla_A88100.d \ + mls_A88101.d \ + mov_A88102.d \ + mov_A88103.d \ + mov_A88104.d \ + movt_A88106.d \ + mrc_A88107.d \ + mrrc_A88108.d \ + mul_A88114.d \ + mvn_A88115.d \ + mvn_A88116.d \ + mvn_A88117.d \ + nop_A88119.d \ + orn_A88120.d \ + orn_A88121.d \ + orr_A88122.d \ + orr_A88123.d \ + orr_A88124.d \ + pop_A88131.d \ + pop_A88132.d \ + push_A88133.d \ + qadd_A88134.d \ + qadd16_A88135.d \ + qadd8_A88136.d \ + qasx_A88137.d \ + qdadd_A88138.d \ + qdsub_A88139.d \ + qsax_A88140.d \ + qsub_A88141.d \ + qsub16_A88142.d \ + qsub8_A88143.d \ + rbit_A88144.d \ + rev_A88145.d \ + rev16_A88146.d \ + revsh_A88147.d \ + ror_A88149.d \ + ror_A88150.d \ + rrx_A88151.d \ + rsb_A88152.d \ + rsb_A88153.d \ + rsb_A88154.d \ + rsc_A88155.d \ + rsc_A88156.d \ + rsc_A88157.d \ + sadd16_A88158.d \ + sadd8_A88159.d \ + sasx_A88160.d \ + sbc_A88161.d \ + sbc_A88162.d \ + sbc_A88163.d \ + sbfx_A88164.d \ + sdiv_A88165.d \ + sel_A88166.d \ + setend_A88167.d \ + sev_A88168.d \ + shadd16_A88169.d \ + shadd8_A88170.d \ + shasx_A88171.d \ + shsax_A88172.d \ + shsub16_A88173.d \ + shsub8_A88174.d \ + smlad_A88177.d \ + smlal_A88178.d \ + smlald_A88180.d \ + smlsd_A88182.d \ + smlsld_A88183.d \ + smmla_A88184.d \ + smmls_A88185.d \ + smmul_A88186.d \ + smuad_A88187.d \ + smull_A88189.d \ + str_A88203.d \ + str_A88204.d \ + str_A88205.d \ + strb_A88206.d \ + strb_A88207.d \ + strb_A88208.d \ + strbt_A88209.d \ + strd_A88210.d \ + strd_A88211.d \ + strex_A88212.d \ + strexb_A88213.d \ + strexd_A88214.d \ + strexh_A88215.d \ + strh_A88216.d \ + strh_A88217.d \ + strh_A88218.d \ + strht_A88219.d \ + strt_A88220.d \ + sub_A88221.d \ + sub_A88222.d \ + sub_A88223.d \ + sub_A88225.d \ + svc_A88228.d \ + swp_A88229.d \ + teq_A88237.d \ + teq_A88238.d \ + teq_A88239.d \ + tst_A88240.d \ + tst_A88241.d \ + tst_A88242.d \ + uadd16_A88243.d \ + uadd8_A88244.d \ + uasx_A88245.d \ + ubfx_A88246.d \ + udf_A88247.d \ + udiv_A88248.d \ + uhadd16_A88249.d \ + uhadd8_A88250.d \ + uhasx_A88251.d \ + uhsax_A88252.d \ + uhsub16_A88253.d \ + uhsub8_A88254.d \ + umaal_A88255.d \ + umlal_A88256.d \ + umull_A88257.d \ + uqadd16_A88258.d \ + uqadd8_A88259.d \ + uqasx_A88260.d \ + uqsax_A88261.d \ + uqsub16_A88262.d \ + uqsub8_A88263.d \ + usad8_A88264.d \ + usada8_A88265.d \ + usat_A88266.d \ + usat16_A88267.d \ + usax_A88268.d \ + usub16_A88269.d \ + usub8_A88270.d \ + uxtab_A88271.d \ + uxtab16_A88272.d \ + uxtah_A88273.d \ + uxtb_A88274.d \ + uxtb16_A88275.d \ + uxth_A88276.d \ + wfi_A88425.d \ + yield_A88426.d + +# subs_B9320.d + +# make dist procède répertoire par répertoire. Or le répertoire opcodes utilise +# le contenu du répertoire opdefs. Il faut donc générer les fichiers nécessaires +# au répertoire opcodes. Et comme on ne peut pas compléter la règle dist, on +# ajoute à la distribution les cibles marquant la génération. (1/2) + +EXTRA_DIST = $(ARMV7_DEFS) $(ARMV7_DEFS:.d=.g) + +# Après coup, on supprime les fichiers inutiles de la distribution/ (2/2) + +dist-hook: + cd $(distdir) && rm $(ARMV7_DEFS:.d=.g) + +all: $(ARMV7_DEFS:.d=.g) fmk.done d2c_final_rules + +fmk.done: $(ARMV7_DEFS) + $(GEN_BIN) ../opcodes/ ../opdefs/.gen ../../../../tools/d2c/globalgen.mk arm thumb_32 thumb_16 + touch $@ + +clean: + rm -rf $(ARMV7_DEFS:.d=.g) .gen fmk.done diff --git a/plugins/arm/v7/opdefs/adc_A881.d b/plugins/arm/v7/opdefs/adc_A881.d new file mode 100644 index 0000000..6bc66e2 --- /dev/null +++ b/plugins/arm/v7/opdefs/adc_A881.d @@ -0,0 +1,74 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * ##FILE## - traduction d'instructions ARMv7 + * + * Copyright (C) 2015 Cyrille Bagard + * + * This file is part of Chrysalide. + * + * Chrysalide is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Chrysalide is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Foobar. If not, see . + */ + + +@title ADC (immediate) + +@desc Add with Carry (immediate) adds an immediate value and the Carry flag value to a register value, and writes the result to the destination register. It can optionally update the condition flags based on the result. + +@encoding (T1) { + + @word 1 1 1 1 0 i(1) 0 1 0 1 0 S(1) Rn(4) 0 imm3(3) Rd(4) imm8(8) + + @syntax + + @conv { + + reg_D = Register(Rd) + reg_N = Register(Rn) + setflags = (S == '1') + imm32 = ThumbExpandImm(i:imm3:imm8) + + } + + @rules { + + if (setflags); chk_call ExtendKeyword("s") + + } + +} + +@encoding (A1) { + + @word cond(4) 0 0 1 0 1 0 1 S(1) Rn(4) Rd(4) imm12(12) + + @syntax + + @conv { + + reg_D = Register(Rd) + reg_N = Register(Rn) + setflags = (S == '1') + imm32 = ARMExpandImm(imm12) + + } + + @rules { + + if (setflags); chk_call ExtendKeyword("s") + chk_call StoreCondition(cond) + + } + +} + diff --git a/plugins/arm/v7/opdefs/adc_A882.d b/plugins/arm/v7/opdefs/adc_A882.d new file mode 100644 index 0000000..27ce6ad --- /dev/null +++ b/plugins/arm/v7/opdefs/adc_A882.d @@ -0,0 +1,92 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * ##FILE## - traduction d'instructions ARMv7 + * + * Copyright (C) 2015 Cyrille Bagard + * + * This file is part of Chrysalide. + * + * Chrysalide is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Chrysalide is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Foobar. If not, see . + */ + + +@title ADC (register) + +@desc Add with Carry (register) adds a register value, the Carry flag value, and an optionally-shifted register value, and writes the result to the destination register. It can optionally update the condition flags based on the result. + +@encoding (t1) { + + @half 0 1 0 0 0 0 0 1 0 1 Rm(3) Rdn(3) + + @syntax "adcs" + + @conv { + + reg_DN = Register(Rdn) + reg_M = Register(Rm) + + } + +} + +@encoding (T2) { + + @word 1 1 1 0 1 0 1 1 0 1 0 S(1) Rn(4) 0 imm3(3) Rd(4) imm2(2) type(2) Rm(4) + + @syntax + + @conv { + + reg_D = Register(Rd) + reg_N = Register(Rn) + reg_M = Register(Rm) + setflags = (S == '1') + shift = DecodeImmShift(type, imm3:imm2) + + } + + @rules { + + if (setflags); chk_call ExtendKeyword("s") + chk_call ExtendKeyword(".w") + + } + +} + +@encoding (A1) { + + @word cond(4) 0 0 0 0 1 0 1 S(1) Rn(4) Rd(4) imm5(5) type(2) 0 Rm(4) + + @syntax + + @conv { + + reg_D = Register(Rd) + reg_N = Register(Rn) + reg_M = Register(Rm) + setflags = (S == '1') + shift = DecodeImmShift(type, imm5) + + } + + @rules { + + if (setflags); chk_call ExtendKeyword("s") + chk_call StoreCondition(cond) + + } + +} + diff --git a/plugins/arm/v7/opdefs/adc_A883.d b/plugins/arm/v7/opdefs/adc_A883.d new file mode 100644 index 0000000..a9c56d8 --- /dev/null +++ b/plugins/arm/v7/opdefs/adc_A883.d @@ -0,0 +1,52 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * ##FILE## - traduction d'instructions ARMv7 + * + * Copyright (C) 2015 Cyrille Bagard + * + * This file is part of Chrysalide. + * + * Chrysalide is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Chrysalide is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Foobar. If not, see . + */ + + +@title ADC (register-shifted register) + +@desc Add with Carry (register-shifted register) adds a register value, the Carry flag value, and a register-shifted register value. It writes the result to the destination register, and can optionally update the condition flags based on the result. + +@encoding (A1) { + + @word cond(4) 0 0 0 0 1 0 1 S(1) Rn(4) Rd(4) Rs(4) 0 type(2) 1 Rm(4) + + @syntax + + @conv { + + reg_shift = RegisterShift(type, Rs) + reg_D = Register(Rd) + reg_N = Register(Rn) + reg_M = Register(Rm) + setflags = (S == '1') + + } + + @rules { + + if (setflags); chk_call ExtendKeyword("s") + chk_call StoreCondition(cond) + + } + +} + diff --git a/plugins/arm/v7/opdefs/add_A8810.d b/plugins/arm/v7/opdefs/add_A8810.d new file mode 100644 index 0000000..2047276 --- /dev/null +++ b/plugins/arm/v7/opdefs/add_A8810.d @@ -0,0 +1,83 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * ##FILE## - traduction d'instructions ARMv7 + * + * Copyright (C) 2015 Cyrille Bagard + * + * This file is part of Chrysalide. + * + * Chrysalide is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Chrysalide is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Foobar. If not, see . + */ + + +@title ADD (SP plus register, Thumb) + +@desc This instruction adds an optionally-shifted register value to the SP value, and writes the result to the destination register. + +@encoding (t1) { + + @half 0 1 0 0 0 1 0 0 DM(1) 1 1 0 1 Rdm(3) + + @syntax + + @conv { + + reg_DM_1 = Register(DM:Rdm) + reg_DM_2 = Register(DM:Rdm) + SP = Register(13) + + } + +} + +@encoding (t2) { + + @half 0 1 0 0 0 1 0 0 1 Rm(4) 1 0 1 + + @syntax + + @conv { + + reg_M = Register(Rm) + SP = Register(13) + + } + +} + +@encoding (T3) { + + @word 1 1 1 0 1 0 1 1 0 0 0 S(1) 1 1 0 1 0 imm3(3) Rd(4) imm2(2) type(2) Rm(4) + + @syntax + + @conv { + + reg_D = Register(Rd) + reg_M = Register(Rm) + setflags = (S == '1') + shift = DecodeImmShift(type, imm3:imm2) + SP = Register(13) + + } + + @rules { + + if (setflags); chk_call ExtendKeyword("s") + chk_call ExtendKeyword(".w") + + } + +} + diff --git a/plugins/arm/v7/opdefs/add_A8811.d b/plugins/arm/v7/opdefs/add_A8811.d new file mode 100644 index 0000000..5b6c0d1 --- /dev/null +++ b/plugins/arm/v7/opdefs/add_A8811.d @@ -0,0 +1,52 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * ##FILE## - traduction d'instructions ARMv7 + * + * Copyright (C) 2015 Cyrille Bagard + * + * This file is part of Chrysalide. + * + * Chrysalide is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Chrysalide is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Foobar. If not, see . + */ + + +@title ADD (SP plus register, ARM) + +@desc This instruction adds an optionally-shifted register value to the SP value, and writes the result to the destination register. + +@encoding (A1) { + + @word cond(4) 0 0 0 0 1 0 0 S(1) 1 1 0 1 Rd(4) imm5(5) type(2) 0 Rm(4) + + @syntax + + @conv { + + reg_D = Register(Rd) + reg_M = Register(Rm) + setflags = (S == '1') + shift = DecodeImmShift(type, imm5) + SP = Register(13) + + } + + @rules { + + if (setflags); chk_call ExtendKeyword("s") + chk_call StoreCondition(cond) + + } + +} + diff --git a/plugins/arm/v7/opdefs/add_A884.d b/plugins/arm/v7/opdefs/add_A884.d new file mode 100644 index 0000000..8b624a7 --- /dev/null +++ b/plugins/arm/v7/opdefs/add_A884.d @@ -0,0 +1,98 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * ##FILE## - traduction d'instructions ARMv7 + * + * Copyright (C) 2015 Cyrille Bagard + * + * This file is part of Chrysalide. + * + * Chrysalide is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Chrysalide is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Foobar. If not, see . + */ + + +@title ADD (immediate, Thumb) + +@desc This instruction adds an immediate value to a register value, and writes the result to the destination register. It can optionally update the condition flags based on the result. + +@encoding (t1) { + + @half 0 0 0 1 1 1 0 imm3(3) Rn(3) Rd(3) + + @syntax "adds" + + @conv { + + reg_D = Register(Rd) + reg_N = Register(Rn) + imm32 = ZeroExtend(imm3, 32) + + } + +} + +@encoding (t2) { + + @half 0 0 1 1 0 Rdn(3) imm8(8) + + @syntax "adds" + + @conv { + + reg_DN = Register(Rdn) + imm32 = ZeroExtend(imm8, 32) + + } + +} + +@encoding (T3) { + + @word 1 1 1 1 0 i(1) 0 1 0 0 0 S(1) Rn(4) 0 imm3(3) Rd(4) imm8(8) + + @syntax + + @conv { + + reg_D = Register(Rd) + reg_N = Register(Rn) + setflags = (S == '1') + imm32 = ThumbExpandImm(i:imm3:imm8) + + } + + @rules { + + if (setflags); chk_call ExtendKeyword("s") + chk_call ExtendKeyword(".w") + + } + +} + +@encoding (T4) { + + @word 1 1 1 1 0 i(1) 1 0 0 0 0 0 Rn(4) 0 imm3(3) Rd(4) imm8(8) + + @syntax "addw" + + @conv { + + reg_D = Register(Rd) + reg_N = Register(Rn) + imm32 = ZeroExtend(i:imm3:imm8, 32) + + } + +} + diff --git a/plugins/arm/v7/opdefs/add_A885.d b/plugins/arm/v7/opdefs/add_A885.d new file mode 100644 index 0000000..0f4a919 --- /dev/null +++ b/plugins/arm/v7/opdefs/add_A885.d @@ -0,0 +1,51 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * ##FILE## - traduction d'instructions ARMv7 + * + * Copyright (C) 2015 Cyrille Bagard + * + * This file is part of Chrysalide. + * + * Chrysalide is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Chrysalide is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Foobar. If not, see . + */ + + +@title ADD (immediate, ARM) + +@desc This instruction adds an immediate value to a register value, and writes the result to the destination register. It can optionally update the condition flags based on the result. + +@encoding (A1) { + + @word cond(4) 0 0 1 0 1 0 0 S(1) Rn(4) Rd(4) imm12(12) + + @syntax + + @conv { + + reg_D = Register(Rd) + reg_N = Register(Rn) + setflags = (S == '1') + imm32 = ARMExpandImm(imm12) + + } + + @rules { + + if (setflags); chk_call ExtendKeyword("s") + chk_call StoreCondition(cond) + + } + +} + diff --git a/plugins/arm/v7/opdefs/add_A886.d b/plugins/arm/v7/opdefs/add_A886.d new file mode 100644 index 0000000..e4f9e00 --- /dev/null +++ b/plugins/arm/v7/opdefs/add_A886.d @@ -0,0 +1,83 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * ##FILE## - traduction d'instructions ARMv7 + * + * Copyright (C) 2015 Cyrille Bagard + * + * This file is part of Chrysalide. + * + * Chrysalide is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Chrysalide is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Foobar. If not, see . + */ + + +@title ADD (register, Thumb) + +@desc This instruction adds a register value and an optionally-shifted register value, and writes the result to the destination register. It can optionally update the condition flags based on the result. + +@encoding (t1) { + + @half 0 0 0 1 1 0 0 Rm(3) Rn(3) Rd(3) + + @syntax "adds" + + @conv { + + reg_D = Register(Rd) + reg_N = Register(Rn) + reg_M = Register(Rm) + + } + +} + +@encoding (t2) { + + @half 0 1 0 0 0 1 0 0 DN(1) Rm(4) Rdn(3) + + @syntax + + @conv { + + reg_DN = Register(DN:Rdn) + reg_M = Register(Rm) + + } + +} + +@encoding (T3) { + + @word 1 1 1 0 1 0 1 1 0 0 0 S(1) Rn(4) 0 imm3(3) Rd(4) imm2(2) type(2) Rm(4) + + @syntax + + @conv { + + reg_D = Register(Rd) + reg_N = Register(Rn) + reg_M = Register(Rm) + setflags = (S == '1') + shift = DecodeImmShift(type, imm3:imm2) + + } + + @rules { + + if (setflags); chk_call ExtendKeyword("s") + chk_call ExtendKeyword(".w") + + } + +} + diff --git a/plugins/arm/v7/opdefs/add_A887.d b/plugins/arm/v7/opdefs/add_A887.d new file mode 100644 index 0000000..18400a6 --- /dev/null +++ b/plugins/arm/v7/opdefs/add_A887.d @@ -0,0 +1,52 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * ##FILE## - traduction d'instructions ARMv7 + * + * Copyright (C) 2015 Cyrille Bagard + * + * This file is part of Chrysalide. + * + * Chrysalide is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Chrysalide is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Foobar. If not, see . + */ + + +@title ADD (register, ARM) + +@desc This instruction adds a register value and an optionally-shifted register value, and writes the result to the destination register. It can optionally update the condition flags based on the result. + +@encoding (A1) { + + @word cond(4) 0 0 0 0 1 0 0 S(1) Rn(4) Rd(4) imm5(5) type(2) 0 Rm(4) + + @syntax + + @conv { + + reg_D = Register(Rd) + reg_N = Register(Rn) + reg_M = Register(Rm) + setflags = (S == '1') + shift = DecodeImmShift(type, imm5) + + } + + @rules { + + if (setflags); chk_call ExtendKeyword("s") + chk_call StoreCondition(cond) + + } + +} + diff --git a/plugins/arm/v7/opdefs/add_A888.d b/plugins/arm/v7/opdefs/add_A888.d new file mode 100644 index 0000000..5549145 --- /dev/null +++ b/plugins/arm/v7/opdefs/add_A888.d @@ -0,0 +1,52 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * ##FILE## - traduction d'instructions ARMv7 + * + * Copyright (C) 2015 Cyrille Bagard + * + * This file is part of Chrysalide. + * + * Chrysalide is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Chrysalide is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Foobar. If not, see . + */ + + +@title ADD (register-shifted register) + +@desc Add (register-shifted register) adds a register value and a register-shifted register value. It writes the result to the destination register, and can optionally update the condition flags based on the result. + +@encoding (A1) { + + @word cond(4) 0 0 0 0 1 0 0 S(1) Rn(4) Rd(4) Rs(4) 0 type(2) 1 Rm(4) + + @syntax + + @conv { + + reg_shift = RegisterShift(type, Rs) + reg_D = Register(Rd) + reg_N = Register(Rn) + reg_M = Register(Rm) + setflags = (S == '1') + + } + + @rules { + + if (setflags); chk_call ExtendKeyword("s") + chk_call StoreCondition(cond) + + } + +} + diff --git a/plugins/arm/v7/opdefs/add_A889.d b/plugins/arm/v7/opdefs/add_A889.d new file mode 100644 index 0000000..5fab17c --- /dev/null +++ b/plugins/arm/v7/opdefs/add_A889.d @@ -0,0 +1,123 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * ##FILE## - traduction d'instructions ARMv7 + * + * Copyright (C) 2015 Cyrille Bagard + * + * This file is part of Chrysalide. + * + * Chrysalide is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Chrysalide is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Foobar. If not, see . + */ + + +@title ADD (SP plus immediate) + +@desc This instruction adds an immediate value to the SP value, and writes the result to the destination register. + +@encoding (t1) { + + @half 1 0 1 0 1 Rd(3) imm8(8) + + @syntax + + @conv { + + reg_D = Register(Rd) + imm32 = ZeroExtend(imm8:'00', 32) + SP = Register(13) + + } + +} + +@encoding (t2) { + + @half 1 0 1 1 0 0 0 0 0 imm7(7) + + @syntax + + @conv { + + imm32 = ZeroExtend(imm7:'00', 32) + SP_0 = Register(13) + SP_1 = Register(13) + + } + +} + +@encoding (T3) { + + @word 1 1 1 1 0 i(1) 0 1 0 0 0 S(1) 1 1 0 1 0 imm3(3) Rd(4) imm8(8) + + @syntax + + @conv { + + reg_D = Register(Rd) + setflags = (S == '1') + imm32 = ThumbExpandImm(i:imm3:imm8) + SP = Register(13) + + } + + @rules { + + if (setflags); chk_call ExtendKeyword("s") + chk_call ExtendKeyword(".w") + + } + +} + +@encoding (T4) { + + @word 1 1 1 1 0 i(1) 1 0 0 0 0 0 1 1 0 1 0 imm3(3) Rd(4) imm8(8) + + @syntax "addw" + + @conv { + + reg_D = Register(Rd) + imm32 = ZeroExtend(i:imm3:imm8, 32) + SP = Register(13) + + } + +} + +@encoding (A1) { + + @word cond(4) 0 0 1 0 1 0 0 S(1) 1 1 0 1 Rd(4) imm12(12) + + @syntax + + @conv { + + reg_D = Register(Rd) + setflags = (S == '1') + imm32 = ARMExpandImm(imm12) + SP = Register(13) + + } + + @rules { + + if (setflags); chk_call ExtendKeyword("s") + chk_call StoreCondition(cond) + + } + +} + diff --git a/plugins/arm/v7/opdefs/adr_A8812.d b/plugins/arm/v7/opdefs/adr_A8812.d new file mode 100644 index 0000000..16615cb --- /dev/null +++ b/plugins/arm/v7/opdefs/adr_A8812.d @@ -0,0 +1,114 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * ##FILE## - traduction d'instructions ARMv7 + * + * Copyright (C) 2015 Cyrille Bagard + * + * This file is part of Chrysalide. + * + * Chrysalide is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Chrysalide is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Foobar. If not, see . + */ + + +@title ADR + +@desc This instruction adds an immediate value to the PC value to form a PC-relative address, and writes the result to the destination register. + +@encoding (t1) { + + @half 1 0 1 0 0 Rd(3) imm8(8) + + @syntax + + @conv { + + reg_D = Register(Rd) + imm32 = ZeroExtend(imm8:'00', 32) + + } + +} + +@encoding (T2) { + + @word 1 1 1 1 0 i(1) 1 0 1 0 1 0 1 1 1 1 0 imm3(3) Rd(4) imm8(8) + + @syntax ".W" + + @conv { + + reg_D = Register(Rd) + imm32 = ZeroExtend(i:imm3:imm8, 32) + + } + +} + +@encoding (T3) { + + @word 1 1 1 1 0 i(1) 1 0 0 0 0 0 1 1 1 1 0 imm3(3) Rd(4) imm8(8) + + @syntax ".W" + + @conv { + + reg_D = Register(Rd) + imm32 = ZeroExtend(i:imm3:imm8, 32) + + } + +} + +@encoding (A1) { + + @word cond(4) 0 0 1 0 1 0 0 0 1 1 1 1 Rd(4) imm12(12) + + @syntax + + @conv { + + reg_D = Register(Rd) + imm32 = ARMExpandImm(imm12) + + } + + @rules { + + chk_call StoreCondition(cond) + + } + +} + +@encoding (A2) { + + @word cond(4) 0 0 1 0 0 1 0 0 1 1 1 1 Rd(4) imm12(12) + + @syntax + + @conv { + + reg_D = Register(Rd) + imm32 = ARMExpandImm(imm12) + + } + + @rules { + + chk_call StoreCondition(cond) + + } + +} + diff --git a/plugins/arm/v7/opdefs/and_A8813.d b/plugins/arm/v7/opdefs/and_A8813.d new file mode 100644 index 0000000..3e1d0ed --- /dev/null +++ b/plugins/arm/v7/opdefs/and_A8813.d @@ -0,0 +1,74 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * ##FILE## - traduction d'instructions ARMv7 + * + * Copyright (C) 2015 Cyrille Bagard + * + * This file is part of Chrysalide. + * + * Chrysalide is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Chrysalide is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Foobar. If not, see . + */ + + +@title AND (immediate) + +@desc This instruction performs a bitwise AND of a register value and an immediate value, and writes the result to the destination register. + +@encoding (T1) { + + @word 1 1 1 1 0 i(1) 0 0 0 0 0 S(1) Rn(4) 0 imm3(3) Rd(4) imm8(8) + + @syntax + + @conv { + + reg_D = Register(Rd) + reg_N = Register(Rn) + setflags = (S == '1') + imm32 = ThumbExpandImm_C(i:imm3:imm8, 0) + + } + + @rules { + + if (setflags); chk_call ExtendKeyword("s") + + } + +} + +@encoding (A1) { + + @word cond(4) 0 0 1 0 0 0 0 S(1) Rn(4) Rd(4) imm12(12) + + @syntax + + @conv { + + reg_D = Register(Rd) + reg_N = Register(Rn) + setflags = (S == '1') + imm32 = ARMExpandImm_C(imm12, 0) + + } + + @rules { + + if (setflags); chk_call ExtendKeyword("s") + chk_call StoreCondition(cond) + + } + +} + diff --git a/plugins/arm/v7/opdefs/and_A8814.d b/plugins/arm/v7/opdefs/and_A8814.d new file mode 100644 index 0000000..77f7e55 --- /dev/null +++ b/plugins/arm/v7/opdefs/and_A8814.d @@ -0,0 +1,92 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * ##FILE## - traduction d'instructions ARMv7 + * + * Copyright (C) 2015 Cyrille Bagard + * + * This file is part of Chrysalide. + * + * Chrysalide is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Chrysalide is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Foobar. If not, see . + */ + + +@title AND (register) + +@desc This instruction performs a bitwise AND of a register value and an optionally-shifted register value, and writes the result to the destination register. It can optionally update the condition flags based on the result. + +@encoding (t1) { + + @half 0 1 0 0 0 0 0 0 0 0 Rm(3) Rdn(3) + + @syntax "ands" + + @conv { + + reg_DN = Register(Rdn) + reg_M = Register(Rm) + + } + +} + +@encoding (T2) { + + @word 1 1 1 0 1 0 1 0 0 0 0 S(1) Rn(4) 0 imm3(3) Rd(4) imm2(2) type(2) Rm(4) + + @syntax + + @conv { + + reg_D = Register(Rd) + reg_N = Register(Rn) + reg_M = Register(Rm) + setflags = (S == '1') + shift = DecodeImmShift(type, imm3:imm2) + + } + + @rules { + + if (setflags); chk_call ExtendKeyword("s") + chk_call ExtendKeyword(".w") + + } + +} + +@encoding (A1) { + + @word cond(4) 0 0 0 0 0 0 0 S(1) Rn(4) Rd(4) imm5(5) type(2) 0 Rm(4) + + @syntax + + @conv { + + reg_D = Register(Rd) + reg_N = Register(Rn) + reg_M = Register(Rm) + setflags = (S == '1') + shift = DecodeImmShift(type, imm5) + + } + + @rules { + + if (setflags); chk_call ExtendKeyword("s") + chk_call StoreCondition(cond) + + } + +} + diff --git a/plugins/arm/v7/opdefs/and_A8815.d b/plugins/arm/v7/opdefs/and_A8815.d new file mode 100644 index 0000000..5ace3fa --- /dev/null +++ b/plugins/arm/v7/opdefs/and_A8815.d @@ -0,0 +1,52 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * ##FILE## - traduction d'instructions ARMv7 + * + * Copyright (C) 2015 Cyrille Bagard + * + * This file is part of Chrysalide. + * + * Chrysalide is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Chrysalide is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Foobar. If not, see . + */ + + +@title AND (register-shifted register) + +@desc This instruction performs a bitwise AND of a register value and a register-shifted register value. It writes the result to the destination register, and can optionally update the condition flags based on the result. + +@encoding (A1) { + + @word cond(4) 0 0 0 0 0 0 0 S(1) Rn(4) Rd(4) Rs(4) 0 type(2) 1 Rm(4) + + @syntax + + @conv { + + reg_shift = RegisterShift(type, Rs) + reg_D = Register(Rd) + reg_N = Register(Rn) + reg_M = Register(Rm) + setflags = (S == '1') + + } + + @rules { + + if (setflags); chk_call ExtendKeyword("s") + chk_call StoreCondition(cond) + + } + +} + diff --git a/plugins/arm/v7/opdefs/asr_A8816.d b/plugins/arm/v7/opdefs/asr_A8816.d new file mode 100644 index 0000000..006a26c --- /dev/null +++ b/plugins/arm/v7/opdefs/asr_A8816.d @@ -0,0 +1,91 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * ##FILE## - traduction d'instructions ARMv7 + * + * Copyright (C) 2015 Cyrille Bagard + * + * This file is part of Chrysalide. + * + * Chrysalide is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Chrysalide is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Foobar. If not, see . + */ + + +@title ASR (immediate) + +@desc Arithmetic Shift Right (immediate) shifts a register value right by an immediate number of bits, shifting in copies of its sign bit, and writes the result to the destination register. It can optionally update the condition flags based on the result. + +@encoding (t1) { + + @half 0 0 0 1 0 imm5(5) Rm(3) Rd(3) + + @syntax "asrs" + + @conv { + + reg_D = Register(Rd) + reg_M = Register(Rm) + shift_imm = DecodeImmShift('10', imm5) + + } + +} + +@encoding (T2) { + + @word 1 1 1 0 1 0 1 0 0 1 0 S(1) 1 1 1 1 0 imm3(3) Rd(4) imm2(2) 1 0 Rm(4) + + @syntax + + @conv { + + reg_D = Register(Rd) + reg_M = Register(Rm) + setflags = (S == '1') + shift_imm = DecodeImmShift('10', imm3:imm2) + + } + + @rules { + + if (setflags); chk_call ExtendKeyword("s") + chk_call ExtendKeyword(".w") + + } + +} + +@encoding (A1) { + + @word cond(4) 0 0 0 1 1 0 1 S(1) 0 0 0 0 Rd(4) imm5(5) 1 0 0 Rm(4) + + @syntax + + @conv { + + reg_D = Register(Rd) + reg_M = Register(Rm) + setflags = (S == '1') + shift_imm = DecodeImmShift('10', imm5) + + } + + @rules { + + if (setflags); chk_call ExtendKeyword("s") + chk_call StoreCondition(cond) + + } + +} + diff --git a/plugins/arm/v7/opdefs/asr_A8817.d b/plugins/arm/v7/opdefs/asr_A8817.d new file mode 100644 index 0000000..1e1e9c1 --- /dev/null +++ b/plugins/arm/v7/opdefs/asr_A8817.d @@ -0,0 +1,90 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * ##FILE## - traduction d'instructions ARMv7 + * + * Copyright (C) 2015 Cyrille Bagard + * + * This file is part of Chrysalide. + * + * Chrysalide is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Chrysalide is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Foobar. If not, see . + */ + + +@title ASR (register) + +@desc Arithmetic Shift Right (register) shifts a register value right by a variable number of bits, shifting in copies of its sign bit, and writes the result to the destination register. The variable number of bits is read from the bottom byte of a register. It can optionally update the condition flags based on the result. + +@encoding (t1) { + + @half 0 1 0 0 0 0 0 1 0 0 Rm(3) Rdn(3) + + @syntax "asrs" + + @conv { + + reg_DN = Register(Rdn) + reg_M = Register(Rm) + + } + +} + +@encoding (T2) { + + @word 1 1 1 1 1 0 1 0 0 1 0 S(1) Rn(4) 1 1 1 1 Rd(4) 0 0 0 0 Rm(4) + + @syntax + + @conv { + + reg_D = Register(Rd) + reg_N = Register(Rn) + reg_M = Register(Rm) + setflags = (S == '1') + + } + + @rules { + + if (setflags); chk_call ExtendKeyword("s") + chk_call ExtendKeyword(".w") + + } + +} + +@encoding (A1) { + + @word cond(4) 0 0 0 1 1 0 1 S(1) 0 0 0 0 Rd(4) Rm(4) 0 1 0 1 Rn(4) + + @syntax + + @conv { + + reg_D = Register(Rd) + reg_N = Register(Rn) + reg_M = Register(Rm) + setflags = (S == '1') + + } + + @rules { + + if (setflags); chk_call ExtendKeyword("s") + chk_call StoreCondition(cond) + + } + +} + diff --git a/plugins/arm/v7/opdefs/b_A8818.d b/plugins/arm/v7/opdefs/b_A8818.d new file mode 100644 index 0000000..9e27753 --- /dev/null +++ b/plugins/arm/v7/opdefs/b_A8818.d @@ -0,0 +1,157 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * ##FILE## - traduction d'instructions ARMv7 + * + * Copyright (C) 2015 Cyrille Bagard + * + * This file is part of Chrysalide. + * + * Chrysalide is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Chrysalide is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Foobar. If not, see . + */ + + +@title B + +@desc Branch causes a branch to a target address. + +@encoding (t1) { + + @half 1 1 0 1 cond(4) imm8(8) + + @syntax + + @conv { + + imm32 = SignExtend(imm8:'0', imm8 & 0x80, 32) + + } + + @rules { + + chk_call StoreCondition(cond) + + } + + @hooks { + + fetch = help_fetching_with_instruction_b_from_thumb + link = handle_arm_conditional_branch_as_link + post = post_process_branch_instructions + + } + +} + +@encoding (t2) { + + @half 1 1 1 0 0 imm11(11) + + @syntax + + @conv { + + imm32 = SignExtend(imm11:'0', imm11 & 0x400, 32) + + } + + @hooks { + + fetch = help_fetching_with_instruction_b_from_thumb + link = handle_arm_conditional_branch_as_link + post = post_process_branch_instructions + + } + +} + +@encoding (T3) { + + @word 1 1 1 1 0 S(1) cond(4) imm6(6) 1 0 J1(1) 0 J2(1) imm11(11) + + @syntax ".W" + + @conv { + + imm32 = SignExtend(S:J2:J1:imm6:imm11:'0', S & 0x1, 32) + + } + + @rules { + + chk_call StoreCondition(cond) + + } + + @hooks { + + fetch = help_fetching_with_instruction_b_from_thumb + link = handle_arm_conditional_branch_as_link + post = post_process_branch_instructions + + } + +} + +@encoding (T4) { + + @word 1 1 1 1 0 S(1) imm10(10) 1 0 J1(1) 1 J2(1) imm11(11) + + @syntax ".W" + + @conv { + + I1 = NOT(J1 EOR S) + I2 = NOT(J2 EOR S) + imm32 = SignExtend(S:I1:I2:imm10:imm11:'0', S & 0x1, 32) + + } + + @hooks { + + fetch = help_fetching_with_instruction_b_from_thumb + link = handle_arm_conditional_branch_as_link + post = post_process_branch_instructions + + } + +} + +@encoding (A1) { + + @word cond(4) 1 0 1 0 imm24(24) + + @syntax + + @conv { + + imm32 = SignExtend(imm24:'00', imm24 & 0x800000, 32) + + } + + @rules { + + chk_call StoreCondition(cond) + + } + + @hooks { + + fetch = help_fetching_with_instruction_b_from_arm + link = handle_arm_conditional_branch_as_link + post = post_process_branch_instructions + + } + +} + diff --git a/plugins/arm/v7/opdefs/bfc_A8819.d b/plugins/arm/v7/opdefs/bfc_A8819.d new file mode 100644 index 0000000..0ee99c8 --- /dev/null +++ b/plugins/arm/v7/opdefs/bfc_A8819.d @@ -0,0 +1,67 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * ##FILE## - traduction d'instructions ARMv7 + * + * Copyright (C) 2015 Cyrille Bagard + * + * This file is part of Chrysalide. + * + * Chrysalide is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Chrysalide is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Foobar. If not, see . + */ + + +@title BFC + +@desc Bit Field Clear clears any number of adjacent bits at any position in a register, without affecting the other bits in the register. + +@encoding (T1) { + + @word 1 1 1 1 0 0 1 1 0 1 1 0 1 1 1 1 0 imm3(3) Rd(4) imm2(2) 0 msb(5) + + @syntax + + @conv { + + reg_D = Register(Rd) + msbit = UInt(msb) + lsbit = UInt(imm3:imm2) + width = BitDiff(msbit, lsbit) + + } + +} + +@encoding (A1) { + + @word cond(4) 0 1 1 1 1 1 0 msb(5) Rd(4) lsb(5) 0 0 1 1 1 1 1 + + @syntax + + @conv { + + reg_D = Register(Rd) + msbit = UInt(msb) + lsbit = UInt(lsb) + width = BitDiff(msbit, lsbit) + + } + + @rules { + + chk_call StoreCondition(cond) + + } + +} + diff --git a/plugins/arm/v7/opdefs/bfi_A8820.d b/plugins/arm/v7/opdefs/bfi_A8820.d new file mode 100644 index 0000000..1d2bb2f --- /dev/null +++ b/plugins/arm/v7/opdefs/bfi_A8820.d @@ -0,0 +1,69 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * ##FILE## - traduction d'instructions ARMv7 + * + * Copyright (C) 2015 Cyrille Bagard + * + * This file is part of Chrysalide. + * + * Chrysalide is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Chrysalide is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Foobar. If not, see . + */ + + +@title BFI + +@desc Bit Field Insert copies any number of low order bits from a register into the same number of adjacent bits at any position in the destination register. + +@encoding (T1) { + + @word 1 1 1 1 0 0 1 1 0 1 1 0 Rn(4) 0 imm3(3) Rd(4) imm2(2) 0 msb(5) + + @syntax + + @conv { + + reg_D = Register(Rd) + reg_N = Register(Rn) + msbit = UInt(msb) + lsbit = UInt(imm3:imm2) + width = BitDiff(msbit, lsbit) + + } + +} + +@encoding (A1) { + + @word cond(4) 0 1 1 1 1 1 0 msb(5) Rd(4) lsb(5) 0 0 1 Rn(4) + + @syntax + + @conv { + + reg_D = Register(Rd) + reg_N = Register(Rn) + msbit = UInt(msb) + lsbit = UInt(lsb) + width = BitDiff(msbit, lsbit) + + } + + @rules { + + chk_call StoreCondition(cond) + + } + +} + diff --git a/plugins/arm/v7/opdefs/bic_A8821.d b/plugins/arm/v7/opdefs/bic_A8821.d new file mode 100644 index 0000000..9171b69 --- /dev/null +++ b/plugins/arm/v7/opdefs/bic_A8821.d @@ -0,0 +1,74 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * ##FILE## - traduction d'instructions ARMv7 + * + * Copyright (C) 2015 Cyrille Bagard + * + * This file is part of Chrysalide. + * + * Chrysalide is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Chrysalide is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Foobar. If not, see . + */ + + +@title BIC (immediate) + +@desc Bitwise Bit Clear (immediate) performs a bitwise AND of a register value and the complement of an immediate value, and writes the result to the destination register. It can optionally update the condition flags based on the result. + +@encoding (T1) { + + @word 1 1 1 1 0 i(1) 0 0 0 0 1 S(1) Rn(4) 0 imm3(3) Rd(4) imm8(8) + + @syntax + + @conv { + + reg_D = Register(Rd) + reg_N = Register(Rn) + setflags = (S == '1') + imm32 = ThumbExpandImm_C(i:imm3:imm8, 0) + + } + + @rules { + + if (setflags); chk_call ExtendKeyword("s") + + } + +} + +@encoding (A1) { + + @word cond(4) 0 0 1 1 1 1 0 S(1) Rn(4) Rd(4) imm12(12) + + @syntax + + @conv { + + reg_D = Register(Rd) + reg_N = Register(Rn) + setflags = (S == '1') + imm32 = ARMExpandImm_C(imm12, 0) + + } + + @rules { + + if (setflags); chk_call ExtendKeyword("s") + chk_call StoreCondition(cond) + + } + +} + diff --git a/plugins/arm/v7/opdefs/bic_A8822.d b/plugins/arm/v7/opdefs/bic_A8822.d new file mode 100644 index 0000000..8503460 --- /dev/null +++ b/plugins/arm/v7/opdefs/bic_A8822.d @@ -0,0 +1,92 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * ##FILE## - traduction d'instructions ARMv7 + * + * Copyright (C) 2015 Cyrille Bagard + * + * This file is part of Chrysalide. + * + * Chrysalide is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Chrysalide is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Foobar. If not, see . + */ + + +@title BIC (register) + +@desc Bitwise Bit Clear (register) performs a bitwise AND of a register value and the complement of an optionally-shifted register value, and writes the result to the destination register. It can optionally update the condition flags based on the result. + +@encoding (t1) { + + @half 0 1 0 0 0 0 1 1 1 0 Rm(3) Rdn(3) + + @syntax "bics" + + @conv { + + reg_DN = Register(Rdn) + reg_M = Register(Rm) + + } + +} + +@encoding (T2) { + + @word 1 1 1 0 1 0 1 0 0 0 1 S(1) Rn(4) 0 imm3(3) Rd(4) imm2(2) type(2) Rm(4) + + @syntax + + @conv { + + reg_D = Register(Rd) + reg_N = Register(Rn) + reg_M = Register(Rm) + setflags = (S == '1') + shift = DecodeImmShift(type, imm3:imm2) + + } + + @rules { + + if (setflags); chk_call ExtendKeyword("s") + chk_call ExtendKeyword(".w") + + } + +} + +@encoding (A1) { + + @word cond(4) 0 0 0 1 1 1 0 S(1) Rn(4) Rd(4) imm5(5) type(2) 0 Rm(4) + + @syntax + + @conv { + + reg_D = Register(Rd) + reg_N = Register(Rn) + reg_M = Register(Rm) + setflags = (S == '1') + shift = DecodeImmShift(type, imm5) + + } + + @rules { + + if (setflags); chk_call ExtendKeyword("s") + chk_call StoreCondition(cond) + + } + +} + diff --git a/plugins/arm/v7/opdefs/bic_A8823.d b/plugins/arm/v7/opdefs/bic_A8823.d new file mode 100644 index 0000000..e6903db --- /dev/null +++ b/plugins/arm/v7/opdefs/bic_A8823.d @@ -0,0 +1,52 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * ##FILE## - traduction d'instructions ARMv7 + * + * Copyright (C) 2015 Cyrille Bagard + * + * This file is part of Chrysalide. + * + * Chrysalide is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Chrysalide is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Foobar. If not, see . + */ + + +@title BIC (register-shifted register) + +@desc Bitwise Bit Clear (register-shifted register) performs a bitwise AND of a register value and the complement of a register-shifted register value. It writes the result to the destination register, and can optionally update the condition flags based on the result. + +@encoding (A1) { + + @word cond(4) 0 0 0 1 1 1 0 S(1) Rn(4) Rd(4) Rs(4) 0 type(2) 1 Rm(4) + + @syntax + + @conv { + + reg_shift = RegisterShift(type, Rs) + reg_D = Register(Rd) + reg_N = Register(Rn) + reg_M = Register(Rm) + setflags = (S == '1') + + } + + @rules { + + if (setflags); chk_call ExtendKeyword("s") + chk_call StoreCondition(cond) + + } + +} + diff --git a/plugins/arm/v7/opdefs/bkpt_A8824.d b/plugins/arm/v7/opdefs/bkpt_A8824.d new file mode 100644 index 0000000..f0aa13a --- /dev/null +++ b/plugins/arm/v7/opdefs/bkpt_A8824.d @@ -0,0 +1,55 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * ##FILE## - traduction d'instructions ARMv7 + * + * Copyright (C) 2015 Cyrille Bagard + * + * This file is part of Chrysalide. + * + * Chrysalide is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Chrysalide is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Foobar. If not, see . + */ + + +@title BKPT + +@desc Breakpoint causes a software breakpoint to occur. Breakpoint is always unconditional, even when inside an IT block. + +@encoding (t1) { + + @half 1 0 1 1 1 1 1 0 imm8(8) + + @syntax + + @conv { + + imm32 = ZeroExtend(imm8, 32) + + } + +} + +@encoding (A1) { + + @word cond(4) 0 0 0 1 0 0 1 0 imm12(12) 0 1 1 1 imm4(4) + + @syntax + + @conv { + + imm32 = ZeroExtend(imm12:imm4, 32) + + } + +} + diff --git a/plugins/arm/v7/opdefs/bl_A8825.d b/plugins/arm/v7/opdefs/bl_A8825.d new file mode 100644 index 0000000..da0def4 --- /dev/null +++ b/plugins/arm/v7/opdefs/bl_A8825.d @@ -0,0 +1,125 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * ##FILE## - traduction d'instructions ARMv7 + * + * Copyright (C) 2015 Cyrille Bagard + * + * This file is part of Chrysalide. + * + * Chrysalide is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Chrysalide is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Foobar. If not, see . + */ + + +@title BL, BLX (immediate) + +@desc Branch with Link calls a subroutine at a PC-relative address. Branch with Link and Exchange Instruction Sets (immediate) calls a subroutine at a PC-relative address, and changes instruction set from ARM to Thumb, or from Thumb to ARM. + +@encoding (T1) { + + @word 1 1 1 1 0 S(1) imm10(10) 1 1 J1(1) 1 J2(1) imm11(11) + + @syntax + + @conv { + + I1 = NOT(J1 EOR S) + I2 = NOT(J2 EOR S) + imm32 = SignExtend(S:I1:I2:imm10:imm11:'0', S & 0x1, 32) + + } + + @hooks { + + fetch = help_fetching_with_instruction_bl_from_thumb + link = handle_call_as_link + post = post_process_branch_and_link_instructions + + } + +} + +@encoding (T2) { + + @word 1 1 1 1 0 S(1) imm10H(10) 1 1 J1(1) 0 J2(1) imm10L(10) H(1) + + @syntax "blx" + + @conv { + + I1 = NOT(J1 EOR S) + I2 = NOT(J2 EOR S) + imm32 = SignExtend(S:I1:I2:imm10H:imm10L:'00', S & 0x1, 32) + + } + + @hooks { + + fetch = help_fetching_with_instruction_blx_from_thumb + link = handle_call_as_link + post = post_process_branch_and_link_instructions + + } + +} + +@encoding (A1) { + + @word cond(4) 1 0 1 1 imm24(24) + + @syntax + + @conv { + + imm32 = SignExtend(imm24:'00', imm24 & 0x800000, 32) + + } + + @rules { + + chk_call StoreCondition(cond) + + } + + @hooks { + + fetch = help_fetching_with_instruction_bl_from_arm + link = handle_call_as_link + post = post_process_branch_and_link_instructions + + } + +} + +@encoding (A2) { + + @word 1 1 1 1 1 0 1 H(1) imm24(24) + + @syntax "blx" + + @conv { + + imm32 = SignExtend(imm24:H:'0', imm24 & 0x800000, 32) + + } + + @hooks { + + fetch = help_fetching_with_instruction_blx_from_arm + link = handle_call_as_link + post = post_process_branch_and_link_instructions + + } + +} + diff --git a/plugins/arm/v7/opdefs/blx_A8826.d b/plugins/arm/v7/opdefs/blx_A8826.d new file mode 100644 index 0000000..29719fa --- /dev/null +++ b/plugins/arm/v7/opdefs/blx_A8826.d @@ -0,0 +1,61 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * ##FILE## - traduction d'instructions ARMv7 + * + * Copyright (C) 2015 Cyrille Bagard + * + * This file is part of Chrysalide. + * + * Chrysalide is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Chrysalide is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Foobar. If not, see . + */ + + +@title BLX (register) + +@desc Branch with Link and Exchange (register) calls a subroutine at an address and instruction set specified by a register. + +@encoding (t1) { + + @half 0 1 0 0 0 1 1 1 1 Rm(4) 0 0 0 + + @syntax + + @conv { + + reg_M = Register(Rm) + + } + +} + +@encoding (A1) { + + @word cond(4) 0 0 0 1 0 0 1 0 1 1 1 1 1 1 1 1 1 1 1 1 0 0 1 1 Rm(4) + + @syntax + + @conv { + + reg_M = Register(Rm) + + } + + @rules { + + chk_call StoreCondition(cond) + + } + +} + diff --git a/plugins/arm/v7/opdefs/bx_A8827.d b/plugins/arm/v7/opdefs/bx_A8827.d new file mode 100644 index 0000000..f3681e7 --- /dev/null +++ b/plugins/arm/v7/opdefs/bx_A8827.d @@ -0,0 +1,75 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * ##FILE## - traduction d'instructions ARMv7 + * + * Copyright (C) 2015 Cyrille Bagard + * + * This file is part of Chrysalide. + * + * Chrysalide is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Chrysalide is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Foobar. If not, see . + */ + + +@title BX + +@desc Branch and Exchange causes a branch to an address and instruction set specified by a register. + +@encoding (t1) { + + @half 0 1 0 0 0 1 1 1 0 Rm(4) 0 0 0 + + @syntax + + @conv { + + reg_M = Register(Rm) + + } + + @hooks { + + fetch = help_fetching_with_instruction_bx_from_thumb + link = handle_armv7_conditional_branch_from_register + + } + +} + +@encoding (A1) { + + @word cond(4) 0 0 0 1 0 0 1 0 1 1 1 1 1 1 1 1 1 1 1 1 0 0 0 1 Rm(4) + + @syntax + + @conv { + + reg_M = Register(Rm) + + } + + @rules { + + chk_call StoreCondition(cond) + + } + + @hooks { + + fetch = help_fetching_with_instruction_bx_from_arm + link = handle_armv7_conditional_branch_from_register + + } + +} + diff --git a/plugins/arm/v7/opdefs/bxj_A8828.d b/plugins/arm/v7/opdefs/bxj_A8828.d new file mode 100644 index 0000000..efa2de2 --- /dev/null +++ b/plugins/arm/v7/opdefs/bxj_A8828.d @@ -0,0 +1,61 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * ##FILE## - traduction d'instructions ARMv7 + * + * Copyright (C) 2015 Cyrille Bagard + * + * This file is part of Chrysalide. + * + * Chrysalide is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Chrysalide is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Foobar. If not, see . + */ + + +@title BXJ + +@desc Branch and Exchange Jazelle attempts to change to Jazelle state. If the attempt fails, it branches to an address and instruction set specified by a register as though it were a BX instruction. In an implementation that includes the Virtualization Extensions, if HSTR.TJDBX is set to 1, execution of a BXJ instruction in a Non-secure mode other than Hyp mode generates a Hyp Trap exception. For more information see Trapping accesses to Jazelle functionality on page B1-1255. + +@encoding (T1) { + + @word 1 1 1 1 0 0 1 1 1 1 0 0 Rm(4) 1 0 0 0 1 1 1 1 0 0 0 0 0 0 0 0 + + @syntax + + @conv { + + reg_M = Register(Rm) + + } + +} + +@encoding (A1) { + + @word cond(4) 0 0 0 1 0 0 1 0 1 1 1 1 1 1 1 1 1 1 1 1 0 0 1 0 Rm(4) + + @syntax + + @conv { + + reg_M = Register(Rm) + + } + + @rules { + + chk_call StoreCondition(cond) + + } + +} + diff --git a/plugins/arm/v7/opdefs/cb_A8829.d b/plugins/arm/v7/opdefs/cb_A8829.d new file mode 100644 index 0000000..134e0f4 --- /dev/null +++ b/plugins/arm/v7/opdefs/cb_A8829.d @@ -0,0 +1,58 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * ##FILE## - traduction d'instructions ARMv7 + * + * Copyright (C) 2015 Cyrille Bagard + * + * This file is part of Chrysalide. + * + * Chrysalide is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Chrysalide is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Foobar. If not, see . + */ + + +@title CBNZ, CBZ + +@desc Compare and Branch on Nonzero and Compare and Branch on Zero compare the value in a register with zero, and conditionally branch forward a constant value. They do not affect the condition flags. + +@encoding (t1) { + + @half 1 0 1 1 op(1) 0 i(1) 1 imm5(5) Rn(3) + + @syntax + + @conv { + + reg_N = Register(Rn) + imm32 = ZeroExtend(i:imm5:'0', 32) + nonzero = (op == '1') + + } + + @rules { + + if (nonzero); chk_call ExtendKeyword("n") + chk_call ExtendKeyword("z") + + } + + @hooks { + + fetch = help_fetching_with_instruction_cb_n_z + link = handle_comp_and_branch_if_true_as_link + post = post_process_comp_and_branch_instructions + + } + +} + diff --git a/plugins/arm/v7/opdefs/cdp_A8830.d b/plugins/arm/v7/opdefs/cdp_A8830.d new file mode 100644 index 0000000..109b89b --- /dev/null +++ b/plugins/arm/v7/opdefs/cdp_A8830.d @@ -0,0 +1,109 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * ##FILE## - traduction d'instructions ARMv7 + * + * Copyright (C) 2015 Cyrille Bagard + * + * This file is part of Chrysalide. + * + * Chrysalide is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Chrysalide is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Foobar. If not, see . + */ + + +@title CDP, CDP2 + +@desc Coprocessor Data Processing tells a coprocessor to perform an operation that is independent of ARM core registers and memory. If no coprocessor can execute the instruction, an Undefined Instruction exception is generated. This is a generic coprocessor instruction. Some of the fields have no functionality defined by the architecture and are free for use by the coprocessor instruction set designer. These are the opc1, opc2, CRd, CRn, and CRm fields. However, coprocessors CP8-CP15 are reserved for use by ARM, and this manual defines the valid CDP and CDP2 instructions when coproc is in the range p8-p15. For more information see Coprocessor support on page A2-94. + +@encoding (T1) { + + @word 1 1 1 0 1 1 1 0 opc1(4) CRn(4) CRd(4) coproc(4) opc2(3) 0 CRm(4) + + @syntax + + @conv { + + cp = CoProcessor(coproc) + undef_opc1 = RawValue(opc1) + creg_D = CRegister(CRd) + creg_N = CRegister(CRn) + creg_M = CRegister(CRm) + undef_opc2 = RawValue(opc2) + + } + +} + +@encoding (A1) { + + @word cond(4) 1 1 1 0 opc1(4) CRn(4) CRd(4) coproc(4) opc2(3) 0 CRm(4) + + @syntax + + @conv { + + cp = CoProcessor(coproc) + undef_opc1 = RawValue(opc1) + creg_D = CRegister(CRd) + creg_N = CRegister(CRn) + creg_M = CRegister(CRm) + undef_opc2 = RawValue(opc2) + + } + + @rules { + + chk_call StoreCondition(cond) + + } + +} + +@encoding (T2) { + + @word 1 1 1 1 1 1 1 0 opc1(4) CRn(4) CRd(4) coproc(4) opc2(3) 0 CRm(4) + + @syntax "cdp2" + + @conv { + + cp = CoProcessor(coproc) + undef_opc1 = RawValue(opc1) + creg_D = CRegister(CRd) + creg_N = CRegister(CRn) + creg_M = CRegister(CRm) + undef_opc2 = RawValue(opc2) + + } + +} + +@encoding (A2) { + + @word 1 1 1 1 1 1 1 0 opc1(4) CRn(4) CRd(4) coproc(4) opc2(3) 0 CRm(4) + + @syntax "cdp2" + + @conv { + + cp = CoProcessor(coproc) + undef_opc1 = RawValue(opc1) + creg_D = CRegister(CRd) + creg_N = CRegister(CRn) + creg_M = CRegister(CRm) + undef_opc2 = RawValue(opc2) + + } + +} + diff --git a/plugins/arm/v7/opdefs/clrex_A8832.d b/plugins/arm/v7/opdefs/clrex_A8832.d new file mode 100644 index 0000000..4f313f2 --- /dev/null +++ b/plugins/arm/v7/opdefs/clrex_A8832.d @@ -0,0 +1,39 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * ##FILE## - traduction d'instructions ARMv7 + * + * Copyright (C) 2015 Cyrille Bagard + * + * This file is part of Chrysalide. + * + * Chrysalide is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Chrysalide is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Foobar. If not, see . + */ + + +@title CLREX + +@desc Clear-Exclusive clears the local record of the executing processor that an address has had a request for an exclusive access. + +@encoding (T1) { + + @word 1 1 1 1 0 0 1 1 1 0 1 1 1 1 1 1 1 0 0 0 1 1 1 1 0 0 1 0 1 1 1 1 + +} + +@encoding (A1) { + + @word 1 1 1 1 0 1 0 1 0 1 1 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 1 1 1 1 1 + +} + diff --git a/plugins/arm/v7/opdefs/clz_A8833.d b/plugins/arm/v7/opdefs/clz_A8833.d new file mode 100644 index 0000000..d4fdac6 --- /dev/null +++ b/plugins/arm/v7/opdefs/clz_A8833.d @@ -0,0 +1,63 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * ##FILE## - traduction d'instructions ARMv7 + * + * Copyright (C) 2015 Cyrille Bagard + * + * This file is part of Chrysalide. + * + * Chrysalide is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Chrysalide is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Foobar. If not, see . + */ + + +@title CLZ + +@desc Count Leading Zeros returns the number of binary zero bits before the first binary one bit in a value. + +@encoding (T1) { + + @word 1 1 1 1 1 0 1 0 1 0 1 1 Rm(4) 1 1 1 1 Rd(4) 1 0 0 0 Rm(4) + + @syntax + + @conv { + + reg_D = Register(Rd) + reg_M = Register(Rm) + + } + +} + +@encoding (A1) { + + @word cond(4) 0 0 0 1 0 1 1 0 1 1 1 1 Rd(4) 1 1 1 1 0 0 0 1 Rm(4) + + @syntax + + @conv { + + reg_D = Register(Rd) + reg_M = Register(Rm) + + } + + @rules { + + chk_call StoreCondition(cond) + + } + +} + diff --git a/plugins/arm/v7/opdefs/cmn_A8834.d b/plugins/arm/v7/opdefs/cmn_A8834.d new file mode 100644 index 0000000..fc0b19f --- /dev/null +++ b/plugins/arm/v7/opdefs/cmn_A8834.d @@ -0,0 +1,63 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * ##FILE## - traduction d'instructions ARMv7 + * + * Copyright (C) 2015 Cyrille Bagard + * + * This file is part of Chrysalide. + * + * Chrysalide is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Chrysalide is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Foobar. If not, see . + */ + + +@title CMN (immediate) + +@desc Compare Negative (immediate) adds a register value and an immediate value. It updates the condition flags based on the result, and discards the result. + +@encoding (T1) { + + @word 1 1 1 1 0 i(1) 0 1 0 0 0 1 Rn(4) 0 imm3(3) 1 1 1 1 imm8(8) + + @syntax + + @conv { + + reg_N = Register(Rn) + imm32 = ThumbExpandImm(i:imm3:imm8) + + } + +} + +@encoding (A1) { + + @word cond(4) 0 0 1 1 0 1 1 1 Rn(4) 0 0 0 0 imm12(12) + + @syntax + + @conv { + + reg_N = Register(Rn) + imm32 = ARMExpandImm(imm12) + + } + + @rules { + + chk_call StoreCondition(cond) + + } + +} + diff --git a/plugins/arm/v7/opdefs/cmn_A8835.d b/plugins/arm/v7/opdefs/cmn_A8835.d new file mode 100644 index 0000000..cd228de --- /dev/null +++ b/plugins/arm/v7/opdefs/cmn_A8835.d @@ -0,0 +1,80 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * ##FILE## - traduction d'instructions ARMv7 + * + * Copyright (C) 2015 Cyrille Bagard + * + * This file is part of Chrysalide. + * + * Chrysalide is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Chrysalide is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Foobar. If not, see . + */ + + +@title CMN (register) + +@desc Compare Negative (register) adds a register value and an optionally-shifted register value. It updates the condition flags based on the result, and discards the result. + +@encoding (t1) { + + @half 0 1 0 0 0 0 1 0 1 1 Rm(3) Rn(3) + + @syntax + + @conv { + + reg_N = Register(Rn) + reg_M = Register(Rm) + + } + +} + +@encoding (T2) { + + @word 1 1 1 0 1 0 1 1 0 0 0 1 Rn(4) 0 imm3(3) 1 1 1 1 imm2(2) type(2) Rm(4) + + @syntax ".W" + + @conv { + + reg_N = Register(Rn) + reg_M = Register(Rm) + shift = DecodeImmShift(type, imm3:imm2) + + } + +} + +@encoding (A1) { + + @word cond(4) 0 0 0 1 0 1 1 1 Rn(4) 0 0 0 0 imm5(5) type(2) 0 Rm(4) + + @syntax + + @conv { + + reg_N = Register(Rn) + reg_M = Register(Rm) + shift = DecodeImmShift(type, imm5) + + } + + @rules { + + chk_call StoreCondition(cond) + + } + +} + diff --git a/plugins/arm/v7/opdefs/cmn_A8836.d b/plugins/arm/v7/opdefs/cmn_A8836.d new file mode 100644 index 0000000..ad58482 --- /dev/null +++ b/plugins/arm/v7/opdefs/cmn_A8836.d @@ -0,0 +1,49 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * ##FILE## - traduction d'instructions ARMv7 + * + * Copyright (C) 2015 Cyrille Bagard + * + * This file is part of Chrysalide. + * + * Chrysalide is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Chrysalide is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Foobar. If not, see . + */ + + +@title CMN (register-shifted register) + +@desc Compare Negative (register-shifted register) adds a register value and a register-shifted register value. It updates the condition flags based on the result, and discards the result. + +@encoding (A1) { + + @word cond(4) 0 0 0 1 0 1 1 1 Rn(4) 0 0 0 0 Rs(4) 0 type(2) 1 Rm(4) + + @syntax + + @conv { + + reg_shift = RegisterShift(type, Rs) + reg_N = Register(Rn) + reg_M = Register(Rm) + + } + + @rules { + + chk_call StoreCondition(cond) + + } + +} + diff --git a/plugins/arm/v7/opdefs/cmp_A8837.d b/plugins/arm/v7/opdefs/cmp_A8837.d new file mode 100644 index 0000000..76b7a76 --- /dev/null +++ b/plugins/arm/v7/opdefs/cmp_A8837.d @@ -0,0 +1,78 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * ##FILE## - traduction d'instructions ARMv7 + * + * Copyright (C) 2015 Cyrille Bagard + * + * This file is part of Chrysalide. + * + * Chrysalide is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Chrysalide is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Foobar. If not, see . + */ + + +@title CMP (immediate) + +@desc Compare (immediate) subtracts an immediate value from a register value. It updates the condition flags based on the result, and discards the result. + +@encoding (t1) { + + @half 0 0 1 0 1 Rn(3) imm8(8) + + @syntax + + @conv { + + reg_N = Register(Rn) + imm32 = ZeroExtend(imm8, 32) + + } + +} + +@encoding (T2) { + + @word 1 1 1 1 0 i(1) 0 1 1 0 1 1 Rn(4) 0 imm3(3) 1 1 1 1 imm8(8) + + @syntax ".W" + + @conv { + + reg_N = Register(Rn) + imm32 = ThumbExpandImm(i:imm3:imm8) + + } + +} + +@encoding (A1) { + + @word cond(4) 0 0 1 1 0 1 0 1 Rn(4) 0 0 0 0 imm12(12) + + @syntax + + @conv { + + reg_N = Register(Rn) + imm32 = ARMExpandImm(imm12) + + } + + @rules { + + chk_call StoreCondition(cond) + + } + +} + diff --git a/plugins/arm/v7/opdefs/cmp_A8838.d b/plugins/arm/v7/opdefs/cmp_A8838.d new file mode 100644 index 0000000..cd02543 --- /dev/null +++ b/plugins/arm/v7/opdefs/cmp_A8838.d @@ -0,0 +1,95 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * ##FILE## - traduction d'instructions ARMv7 + * + * Copyright (C) 2015 Cyrille Bagard + * + * This file is part of Chrysalide. + * + * Chrysalide is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Chrysalide is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Foobar. If not, see . + */ + + +@title CMP (register) + +@desc Compare (register) subtracts an optionally-shifted register value from a register value. It updates the condition flags based on the result, and discards the result. + +@encoding (t1) { + + @half 0 1 0 0 0 0 1 0 1 0 Rm(3) Rn(3) + + @syntax + + @conv { + + reg_N = Register(Rn) + reg_M = Register(Rm) + + } + +} + +@encoding (t2) { + + @half 0 1 0 0 0 1 0 1 N(1) Rm(4) Rn(3) + + @syntax + + @conv { + + reg_N = Register(N:Rn) + reg_M = Register(Rm) + + } + +} + +@encoding (T3) { + + @word 1 1 1 0 1 0 1 1 1 0 1 1 Rn(4) 0 imm3(3) 1 1 1 1 imm2(2) type(2) Rm(4) + + @syntax ".W" + + @conv { + + reg_N = Register(Rn) + reg_M = Register(Rm) + shift = DecodeImmShift(type, imm3:imm2) + + } + +} + +@encoding (A1) { + + @word cond(4) 0 0 0 1 0 1 0 1 Rn(4) 0 0 0 0 imm5(5) type(2) 0 Rm(4) + + @syntax + + @conv { + + reg_N = Register(Rn) + reg_M = Register(Rm) + shift = DecodeImmShift(type, imm5) + + } + + @rules { + + chk_call StoreCondition(cond) + + } + +} + diff --git a/plugins/arm/v7/opdefs/cmp_A8839.d b/plugins/arm/v7/opdefs/cmp_A8839.d new file mode 100644 index 0000000..45ed0f9 --- /dev/null +++ b/plugins/arm/v7/opdefs/cmp_A8839.d @@ -0,0 +1,49 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * ##FILE## - traduction d'instructions ARMv7 + * + * Copyright (C) 2015 Cyrille Bagard + * + * This file is part of Chrysalide. + * + * Chrysalide is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Chrysalide is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Foobar. If not, see . + */ + + +@title CMP (register-shifted register) + +@desc Compare (register-shifted register) subtracts a register-shifted register value from a register value. It updates the condition flags based on the result, and discards the result. + +@encoding (A1) { + + @word cond(4) 0 0 0 1 0 1 0 1 Rn(4) 0 0 0 0 Rs(4) 0 type(2) 1 Rm(4) + + @syntax + + @conv { + + reg_shift = RegisterShift(type, Rs) + reg_N = Register(Rn) + reg_M = Register(Rm) + + } + + @rules { + + chk_call StoreCondition(cond) + + } + +} + diff --git a/plugins/arm/v7/opdefs/dbg_A8842.d b/plugins/arm/v7/opdefs/dbg_A8842.d new file mode 100644 index 0000000..62142f5 --- /dev/null +++ b/plugins/arm/v7/opdefs/dbg_A8842.d @@ -0,0 +1,61 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * ##FILE## - traduction d'instructions ARMv7 + * + * Copyright (C) 2015 Cyrille Bagard + * + * This file is part of Chrysalide. + * + * Chrysalide is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Chrysalide is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Foobar. If not, see . + */ + + +@title DBG + +@desc Debug Hint provides a hint to debug and related systems. See their documentation for what use (if any) they make of this instruction. + +@encoding (T1) { + + @word 1 1 1 1 0 0 1 1 1 0 1 0 1 1 1 1 1 0 0 0 0 0 0 0 1 1 1 1 option(4) + + @syntax + + @conv { + + undef_option = RawValue(option) + + } + +} + +@encoding (A1) { + + @word cond(4) 0 0 1 1 0 0 1 0 0 0 0 0 1 1 1 1 0 0 0 0 1 1 1 1 option(4) + + @syntax + + @conv { + + undef_option = RawValue(option) + + } + + @rules { + + chk_call StoreCondition(cond) + + } + +} + diff --git a/plugins/arm/v7/opdefs/dmb_A8843.d b/plugins/arm/v7/opdefs/dmb_A8843.d new file mode 100644 index 0000000..34f053a --- /dev/null +++ b/plugins/arm/v7/opdefs/dmb_A8843.d @@ -0,0 +1,55 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * ##FILE## - traduction d'instructions ARMv7 + * + * Copyright (C) 2015 Cyrille Bagard + * + * This file is part of Chrysalide. + * + * Chrysalide is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Chrysalide is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Foobar. If not, see . + */ + + +@title DMB + +@desc Data Memory Barrier is a memory barrier that ensures the ordering of observations of memory accesses, see Data Memory Barrier (DMB) on page A3-151. + +@encoding (T1) { + + @word 1 1 1 1 0 0 1 1 1 0 1 1 1 1 1 1 1 0 0 0 1 1 1 1 0 1 0 1 option(4) + + @syntax + + @conv { + + limitation = BarrierLimitation(option) + + } + +} + +@encoding (A1) { + + @word 1 1 1 1 0 1 0 1 0 1 1 1 1 1 1 1 1 1 1 1 0 0 0 0 0 1 0 1 option(4) + + @syntax + + @conv { + + limitation = BarrierLimitation(option) + + } + +} + diff --git a/plugins/arm/v7/opdefs/dsb_A8844.d b/plugins/arm/v7/opdefs/dsb_A8844.d new file mode 100644 index 0000000..512220c --- /dev/null +++ b/plugins/arm/v7/opdefs/dsb_A8844.d @@ -0,0 +1,55 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * ##FILE## - traduction d'instructions ARMv7 + * + * Copyright (C) 2015 Cyrille Bagard + * + * This file is part of Chrysalide. + * + * Chrysalide is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Chrysalide is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Foobar. If not, see . + */ + + +@title DSB + +@desc Data Synchronization Barrier is a memory barrier that ensures the completion of memory accesses, see Data Synchronization Barrier (DSB) on page A3-152. + +@encoding (T1) { + + @word 1 1 1 1 0 0 1 1 1 0 1 1 1 1 1 1 1 0 0 0 1 1 1 1 0 1 0 0 option(4) + + @syntax + + @conv { + + limitation = BarrierLimitation(option) + + } + +} + +@encoding (A1) { + + @word 1 1 1 1 0 1 0 1 0 1 1 1 1 1 1 1 1 1 1 1 0 0 0 0 0 1 0 0 option(4) + + @syntax + + @conv { + + limitation = BarrierLimitation(option) + + } + +} + diff --git a/plugins/arm/v7/opdefs/eor_A8846.d b/plugins/arm/v7/opdefs/eor_A8846.d new file mode 100644 index 0000000..38dc858 --- /dev/null +++ b/plugins/arm/v7/opdefs/eor_A8846.d @@ -0,0 +1,74 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * ##FILE## - traduction d'instructions ARMv7 + * + * Copyright (C) 2015 Cyrille Bagard + * + * This file is part of Chrysalide. + * + * Chrysalide is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Chrysalide is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Foobar. If not, see . + */ + + +@title EOR (immediate) + +@desc Bitwise Exclusive OR (immediate) performs a bitwise Exclusive OR of a register value and an immediate value, and writes the result to the destination register. It can optionally update the condition flags based on the result. + +@encoding (T1) { + + @word 1 1 1 1 0 i(1) 0 0 1 0 0 S(1) Rn(4) 0 imm3(3) Rd(4) imm8(8) + + @syntax + + @conv { + + reg_D = Register(Rd) + reg_N = Register(Rn) + setflags = (S == '1') + imm32 = ThumbExpandImm_C(i:imm3:imm8, 0) + + } + + @rules { + + if (setflags); chk_call ExtendKeyword("s") + + } + +} + +@encoding (A1) { + + @word cond(4) 0 0 1 0 0 0 1 S(1) Rn(4) Rd(4) imm12(12) + + @syntax + + @conv { + + reg_D = Register(Rd) + reg_N = Register(Rn) + setflags = (S == '1') + imm32 = ARMExpandImm_C(imm12, 0) + + } + + @rules { + + if (setflags); chk_call ExtendKeyword("s") + chk_call StoreCondition(cond) + + } + +} + diff --git a/plugins/arm/v7/opdefs/eor_A8847.d b/plugins/arm/v7/opdefs/eor_A8847.d new file mode 100644 index 0000000..66643a1 --- /dev/null +++ b/plugins/arm/v7/opdefs/eor_A8847.d @@ -0,0 +1,92 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * ##FILE## - traduction d'instructions ARMv7 + * + * Copyright (C) 2015 Cyrille Bagard + * + * This file is part of Chrysalide. + * + * Chrysalide is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Chrysalide is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Foobar. If not, see . + */ + + +@title EOR (register) + +@desc Bitwise Exclusive OR (register) performs a bitwise Exclusive OR of a register value and an optionally-shifted register value, and writes the result to the destination register. It can optionally update the condition flags based on the result. + +@encoding (t1) { + + @half 0 1 0 0 0 0 0 0 0 1 Rm(3) Rdn(3) + + @syntax "eors" + + @conv { + + reg_DN = Register(Rdn) + reg_M = Register(Rm) + + } + +} + +@encoding (T2) { + + @word 1 1 1 0 1 0 1 0 1 0 0 S(1) Rn(4) 0 imm3(3) Rd(4) imm2(2) type(2) Rm(4) + + @syntax + + @conv { + + reg_D = Register(Rd) + reg_N = Register(Rn) + reg_M = Register(Rm) + setflags = (S == '1') + shift = DecodeImmShift(type, imm3:imm2) + + } + + @rules { + + if (setflags); chk_call ExtendKeyword("s") + chk_call ExtendKeyword(".w") + + } + +} + +@encoding (A1) { + + @word cond(4) 0 0 0 0 0 0 1 S(1) Rn(4) Rd(4) imm5(5) type(2) 0 Rm(4) + + @syntax + + @conv { + + reg_D = Register(Rd) + reg_N = Register(Rn) + reg_M = Register(Rm) + setflags = (S == '1') + shift = DecodeImmShift(type, imm5) + + } + + @rules { + + if (setflags); chk_call ExtendKeyword("s") + chk_call StoreCondition(cond) + + } + +} + diff --git a/plugins/arm/v7/opdefs/eor_A8848.d b/plugins/arm/v7/opdefs/eor_A8848.d new file mode 100644 index 0000000..f38fa74 --- /dev/null +++ b/plugins/arm/v7/opdefs/eor_A8848.d @@ -0,0 +1,52 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * ##FILE## - traduction d'instructions ARMv7 + * + * Copyright (C) 2015 Cyrille Bagard + * + * This file is part of Chrysalide. + * + * Chrysalide is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Chrysalide is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Foobar. If not, see . + */ + + +@title EOR (register-shifted register) + +@desc Bitwise Exclusive OR (register-shifted register) performs a bitwise Exclusive OR of a register value and a register-shifted register value. It writes the result to the destination register, and can optionally update the condition flags based on the result. + +@encoding (A1) { + + @word cond(4) 0 0 0 0 0 0 1 S(1) Rn(4) Rd(4) Rs(4) 0 type(2) 1 Rm(4) + + @syntax + + @conv { + + reg_shift = RegisterShift(type, Rs) + reg_D = Register(Rd) + reg_N = Register(Rn) + reg_M = Register(Rm) + setflags = (S == '1') + + } + + @rules { + + if (setflags); chk_call ExtendKeyword("s") + chk_call StoreCondition(cond) + + } + +} + diff --git a/plugins/arm/v7/opdefs/ldr_A8862.d b/plugins/arm/v7/opdefs/ldr_A8862.d new file mode 100644 index 0000000..03df506 --- /dev/null +++ b/plugins/arm/v7/opdefs/ldr_A8862.d @@ -0,0 +1,98 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * ##FILE## - traduction d'instructions ARMv7 + * + * Copyright (C) 2015 Cyrille Bagard + * + * This file is part of Chrysalide. + * + * Chrysalide is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Chrysalide is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Foobar. If not, see . + */ + + +@title LDR (immediate, Thumb) + +@desc Load Register (immediate) calculates an address from a base register value and an immediate offset, loads a word from memory, and writes it to a register. It can use offset, post-indexed, or pre-indexed addressing. For information about memory accesses see Memory accesses on page A8-294. + +@encoding (t1) { + + @half 0 1 1 0 1 imm5(5) Rn(3) Rt(3) + + @syntax + + @conv { + + reg_T = Register(Rt) + reg_N = Register(Rn) + imm32 = ZeroExtend(imm5:'00', 32) + mem_access = MakeMemoryAccess(reg_N, imm32, NULL, true, true, false) + + } + +} + +@encoding (t2) { + + @half 1 0 0 1 1 Rt(3) imm8(8) + + @syntax + + @conv { + + reg_T = Register(Rt) + imm32 = ZeroExtend(imm8:'00', 32) + SP = Register(13) + mem_access = MakeMemoryAccess(SP, imm32, NULL, true, true, false) + + } + +} + +@encoding (T3) { + + @word 1 1 1 1 1 0 0 0 1 1 0 1 Rn(4) Rt(4) imm12(12) + + @syntax ".W" + + @conv { + + reg_T = Register(Rt) + reg_N = Register(Rn) + imm32 = ZeroExtend(imm12, 32) + mem_access = MakeMemoryAccess(reg_N, imm32, NULL, true, true, false) + + } + +} + +@encoding (T4) { + + @word 1 1 1 1 1 0 0 0 0 1 0 1 Rn(4) Rt(4) 1 P(1) U(1) W(1) imm8(8) + + @syntax + + @conv { + + reg_T = Register(Rt) + reg_N = Register(Rn) + imm32 = ZeroExtend(imm8, 32) + index = (P == '1') + add = (U == '1') + wback = (W == '1') + mem_access = MakeMemoryAccess(reg_N, imm32, NULL, index, add, wback) + + } + +} + diff --git a/plugins/arm/v7/opdefs/ldr_A8863.d b/plugins/arm/v7/opdefs/ldr_A8863.d new file mode 100644 index 0000000..0d0ce1f --- /dev/null +++ b/plugins/arm/v7/opdefs/ldr_A8863.d @@ -0,0 +1,53 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * ##FILE## - traduction d'instructions ARMv7 + * + * Copyright (C) 2015 Cyrille Bagard + * + * This file is part of Chrysalide. + * + * Chrysalide is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Chrysalide is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Foobar. If not, see . + */ + + +@title LDR (immediate, ARM) + +@desc Load Register (immediate) calculates an address from a base register value and an immediate offset, loads a word from memory, and writes it to a register. It can use offset, post-indexed, or pre-indexed addressing. For information about memory accesses see Memory accesses on page A8-294. + +@encoding (A1) { + + @word cond(4) 0 1 0 P(1) U(1) 0 W(1) 1 Rn(4) Rt(4) imm12(12) + + @syntax + + @conv { + + reg_T = Register(Rt) + reg_N = Register(Rn) + imm32 = ZeroExtend(imm12, 32) + index = (P == '1') + add = (U == '1') + wback = (P == '0') || (W == '1') + mem_access = MakeMemoryAccess(reg_N, imm32, NULL, index, add, wback) + + } + + @rules { + + chk_call StoreCondition(cond) + + } + +} + diff --git a/plugins/arm/v7/opdefs/ldr_A8864.d b/plugins/arm/v7/opdefs/ldr_A8864.d new file mode 100644 index 0000000..74afa2d --- /dev/null +++ b/plugins/arm/v7/opdefs/ldr_A8864.d @@ -0,0 +1,99 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * ##FILE## - traduction d'instructions ARMv7 + * + * Copyright (C) 2015 Cyrille Bagard + * + * This file is part of Chrysalide. + * + * Chrysalide is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Chrysalide is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Foobar. If not, see . + */ + + +@title LDR (literal) + +@desc Load Register (literal) calculates an address from the PC value and an immediate offset, loads a word from memory, and writes it to a register. For information about memory accesses see Memory accesses on page A8-294. + +@encoding (t1) { + + @half 0 1 0 0 1 Rt(3) imm8(8) + + @syntax + + @conv { + + reg_T = Register(Rt) + imm32 = ZeroExtend(imm8:'00', 32) + + } + + @hooks { + + fetch = help_fetching_with_instruction_ldr_literal_from_thumb + post = post_process_ldr_instructions + + } + +} + +@encoding (T2) { + + @word 1 1 1 1 1 0 0 0 U(1) 1 0 1 1 1 1 1 Rt(4) imm12(12) + + @syntax ".W" + + @conv { + + reg_T = Register(Rt) + imm32 = ZeroExtend(imm12, 32) + + } + + @hooks { + + fetch = help_fetching_with_instruction_ldr_literal_from_thumb + post = post_process_ldr_instructions + + } + +} + +@encoding (A1) { + + @word cond(4) 0 1 0 1 U(1) 0 0 1 1 1 1 1 Rt(4) imm12(12) + + @syntax + + @conv { + + reg_T = Register(Rt) + imm32 = ZeroExtend(imm12, 32) + + } + + @rules { + + chk_call StoreCondition(cond) + + } + + @hooks { + + fetch = help_fetching_with_instruction_ldr_literal_from_arm + post = post_process_ldr_instructions + + } + +} + diff --git a/plugins/arm/v7/opdefs/ldr_A8865.d b/plugins/arm/v7/opdefs/ldr_A8865.d new file mode 100644 index 0000000..ebb4e09 --- /dev/null +++ b/plugins/arm/v7/opdefs/ldr_A8865.d @@ -0,0 +1,62 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * ##FILE## - traduction d'instructions ARMv7 + * + * Copyright (C) 2015 Cyrille Bagard + * + * This file is part of Chrysalide. + * + * Chrysalide is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Chrysalide is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Foobar. If not, see . + */ + + +@title LDR (register, Thumb) + +@desc Load Register (register) calculates an address from a base register value and an offset register value, loads a word from memory, and writes it to a register. The offset register value can optionally be shifted. For information about memory accesses, see Memory accesses on page A8-294. The Thumb form of LDR (register) does not support register writeback. + +@encoding (t1) { + + @half 0 1 0 1 1 0 0 Rm(3) Rn(3) Rt(3) + + @syntax + + @conv { + + reg_T = Register(Rt) + reg_N = Register(Rn) + reg_M = Register(Rm) + mem_access = MakeMemoryAccess(reg_N, reg_M, NULL, true, false, false) + + } + +} + +@encoding (T2) { + + @word 1 1 1 1 1 0 0 0 0 1 0 1 Rn(4) Rt(4) 0 0 0 0 0 0 imm2(2) Rm(4) + + @syntax ".W" + + @conv { + + reg_T = Register(Rt) + reg_N = Register(Rn) + reg_M = Register(Rm) + shift = DecodeImmShift(0, imm2) + mem_access = MakeMemoryAccess(reg_N, reg_M, shift, true, false, false) + + } + +} + diff --git a/plugins/arm/v7/opdefs/ldr_A8866.d b/plugins/arm/v7/opdefs/ldr_A8866.d new file mode 100644 index 0000000..b161043 --- /dev/null +++ b/plugins/arm/v7/opdefs/ldr_A8866.d @@ -0,0 +1,54 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * ##FILE## - traduction d'instructions ARMv7 + * + * Copyright (C) 2015 Cyrille Bagard + * + * This file is part of Chrysalide. + * + * Chrysalide is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Chrysalide is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Foobar. If not, see . + */ + + +@title LDR (register, ARM) + +@desc Load Register (register) calculates an address from a base register value and an offset register value, loads a word from memory, and writes it to a register. The offset register value can optionally be shifted. For information about memory accesses, see Memory accesses on page A8-294. + +@encoding (A1) { + + @word cond(4) 0 1 1 P(1) U(1) 0 W(1) 1 Rn(4) Rt(4) imm5(5) type(2) 0 Rm(4) + + @syntax + + @conv { + + reg_T = Register(Rt) + reg_N = Register(Rn) + reg_M = Register(Rm) + index = (P == '1') + add = (U == '1') + wback = (P == '0') || (W == '1') + shift = DecodeImmShift(type, imm5) + mem_access = MakeMemoryAccess(reg_N, reg_M, shift, index, add, wback) + + } + + @rules { + + chk_call StoreCondition(cond) + + } + +} + diff --git a/plugins/arm/v7/opdefs/ldrb_A8867.d b/plugins/arm/v7/opdefs/ldrb_A8867.d new file mode 100644 index 0000000..2dea64e --- /dev/null +++ b/plugins/arm/v7/opdefs/ldrb_A8867.d @@ -0,0 +1,81 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * ##FILE## - traduction d'instructions ARMv7 + * + * Copyright (C) 2015 Cyrille Bagard + * + * This file is part of Chrysalide. + * + * Chrysalide is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Chrysalide is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Foobar. If not, see . + */ + + +@title LDRB (immediate, Thumb) + +@desc Load Register Byte (immediate) calculates an address from a base register value and an immediate offset, loads a byte from memory, zero-extends it to form a 32-bit word, and writes it to a register. It can use offset, post-indexed, or pre-indexed addressing. For information about memory accesses see Memory accesses on page A8-294. + +@encoding (t1) { + + @half 0 1 1 1 1 imm5(5) Rn(3) Rt(3) + + @syntax + + @conv { + + reg_T = Register(Rt) + reg_N = Register(Rn) + imm32 = ZeroExtend(imm5, 32) + mem_access = MakeMemoryAccess(reg_N, imm32, NULL, true, true, false) + + } + +} + +@encoding (T2) { + + @word 1 1 1 1 1 0 0 0 1 0 0 1 Rn(4) Rt(4) imm12(12) + + @syntax ".W" + + @conv { + + reg_T = Register(Rt) + reg_N = Register(Rn) + imm32 = ZeroExtend(imm12, 32) + mem_access = MakeMemoryAccess(reg_N, imm32, NULL, true, true, false) + + } + +} + +@encoding (T3) { + + @word 1 1 1 1 1 0 0 0 0 0 0 1 Rn(4) Rt(4) 1 P(1) U(1) W(1) imm8(8) + + @syntax + + @conv { + + reg_T = Register(Rt) + reg_N = Register(Rn) + imm32 = ZeroExtend(imm8, 32) + index = (P == '1') + add = (U == '1') + wback = (W == '1') + mem_access = MakeMemoryAccess(reg_N, imm32, NULL, index, add, wback) + + } + +} + diff --git a/plugins/arm/v7/opdefs/ldrb_A8868.d b/plugins/arm/v7/opdefs/ldrb_A8868.d new file mode 100644 index 0000000..519c309 --- /dev/null +++ b/plugins/arm/v7/opdefs/ldrb_A8868.d @@ -0,0 +1,53 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * ##FILE## - traduction d'instructions ARMv7 + * + * Copyright (C) 2015 Cyrille Bagard + * + * This file is part of Chrysalide. + * + * Chrysalide is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Chrysalide is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Foobar. If not, see . + */ + + +@title LDRB (immediate, ARM) + +@desc Load Register Byte (immediate) calculates an address from a base register value and an immediate offset, loads a byte from memory, zero-extends it to form a 32-bit word, and writes it to a register. It can use offset, post-indexed, or pre-indexed addressing. For information about memory accesses see Memory accesses on page A8-294. + +@encoding (A1) { + + @word cond(4) 0 1 0 P(1) U(1) 1 W(1) 1 Rn(4) Rt(4) imm12(12) + + @syntax + + @conv { + + reg_T = Register(Rt) + reg_N = Register(Rn) + imm32 = ZeroExtend(imm12, 32) + index = (P == '1') + add = (U == '1') + wback = (P == '0') || (W == '1') + mem_access = MakeMemoryAccess(reg_N, imm32, NULL, index, add, wback) + + } + + @rules { + + chk_call StoreCondition(cond) + + } + +} + diff --git a/plugins/arm/v7/opdefs/ldrb_A8869.d b/plugins/arm/v7/opdefs/ldrb_A8869.d new file mode 100644 index 0000000..fb80049 --- /dev/null +++ b/plugins/arm/v7/opdefs/ldrb_A8869.d @@ -0,0 +1,63 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * ##FILE## - traduction d'instructions ARMv7 + * + * Copyright (C) 2015 Cyrille Bagard + * + * This file is part of Chrysalide. + * + * Chrysalide is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Chrysalide is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Foobar. If not, see . + */ + + +@title LDRB (literal) + +@desc Load Register Byte (literal) calculates an address from the PC value and an immediate offset, loads a byte from memory, zero-extends it to form a 32-bit word, and writes it to a register. For information about memory accesses see Memory accesses on page A8-294. + +@encoding (T1) { + + @word 1 1 1 1 1 0 0 0 U(1) 0 0 1 1 1 1 1 Rt(4) imm12(12) + + @syntax + + @conv { + + reg_T = Register(Rt) + imm32 = ZeroExtend(imm12, 32) + + } + +} + +@encoding (A1) { + + @word cond(4) 0 1 0 1 U(1) 1 0 1 1 1 1 1 Rt(4) imm12(12) + + @syntax + + @conv { + + reg_T = Register(Rt) + imm32 = ZeroExtend(imm12, 32) + + } + + @rules { + + chk_call StoreCondition(cond) + + } + +} + diff --git a/plugins/arm/v7/opdefs/ldrb_A8870.d b/plugins/arm/v7/opdefs/ldrb_A8870.d new file mode 100644 index 0000000..35f95ab --- /dev/null +++ b/plugins/arm/v7/opdefs/ldrb_A8870.d @@ -0,0 +1,89 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * ##FILE## - traduction d'instructions ARMv7 + * + * Copyright (C) 2015 Cyrille Bagard + * + * This file is part of Chrysalide. + * + * Chrysalide is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Chrysalide is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Foobar. If not, see . + */ + + +@title LDRB (register) + +@desc Load Register Byte (register) calculates an address from a base register value and an offset register value, loads a byte from memory, zero-extends it to form a 32-bit word, and writes it to a register. The offset register value can optionally be shifted. For information about memory accesses see Memory accesses on page A8-294. + +@encoding (t1) { + + @half 0 1 0 1 1 1 0 Rm(3) Rn(3) Rt(3) + + @syntax + + @conv { + + reg_T = Register(Rt) + reg_N = Register(Rn) + reg_M = Register(Rm) + mem_access = MakeMemoryAccess(reg_N, reg_M, NULL, true, true, false) + + } + +} + +@encoding (T2) { + + @word 1 1 1 1 1 0 0 0 0 0 0 1 Rn(4) Rt(4) 0 0 0 0 0 0 imm2(2) Rm(4) + + @syntax ".W" + + @conv { + + reg_T = Register(Rt) + reg_N = Register(Rn) + reg_M = Register(Rm) + shift = DecodeImmShift(0, imm2) + mem_access = MakeMemoryAccess(reg_N, reg_M, shift, true, true, false) + + } + +} + +@encoding (A1) { + + @word cond(4) 0 1 1 P(1) U(1) 1 W(1) 1 Rn(4) Rt(4) imm5(5) type(2) 0 Rm(4) + + @syntax + + @conv { + + reg_T = Register(Rt) + reg_N = Register(Rn) + reg_M = Register(Rm) + index = (P == '1') + add = (U == '1') + wback = (P == '0') || (W == '1') + shift = DecodeImmShift(type, imm5) + mem_access = MakeMemoryAccess(reg_N, reg_M, shift, index, add, wback) + + } + + @rules { + + chk_call StoreCondition(cond) + + } + +} + diff --git a/plugins/arm/v7/opdefs/ldrbt_A8871.d b/plugins/arm/v7/opdefs/ldrbt_A8871.d new file mode 100644 index 0000000..0bf9c3c --- /dev/null +++ b/plugins/arm/v7/opdefs/ldrbt_A8871.d @@ -0,0 +1,93 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * ##FILE## - traduction d'instructions ARMv7 + * + * Copyright (C) 2015 Cyrille Bagard + * + * This file is part of Chrysalide. + * + * Chrysalide is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Chrysalide is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Foobar. If not, see . + */ + + +@title LDRBT + +@desc Load Register Byte Unprivileged loads a byte from memory, zero-extends it to form a 32-bit word, and writes it to a register. For information about memory accesses see Memory accesses on page A8-294. The memory access is restricted as if the processor were running in User mode. This makes no difference if the processor is actually running in User mode. LDRBT is UNPREDICTABLE in Hyp mode. The Thumb instruction uses an offset addressing mode, that calculates the address used for the memory access from a base register value and an immediate offset, and leaves the base register unchanged. The ARM instruction uses a post-indexed addressing mode, that uses a base register value as the address for the memory access, and calculates a new address from a base register value and an offset and writes it back to the base register. The offset can be an immediate value or an optionally-shifted register value. + +@encoding (T1) { + + @word 1 1 1 1 1 0 0 0 0 0 0 1 Rn(4) Rt(4) 1 1 1 0 imm8(8) + + @syntax + + @conv { + + reg_T = Register(Rt) + reg_N = Register(Rn) + imm32 = ZeroExtend(imm8, 32) + mem_access = MakeMemoryAccess(reg_N, imm32, NULL, true, true, false) + + } + +} + +@encoding (A1) { + + @word cond(4) 0 1 0 0 U(1) 1 1 1 Rn(4) Rt(4) imm12(12) + + @syntax + + @conv { + + reg_T = Register(Rt) + reg_N = Register(Rn) + add = (U == '1') + imm32 = ZeroExtend(imm12, 32) + mem_access = MakeMemoryAccess(reg_N, imm32, NULL, false, add, false) + + } + + @rules { + + chk_call StoreCondition(cond) + + } + +} + +@encoding (A2) { + + @word cond(4) 0 1 1 0 U(1) 1 1 1 Rn(4) Rt(4) imm5(5) type(2) 0 Rm(4) + + @syntax + + @conv { + + reg_T = Register(Rt) + reg_N = Register(Rn) + reg_M = Register(Rm) + add = (U == '1') + shift = DecodeImmShift(type, imm5) + mem_access = MakeMemoryAccess(reg_N, reg_M, shift, false, add, false) + + } + + @rules { + + chk_call StoreCondition(cond) + + } + +} + diff --git a/plugins/arm/v7/opdefs/ldrd_A8872.d b/plugins/arm/v7/opdefs/ldrd_A8872.d new file mode 100644 index 0000000..c73fdca --- /dev/null +++ b/plugins/arm/v7/opdefs/ldrd_A8872.d @@ -0,0 +1,75 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * ##FILE## - traduction d'instructions ARMv7 + * + * Copyright (C) 2015 Cyrille Bagard + * + * This file is part of Chrysalide. + * + * Chrysalide is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Chrysalide is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Foobar. If not, see . + */ + + +@title LDRD (immediate) + +@desc Load Register Dual (immediate) calculates an address from a base register value and an immediate offset, loads two words from memory, and writes them to two registers. It can use offset, post-indexed, or pre-indexed addressing. For information about memory accesses see Memory accesses on page A8-294. + +@encoding (T1) { + + @word 1 1 1 0 1 0 0 P(1) U(1) 1 W(1) 1 Rn(4) Rt(4) Rt2(4) imm8(8) + + @syntax + + @conv { + + reg_T = Register(Rt) + reg_T2 = Register(Rt2) + reg_N = Register(Rn) + imm32 = ZeroExtend(imm8:'00', 32) + index = (P == '1') + add = (U == '1') + wback = (W == '1') + mem_access = MakeMemoryAccess(reg_N, imm32, NULL, index, add, wback) + + } + +} + +@encoding (A1) { + + @word cond(4) 0 0 0 P(1) U(1) 1 W(1) 0 Rn(4) Rt(4) imm4H(4) 1 1 0 1 imm4L(4) + + @syntax + + @conv { + + reg_T = Register(Rt) + reg_T2 = NextRegister(reg_T) + reg_N = Register(Rn) + imm32 = ZeroExtend(imm4H:imm4L, 32) + index = (P == '1') + add = (U == '1') + wback = (P == '0') || (W == '1') + mem_access = MakeMemoryAccess(reg_N, imm32, NULL, index, add, wback) + + } + + @rules { + + chk_call StoreCondition(cond) + + } + +} + diff --git a/plugins/arm/v7/opdefs/ldrd_A8873.d b/plugins/arm/v7/opdefs/ldrd_A8873.d new file mode 100644 index 0000000..828e4a3 --- /dev/null +++ b/plugins/arm/v7/opdefs/ldrd_A8873.d @@ -0,0 +1,65 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * ##FILE## - traduction d'instructions ARMv7 + * + * Copyright (C) 2015 Cyrille Bagard + * + * This file is part of Chrysalide. + * + * Chrysalide is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Chrysalide is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Foobar. If not, see . + */ + + +@title LDRD (literal) + +@desc Load Register Dual (literal) calculates an address from the PC value and an immediate offset, loads two words from memory, and writes them to two registers. For information about memory accesses see Memory accesses on page A8-294. + +@encoding (T1) { + + @word 1 1 1 0 1 0 0 P(1) U(1) 1 W(1) 1 1 1 1 1 Rt(4) Rt2(4) imm8(8) + + @syntax + + @conv { + + reg_T = Register(Rt) + reg_T2 = Register(Rt2) + imm32 = ZeroExtend(imm8:'00', 32) + + } + +} + +@encoding (A1) { + + @word cond(4) 0 0 0 1 U(1) 1 0 0 1 1 1 1 Rt(4) imm4H(4) 1 1 0 1 imm4L(4) + + @syntax + + @conv { + + reg_T = Register(Rt) + reg_T2 = NextRegister(reg_T) + imm32 = ZeroExtend(imm4H:imm4L, 32) + + } + + @rules { + + chk_call StoreCondition(cond) + + } + +} + diff --git a/plugins/arm/v7/opdefs/ldrd_A8874.d b/plugins/arm/v7/opdefs/ldrd_A8874.d new file mode 100644 index 0000000..ed055a6 --- /dev/null +++ b/plugins/arm/v7/opdefs/ldrd_A8874.d @@ -0,0 +1,54 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * ##FILE## - traduction d'instructions ARMv7 + * + * Copyright (C) 2015 Cyrille Bagard + * + * This file is part of Chrysalide. + * + * Chrysalide is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Chrysalide is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Foobar. If not, see . + */ + + +@title LDRD (register) + +@desc Load Register Dual (register) calculates an address from a base register value and a register offset, loads two words from memory, and writes them to two registers. It can use offset, post-indexed, or pre-indexed addressing. For information about memory accesses see Memory accesses on page A8-294. + +@encoding (A1) { + + @word cond(4) 0 0 0 P(1) U(1) 0 W(1) 0 Rn(4) Rt(4) 0 0 0 0 1 1 0 1 Rm(4) + + @syntax + + @conv { + + reg_T = Register(Rt) + reg_T2 = NextRegister(reg_T) + reg_N = Register(Rn) + reg_M = Register(Rm) + index = (P == '1') + add = (U == '1') + wback = (P == '0') || (W == '1') + mem_access = MakeMemoryAccess(reg_N, reg_M, NULL, index, add, wback) + + } + + @rules { + + chk_call StoreCondition(cond) + + } + +} + diff --git a/plugins/arm/v7/opdefs/ldrex_A8875.d b/plugins/arm/v7/opdefs/ldrex_A8875.d new file mode 100644 index 0000000..b915061 --- /dev/null +++ b/plugins/arm/v7/opdefs/ldrex_A8875.d @@ -0,0 +1,66 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * ##FILE## - traduction d'instructions ARMv7 + * + * Copyright (C) 2015 Cyrille Bagard + * + * This file is part of Chrysalide. + * + * Chrysalide is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Chrysalide is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Foobar. If not, see . + */ + + +@title LDREX + +@desc Load Register Exclusive calculates an address from a base register value and an immediate offset, loads a word from memory, writes it to a register and: • if the address has the Shared Memory attribute, marks the physical address as exclusive access for the executing processor in a global monitor • causes the executing processor to indicate an active exclusive access in the local monitor. For more information about support for shared memory see Synchronization and semaphores on page A3-114. For information about memory accesses see Memory accesses on page A8-294. + +@encoding (T1) { + + @word 1 1 1 0 1 0 0 0 0 1 0 1 Rn(4) Rt(4) 1 1 1 1 imm8(8) + + @syntax + + @conv { + + reg_T = Register(Rt) + reg_N = Register(Rn) + imm32 = ZeroExtend(imm8:'00', 32) + mem_access = MakeMemoryAccess(reg_N, imm32, NULL, true, false, false) + + } + +} + +@encoding (A1) { + + @word cond(4) 0 0 0 1 1 0 0 1 Rn(4) Rt(4) 1 1 1 1 1 0 0 1 1 1 1 1 + + @syntax + + @conv { + + reg_T = Register(Rt) + reg_N = Register(Rn) + mem_access = MakeMemoryAccess(reg_N, NULL, NULL, true, false, false) + + } + + @rules { + + chk_call StoreCondition(cond) + + } + +} + diff --git a/plugins/arm/v7/opdefs/ldrexb_A8876.d b/plugins/arm/v7/opdefs/ldrexb_A8876.d new file mode 100644 index 0000000..e398ef2 --- /dev/null +++ b/plugins/arm/v7/opdefs/ldrexb_A8876.d @@ -0,0 +1,65 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * ##FILE## - traduction d'instructions ARMv7 + * + * Copyright (C) 2015 Cyrille Bagard + * + * This file is part of Chrysalide. + * + * Chrysalide is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Chrysalide is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Foobar. If not, see . + */ + + +@title LDREXB + +@desc Load Register Exclusive Byte derives an address from a base register value, loads a byte from memory, zero-extends it to form a 32-bit word, writes it to a register and: • if the address has the Shared Memory attribute, marks the physical address as exclusive access for the executing processor in a global monitor • causes the executing processor to indicate an active exclusive access in the local monitor. For more information about support for shared memory see Synchronization and semaphores on page A3-114. For information about memory accesses see Memory accesses on page A8-294. + +@encoding (T1) { + + @word 1 1 1 0 1 0 0 0 1 1 0 1 Rn(4) Rt(4) 1 1 1 1 0 1 0 0 1 1 1 1 + + @syntax + + @conv { + + reg_T = Register(Rt) + reg_N = Register(Rn) + mem_access = MakeMemoryAccess(reg_N, NULL, NULL, true, false, false) + + } + +} + +@encoding (A1) { + + @word cond(4) 0 0 0 1 1 1 0 1 Rn(4) Rt(4) 1 1 1 1 1 0 0 1 1 1 1 1 + + @syntax + + @conv { + + reg_T = Register(Rt) + reg_N = Register(Rn) + mem_access = MakeMemoryAccess(reg_N, NULL, NULL, true, false, false) + + } + + @rules { + + chk_call StoreCondition(cond) + + } + +} + diff --git a/plugins/arm/v7/opdefs/ldrexd_A8877.d b/plugins/arm/v7/opdefs/ldrexd_A8877.d new file mode 100644 index 0000000..0188cb7 --- /dev/null +++ b/plugins/arm/v7/opdefs/ldrexd_A8877.d @@ -0,0 +1,67 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * ##FILE## - traduction d'instructions ARMv7 + * + * Copyright (C) 2015 Cyrille Bagard + * + * This file is part of Chrysalide. + * + * Chrysalide is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Chrysalide is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Foobar. If not, see . + */ + + +@title LDREXD + +@desc Load Register Exclusive Doubleword derives an address from a base register value, loads a 64-bit doubleword from memory, writes it to two registers and: • if the address has the Shared Memory attribute, marks the physical address as exclusive access for the executing processor in a global monitor • causes the executing processor to indicate an active exclusive access in the local monitor. For more information about support for shared memory see Synchronization and semaphores on page A3-114. For information about memory accesses see Memory accesses on page A8-294. + +@encoding (T1) { + + @word 1 1 1 0 1 0 0 0 1 1 0 1 Rn(4) Rt(4) Rt2(4) 0 1 1 1 1 1 1 1 + + @syntax + + @conv { + + reg_T = Register(Rt) + reg_T2 = Register(Rt2) + reg_N = Register(Rn) + mem_access = MakeMemoryAccess(reg_N, NULL, NULL, true, false, false) + + } + +} + +@encoding (A1) { + + @word cond(4) 0 0 0 1 1 0 1 1 Rn(4) Rt(4) 1 1 1 1 1 0 0 1 1 1 1 1 + + @syntax + + @conv { + + reg_T = Register(Rt) + reg_T2 = NextRegister(reg_T) + reg_N = Register(Rn) + mem_access = MakeMemoryAccess(reg_N, NULL, NULL, true, false, false) + + } + + @rules { + + chk_call StoreCondition(cond) + + } + +} + diff --git a/plugins/arm/v7/opdefs/ldrexh_A8878.d b/plugins/arm/v7/opdefs/ldrexh_A8878.d new file mode 100644 index 0000000..8e9366f --- /dev/null +++ b/plugins/arm/v7/opdefs/ldrexh_A8878.d @@ -0,0 +1,65 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * ##FILE## - traduction d'instructions ARMv7 + * + * Copyright (C) 2015 Cyrille Bagard + * + * This file is part of Chrysalide. + * + * Chrysalide is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Chrysalide is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Foobar. If not, see . + */ + + +@title LDREXH + +@desc Load Register Exclusive Halfword derives an address from a base register value, loads a halfword from memory, zero-extends it to form a 32-bit word, writes it to a register and: • if the address has the Shared Memory attribute, marks the physical address as exclusive access for the executing processor in a global monitor • causes the executing processor to indicate an active exclusive access in the local monitor. For more information about support for shared memory see Synchronization and semaphores on page A3-114. For information about memory accesses see Memory accesses on page A8-294. + +@encoding (T1) { + + @word 1 1 1 0 1 0 0 0 1 1 0 1 Rn(4) Rt(4) 1 1 1 1 0 1 0 1 1 1 1 1 + + @syntax + + @conv { + + reg_T = Register(Rt) + reg_N = Register(Rn) + mem_access = MakeMemoryAccess(reg_N, NULL, NULL, true, false, false) + + } + +} + +@encoding (A1) { + + @word cond(4) 0 0 0 1 1 1 1 1 Rn(4) Rt(4) 1 1 1 1 1 0 0 1 1 1 1 1 + + @syntax + + @conv { + + reg_T = Register(Rt) + reg_N = Register(Rn) + mem_access = MakeMemoryAccess(reg_N, NULL, NULL, true, false, false) + + } + + @rules { + + chk_call StoreCondition(cond) + + } + +} + diff --git a/plugins/arm/v7/opdefs/ldrh_A8879.d b/plugins/arm/v7/opdefs/ldrh_A8879.d new file mode 100644 index 0000000..3b57bf8 --- /dev/null +++ b/plugins/arm/v7/opdefs/ldrh_A8879.d @@ -0,0 +1,81 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * ##FILE## - traduction d'instructions ARMv7 + * + * Copyright (C) 2015 Cyrille Bagard + * + * This file is part of Chrysalide. + * + * Chrysalide is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Chrysalide is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Foobar. If not, see . + */ + + +@title LDRH (immediate, Thumb) + +@desc Load Register Halfword (immediate) calculates an address from a base register value and an immediate offset, loads a halfword from memory, zero-extends it to form a 32-bit word, and writes it to a register. It can use offset, post-indexed, or pre-indexed addressing. For information about memory accesses see Memory accesses on page A8-294. + +@encoding (t1) { + + @half 1 0 0 0 1 imm5(5) Rn(3) Rt(3) + + @syntax + + @conv { + + reg_T = Register(Rt) + reg_N = Register(Rn) + imm32 = ZeroExtend(imm5:'0', 32) + mem_access = MakeMemoryAccess(reg_N, imm32, NULL, true, true, false) + + } + +} + +@encoding (T2) { + + @word 1 1 1 1 1 0 0 0 1 0 1 1 Rn(4) Rt(4) imm12(12) + + @syntax ".W" + + @conv { + + reg_T = Register(Rt) + reg_N = Register(Rn) + imm32 = ZeroExtend(imm12, 32) + mem_access = MakeMemoryAccess(reg_N, imm32, NULL, true, true, false) + + } + +} + +@encoding (T3) { + + @word 1 1 1 1 1 0 0 0 0 0 1 1 Rn(4) Rt(4) 1 P(1) U(1) W(1) imm8(8) + + @syntax + + @conv { + + reg_T = Register(Rt) + reg_N = Register(Rn) + imm32 = ZeroExtend(imm8, 32) + index = (P == '1') + add = (U == '1') + wback = (W == '1') + mem_access = MakeMemoryAccess(reg_N, imm32, NULL, index, add, wback) + + } + +} + diff --git a/plugins/arm/v7/opdefs/ldrh_A8880.d b/plugins/arm/v7/opdefs/ldrh_A8880.d new file mode 100644 index 0000000..f5f7ab0 --- /dev/null +++ b/plugins/arm/v7/opdefs/ldrh_A8880.d @@ -0,0 +1,53 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * ##FILE## - traduction d'instructions ARMv7 + * + * Copyright (C) 2015 Cyrille Bagard + * + * This file is part of Chrysalide. + * + * Chrysalide is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Chrysalide is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Foobar. If not, see . + */ + + +@title LDRH (immediate, ARM) + +@desc Load Register Halfword (immediate) calculates an address from a base register value and an immediate offset, loads a halfword from memory, zero-extends it to form a 32-bit word, and writes it to a register. It can use offset, post-indexed, or pre-indexed addressing. For information about memory accesses see Memory accesses on page A8-294. + +@encoding (A1) { + + @word cond(4) 0 0 0 P(1) U(1) 1 W(1) 1 Rn(4) Rt(4) imm4H(4) 1 0 1 1 imm4L(4) + + @syntax + + @conv { + + reg_T = Register(Rt) + reg_N = Register(Rn) + imm32 = ZeroExtend(imm4H:imm4L, 32) + index = (P == '1') + add = (U == '1') + wback = (P == '0') || (W == '1') + mem_access = MakeMemoryAccess(reg_N, imm32, NULL, index, add, wback) + + } + + @rules { + + chk_call StoreCondition(cond) + + } + +} + diff --git a/plugins/arm/v7/opdefs/ldrh_A8881.d b/plugins/arm/v7/opdefs/ldrh_A8881.d new file mode 100644 index 0000000..59005e4 --- /dev/null +++ b/plugins/arm/v7/opdefs/ldrh_A8881.d @@ -0,0 +1,63 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * ##FILE## - traduction d'instructions ARMv7 + * + * Copyright (C) 2015 Cyrille Bagard + * + * This file is part of Chrysalide. + * + * Chrysalide is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Chrysalide is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Foobar. If not, see . + */ + + +@title LDRH (literal) + +@desc Load Register Halfword (literal) calculates an address from the PC value and an immediate offset, loads a halfword from memory, zero-extends it to form a 32-bit word, and writes it to a register. For information about memory accesses see Memory accesses on page A8-294. + +@encoding (T1) { + + @word 1 1 1 1 1 0 0 0 U(1) 0 1 1 1 1 1 1 Rt(4) imm12(12) + + @syntax + + @conv { + + reg_T = Register(Rt) + imm32 = ZeroExtend(imm12, 32) + + } + +} + +@encoding (A1) { + + @word cond(4) 0 0 0 P(1) U(1) 1 W(1) 1 1 1 1 1 Rt(4) imm4H(4) 1 0 1 1 imm4L(4) + + @syntax + + @conv { + + reg_T = Register(Rt) + imm32 = ZeroExtend(imm4H:imm4L, 32) + + } + + @rules { + + chk_call StoreCondition(cond) + + } + +} + diff --git a/plugins/arm/v7/opdefs/ldrh_A8882.d b/plugins/arm/v7/opdefs/ldrh_A8882.d new file mode 100644 index 0000000..823bf24 --- /dev/null +++ b/plugins/arm/v7/opdefs/ldrh_A8882.d @@ -0,0 +1,88 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * ##FILE## - traduction d'instructions ARMv7 + * + * Copyright (C) 2015 Cyrille Bagard + * + * This file is part of Chrysalide. + * + * Chrysalide is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Chrysalide is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Foobar. If not, see . + */ + + +@title LDRH (register) + +@desc Load Register Halfword (register) calculates an address from a base register value and an offset register value, loads a halfword from memory, zero-extends it to form a 32-bit word, and writes it to a register. The offset register value can be shifted left by 0, 1, 2, or 3 bits. For information about memory accesses see Memory accesses on page A8-294. + +@encoding (t1) { + + @half 0 1 0 1 1 0 1 Rm(3) Rn(3) Rt(3) + + @syntax + + @conv { + + reg_T = Register(Rt) + reg_N = Register(Rn) + reg_M = Register(Rm) + mem_access = MakeMemoryAccess(reg_N, reg_M, NULL, true, true, false) + + } + +} + +@encoding (T2) { + + @word 1 1 1 1 1 0 0 0 0 0 1 1 Rn(4) Rt(4) 0 0 0 0 0 0 imm2(2) Rm(4) + + @syntax ".W" + + @conv { + + reg_T = Register(Rt) + reg_N = Register(Rn) + reg_M = Register(Rm) + shift = DecodeImmShift(0, imm2) + mem_access = MakeMemoryAccess(reg_N, reg_M, shift, true, true, false) + + } + +} + +@encoding (A1) { + + @word cond(4) 0 0 0 P(1) U(1) 0 W(1) 1 Rn(4) Rt(4) 0 0 0 0 1 0 1 1 Rm(4) + + @syntax + + @conv { + + reg_T = Register(Rt) + reg_N = Register(Rn) + reg_M = Register(Rm) + index = (P == '1') + add = (U == '1') + wback = (P == '0') || (W == '1') + mem_access = MakeMemoryAccess(reg_N, reg_M, NULL, index, add, wback) + + } + + @rules { + + chk_call StoreCondition(cond) + + } + +} + diff --git a/plugins/arm/v7/opdefs/ldrht_A8883.d b/plugins/arm/v7/opdefs/ldrht_A8883.d new file mode 100644 index 0000000..8f8f015 --- /dev/null +++ b/plugins/arm/v7/opdefs/ldrht_A8883.d @@ -0,0 +1,92 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * ##FILE## - traduction d'instructions ARMv7 + * + * Copyright (C) 2015 Cyrille Bagard + * + * This file is part of Chrysalide. + * + * Chrysalide is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Chrysalide is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Foobar. If not, see . + */ + + +@title LDRHT + +@desc Load Register Halfword Unprivileged loads a halfword from memory, zero-extends it to form a 32-bit word, and writes it to a register. For information about memory accesses see Memory accesses on page A8-294. The memory access is restricted as if the processor were running in User mode. This makes no difference if the processor is actually running in User mode. LDRHT is UNPREDICTABLE in Hyp mode. The Thumb instruction uses an offset addressing mode, that calculates the address used for the memory access from a base register value and an immediate offset, and leaves the base register unchanged. The ARM instruction uses a post-indexed addressing mode, that uses a base register value as the address for the memory access, and calculates a new address from a base register value and an offset and writes it back to the base register. The offset can be an immediate value or a register value. + +@encoding (T1) { + + @word 1 1 1 1 1 0 0 0 0 0 1 1 Rn(4) Rt(4) 1 1 1 0 imm8(8) + + @syntax + + @conv { + + reg_T = Register(Rt) + reg_N = Register(Rn) + imm32 = ZeroExtend(imm8, 32) + mem_access = MakeMemoryAccess(reg_N, imm32, NULL, true, true, false) + + } + +} + +@encoding (A1) { + + @word cond(4) 0 0 0 0 U(1) 1 1 1 Rn(4) Rt(4) imm4H(4) 1 0 1 1 imm4L(4) + + @syntax + + @conv { + + reg_T = Register(Rt) + reg_N = Register(Rn) + add = (U == '1') + imm32 = ZeroExtend(imm4H:imm4L, 32) + mem_access = MakeMemoryAccess(reg_N, imm32, NULL, false, add, false) + + } + + @rules { + + chk_call StoreCondition(cond) + + } + +} + +@encoding (A2) { + + @word cond(4) 0 0 0 0 U(1) 0 1 1 Rn(4) Rt(4) 0 0 0 0 1 0 1 1 Rm(4) + + @syntax + + @conv { + + reg_T = Register(Rt) + reg_N = Register(Rn) + reg_M = Register(Rm) + add = (U == '1') + mem_access = MakeMemoryAccess(reg_N, reg_M, NULL, false, add, false) + + } + + @rules { + + chk_call StoreCondition(cond) + + } + +} + diff --git a/plugins/arm/v7/opdefs/ldrsb_A8884.d b/plugins/arm/v7/opdefs/ldrsb_A8884.d new file mode 100644 index 0000000..fc41134 --- /dev/null +++ b/plugins/arm/v7/opdefs/ldrsb_A8884.d @@ -0,0 +1,90 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * ##FILE## - traduction d'instructions ARMv7 + * + * Copyright (C) 2015 Cyrille Bagard + * + * This file is part of Chrysalide. + * + * Chrysalide is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Chrysalide is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Foobar. If not, see . + */ + + +@title LDRSB (immediate) + +@desc Load Register Signed Byte (immediate) calculates an address from a base register value and an immediate offset, loads a byte from memory, sign-extends it to form a 32-bit word, and writes it to a register. It can use offset, post-indexed, or pre-indexed addressing. For information about memory accesses see Memory accesses on page A8-294. + +@encoding (T1) { + + @word 1 1 1 1 1 0 0 1 1 0 0 1 Rn(4) Rt(4) imm12(12) + + @syntax + + @conv { + + reg_T = Register(Rt) + reg_N = Register(Rn) + imm32 = ZeroExtend(imm12, 32) + mem_access = MakeMemoryAccess(reg_N, imm32, NULL, true, true, false) + + } + +} + +@encoding (T2) { + + @word 1 1 1 1 1 0 0 1 0 0 0 1 Rn(4) Rt(4) 1 P(1) U(1) W(1) imm8(8) + + @syntax + + @conv { + + reg_T = Register(Rt) + reg_N = Register(Rn) + imm32 = ZeroExtend(imm8, 32) + index = (P == '1') + add = (U == '1') + wback = (W == '1') + mem_access = MakeMemoryAccess(reg_N, imm32, NULL, index, add, wback) + + } + +} + +@encoding (A1) { + + @word cond(4) 0 0 0 P(1) U(1) 1 W(1) 1 Rn(4) Rt(4) imm4H(4) 1 1 0 1 imm4L(4) + + @syntax + + @conv { + + reg_T = Register(Rt) + reg_N = Register(Rn) + imm32 = ZeroExtend(imm4H:imm4L, 32) + index = (P == '1') + add = (U == '1') + wback = (P == '0') || (W == '1') + mem_access = MakeMemoryAccess(reg_N, imm32, NULL, index, add, wback) + + } + + @rules { + + chk_call StoreCondition(cond) + + } + +} + diff --git a/plugins/arm/v7/opdefs/ldrsb_A8885.d b/plugins/arm/v7/opdefs/ldrsb_A8885.d new file mode 100644 index 0000000..6cb1d34 --- /dev/null +++ b/plugins/arm/v7/opdefs/ldrsb_A8885.d @@ -0,0 +1,63 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * ##FILE## - traduction d'instructions ARMv7 + * + * Copyright (C) 2015 Cyrille Bagard + * + * This file is part of Chrysalide. + * + * Chrysalide is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Chrysalide is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Foobar. If not, see . + */ + + +@title LDRSB (literal) + +@desc Load Register Signed Byte (literal) calculates an address from the PC value and an immediate offset, loads a byte from memory, sign-extends it to form a 32-bit word, and writes it to a register. For information about memory accesses see Memory accesses on page A8-294. + +@encoding (T1) { + + @word 1 1 1 1 1 0 0 1 U(1) 0 0 1 1 1 1 1 Rt(4) imm12(12) + + @syntax + + @conv { + + reg_T = Register(Rt) + imm32 = ZeroExtend(imm12, 32) + + } + +} + +@encoding (A1) { + + @word cond(4) 0 0 0 1 U(1) 1 0 1 1 1 1 1 Rt(4) imm4H(4) 1 1 0 1 imm4L(4) + + @syntax + + @conv { + + reg_T = Register(Rt) + imm32 = ZeroExtend(imm4H:imm4L, 32) + + } + + @rules { + + chk_call StoreCondition(cond) + + } + +} + diff --git a/plugins/arm/v7/opdefs/ldrsb_A8886.d b/plugins/arm/v7/opdefs/ldrsb_A8886.d new file mode 100644 index 0000000..4a66278 --- /dev/null +++ b/plugins/arm/v7/opdefs/ldrsb_A8886.d @@ -0,0 +1,88 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * ##FILE## - traduction d'instructions ARMv7 + * + * Copyright (C) 2015 Cyrille Bagard + * + * This file is part of Chrysalide. + * + * Chrysalide is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Chrysalide is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Foobar. If not, see . + */ + + +@title LDRSB (register) + +@desc Load Register Signed Byte (register) calculates an address from a base register value and an offset register value, loads a byte from memory, sign-extends it to form a 32-bit word, and writes it to a register. The offset register value can be shifted left by 0, 1, 2, or 3 bits. For information about memory accesses see Memory accesses on page A8-294. + +@encoding (t1) { + + @half 0 1 0 1 0 1 1 Rm(3) Rn(3) Rt(3) + + @syntax + + @conv { + + reg_T = Register(Rt) + reg_N = Register(Rn) + reg_M = Register(Rm) + mem_access = MakeMemoryAccess(reg_N, reg_M, NULL, true, true, false) + + } + +} + +@encoding (T2) { + + @word 1 1 1 1 1 0 0 1 0 0 0 1 Rn(4) Rt(4) 0 0 0 0 0 0 imm2(2) Rm(4) + + @syntax ".W" + + @conv { + + reg_T = Register(Rt) + reg_N = Register(Rn) + reg_M = Register(Rm) + shift = DecodeImmShift(0, imm2) + mem_access = MakeMemoryAccess(reg_N, reg_M, shift, true, true, false) + + } + +} + +@encoding (A1) { + + @word cond(4) 0 0 0 P(1) U(1) 0 W(1) 1 Rn(4) Rt(4) 0 0 0 0 1 1 0 1 Rm(4) + + @syntax + + @conv { + + reg_T = Register(Rt) + reg_N = Register(Rn) + reg_M = Register(Rm) + index = (P == '1') + add = (U == '1') + wback = (P == '0') || (W == '1') + mem_access = MakeMemoryAccess(reg_N, reg_M, NULL, index, add, wback) + + } + + @rules { + + chk_call StoreCondition(cond) + + } + +} + diff --git a/plugins/arm/v7/opdefs/ldrsbt_A8887.d b/plugins/arm/v7/opdefs/ldrsbt_A8887.d new file mode 100644 index 0000000..b545f32 --- /dev/null +++ b/plugins/arm/v7/opdefs/ldrsbt_A8887.d @@ -0,0 +1,92 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * ##FILE## - traduction d'instructions ARMv7 + * + * Copyright (C) 2015 Cyrille Bagard + * + * This file is part of Chrysalide. + * + * Chrysalide is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Chrysalide is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Foobar. If not, see . + */ + + +@title LDRSBT + +@desc Load Register Signed Byte Unprivileged loads a byte from memory, sign-extends it to form a 32-bit word, and writes it to a register. For information about memory accesses see Memory accesses on page A8-294. The memory access is restricted as if the processor were running in User mode. This makes no difference if the processor is actually running in User mode. LDRSBT is UNPREDICTABLE in Hyp mode. The Thumb instruction uses an offset addressing mode, that calculates the address used for the memory access from a base register value and an immediate offset, and leaves the base register unchanged. The ARM instruction uses a post-indexed addressing mode, that uses a base register value as the address for the memory access, and calculates a new address from a base register value and an offset and writes it back to the base register. The offset can be an immediate value or a register value. + +@encoding (T1) { + + @word 1 1 1 1 1 0 0 1 0 0 0 1 Rn(4) Rt(4) 1 1 1 0 imm8(8) + + @syntax + + @conv { + + reg_T = Register(Rt) + reg_N = Register(Rn) + imm32 = ZeroExtend(imm8, 32) + mem_access = MakeMemoryAccess(reg_N, imm32, NULL, true, true, false) + + } + +} + +@encoding (A1) { + + @word cond(4) 0 0 0 0 U(1) 1 1 1 Rn(4) Rt(4) imm4H(4) 1 1 0 1 imm4L(4) + + @syntax + + @conv { + + reg_T = Register(Rt) + reg_N = Register(Rn) + add = (U == '1') + imm32 = ZeroExtend(imm4H:imm4L, 32) + mem_access = MakeMemoryAccess(reg_N, imm32, NULL, false, add, false) + + } + + @rules { + + chk_call StoreCondition(cond) + + } + +} + +@encoding (A2) { + + @word cond(4) 0 0 0 0 U(1) 0 1 1 Rn(4) Rt(4) 0 0 0 0 1 1 0 1 Rm(4) + + @syntax + + @conv { + + reg_T = Register(Rt) + reg_N = Register(Rn) + reg_M = Register(Rm) + add = (U == '1') + mem_access = MakeMemoryAccess(reg_N, reg_M, NULL, false, add, false) + + } + + @rules { + + chk_call StoreCondition(cond) + + } + +} + diff --git a/plugins/arm/v7/opdefs/ldrsh_A8888.d b/plugins/arm/v7/opdefs/ldrsh_A8888.d new file mode 100644 index 0000000..f01024c --- /dev/null +++ b/plugins/arm/v7/opdefs/ldrsh_A8888.d @@ -0,0 +1,90 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * ##FILE## - traduction d'instructions ARMv7 + * + * Copyright (C) 2015 Cyrille Bagard + * + * This file is part of Chrysalide. + * + * Chrysalide is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Chrysalide is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Foobar. If not, see . + */ + + +@title LDRSH (immediate) + +@desc Load Register Signed Halfword (immediate) calculates an address from a base register value and an immediate offset, loads a halfword from memory, sign-extends it to form a 32-bit word, and writes it to a register. It can use offset, post-indexed, or pre-indexed addressing. For information about memory accesses see Memory accesses on page A8-294. + +@encoding (T1) { + + @word 1 1 1 1 1 0 0 1 1 0 1 1 Rn(4) Rt(4) imm12(12) + + @syntax + + @conv { + + reg_T = Register(Rt) + reg_N = Register(Rn) + imm32 = ZeroExtend(imm12, 32) + mem_access = MakeMemoryAccess(reg_N, imm32, NULL, true, true, false) + + } + +} + +@encoding (T2) { + + @word 1 1 1 1 1 0 0 1 0 0 1 1 Rn(4) Rt(4) 1 P(1) U(1) W(1) imm8(8) + + @syntax + + @conv { + + reg_T = Register(Rt) + reg_N = Register(Rn) + imm32 = ZeroExtend(imm8, 32) + index = (P == '1') + add = (U == '1') + wback = (W == '1') + mem_access = MakeMemoryAccess(reg_N, imm32, NULL, index, add, wback) + + } + +} + +@encoding (A1) { + + @word cond(4) 0 0 0 P(1) U(1) 1 W(1) 1 Rn(4) Rt(4) imm4H(4) 1 1 1 1 imm4L(4) + + @syntax + + @conv { + + reg_T = Register(Rt) + reg_N = Register(Rn) + imm32 = ZeroExtend(imm4H:imm4L, 32) + index = (P == '1') + add = (U == '1') + wback = (P == '0') || (W == '1') + mem_access = MakeMemoryAccess(reg_N, imm32, NULL, index, add, wback) + + } + + @rules { + + chk_call StoreCondition(cond) + + } + +} + diff --git a/plugins/arm/v7/opdefs/ldrsh_A8889.d b/plugins/arm/v7/opdefs/ldrsh_A8889.d new file mode 100644 index 0000000..074cd5c --- /dev/null +++ b/plugins/arm/v7/opdefs/ldrsh_A8889.d @@ -0,0 +1,63 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * ##FILE## - traduction d'instructions ARMv7 + * + * Copyright (C) 2015 Cyrille Bagard + * + * This file is part of Chrysalide. + * + * Chrysalide is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Chrysalide is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Foobar. If not, see . + */ + + +@title LDRSH (literal) + +@desc Load Register Signed Halfword (literal) calculates an address from the PC value and an immediate offset, loads a halfword from memory, sign-extends it to form a 32-bit word, and writes it to a register. For information about memory accesses see Memory accesses on page A8-294. + +@encoding (T1) { + + @word 1 1 1 1 1 0 0 1 U(1) 0 1 1 1 1 1 1 Rt(4) imm12(12) + + @syntax + + @conv { + + reg_T = Register(Rt) + imm32 = ZeroExtend(imm12, 32) + + } + +} + +@encoding (A1) { + + @word cond(4) 0 0 0 1 U(1) 1 0 1 1 1 1 1 Rt(4) imm4H(4) 1 1 1 1 imm4L(4) + + @syntax + + @conv { + + reg_T = Register(Rt) + imm32 = ZeroExtend(imm4H:imm4L, 32) + + } + + @rules { + + chk_call StoreCondition(cond) + + } + +} + diff --git a/plugins/arm/v7/opdefs/ldrsh_A8890.d b/plugins/arm/v7/opdefs/ldrsh_A8890.d new file mode 100644 index 0000000..eac6c09 --- /dev/null +++ b/plugins/arm/v7/opdefs/ldrsh_A8890.d @@ -0,0 +1,88 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * ##FILE## - traduction d'instructions ARMv7 + * + * Copyright (C) 2015 Cyrille Bagard + * + * This file is part of Chrysalide. + * + * Chrysalide is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Chrysalide is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Foobar. If not, see . + */ + + +@title LDRSH (register) + +@desc Load Register Signed Halfword (register) calculates an address from a base register value and an offset register value, loads a halfword from memory, sign-extends it to form a 32-bit word, and writes it to a register. The offset register value can be shifted left by 0, 1, 2, or 3 bits. For information about memory accesses see Memory accesses on page A8-294. + +@encoding (t1) { + + @half 0 1 0 1 1 1 1 Rm(3) Rn(3) Rt(3) + + @syntax + + @conv { + + reg_T = Register(Rt) + reg_N = Register(Rn) + reg_M = Register(Rm) + mem_access = MakeMemoryAccess(reg_N, reg_M, NULL, true, true, false) + + } + +} + +@encoding (T2) { + + @word 1 1 1 1 1 0 0 1 0 0 1 1 Rn(4) Rt(4) 0 0 0 0 0 0 imm2(2) Rm(4) + + @syntax ".W" + + @conv { + + reg_T = Register(Rt) + reg_N = Register(Rn) + reg_M = Register(Rm) + shift = DecodeImmShift(0, imm2) + mem_access = MakeMemoryAccess(reg_N, reg_M, shift, true, true, false) + + } + +} + +@encoding (A1) { + + @word cond(4) 0 0 0 P(1) U(1) 0 W(1) 1 Rn(4) Rt(4) 0 0 0 0 1 1 1 1 Rm(4) + + @syntax + + @conv { + + reg_T = Register(Rt) + reg_N = Register(Rn) + reg_M = Register(Rm) + index = (P == '1') + add = (U == '1') + wback = (P == '0') || (W == '1') + mem_access = MakeMemoryAccess(reg_N, reg_M, NULL, index, add, wback) + + } + + @rules { + + chk_call StoreCondition(cond) + + } + +} + diff --git a/plugins/arm/v7/opdefs/ldrsht_A8891.d b/plugins/arm/v7/opdefs/ldrsht_A8891.d new file mode 100644 index 0000000..355178b --- /dev/null +++ b/plugins/arm/v7/opdefs/ldrsht_A8891.d @@ -0,0 +1,92 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * ##FILE## - traduction d'instructions ARMv7 + * + * Copyright (C) 2015 Cyrille Bagard + * + * This file is part of Chrysalide. + * + * Chrysalide is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Chrysalide is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Foobar. If not, see . + */ + + +@title LDRSHT + +@desc Load Register Signed Halfword Unprivileged loads a halfword from memory, sign-extends it to form a 32-bit word, and writes it to a register. For information about memory accesses see Memory accesses on page A8-294. The memory access is restricted as if the processor were running in User mode. This makes no difference if the processor is actually running in User mode. LDRSHT is UNPREDICTABLE in Hyp mode. The Thumb instruction uses an offset addressing mode, that calculates the address used for the memory access from a base register value and an immediate offset, and leaves the base register unchanged. The ARM instruction uses a post-indexed addressing mode, that uses a base register value as the address for the memory access, and calculates a new address from a base register value and an offset and writes it back to the base register. The offset can be an immediate value or a register value. + +@encoding (T1) { + + @word 1 1 1 1 1 0 0 1 0 0 1 1 Rn(4) Rt(4) 1 1 1 0 imm8(8) + + @syntax + + @conv { + + reg_T = Register(Rt) + reg_N = Register(Rn) + imm32 = ZeroExtend(imm8, 32) + mem_access = MakeMemoryAccess(reg_N, imm32, NULL, true, true, false) + + } + +} + +@encoding (A1) { + + @word cond(4) 0 0 0 0 U(1) 1 1 1 Rn(4) Rt(4) imm4H(4) 1 1 1 1 imm4L(4) + + @syntax + + @conv { + + reg_T = Register(Rt) + reg_N = Register(Rn) + add = (U == '1') + imm32 = ZeroExtend(imm4H:imm4L, 32) + mem_access = MakeMemoryAccess(reg_N, imm32, NULL, false, add, false) + + } + + @rules { + + chk_call StoreCondition(cond) + + } + +} + +@encoding (A2) { + + @word cond(4) 0 0 0 0 U(1) 0 1 1 Rn(4) Rt(4) 0 0 0 0 1 1 1 1 Rm(4) + + @syntax + + @conv { + + reg_T = Register(Rt) + reg_N = Register(Rn) + reg_M = Register(Rm) + add = (U == '1') + mem_access = MakeMemoryAccess(reg_N, reg_M, NULL, false, add, false) + + } + + @rules { + + chk_call StoreCondition(cond) + + } + +} + diff --git a/plugins/arm/v7/opdefs/ldrt_A8892.d b/plugins/arm/v7/opdefs/ldrt_A8892.d new file mode 100644 index 0000000..e13f0e7 --- /dev/null +++ b/plugins/arm/v7/opdefs/ldrt_A8892.d @@ -0,0 +1,93 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * ##FILE## - traduction d'instructions ARMv7 + * + * Copyright (C) 2015 Cyrille Bagard + * + * This file is part of Chrysalide. + * + * Chrysalide is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Chrysalide is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Foobar. If not, see . + */ + + +@title LDRT + +@desc Load Register Unprivileged loads a word from memory, and writes it to a register. For information about memory accesses see Memory accesses on page A8-294. The memory access is restricted as if the processor were running in User mode. This makes no difference if the processor is actually running in User mode. LDRT is UNPREDICTABLE in Hyp mode. The Thumb instruction uses an offset addressing mode, that calculates the address used for the memory access from a base register value and an immediate offset, and leaves the base register unchanged. The ARM instruction uses a post-indexed addressing mode, that uses a base register value as the address for the memory access, and calculates a new address from a base register value and an offset and writes it back to the base register. The offset can be an immediate value or an optionally-shifted register value. + +@encoding (T1) { + + @word 1 1 1 1 1 0 0 0 0 1 0 1 Rn(4) Rt(4) 1 1 1 0 imm8(8) + + @syntax + + @conv { + + reg_T = Register(Rt) + reg_N = Register(Rn) + imm32 = ZeroExtend(imm8, 32) + mem_access = MakeMemoryAccess(reg_N, imm32, NULL, true, true, false) + + } + +} + +@encoding (A1) { + + @word cond(4) 0 1 0 0 U(1) 0 1 1 Rn(4) Rt(4) imm12(12) + + @syntax + + @conv { + + reg_T = Register(Rt) + reg_N = Register(Rn) + add = (U == '1') + imm32 = ZeroExtend(imm12, 32) + mem_access = MakeMemoryAccess(reg_N, imm32, NULL, false, add, false) + + } + + @rules { + + chk_call StoreCondition(cond) + + } + +} + +@encoding (A2) { + + @word cond(4) 0 1 1 0 U(1) 0 1 1 Rn(4) Rt(4) imm5(5) type(2) 0 Rm(4) + + @syntax + + @conv { + + reg_T = Register(Rt) + reg_N = Register(Rn) + reg_M = Register(Rm) + add = (U == '1') + shift = DecodeImmShift(type, imm5) + mem_access = MakeMemoryAccess(reg_N, reg_M, shift, false, add, false) + + } + + @rules { + + chk_call StoreCondition(cond) + + } + +} + diff --git a/plugins/arm/v7/opdefs/lsl_A8894.d b/plugins/arm/v7/opdefs/lsl_A8894.d new file mode 100644 index 0000000..89924c6 --- /dev/null +++ b/plugins/arm/v7/opdefs/lsl_A8894.d @@ -0,0 +1,91 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * ##FILE## - traduction d'instructions ARMv7 + * + * Copyright (C) 2015 Cyrille Bagard + * + * This file is part of Chrysalide. + * + * Chrysalide is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Chrysalide is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Foobar. If not, see . + */ + + +@title LSL (immediate) + +@desc Logical Shift Left (immediate) shifts a register value left by an immediate number of bits, shifting in zeros, and writes the result to the destination register. It can optionally update the condition flags based on the result. + +@encoding (t1) { + + @half 0 0 0 0 0 imm5(5) Rm(3) Rd(3) + + @syntax "lsls" + + @conv { + + reg_D = Register(Rd) + reg_M = Register(Rm) + shift_imm = DecodeImmShift('00', imm5) + + } + +} + +@encoding (T2) { + + @word 1 1 1 0 1 0 1 0 0 1 0 S(1) 1 1 1 1 0 imm3(3) Rd(4) imm2(2) 0 0 Rm(4) + + @syntax + + @conv { + + reg_D = Register(Rd) + reg_M = Register(Rm) + setflags = (S == '1') + shift_imm = DecodeImmShift('00', imm3:imm2) + + } + + @rules { + + if (setflags); chk_call ExtendKeyword("s") + chk_call ExtendKeyword(".w") + + } + +} + +@encoding (A1) { + + @word cond(4) 0 0 0 1 1 0 1 S(1) 0 0 0 0 Rd(4) imm5(5) 0 0 0 Rm(4) + + @syntax + + @conv { + + reg_D = Register(Rd) + reg_M = Register(Rm) + setflags = (S == '1') + shift_imm = DecodeImmShift('00', imm5) + + } + + @rules { + + if (setflags); chk_call ExtendKeyword("s") + chk_call StoreCondition(cond) + + } + +} + diff --git a/plugins/arm/v7/opdefs/lsl_A8895.d b/plugins/arm/v7/opdefs/lsl_A8895.d new file mode 100644 index 0000000..4ac5ab6 --- /dev/null +++ b/plugins/arm/v7/opdefs/lsl_A8895.d @@ -0,0 +1,90 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * ##FILE## - traduction d'instructions ARMv7 + * + * Copyright (C) 2015 Cyrille Bagard + * + * This file is part of Chrysalide. + * + * Chrysalide is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Chrysalide is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Foobar. If not, see . + */ + + +@title LSL (register) + +@desc Logical Shift Left (register) shifts a register value left by a variable number of bits, shifting in zeros, and writes the result to the destination register. The variable number of bits is read from the bottom byte of a register. It can optionally update the condition flags based on the result. + +@encoding (t1) { + + @half 0 1 0 0 0 0 0 0 1 0 Rm(3) Rdn(3) + + @syntax "lsls" + + @conv { + + reg_DN = Register(Rdn) + reg_M = Register(Rm) + + } + +} + +@encoding (T2) { + + @word 1 1 1 1 1 0 1 0 0 0 0 S(1) Rn(4) 1 1 1 1 Rd(4) 0 0 0 0 Rm(4) + + @syntax + + @conv { + + reg_D = Register(Rd) + reg_N = Register(Rn) + reg_M = Register(Rm) + setflags = (S == '1') + + } + + @rules { + + if (setflags); chk_call ExtendKeyword("s") + chk_call ExtendKeyword(".w") + + } + +} + +@encoding (A1) { + + @word cond(4) 0 0 0 1 1 0 1 S(1) 0 0 0 0 Rd(4) Rm(4) 0 0 0 1 Rn(4) + + @syntax + + @conv { + + reg_D = Register(Rd) + reg_N = Register(Rn) + reg_M = Register(Rm) + setflags = (S == '1') + + } + + @rules { + + if (setflags); chk_call ExtendKeyword("s") + chk_call StoreCondition(cond) + + } + +} + diff --git a/plugins/arm/v7/opdefs/lsr_A8896.d b/plugins/arm/v7/opdefs/lsr_A8896.d new file mode 100644 index 0000000..acb9e25 --- /dev/null +++ b/plugins/arm/v7/opdefs/lsr_A8896.d @@ -0,0 +1,91 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * ##FILE## - traduction d'instructions ARMv7 + * + * Copyright (C) 2015 Cyrille Bagard + * + * This file is part of Chrysalide. + * + * Chrysalide is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Chrysalide is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Foobar. If not, see . + */ + + +@title LSR (immediate) + +@desc Logical Shift Right (immediate) shifts a register value right by an immediate number of bits, shifting in zeros, and writes the result to the destination register. It can optionally update the condition flags based on the result. + +@encoding (t1) { + + @half 0 0 0 0 1 imm5(5) Rm(3) Rd(3) + + @syntax "lsrs" + + @conv { + + reg_D = Register(Rd) + reg_M = Register(Rm) + shift_imm = DecodeImmShift('01', imm5) + + } + +} + +@encoding (T2) { + + @word 1 1 1 0 1 0 1 0 0 1 0 S(1) 1 1 1 1 0 imm3(3) Rd(4) imm2(2) 0 1 Rm(4) + + @syntax + + @conv { + + reg_D = Register(Rd) + reg_M = Register(Rm) + setflags = (S == '1') + shift_imm = DecodeImmShift('01', imm3:imm2) + + } + + @rules { + + if (setflags); chk_call ExtendKeyword("s") + chk_call ExtendKeyword(".w") + + } + +} + +@encoding (A1) { + + @word cond(4) 0 0 0 1 1 0 1 S(1) 0 0 0 0 Rd(4) imm5(5) 0 1 0 Rm(4) + + @syntax + + @conv { + + reg_D = Register(Rd) + reg_M = Register(Rm) + setflags = (S == '1') + shift_imm = DecodeImmShift('01', imm5) + + } + + @rules { + + if (setflags); chk_call ExtendKeyword("s") + chk_call StoreCondition(cond) + + } + +} + diff --git a/plugins/arm/v7/opdefs/lsr_A8897.d b/plugins/arm/v7/opdefs/lsr_A8897.d new file mode 100644 index 0000000..070a152 --- /dev/null +++ b/plugins/arm/v7/opdefs/lsr_A8897.d @@ -0,0 +1,90 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * ##FILE## - traduction d'instructions ARMv7 + * + * Copyright (C) 2015 Cyrille Bagard + * + * This file is part of Chrysalide. + * + * Chrysalide is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Chrysalide is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Foobar. If not, see . + */ + + +@title LSR (register) + +@desc Logical Shift Right (register) shifts a register value right by a variable number of bits, shifting in zeros, and writes the result to the destination register. The variable number of bits is read from the bottom byte of a register. It can optionally update the condition flags based on the result. + +@encoding (t1) { + + @half 0 1 0 0 0 0 0 0 1 1 Rm(3) Rdn(3) + + @syntax "lsrs" + + @conv { + + reg_DN = Register(Rdn) + reg_M = Register(Rm) + + } + +} + +@encoding (T2) { + + @word 1 1 1 1 1 0 1 0 0 0 1 S(1) Rn(4) 1 1 1 1 Rd(4) 0 0 0 0 Rm(4) + + @syntax + + @conv { + + reg_D = Register(Rd) + reg_N = Register(Rn) + reg_M = Register(Rm) + setflags = (S == '1') + + } + + @rules { + + if (setflags); chk_call ExtendKeyword("s") + chk_call ExtendKeyword(".w") + + } + +} + +@encoding (A1) { + + @word cond(4) 0 0 0 1 1 0 1 S(1) 0 0 0 0 Rd(4) Rm(4) 0 0 1 1 Rn(4) + + @syntax + + @conv { + + reg_D = Register(Rd) + reg_N = Register(Rn) + reg_M = Register(Rm) + setflags = (S == '1') + + } + + @rules { + + if (setflags); chk_call ExtendKeyword("s") + chk_call StoreCondition(cond) + + } + +} + diff --git a/plugins/arm/v7/opdefs/mcr_A8898.d b/plugins/arm/v7/opdefs/mcr_A8898.d new file mode 100644 index 0000000..f710d5d --- /dev/null +++ b/plugins/arm/v7/opdefs/mcr_A8898.d @@ -0,0 +1,109 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * ##FILE## - traduction d'instructions ARMv7 + * + * Copyright (C) 2015 Cyrille Bagard + * + * This file is part of Chrysalide. + * + * Chrysalide is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Chrysalide is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Foobar. If not, see . + */ + + +@title MCR, MCR2 + +@desc Move to Coprocessor from ARM core register passes the value of an ARM core register to a coprocessor. If no coprocessor can execute the instruction, an Undefined Instruction exception is generated. This is a generic coprocessor instruction. Some of the fields have no functionality defined by the architecture and are free for use by the coprocessor instruction set designer. These are the opc1, opc2, CRn, and CRm fields. However, coprocessors CP8-CP15 are reserved for use by ARM, and this manual defines the valid MCR and MCR2 instructions when coproc is in the range p8-p15. For more information see Coprocessor support on page A2-94. In an implementation that includes the Virtualization Extensions, MCR accesses to system control registers can be trapped to Hyp mode, meaning that an attempt to execute an MCR instruction in a Non-secure mode other than Hyp mode, that would be permitted in the absence of the Hyp trap controls, generates a Hyp Trap exception. For more information, see Traps to the hypervisor on page B1-1247. Note Because of the range of possible traps to Hyp mode, the MCR pseudocode does not show these possible traps. + +@encoding (T1) { + + @word 1 1 1 0 1 1 1 0 opc1(3) 0 CRn(4) Rt(4) coproc(4) opc2(3) 1 CRm(4) + + @syntax + + @conv { + + reg_T = Register(Rt) + cp = CoProcessor(coproc) + undef_opc1 = RawValue(opc1) + creg_N = CRegister(CRn) + creg_M = CRegister(CRm) + undef_opc2 = RawValue(opc2) + + } + +} + +@encoding (A1) { + + @word cond(4) 1 1 1 0 opc1(3) 0 CRn(4) Rt(4) coproc(4) opc2(3) 1 CRm(4) + + @syntax + + @conv { + + reg_T = Register(Rt) + cp = CoProcessor(coproc) + undef_opc1 = RawValue(opc1) + creg_N = CRegister(CRn) + creg_M = CRegister(CRm) + undef_opc2 = RawValue(opc2) + + } + + @rules { + + chk_call StoreCondition(cond) + + } + +} + +@encoding (T2) { + + @word 1 1 1 1 1 1 1 0 opc1(3) 0 CRn(4) Rt(4) coproc(4) opc2(3) 1 CRm(4) + + @syntax "mcr2" + + @conv { + + reg_T = Register(Rt) + cp = CoProcessor(coproc) + undef_opc1 = RawValue(opc1) + creg_N = CRegister(CRn) + creg_M = CRegister(CRm) + undef_opc2 = RawValue(opc2) + + } + +} + +@encoding (A2) { + + @word 1 1 1 1 1 1 1 0 opc1(3) 0 CRn(4) Rt(4) coproc(4) opc2(3) 1 CRm(4) + + @syntax "mcr2" + + @conv { + + reg_T = Register(Rt) + cp = CoProcessor(coproc) + undef_opc1 = RawValue(opc1) + creg_N = CRegister(CRn) + creg_M = CRegister(CRm) + undef_opc2 = RawValue(opc2) + + } + +} + diff --git a/plugins/arm/v7/opdefs/mcrr_A8899.d b/plugins/arm/v7/opdefs/mcrr_A8899.d new file mode 100644 index 0000000..f643826 --- /dev/null +++ b/plugins/arm/v7/opdefs/mcrr_A8899.d @@ -0,0 +1,105 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * ##FILE## - traduction d'instructions ARMv7 + * + * Copyright (C) 2015 Cyrille Bagard + * + * This file is part of Chrysalide. + * + * Chrysalide is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Chrysalide is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Foobar. If not, see . + */ + + +@title MCRR, MCRR2 + +@desc Move to Coprocessor from two ARM core registers passes the values of two ARM core registers to a coprocessor. If no coprocessor can execute the instruction, an Undefined Instruction exception is generated. This is a generic coprocessor instruction. Some of the fields have no functionality defined by the architecture and are free for use by the coprocessor instruction set designer. These are the opc1 and CRm fields. However, coprocessors CP8-CP15 are reserved for use by ARM, and this manual defines the valid MCRR and MCRR2 instructions when coproc is in the range p8-p15. For more information see Coprocessor support on page A2-94. In an implementation that includes the Virtualization Extensions, MCRR accesses to system control registers can be trapped to Hyp mode, meaning that an attempt to execute an MCRR instruction in a Non-secure mode other than Hyp mode, that would be permitted in the absence of the Hyp trap controls, generates a Hyp Trap exception. For more information, see Traps to the hypervisor on page B1-1247. Note Because of the range of possible traps to Hyp mode, the MCRR pseudocode does not show these possible traps. + +@encoding (T1) { + + @word 1 1 1 0 1 1 0 0 0 1 0 0 Rt2(4) Rt(4) coproc(4) opc1(4) CRm(4) + + @syntax + + @conv { + + reg_T = Register(Rt) + reg_T2 = Register(Rt2) + cp = CoProcessor(coproc) + undef_opc1 = RawValue(opc1) + creg_M = CRegister(CRm) + + } + +} + +@encoding (A1) { + + @word cond(4) 1 1 0 0 0 1 0 0 Rt2(4) Rt(4) coproc(4) opc1(4) CRm(4) + + @syntax + + @conv { + + reg_T = Register(Rt) + reg_T2 = Register(Rt2) + cp = CoProcessor(coproc) + undef_opc1 = RawValue(opc1) + creg_M = CRegister(CRm) + + } + + @rules { + + chk_call StoreCondition(cond) + + } + +} + +@encoding (T2) { + + @word 1 1 1 1 1 1 0 0 0 1 0 0 Rt2(4) Rt(4) coproc(4) opc1(4) CRm(4) + + @syntax "mcrr2" + + @conv { + + reg_T = Register(Rt) + reg_T2 = Register(Rt2) + cp = CoProcessor(coproc) + undef_opc1 = RawValue(opc1) + creg_M = CRegister(CRm) + + } + +} + +@encoding (A2) { + + @word 1 1 1 1 1 1 0 0 0 1 0 0 Rt2(4) Rt(4) coproc(4) opc1(4) CRm(4) + + @syntax "mcrr2" + + @conv { + + reg_T = Register(Rt) + reg_T2 = Register(Rt2) + cp = CoProcessor(coproc) + undef_opc1 = RawValue(opc1) + creg_M = CRegister(CRm) + + } + +} + diff --git a/plugins/arm/v7/opdefs/mla_A88100.d b/plugins/arm/v7/opdefs/mla_A88100.d new file mode 100644 index 0000000..5d4b4e4 --- /dev/null +++ b/plugins/arm/v7/opdefs/mla_A88100.d @@ -0,0 +1,69 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * ##FILE## - traduction d'instructions ARMv7 + * + * Copyright (C) 2015 Cyrille Bagard + * + * This file is part of Chrysalide. + * + * Chrysalide is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Chrysalide is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Foobar. If not, see . + */ + + +@title MLA + +@desc Multiply Accumulate multiplies two register values, and adds a third register value. The least significant 32 bits of the result are written to the destination register. These 32 bits do not depend on whether the source register values are considered to be signed values or unsigned values. In an ARM instruction, the condition flags can optionally be updated based on the result. Use of this option adversely affects performance on many processor implementations. + +@encoding (T1) { + + @word 1 1 1 1 1 0 1 1 0 0 0 0 Rn(4) Ra(4) Rd(4) 0 0 0 0 Rm(4) + + @syntax + + @conv { + + reg_D = Register(Rd) + reg_N = Register(Rn) + reg_M = Register(Rm) + reg_A = Register(Ra) + + } + +} + +@encoding (A1) { + + @word cond(4) 0 0 0 0 0 0 1 S(1) Rd(4) Ra(4) Rm(4) 1 0 0 1 Rn(4) + + @syntax + + @conv { + + reg_D = Register(Rd) + reg_N = Register(Rn) + reg_M = Register(Rm) + reg_A = Register(Ra) + setflags = (S == '1') + + } + + @rules { + + if (setflags); chk_call ExtendKeyword("s") + chk_call StoreCondition(cond) + + } + +} + diff --git a/plugins/arm/v7/opdefs/mls_A88101.d b/plugins/arm/v7/opdefs/mls_A88101.d new file mode 100644 index 0000000..4d10be8 --- /dev/null +++ b/plugins/arm/v7/opdefs/mls_A88101.d @@ -0,0 +1,67 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * ##FILE## - traduction d'instructions ARMv7 + * + * Copyright (C) 2015 Cyrille Bagard + * + * This file is part of Chrysalide. + * + * Chrysalide is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Chrysalide is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Foobar. If not, see . + */ + + +@title MLS + +@desc Multiply and Subtract multiplies two register values, and subtracts the product from a third register value. The least significant 32 bits of the result are written to the destination register. These 32 bits do not depend on whether the source register values are considered to be signed values or unsigned values. + +@encoding (T1) { + + @word 1 1 1 1 1 0 1 1 0 0 0 0 Rn(4) Ra(4) Rd(4) 0 0 0 1 Rm(4) + + @syntax + + @conv { + + reg_D = Register(Rd) + reg_N = Register(Rn) + reg_M = Register(Rm) + reg_A = Register(Ra) + + } + +} + +@encoding (A1) { + + @word cond(4) 0 0 0 0 0 1 1 0 Rd(4) Ra(4) Rm(4) 1 0 0 1 Rn(4) + + @syntax + + @conv { + + reg_D = Register(Rd) + reg_N = Register(Rn) + reg_M = Register(Rm) + reg_A = Register(Ra) + + } + + @rules { + + chk_call StoreCondition(cond) + + } + +} + diff --git a/plugins/arm/v7/opdefs/mov_A88102.d b/plugins/arm/v7/opdefs/mov_A88102.d new file mode 100644 index 0000000..d96baab --- /dev/null +++ b/plugins/arm/v7/opdefs/mov_A88102.d @@ -0,0 +1,124 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * ##FILE## - traduction d'instructions ARMv7 + * + * Copyright (C) 2015 Cyrille Bagard + * + * This file is part of Chrysalide. + * + * Chrysalide is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Chrysalide is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Foobar. If not, see . + */ + + +@title MOV (immediate) + +@desc Move (immediate) writes an immediate value to the destination register. It can optionally update the condition flags based on the value. + +@encoding (t1) { + + @half 0 0 1 0 0 Rd(3) imm8(8) + + @syntax "movs" + + @conv { + + reg_D = Register(Rd) + imm32 = ZeroExtend(imm8, 32) + + } + +} + +@encoding (T2) { + + @word 1 1 1 1 0 i(1) 0 0 0 1 0 S(1) 1 1 1 1 0 imm3(3) Rd(4) imm8(8) + + @syntax + + @conv { + + reg_D = Register(Rd) + setflags = (S == '1') + imm32 = ThumbExpandImm_C(i:imm3:imm8, 0) + + } + + @rules { + + if (setflags); chk_call ExtendKeyword("s") + chk_call ExtendKeyword(".w") + + } + +} + +@encoding (T3) { + + @word 1 1 1 1 0 i(1) 1 0 0 1 0 0 imm4(4) 0 imm3(3) Rd(4) imm8(8) + + @syntax "movw" + + @conv { + + reg_D = Register(Rd) + imm32 = ZeroExtend(imm4:i:imm3:imm8, 32) + + } + +} + +@encoding (A1) { + + @word cond(4) 0 0 1 1 1 0 1 S(1) 0 0 0 0 Rd(4) imm12(12) + + @syntax + + @conv { + + reg_D = Register(Rd) + setflags = (S == '1') + imm32 = ARMExpandImm_C(imm12, 0) + + } + + @rules { + + if (setflags); chk_call ExtendKeyword("s") + chk_call StoreCondition(cond) + + } + +} + +@encoding (A2) { + + @word cond(4) 0 0 1 1 0 0 0 0 imm4(4) Rd(4) imm12(12) + + @syntax "movw" + + @conv { + + reg_D = Register(Rd) + imm32 = ZeroExtend(imm4:imm12, 32) + + } + + @rules { + + chk_call StoreCondition(cond) + + } + +} + diff --git a/plugins/arm/v7/opdefs/mov_A88103.d b/plugins/arm/v7/opdefs/mov_A88103.d new file mode 100644 index 0000000..cd3d75a --- /dev/null +++ b/plugins/arm/v7/opdefs/mov_A88103.d @@ -0,0 +1,80 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * ##FILE## - traduction d'instructions ARMv7 + * + * Copyright (C) 2015 Cyrille Bagard + * + * This file is part of Chrysalide. + * + * Chrysalide is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Chrysalide is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Foobar. If not, see . + */ + + +@title MOV (register, Thumb) + +@desc Move (register) copies a value from a register to the destination register. It can optionally update the condition flags based on the value. + +@encoding (t1) { + + @half 0 1 0 0 0 1 1 0 D(1) Rm(4) Rd(3) + + @syntax + + @conv { + + reg_D = Register(D:Rd) + reg_M = Register(Rm) + + } + +} + +@encoding (t2) { + + @half 0 0 0 0 0 0 0 0 0 0 Rm(3) Rd(3) + + @syntax "movs" + + @conv { + + reg_D = Register(Rd) + reg_M = Register(Rm) + + } + +} + +@encoding (T3) { + + @word 1 1 1 0 1 0 1 0 0 1 0 S(1) 1 1 1 1 0 0 0 0 Rd(4) 0 0 0 0 Rm(4) + + @syntax + + @conv { + + reg_D = Register(Rd) + reg_M = Register(Rm) + setflags = (S == '1') + + } + + @rules { + + if (setflags); chk_call ExtendKeyword("s") + chk_call ExtendKeyword(".w") + + } + +} + diff --git a/plugins/arm/v7/opdefs/mov_A88104.d b/plugins/arm/v7/opdefs/mov_A88104.d new file mode 100644 index 0000000..d164983 --- /dev/null +++ b/plugins/arm/v7/opdefs/mov_A88104.d @@ -0,0 +1,50 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * ##FILE## - traduction d'instructions ARMv7 + * + * Copyright (C) 2015 Cyrille Bagard + * + * This file is part of Chrysalide. + * + * Chrysalide is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Chrysalide is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Foobar. If not, see . + */ + + +@title MOV (register, ARM) + +@desc Move (register) copies a value from a register to the destination register. It can optionally update the condition flags based on the value. + +@encoding (A1) { + + @word cond(4) 0 0 0 1 1 0 1 S(1) 0 0 0 0 Rd(4) 0 0 0 0 0 0 0 0 Rm(4) + + @syntax + + @conv { + + reg_D = Register(Rd) + reg_M = Register(Rm) + setflags = (S == '1') + + } + + @rules { + + if (setflags); chk_call ExtendKeyword("s") + chk_call StoreCondition(cond) + + } + +} + diff --git a/plugins/arm/v7/opdefs/movt_A88106.d b/plugins/arm/v7/opdefs/movt_A88106.d new file mode 100644 index 0000000..265d008 --- /dev/null +++ b/plugins/arm/v7/opdefs/movt_A88106.d @@ -0,0 +1,63 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * ##FILE## - traduction d'instructions ARMv7 + * + * Copyright (C) 2015 Cyrille Bagard + * + * This file is part of Chrysalide. + * + * Chrysalide is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Chrysalide is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Foobar. If not, see . + */ + + +@title MOVT + +@desc Move Top writes an immediate value to the top halfword of the destination register. It does not affect the contents of the bottom halfword. + +@encoding (T1) { + + @word 1 1 1 1 0 i(1) 1 0 1 1 0 0 imm4(4) 0 imm3(3) Rd(4) imm8(8) + + @syntax + + @conv { + + reg_D = Register(Rd) + imm16 = BuildImm16(imm4:i:imm3:imm8) + + } + +} + +@encoding (A1) { + + @word cond(4) 0 0 1 1 0 1 0 0 imm4(4) Rd(4) imm12(12) + + @syntax + + @conv { + + reg_D = Register(Rd) + imm16 = BuildImm16(imm4:imm12) + + } + + @rules { + + chk_call StoreCondition(cond) + + } + +} + diff --git a/plugins/arm/v7/opdefs/mrc_A88107.d b/plugins/arm/v7/opdefs/mrc_A88107.d new file mode 100644 index 0000000..fb9714c --- /dev/null +++ b/plugins/arm/v7/opdefs/mrc_A88107.d @@ -0,0 +1,109 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * ##FILE## - traduction d'instructions ARMv7 + * + * Copyright (C) 2015 Cyrille Bagard + * + * This file is part of Chrysalide. + * + * Chrysalide is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Chrysalide is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Foobar. If not, see . + */ + + +@title MRC, MRC2 + +@desc Move to ARM core register from Coprocessor causes a coprocessor to transfer a value to an ARM core register or to the condition flags. If no coprocessor can execute the instruction, an Undefined Instruction exception is generated. This is a generic coprocessor instruction. Some of the fields have no functionality defined by the architecture and are free for use by the coprocessor instruction set designer. These are the opc1, opc2, CRn, and CRm fields. However, coprocessors CP8-CP15 are reserved for use by ARM, and this manual defines the valid MRC and MRC2 instructions when coproc is in the range p8-p15. For more information see Coprocessor support on page A2-94. In an implementation that includes the Virtualization Extensions, MRC accesses to system control registers can be trapped to Hyp mode, meaning that an attempt to execute an MRC instruction in a Non-secure mode other than Hyp mode, that would be permitted in the absence of the Hyp trap controls, generates a Hyp Trap exception. For more information, see Traps to the hypervisor on page B1-1247. Note Because of the range of possible traps to Hyp mode, the MRC pseudocode does not show these possible traps. + +@encoding (T1) { + + @word 1 1 1 0 1 1 1 0 opc1(3) 1 CRn(4) Rt(4) coproc(4) opc2(3) 1 CRm(4) + + @syntax + + @conv { + + reg_T = Register(Rt) + cp = CoProcessor(coproc) + undef_opc1 = RawValue(opc1) + creg_N = CRegister(CRn) + creg_M = CRegister(CRm) + undef_opc2 = RawValue(opc2) + + } + +} + +@encoding (A1) { + + @word cond(4) 1 1 1 0 opc1(3) 1 CRn(4) Rt(4) coproc(4) opc2(3) 1 CRm(4) + + @syntax + + @conv { + + reg_T = Register(Rt) + cp = CoProcessor(coproc) + undef_opc1 = RawValue(opc1) + creg_N = CRegister(CRn) + creg_M = CRegister(CRm) + undef_opc2 = RawValue(opc2) + + } + + @rules { + + chk_call StoreCondition(cond) + + } + +} + +@encoding (T2) { + + @word 1 1 1 1 1 1 1 0 opc1(3) 1 CRn(4) Rt(4) coproc(4) opc2(3) 1 CRm(4) + + @syntax "mrc2" + + @conv { + + reg_T = Register(Rt) + cp = CoProcessor(coproc) + undef_opc1 = RawValue(opc1) + creg_N = CRegister(CRn) + creg_M = CRegister(CRm) + undef_opc2 = RawValue(opc2) + + } + +} + +@encoding (A2) { + + @word 1 1 1 1 1 1 1 0 opc1(3) 1 CRn(4) Rt(4) coproc(4) opc2(3) 1 CRm(4) + + @syntax "mrc2" + + @conv { + + reg_T = Register(Rt) + cp = CoProcessor(coproc) + undef_opc1 = RawValue(opc1) + creg_N = CRegister(CRn) + creg_M = CRegister(CRm) + undef_opc2 = RawValue(opc2) + + } + +} + diff --git a/plugins/arm/v7/opdefs/mrrc_A88108.d b/plugins/arm/v7/opdefs/mrrc_A88108.d new file mode 100644 index 0000000..026c0ef --- /dev/null +++ b/plugins/arm/v7/opdefs/mrrc_A88108.d @@ -0,0 +1,105 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * ##FILE## - traduction d'instructions ARMv7 + * + * Copyright (C) 2015 Cyrille Bagard + * + * This file is part of Chrysalide. + * + * Chrysalide is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Chrysalide is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Foobar. If not, see . + */ + + +@title MRRC, MRRC2 + +@desc Move to two ARM core registers from Coprocessor causes a coprocessor to transfer values to two ARM core registers. If no coprocessor can execute the instruction, an Undefined Instruction exception is generated. This is a generic coprocessor instruction. Some of the fields have no functionality defined by the architecture and are free for use by the coprocessor instruction set designer. These are the opc1 and CRm fields. However, coprocessors CP8-CP15 are reserved for use by ARM, and this manual defines the valid MRRC and MRRC2 instructions when coproc is in the range p8-p15. For more information see Coprocessor support on page A2-94. In an implementation that includes the Virtualization Extensions, MRRC accesses to system control registers can be trapped to Hyp mode, meaning that an attempt to execute an MRRC instruction in a Non-secure mode other than Hyp mode, that would be permitted in the absence of the Hyp trap controls, generates a Hyp Trap exception. For more information, see Traps to the hypervisor on page B1-1247. Note Because of the range of possible traps to Hyp mode, the MRRC pseudocode does not show these possible traps. + +@encoding (T1) { + + @word 1 1 1 0 1 1 0 0 0 1 0 1 Rt2(4) Rt(4) coproc(4) opc1(4) CRm(4) + + @syntax + + @conv { + + reg_T = Register(Rt) + reg_T2 = Register(Rt2) + cp = CoProcessor(coproc) + opc = RawValue(opc1) + creg_M = CRegister(CRm) + + } + +} + +@encoding (A1) { + + @word cond(4) 1 1 0 0 0 1 0 1 Rt2(4) Rt(4) coproc(4) opc1(4) CRm(4) + + @syntax + + @conv { + + reg_T = Register(Rt) + reg_T2 = Register(Rt2) + cp = CoProcessor(coproc) + opc = RawValue(opc1) + creg_M = CRegister(CRm) + + } + + @rules { + + chk_call StoreCondition(cond) + + } + +} + +@encoding (T2) { + + @word 1 1 1 1 1 1 0 0 0 1 0 1 Rt2(4) Rt(4) coproc(4) opc1(4) CRm(4) + + @syntax "mrrc2" + + @conv { + + reg_T = Register(Rt) + reg_T2 = Register(Rt2) + cp = CoProcessor(coproc) + opc = RawValue(opc1) + creg_M = CRegister(CRm) + + } + +} + +@encoding (A2) { + + @word 1 1 1 1 1 1 0 0 0 1 0 1 Rt2(4) Rt(4) coproc(4) opc1(4) CRm(4) + + @syntax "mrrc2" + + @conv { + + reg_T = Register(Rt) + reg_T2 = Register(Rt2) + cp = CoProcessor(coproc) + opc = RawValue(opc1) + creg_M = CRegister(CRm) + + } + +} + diff --git a/plugins/arm/v7/opdefs/mul_A88114.d b/plugins/arm/v7/opdefs/mul_A88114.d new file mode 100644 index 0000000..fa250b7 --- /dev/null +++ b/plugins/arm/v7/opdefs/mul_A88114.d @@ -0,0 +1,83 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * ##FILE## - traduction d'instructions ARMv7 + * + * Copyright (C) 2015 Cyrille Bagard + * + * This file is part of Chrysalide. + * + * Chrysalide is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Chrysalide is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Foobar. If not, see . + */ + + +@title MUL + +@desc Multiply multiplies two register values. The least significant 32 bits of the result are written to the destination register. These 32 bits do not depend on whether the source register values are considered to be signed values or unsigned values. Optionally, it can update the condition flags based on the result. In the Thumb instruction set, this option is limited to only a few forms of the instruction. Use of this option adversely affects performance on many processor implementations. + +@encoding (t1) { + + @half 0 1 0 0 0 0 1 1 0 1 Rn(3) Rdm(3) + + @syntax "muls" + + @conv { + + reg_N = Register(Rn) + reg_DM_1 = Register(Rdm) + reg_DM_2 = Register(Rdm) + + } + +} + +@encoding (T2) { + + @word 1 1 1 1 1 0 1 1 0 0 0 0 Rn(4) 1 1 1 1 Rd(4) 0 0 0 0 Rm(4) + + @syntax + + @conv { + + reg_D = Register(Rd) + reg_N = Register(Rn) + reg_M = Register(Rm) + + } + +} + +@encoding (A1) { + + @word cond(4) 0 0 0 0 0 0 0 S(1) Rd(4) 0 0 0 0 Rm(4) 1 0 0 1 Rn(4) + + @syntax + + @conv { + + reg_D = Register(Rd) + reg_N = Register(Rn) + reg_M = Register(Rm) + setflags = (S == '1') + + } + + @rules { + + if (setflags); chk_call ExtendKeyword("s") + chk_call StoreCondition(cond) + + } + +} + diff --git a/plugins/arm/v7/opdefs/mvn_A88115.d b/plugins/arm/v7/opdefs/mvn_A88115.d new file mode 100644 index 0000000..2955439 --- /dev/null +++ b/plugins/arm/v7/opdefs/mvn_A88115.d @@ -0,0 +1,72 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * ##FILE## - traduction d'instructions ARMv7 + * + * Copyright (C) 2015 Cyrille Bagard + * + * This file is part of Chrysalide. + * + * Chrysalide is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Chrysalide is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Foobar. If not, see . + */ + + +@title MVN (immediate) + +@desc Bitwise NOT (immediate) writes the bitwise inverse of an immediate value to the destination register. It can optionally update the condition flags based on the value. + +@encoding (T1) { + + @word 1 1 1 1 0 i(1) 0 0 0 1 1 S(1) 1 1 1 1 0 imm3(3) Rd(4) imm8(8) + + @syntax + + @conv { + + reg_D = Register(Rd) + setflags = (S == '1') + imm32 = ThumbExpandImm_C(i:imm3:imm8, 0) + + } + + @rules { + + if (setflags); chk_call ExtendKeyword("s") + + } + +} + +@encoding (A1) { + + @word cond(4) 0 0 1 1 1 1 1 S(1) 0 0 0 0 Rd(4) imm12(12) + + @syntax + + @conv { + + reg_D = Register(Rd) + setflags = (S == '1') + imm32 = ARMExpandImm_C(imm12, 0) + + } + + @rules { + + if (setflags); chk_call ExtendKeyword("s") + chk_call StoreCondition(cond) + + } + +} + diff --git a/plugins/arm/v7/opdefs/mvn_A88116.d b/plugins/arm/v7/opdefs/mvn_A88116.d new file mode 100644 index 0000000..1f3f390 --- /dev/null +++ b/plugins/arm/v7/opdefs/mvn_A88116.d @@ -0,0 +1,90 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * ##FILE## - traduction d'instructions ARMv7 + * + * Copyright (C) 2015 Cyrille Bagard + * + * This file is part of Chrysalide. + * + * Chrysalide is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Chrysalide is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Foobar. If not, see . + */ + + +@title MVN (register) + +@desc Bitwise NOT (register) writes the bitwise inverse of a register value to the destination register. It can optionally update the condition flags based on the result. + +@encoding (t1) { + + @half 0 1 0 0 0 0 1 1 1 1 Rm(3) Rd(3) + + @syntax "mvns" + + @conv { + + reg_D = Register(Rd) + reg_M = Register(Rm) + + } + +} + +@encoding (T2) { + + @word 1 1 1 0 1 0 1 0 0 1 1 S(1) 1 1 1 1 0 imm3(3) Rd(4) imm2(2) type(2) Rm(4) + + @syntax + + @conv { + + reg_D = Register(Rd) + reg_M = Register(Rm) + setflags = (S == '1') + shift = DecodeImmShift(type, imm3:imm2) + + } + + @rules { + + if (setflags); chk_call ExtendKeyword("s") + chk_call ExtendKeyword(".w") + + } + +} + +@encoding (A1) { + + @word cond(4) 0 0 0 1 1 1 1 S(1) 0 0 0 0 Rd(4) imm5(5) type(2) 0 Rm(4) + + @syntax + + @conv { + + reg_D = Register(Rd) + reg_M = Register(Rm) + setflags = (S == '1') + shift = DecodeImmShift(type, imm5) + + } + + @rules { + + if (setflags); chk_call ExtendKeyword("s") + chk_call StoreCondition(cond) + + } + +} + diff --git a/plugins/arm/v7/opdefs/mvn_A88117.d b/plugins/arm/v7/opdefs/mvn_A88117.d new file mode 100644 index 0000000..cc6ef16 --- /dev/null +++ b/plugins/arm/v7/opdefs/mvn_A88117.d @@ -0,0 +1,51 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * ##FILE## - traduction d'instructions ARMv7 + * + * Copyright (C) 2015 Cyrille Bagard + * + * This file is part of Chrysalide. + * + * Chrysalide is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Chrysalide is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Foobar. If not, see . + */ + + +@title MVN (register-shifted register) + +@desc Bitwise NOT (register-shifted register) writes the bitwise inverse of a register-shifted register value to the destination register. It can optionally update the condition flags based on the result. + +@encoding (A1) { + + @word cond(4) 0 0 0 1 1 1 1 S(1) 0 0 0 0 Rd(4) Rs(4) 0 type(2) 1 Rm(4) + + @syntax + + @conv { + + reg_shift = RegisterShift(type, Rs) + reg_D = Register(Rd) + reg_M = Register(Rm) + setflags = (S == '1') + + } + + @rules { + + if (setflags); chk_call ExtendKeyword("s") + chk_call StoreCondition(cond) + + } + +} + diff --git a/plugins/arm/v7/opdefs/nop_A88119.d b/plugins/arm/v7/opdefs/nop_A88119.d new file mode 100644 index 0000000..84c495a --- /dev/null +++ b/plugins/arm/v7/opdefs/nop_A88119.d @@ -0,0 +1,53 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * ##FILE## - traduction d'instructions ARMv7 + * + * Copyright (C) 2015 Cyrille Bagard + * + * This file is part of Chrysalide. + * + * Chrysalide is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Chrysalide is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Foobar. If not, see . + */ + + +@title NOP + +@desc No Operation does nothing. This instruction can be used for instruction alignment purposes. See Pre-UAL pseudo-instruction NOP on page AppxH-2472 for details of NOP before the introduction of UAL and the ARMv6K and ARMv6T2 architecture variants. Note The timing effects of including a NOP instruction in a program are not guaranteed. It can increase execution time, leave it unchanged, or even reduce it. Therefore, NOP instructions are not suitable for timing loops. + +@encoding (t1) { + + @half 1 0 1 1 1 1 1 1 0 0 0 0 0 0 0 0 + +} + +@encoding (T2) { + + @word 1 1 1 1 0 0 1 1 1 0 1 0 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 + + @syntax ".W" + +} + +@encoding (A1) { + + @word cond(4) 0 0 1 1 0 0 1 0 0 0 0 0 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 + + @rules { + + chk_call StoreCondition(cond) + + } + +} + diff --git a/plugins/arm/v7/opdefs/orn_A88120.d b/plugins/arm/v7/opdefs/orn_A88120.d new file mode 100644 index 0000000..b823b6c --- /dev/null +++ b/plugins/arm/v7/opdefs/orn_A88120.d @@ -0,0 +1,50 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * ##FILE## - traduction d'instructions ARMv7 + * + * Copyright (C) 2015 Cyrille Bagard + * + * This file is part of Chrysalide. + * + * Chrysalide is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Chrysalide is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Foobar. If not, see . + */ + + +@title ORN (immediate) + +@desc Bitwise OR NOT (immediate) performs a bitwise (inclusive) OR of a register value and the complement of an immediate value, and writes the result to the destination register. It can optionally update the condition flags based on the result. + +@encoding (T1) { + + @word 1 1 1 1 0 i(1) 0 0 0 1 1 S(1) Rn(4) 0 imm3(3) Rd(4) imm8(8) + + @syntax + + @conv { + + reg_D = Register(Rd) + reg_N = Register(Rn) + setflags = (S == '1') + imm32 = ThumbExpandImm_C(i:imm3:imm8, 0) + + } + + @rules { + + if (setflags); chk_call ExtendKeyword("s") + + } + +} + diff --git a/plugins/arm/v7/opdefs/orn_A88121.d b/plugins/arm/v7/opdefs/orn_A88121.d new file mode 100644 index 0000000..f1523ec --- /dev/null +++ b/plugins/arm/v7/opdefs/orn_A88121.d @@ -0,0 +1,51 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * ##FILE## - traduction d'instructions ARMv7 + * + * Copyright (C) 2015 Cyrille Bagard + * + * This file is part of Chrysalide. + * + * Chrysalide is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Chrysalide is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Foobar. If not, see . + */ + + +@title ORN (register) + +@desc Bitwise OR NOT (register) performs a bitwise (inclusive) OR of a register value and the complement of an optionally-shifted register value, and writes the result to the destination register. It can optionally update the condition flags based on the result. + +@encoding (T1) { + + @word 1 1 1 0 1 0 1 0 0 1 1 S(1) Rn(4) 0 imm3(3) Rd(4) imm2(2) type(2) Rm(4) + + @syntax + + @conv { + + reg_D = Register(Rd) + reg_N = Register(Rn) + reg_M = Register(Rm) + setflags = (S == '1') + shift = DecodeImmShift(type, imm3:imm2) + + } + + @rules { + + if (setflags); chk_call ExtendKeyword("s") + + } + +} + diff --git a/plugins/arm/v7/opdefs/orr_A88122.d b/plugins/arm/v7/opdefs/orr_A88122.d new file mode 100644 index 0000000..766b5ee --- /dev/null +++ b/plugins/arm/v7/opdefs/orr_A88122.d @@ -0,0 +1,74 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * ##FILE## - traduction d'instructions ARMv7 + * + * Copyright (C) 2015 Cyrille Bagard + * + * This file is part of Chrysalide. + * + * Chrysalide is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Chrysalide is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Foobar. If not, see . + */ + + +@title ORR (immediate) + +@desc Bitwise OR (immediate) performs a bitwise (inclusive) OR of a register value and an immediate value, and writes the result to the destination register. It can optionally update the condition flags based on the result. + +@encoding (T1) { + + @word 1 1 1 1 0 i(1) 0 0 0 1 0 S(1) Rn(4) 0 imm3(3) Rd(4) imm8(8) + + @syntax + + @conv { + + reg_D = Register(Rd) + reg_N = Register(Rn) + setflags = (S == '1') + imm32 = ThumbExpandImm_C(i:imm3:imm8, 0) + + } + + @rules { + + if (setflags); chk_call ExtendKeyword("s") + + } + +} + +@encoding (A1) { + + @word cond(4) 0 0 1 1 1 0 0 S(1) Rn(4) Rd(4) imm12(12) + + @syntax + + @conv { + + reg_D = Register(Rd) + reg_N = Register(Rn) + setflags = (S == '1') + imm32 = ARMExpandImm_C(imm12, 0) + + } + + @rules { + + if (setflags); chk_call ExtendKeyword("s") + chk_call StoreCondition(cond) + + } + +} + diff --git a/plugins/arm/v7/opdefs/orr_A88123.d b/plugins/arm/v7/opdefs/orr_A88123.d new file mode 100644 index 0000000..2395c89 --- /dev/null +++ b/plugins/arm/v7/opdefs/orr_A88123.d @@ -0,0 +1,92 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * ##FILE## - traduction d'instructions ARMv7 + * + * Copyright (C) 2015 Cyrille Bagard + * + * This file is part of Chrysalide. + * + * Chrysalide is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Chrysalide is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Foobar. If not, see . + */ + + +@title ORR (register) + +@desc Bitwise OR (register) performs a bitwise (inclusive) OR of a register value and an optionally-shifted register value, and writes the result to the destination register. It can optionally update the condition flags based on the result. + +@encoding (t1) { + + @half 0 1 0 0 0 0 1 1 0 0 Rm(3) Rdn(3) + + @syntax "orrs" + + @conv { + + reg_DN = Register(Rdn) + reg_M = Register(Rm) + + } + +} + +@encoding (T2) { + + @word 1 1 1 0 1 0 1 0 0 1 0 S(1) Rn(4) 0 imm3(3) Rd(4) imm2(2) type(2) Rm(4) + + @syntax + + @conv { + + reg_D = Register(Rd) + reg_N = Register(Rn) + reg_M = Register(Rm) + setflags = (S == '1') + shift = DecodeImmShift(type, imm3:imm2) + + } + + @rules { + + if (setflags); chk_call ExtendKeyword("s") + chk_call ExtendKeyword(".w") + + } + +} + +@encoding (A1) { + + @word cond(4) 0 0 0 1 1 0 0 S(1) Rn(4) Rd(4) imm5(5) type(2) 0 Rm(4) + + @syntax + + @conv { + + reg_D = Register(Rd) + reg_N = Register(Rn) + reg_M = Register(Rm) + setflags = (S == '1') + shift = DecodeImmShift(type, imm5) + + } + + @rules { + + if (setflags); chk_call ExtendKeyword("s") + chk_call StoreCondition(cond) + + } + +} + diff --git a/plugins/arm/v7/opdefs/orr_A88124.d b/plugins/arm/v7/opdefs/orr_A88124.d new file mode 100644 index 0000000..f4d78b9 --- /dev/null +++ b/plugins/arm/v7/opdefs/orr_A88124.d @@ -0,0 +1,52 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * ##FILE## - traduction d'instructions ARMv7 + * + * Copyright (C) 2015 Cyrille Bagard + * + * This file is part of Chrysalide. + * + * Chrysalide is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Chrysalide is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Foobar. If not, see . + */ + + +@title ORR (register-shifted register) + +@desc Bitwise OR (register-shifted register) performs a bitwise (inclusive) OR of a register value and a register-shifted register value, and writes the result to the destination register. It can optionally update the condition flags based on the result. + +@encoding (A1) { + + @word cond(4) 0 0 0 1 1 0 0 S(1) Rn(4) Rd(4) Rs(4) 0 type(2) 1 Rm(4) + + @syntax + + @conv { + + reg_shift = RegisterShift(type, Rs) + reg_D = Register(Rd) + reg_N = Register(Rn) + reg_M = Register(Rm) + setflags = (S == '1') + + } + + @rules { + + if (setflags); chk_call ExtendKeyword("s") + chk_call StoreCondition(cond) + + } + +} + diff --git a/plugins/arm/v7/opdefs/pop_A88131.d b/plugins/arm/v7/opdefs/pop_A88131.d new file mode 100644 index 0000000..2dee09a --- /dev/null +++ b/plugins/arm/v7/opdefs/pop_A88131.d @@ -0,0 +1,87 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * ##FILE## - traduction d'instructions ARMv7 + * + * Copyright (C) 2015 Cyrille Bagard + * + * This file is part of Chrysalide. + * + * Chrysalide is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Chrysalide is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Foobar. If not, see . + */ + + +@title POP (Thumb) + +@desc Pop Multiple Registers loads multiple registers from the stack, loading from consecutive memory locations starting at the address in SP, and updates SP to point just above the loaded data. + +@encoding (t1) { + + @half 1 0 1 1 1 1 0 P(1) register_list(8) + + @syntax + + @conv { + + registers = RegistersList(P:'0000000':register_list) + + } + + @hooks { + + link = handle_armv7_return_from_pop + + } + +} + +@encoding (T2) { + + @word 1 1 1 0 1 0 0 0 1 0 1 1 1 1 0 1 P(1) M(1) 0 register_list(13) + + @syntax ".W" + + @conv { + + registers = RegistersList(P:M:'0':register_list) + + } + + @hooks { + + link = handle_armv7_return_from_pop + + } + +} + +@encoding (T3) { + + @word 1 1 1 1 1 0 0 0 0 1 0 1 1 1 0 1 Rt(4) 1 0 1 1 0 0 0 0 0 1 0 0 + + @syntax ".W" + + @conv { + + registers = RegistersList(1 << Rt) + + } + + @hooks { + + link = handle_armv7_return_from_pop + + } + +} + diff --git a/plugins/arm/v7/opdefs/pop_A88132.d b/plugins/arm/v7/opdefs/pop_A88132.d new file mode 100644 index 0000000..27bbf3b --- /dev/null +++ b/plugins/arm/v7/opdefs/pop_A88132.d @@ -0,0 +1,79 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * ##FILE## - traduction d'instructions ARMv7 + * + * Copyright (C) 2015 Cyrille Bagard + * + * This file is part of Chrysalide. + * + * Chrysalide is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Chrysalide is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Foobar. If not, see . + */ + + +@title POP (ARM) + +@desc Pop Multiple Registers loads multiple registers from the stack, loading from consecutive memory locations starting at the address in SP, and updates SP to point just above the loaded data. + +@encoding (A1) { + + @word cond(4) 1 0 0 0 1 0 1 1 1 1 0 1 register_list(16) + + @syntax + + @conv { + + registers = RegistersList(register_list) + + } + + @rules { + + chk_call StoreCondition(cond) + + } + + @hooks { + + link = handle_armv7_return_from_pop + + } + +} + +@encoding (A2) { + + @word cond(4) 0 1 0 0 1 0 0 1 1 1 0 1 Rt(4) 0 0 0 0 0 0 0 0 0 1 0 0 + + @syntax + + @conv { + + registers = RegistersList(1 << Rt) + + } + + @rules { + + chk_call StoreCondition(cond) + + } + + @hooks { + + link = handle_armv7_return_from_pop + + } + +} + diff --git a/plugins/arm/v7/opdefs/push_A88133.d b/plugins/arm/v7/opdefs/push_A88133.d new file mode 100644 index 0000000..14fc3e9 --- /dev/null +++ b/plugins/arm/v7/opdefs/push_A88133.d @@ -0,0 +1,109 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * ##FILE## - traduction d'instructions ARMv7 + * + * Copyright (C) 2015 Cyrille Bagard + * + * This file is part of Chrysalide. + * + * Chrysalide is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Chrysalide is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Foobar. If not, see . + */ + + +@title PUSH + +@desc Push Multiple Registers stores multiple registers to the stack, storing to consecutive memory locations ending just below the address in SP, and updates SP to point to the start of the stored data. + +@encoding (t1) { + + @half 1 0 1 1 0 1 0 M(1) register_list(8) + + @syntax + + @conv { + + registers = RegistersList('0':M:'000000':register_list) + + } + +} + +@encoding (T2) { + + @word 1 1 1 0 1 0 0 1 0 0 1 0 1 1 0 1 0 M(1) 0 register_list(13) + + @syntax ".W" + + @conv { + + registers = RegistersList('0':M:'0':register_list) + + } + +} + +@encoding (T3) { + + @word 1 1 1 1 1 0 0 0 0 1 0 0 1 1 0 1 Rt(4) 1 1 0 1 0 0 0 0 0 1 0 0 + + @syntax ".W" + + @conv { + + registers = Zeros(16) + + } + +} + +@encoding (A1) { + + @word cond(4) 1 0 0 1 0 0 1 0 1 1 0 1 register_list(16) + + @syntax + + @conv { + + registers = RegistersList(register_list) + + } + + @rules { + + chk_call StoreCondition(cond) + + } + +} + +@encoding (A2) { + + @word cond(4) 0 1 0 1 0 0 1 0 1 1 0 1 Rt(4) 0 0 0 0 0 0 0 0 0 1 0 0 + + @syntax + + @conv { + + registers = Zeros(16) + + } + + @rules { + + chk_call StoreCondition(cond) + + } + +} + diff --git a/plugins/arm/v7/opdefs/qadd16_A88135.d b/plugins/arm/v7/opdefs/qadd16_A88135.d new file mode 100644 index 0000000..15af29d --- /dev/null +++ b/plugins/arm/v7/opdefs/qadd16_A88135.d @@ -0,0 +1,65 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * ##FILE## - traduction d'instructions ARMv7 + * + * Copyright (C) 2015 Cyrille Bagard + * + * This file is part of Chrysalide. + * + * Chrysalide is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Chrysalide is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Foobar. If not, see . + */ + + +@title QADD16 + +@desc Saturating Add 16 performs two 16-bit integer additions, saturates the results to the 16-bit signed integer range –215 ≤ x ≤ 215 – 1, and writes the results to the destination register. + +@encoding (T1) { + + @word 1 1 1 1 1 0 1 0 1 0 0 1 Rn(4) 1 1 1 1 Rd(4) 0 0 0 1 Rm(4) + + @syntax + + @conv { + + reg_D = Register(Rd) + reg_N = Register(Rn) + reg_M = Register(Rm) + + } + +} + +@encoding (A1) { + + @word cond(4) 0 1 1 0 0 0 1 0 Rn(4) Rd(4) 1 1 1 1 0 0 0 1 Rm(4) + + @syntax + + @conv { + + reg_D = Register(Rd) + reg_N = Register(Rn) + reg_M = Register(Rm) + + } + + @rules { + + chk_call StoreCondition(cond) + + } + +} + diff --git a/plugins/arm/v7/opdefs/qadd8_A88136.d b/plugins/arm/v7/opdefs/qadd8_A88136.d new file mode 100644 index 0000000..a71b251 --- /dev/null +++ b/plugins/arm/v7/opdefs/qadd8_A88136.d @@ -0,0 +1,65 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * ##FILE## - traduction d'instructions ARMv7 + * + * Copyright (C) 2015 Cyrille Bagard + * + * This file is part of Chrysalide. + * + * Chrysalide is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Chrysalide is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Foobar. If not, see . + */ + + +@title QADD8 + +@desc Saturating Add 8 performs four 8-bit integer additions, saturates the results to the 8-bit signed integer range –27 ≤ x ≤ 27 – 1, and writes the results to the destination register. + +@encoding (T1) { + + @word 1 1 1 1 1 0 1 0 1 0 0 0 Rn(4) 1 1 1 1 Rd(4) 0 0 0 1 Rm(4) + + @syntax + + @conv { + + reg_D = Register(Rd) + reg_N = Register(Rn) + reg_M = Register(Rm) + + } + +} + +@encoding (A1) { + + @word cond(4) 0 1 1 0 0 0 1 0 Rn(4) Rd(4) 1 1 1 1 1 0 0 1 Rm(4) + + @syntax + + @conv { + + reg_D = Register(Rd) + reg_N = Register(Rn) + reg_M = Register(Rm) + + } + + @rules { + + chk_call StoreCondition(cond) + + } + +} + diff --git a/plugins/arm/v7/opdefs/qadd_A88134.d b/plugins/arm/v7/opdefs/qadd_A88134.d new file mode 100644 index 0000000..f932983 --- /dev/null +++ b/plugins/arm/v7/opdefs/qadd_A88134.d @@ -0,0 +1,65 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * ##FILE## - traduction d'instructions ARMv7 + * + * Copyright (C) 2015 Cyrille Bagard + * + * This file is part of Chrysalide. + * + * Chrysalide is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Chrysalide is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Foobar. If not, see . + */ + + +@title QADD + +@desc Saturating Add adds two register values, saturates the result to the 32-bit signed integer range –231 to (231 – 1), and writes the result to the destination register. If saturation occurs, it sets the Q flag in the APSR. + +@encoding (T1) { + + @word 1 1 1 1 1 0 1 0 1 0 0 0 Rn(4) 1 1 1 1 Rd(4) 1 0 0 0 Rm(4) + + @syntax + + @conv { + + reg_D = Register(Rd) + reg_N = Register(Rn) + reg_M = Register(Rm) + + } + +} + +@encoding (A1) { + + @word cond(4) 0 0 0 1 0 0 0 0 Rn(4) Rd(4) 0 0 0 0 0 1 0 1 Rm(4) + + @syntax + + @conv { + + reg_D = Register(Rd) + reg_N = Register(Rn) + reg_M = Register(Rm) + + } + + @rules { + + chk_call StoreCondition(cond) + + } + +} + diff --git a/plugins/arm/v7/opdefs/qasx_A88137.d b/plugins/arm/v7/opdefs/qasx_A88137.d new file mode 100644 index 0000000..68251ca --- /dev/null +++ b/plugins/arm/v7/opdefs/qasx_A88137.d @@ -0,0 +1,65 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * ##FILE## - traduction d'instructions ARMv7 + * + * Copyright (C) 2015 Cyrille Bagard + * + * This file is part of Chrysalide. + * + * Chrysalide is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Chrysalide is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Foobar. If not, see . + */ + + +@title QASX + +@desc Saturating Add and Subtract with Exchange exchanges the two halfwords of the second operand, performs one 16-bit integer addition and one 16-bit subtraction, saturates the results to the 16-bit signed integer range –215 ≤ x ≤ 215 – 1, and writes the results to the destination register. + +@encoding (T1) { + + @word 1 1 1 1 1 0 1 0 1 0 1 0 Rn(4) 1 1 1 1 Rd(4) 0 0 0 1 Rm(4) + + @syntax + + @conv { + + reg_D = Register(Rd) + reg_N = Register(Rn) + reg_M = Register(Rm) + + } + +} + +@encoding (A1) { + + @word cond(4) 0 1 1 0 0 0 1 0 Rn(4) Rd(4) 1 1 1 1 0 0 1 1 Rm(4) + + @syntax + + @conv { + + reg_D = Register(Rd) + reg_N = Register(Rn) + reg_M = Register(Rm) + + } + + @rules { + + chk_call StoreCondition(cond) + + } + +} + diff --git a/plugins/arm/v7/opdefs/qdadd_A88138.d b/plugins/arm/v7/opdefs/qdadd_A88138.d new file mode 100644 index 0000000..c40cdcd --- /dev/null +++ b/plugins/arm/v7/opdefs/qdadd_A88138.d @@ -0,0 +1,65 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * ##FILE## - traduction d'instructions ARMv7 + * + * Copyright (C) 2015 Cyrille Bagard + * + * This file is part of Chrysalide. + * + * Chrysalide is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Chrysalide is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Foobar. If not, see . + */ + + +@title QDADD + +@desc Saturating Double and Add adds a doubled register value to another register value, and writes the result to the destination register. Both the doubling and the addition have their results saturated to the 32-bit signed integer range –231 ≤ x ≤ 231 – 1. If saturation occurs in either operation, it sets the Q flag in the APSR. + +@encoding (T1) { + + @word 1 1 1 1 1 0 1 0 1 0 0 0 Rn(4) 1 1 1 1 Rd(4) 1 0 0 1 Rm(4) + + @syntax + + @conv { + + reg_D = Register(Rd) + reg_N = Register(Rn) + reg_M = Register(Rm) + + } + +} + +@encoding (A1) { + + @word cond(4) 0 0 0 1 0 1 0 0 Rn(4) Rd(4) 0 0 0 0 0 1 0 1 Rm(4) + + @syntax + + @conv { + + reg_D = Register(Rd) + reg_N = Register(Rn) + reg_M = Register(Rm) + + } + + @rules { + + chk_call StoreCondition(cond) + + } + +} + diff --git a/plugins/arm/v7/opdefs/qdsub_A88139.d b/plugins/arm/v7/opdefs/qdsub_A88139.d new file mode 100644 index 0000000..87bd083 --- /dev/null +++ b/plugins/arm/v7/opdefs/qdsub_A88139.d @@ -0,0 +1,65 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * ##FILE## - traduction d'instructions ARMv7 + * + * Copyright (C) 2015 Cyrille Bagard + * + * This file is part of Chrysalide. + * + * Chrysalide is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Chrysalide is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Foobar. If not, see . + */ + + +@title QDSUB + +@desc Saturating Double and Subtract subtracts a doubled register value from another register value, and writes the result to the destination register. Both the doubling and the subtraction have their results saturated to the 32-bit signed integer range –231 ≤ x ≤ 231 – 1. If saturation occurs in either operation, it sets the Q flag in the APSR. + +@encoding (T1) { + + @word 1 1 1 1 1 0 1 0 1 0 0 0 Rn(4) 1 1 1 1 Rd(4) 1 0 1 1 Rm(4) + + @syntax + + @conv { + + reg_D = Register(Rd) + reg_N = Register(Rn) + reg_M = Register(Rm) + + } + +} + +@encoding (A1) { + + @word cond(4) 0 0 0 1 0 1 1 0 Rn(4) Rd(4) 0 0 0 0 0 1 0 1 Rm(4) + + @syntax + + @conv { + + reg_D = Register(Rd) + reg_N = Register(Rn) + reg_M = Register(Rm) + + } + + @rules { + + chk_call StoreCondition(cond) + + } + +} + diff --git a/plugins/arm/v7/opdefs/qsax_A88140.d b/plugins/arm/v7/opdefs/qsax_A88140.d new file mode 100644 index 0000000..df24cf8 --- /dev/null +++ b/plugins/arm/v7/opdefs/qsax_A88140.d @@ -0,0 +1,65 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * ##FILE## - traduction d'instructions ARMv7 + * + * Copyright (C) 2015 Cyrille Bagard + * + * This file is part of Chrysalide. + * + * Chrysalide is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Chrysalide is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Foobar. If not, see . + */ + + +@title QSAX + +@desc Saturating Subtract and Add with Exchange exchanges the two halfwords of the second operand, performs one 16-bit integer subtraction and one 16-bit addition, saturates the results to the 16-bit signed integer range –215 ≤ x ≤ 215 – 1, and writes the results to the destination register. + +@encoding (T1) { + + @word 1 1 1 1 1 0 1 0 1 1 1 0 Rn(4) 1 1 1 1 Rd(4) 0 0 0 1 Rm(4) + + @syntax + + @conv { + + reg_D = Register(Rd) + reg_N = Register(Rn) + reg_M = Register(Rm) + + } + +} + +@encoding (A1) { + + @word cond(4) 0 1 1 0 0 0 1 0 Rn(4) Rd(4) 1 1 1 1 0 1 0 1 Rm(4) + + @syntax + + @conv { + + reg_D = Register(Rd) + reg_N = Register(Rn) + reg_M = Register(Rm) + + } + + @rules { + + chk_call StoreCondition(cond) + + } + +} + diff --git a/plugins/arm/v7/opdefs/qsub16_A88142.d b/plugins/arm/v7/opdefs/qsub16_A88142.d new file mode 100644 index 0000000..5b2c96b --- /dev/null +++ b/plugins/arm/v7/opdefs/qsub16_A88142.d @@ -0,0 +1,65 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * ##FILE## - traduction d'instructions ARMv7 + * + * Copyright (C) 2015 Cyrille Bagard + * + * This file is part of Chrysalide. + * + * Chrysalide is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Chrysalide is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Foobar. If not, see . + */ + + +@title QSUB16 + +@desc Saturating Subtract 16 performs two 16-bit integer subtractions, saturates the results to the 16-bit signed integer range –215 ≤ x ≤ 215 – 1, and writes the results to the destination register. + +@encoding (T1) { + + @word 1 1 1 1 1 0 1 0 1 1 0 1 Rn(4) 1 1 1 1 Rd(4) 0 0 0 1 Rm(4) + + @syntax + + @conv { + + reg_D = Register(Rd) + reg_N = Register(Rn) + reg_M = Register(Rm) + + } + +} + +@encoding (A1) { + + @word cond(4) 0 1 1 0 0 0 1 0 Rn(4) Rd(4) 1 1 1 1 0 1 1 1 Rm(4) + + @syntax + + @conv { + + reg_D = Register(Rd) + reg_N = Register(Rn) + reg_M = Register(Rm) + + } + + @rules { + + chk_call StoreCondition(cond) + + } + +} + diff --git a/plugins/arm/v7/opdefs/qsub8_A88143.d b/plugins/arm/v7/opdefs/qsub8_A88143.d new file mode 100644 index 0000000..270a99d --- /dev/null +++ b/plugins/arm/v7/opdefs/qsub8_A88143.d @@ -0,0 +1,65 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * ##FILE## - traduction d'instructions ARMv7 + * + * Copyright (C) 2015 Cyrille Bagard + * + * This file is part of Chrysalide. + * + * Chrysalide is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Chrysalide is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Foobar. If not, see . + */ + + +@title QSUB8 + +@desc Saturating Subtract 8 performs four 8-bit integer subtractions, saturates the results to the 8-bit signed integer range –27 ≤ x ≤ 27 – 1, and writes the results to the destination register. + +@encoding (T1) { + + @word 1 1 1 1 1 0 1 0 1 1 0 0 Rn(4) 1 1 1 1 Rd(4) 0 0 0 1 Rm(4) + + @syntax + + @conv { + + reg_D = Register(Rd) + reg_N = Register(Rn) + reg_M = Register(Rm) + + } + +} + +@encoding (A1) { + + @word cond(4) 0 1 1 0 0 0 1 0 Rn(4) Rd(4) 1 1 1 1 1 1 1 1 Rm(4) + + @syntax + + @conv { + + reg_D = Register(Rd) + reg_N = Register(Rn) + reg_M = Register(Rm) + + } + + @rules { + + chk_call StoreCondition(cond) + + } + +} + diff --git a/plugins/arm/v7/opdefs/qsub_A88141.d b/plugins/arm/v7/opdefs/qsub_A88141.d new file mode 100644 index 0000000..c60ec57 --- /dev/null +++ b/plugins/arm/v7/opdefs/qsub_A88141.d @@ -0,0 +1,65 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * ##FILE## - traduction d'instructions ARMv7 + * + * Copyright (C) 2015 Cyrille Bagard + * + * This file is part of Chrysalide. + * + * Chrysalide is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Chrysalide is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Foobar. If not, see . + */ + + +@title QSUB + +@desc Saturating Subtract subtracts one register value from another register value, saturates the result to the 32-bit signed integer range –231 ≤ x ≤ 231 – 1, and writes the result to the destination register. If saturation occurs, it sets the Q flag in the APSR. + +@encoding (T1) { + + @word 1 1 1 1 1 0 1 0 1 0 0 0 Rn(4) 1 1 1 1 Rd(4) 1 0 1 0 Rm(4) + + @syntax + + @conv { + + reg_D = Register(Rd) + reg_N = Register(Rn) + reg_M = Register(Rm) + + } + +} + +@encoding (A1) { + + @word cond(4) 0 0 0 1 0 0 1 0 Rn(4) Rd(4) 0 0 0 0 0 1 0 1 Rm(4) + + @syntax + + @conv { + + reg_D = Register(Rd) + reg_N = Register(Rn) + reg_M = Register(Rm) + + } + + @rules { + + chk_call StoreCondition(cond) + + } + +} + diff --git a/plugins/arm/v7/opdefs/rbit_A88144.d b/plugins/arm/v7/opdefs/rbit_A88144.d new file mode 100644 index 0000000..7f2bdb6 --- /dev/null +++ b/plugins/arm/v7/opdefs/rbit_A88144.d @@ -0,0 +1,63 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * ##FILE## - traduction d'instructions ARMv7 + * + * Copyright (C) 2015 Cyrille Bagard + * + * This file is part of Chrysalide. + * + * Chrysalide is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Chrysalide is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Foobar. If not, see . + */ + + +@title RBIT + +@desc Reverse Bits reverses the bit order in a 32-bit register. + +@encoding (T1) { + + @word 1 1 1 1 1 0 1 0 1 0 0 1 Rm(4) 1 1 1 1 Rd(4) 1 0 1 0 Rm(4) + + @syntax + + @conv { + + reg_D = Register(Rd) + reg_M = Register(Rm) + + } + +} + +@encoding (A1) { + + @word cond(4) 0 1 1 0 1 1 1 1 1 1 1 1 Rd(4) 1 1 1 1 0 0 1 1 Rm(4) + + @syntax + + @conv { + + reg_D = Register(Rd) + reg_M = Register(Rm) + + } + + @rules { + + chk_call StoreCondition(cond) + + } + +} + diff --git a/plugins/arm/v7/opdefs/rev16_A88146.d b/plugins/arm/v7/opdefs/rev16_A88146.d new file mode 100644 index 0000000..53b9a82 --- /dev/null +++ b/plugins/arm/v7/opdefs/rev16_A88146.d @@ -0,0 +1,78 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * ##FILE## - traduction d'instructions ARMv7 + * + * Copyright (C) 2015 Cyrille Bagard + * + * This file is part of Chrysalide. + * + * Chrysalide is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Chrysalide is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Foobar. If not, see . + */ + + +@title REV16 + +@desc Byte-Reverse Packed Halfword reverses the byte order in each16-bit halfword of a 32-bit register. + +@encoding (t1) { + + @half 1 0 1 1 1 0 1 0 0 1 Rm(3) Rd(3) + + @syntax + + @conv { + + reg_D = Register(Rd) + reg_M = Register(Rm) + + } + +} + +@encoding (T2) { + + @word 1 1 1 1 1 0 1 0 1 0 0 1 Rm(4) 1 1 1 1 Rd(4) 1 0 0 1 Rm(4) + + @syntax ".W" + + @conv { + + reg_D = Register(Rd) + reg_M = Register(Rm) + + } + +} + +@encoding (A1) { + + @word cond(4) 0 1 1 0 1 0 1 1 1 1 1 1 Rd(4) 1 1 1 1 1 0 1 1 Rm(4) + + @syntax + + @conv { + + reg_D = Register(Rd) + reg_M = Register(Rm) + + } + + @rules { + + chk_call StoreCondition(cond) + + } + +} + diff --git a/plugins/arm/v7/opdefs/rev_A88145.d b/plugins/arm/v7/opdefs/rev_A88145.d new file mode 100644 index 0000000..2fe305d --- /dev/null +++ b/plugins/arm/v7/opdefs/rev_A88145.d @@ -0,0 +1,78 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * ##FILE## - traduction d'instructions ARMv7 + * + * Copyright (C) 2015 Cyrille Bagard + * + * This file is part of Chrysalide. + * + * Chrysalide is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Chrysalide is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Foobar. If not, see . + */ + + +@title REV + +@desc Byte-Reverse Word reverses the byte order in a 32-bit register. + +@encoding (t1) { + + @half 1 0 1 1 1 0 1 0 0 0 Rm(3) Rd(3) + + @syntax + + @conv { + + reg_D = Register(Rd) + reg_M = Register(Rm) + + } + +} + +@encoding (T2) { + + @word 1 1 1 1 1 0 1 0 1 0 0 1 Rm(4) 1 1 1 1 Rd(4) 1 0 0 0 Rm(4) + + @syntax ".W" + + @conv { + + reg_D = Register(Rd) + reg_M = Register(Rm) + + } + +} + +@encoding (A1) { + + @word cond(4) 0 1 1 0 1 0 1 1 1 1 1 1 Rd(4) 1 1 1 1 0 0 1 1 Rm(4) + + @syntax + + @conv { + + reg_D = Register(Rd) + reg_M = Register(Rm) + + } + + @rules { + + chk_call StoreCondition(cond) + + } + +} + diff --git a/plugins/arm/v7/opdefs/revsh_A88147.d b/plugins/arm/v7/opdefs/revsh_A88147.d new file mode 100644 index 0000000..551582c --- /dev/null +++ b/plugins/arm/v7/opdefs/revsh_A88147.d @@ -0,0 +1,78 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * ##FILE## - traduction d'instructions ARMv7 + * + * Copyright (C) 2015 Cyrille Bagard + * + * This file is part of Chrysalide. + * + * Chrysalide is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Chrysalide is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Foobar. If not, see . + */ + + +@title REVSH + +@desc Byte-Reverse Signed Halfword reverses the byte order in the lower 16-bit halfword of a 32-bit register, and sign-extends the result to 32 bits. + +@encoding (t1) { + + @half 1 0 1 1 1 0 1 0 1 1 Rm(3) Rd(3) + + @syntax + + @conv { + + reg_D = Register(Rd) + reg_M = Register(Rm) + + } + +} + +@encoding (T2) { + + @word 1 1 1 1 1 0 1 0 1 0 0 1 Rm(4) 1 1 1 1 Rd(4) 1 0 1 1 Rm(4) + + @syntax ".W" + + @conv { + + reg_D = Register(Rd) + reg_M = Register(Rm) + + } + +} + +@encoding (A1) { + + @word cond(4) 0 1 1 0 1 1 1 1 1 1 1 1 Rd(4) 1 1 1 1 1 0 1 1 Rm(4) + + @syntax + + @conv { + + reg_D = Register(Rd) + reg_M = Register(Rm) + + } + + @rules { + + chk_call StoreCondition(cond) + + } + +} + diff --git a/plugins/arm/v7/opdefs/ror_A88149.d b/plugins/arm/v7/opdefs/ror_A88149.d new file mode 100644 index 0000000..7e061c6 --- /dev/null +++ b/plugins/arm/v7/opdefs/ror_A88149.d @@ -0,0 +1,74 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * ##FILE## - traduction d'instructions ARMv7 + * + * Copyright (C) 2015 Cyrille Bagard + * + * This file is part of Chrysalide. + * + * Chrysalide is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Chrysalide is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Foobar. If not, see . + */ + + +@title ROR (immediate) + +@desc Rotate Right (immediate) provides the value of the contents of a register rotated by a constant value. The bits that are rotated off the right end are inserted into the vacated bit positions on the left. It can optionally update the condition flags based on the result. + +@encoding (T1) { + + @word 1 1 1 0 1 0 1 0 0 1 0 S(1) 1 1 1 1 0 imm3(3) Rd(4) imm2(2) 1 1 Rm(4) + + @syntax + + @conv { + + reg_D = Register(Rd) + reg_M = Register(Rm) + setflags = (S == '1') + shift_imm = DecodeImmShift('11', imm3:imm2) + + } + + @rules { + + if (setflags); chk_call ExtendKeyword("s") + + } + +} + +@encoding (A1) { + + @word cond(4) 0 0 0 1 1 0 1 S(1) 0 0 0 0 Rd(4) imm5(5) 1 1 0 Rm(4) + + @syntax + + @conv { + + reg_D = Register(Rd) + reg_M = Register(Rm) + setflags = (S == '1') + shift_imm = DecodeImmShift('11', imm5) + + } + + @rules { + + if (setflags); chk_call ExtendKeyword("s") + chk_call StoreCondition(cond) + + } + +} + diff --git a/plugins/arm/v7/opdefs/ror_A88150.d b/plugins/arm/v7/opdefs/ror_A88150.d new file mode 100644 index 0000000..c046bf7 --- /dev/null +++ b/plugins/arm/v7/opdefs/ror_A88150.d @@ -0,0 +1,90 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * ##FILE## - traduction d'instructions ARMv7 + * + * Copyright (C) 2015 Cyrille Bagard + * + * This file is part of Chrysalide. + * + * Chrysalide is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Chrysalide is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Foobar. If not, see . + */ + + +@title ROR (register) + +@desc Rotate Right (register) provides the value of the contents of a register rotated by a variable number of bits. The bits that are rotated off the right end are inserted into the vacated bit positions on the left. The variable number of bits is read from the bottom byte of a register. It can optionally update the condition flags based on the result. + +@encoding (t1) { + + @half 0 1 0 0 0 0 0 1 1 1 Rm(3) Rdn(3) + + @syntax "rors" + + @conv { + + reg_DN = Register(Rdn) + reg_M = Register(Rm) + + } + +} + +@encoding (T2) { + + @word 1 1 1 1 1 0 1 0 0 1 1 S(1) Rn(4) 1 1 1 1 Rd(4) 0 0 0 0 Rm(4) + + @syntax + + @conv { + + reg_D = Register(Rd) + reg_N = Register(Rn) + reg_M = Register(Rm) + setflags = (S == '1') + + } + + @rules { + + if (setflags); chk_call ExtendKeyword("s") + chk_call ExtendKeyword(".w") + + } + +} + +@encoding (A1) { + + @word cond(4) 0 0 0 1 1 0 1 S(1) 0 0 0 0 Rd(4) Rm(4) 0 1 1 1 Rn(4) + + @syntax + + @conv { + + reg_D = Register(Rd) + reg_N = Register(Rn) + reg_M = Register(Rm) + setflags = (S == '1') + + } + + @rules { + + if (setflags); chk_call ExtendKeyword("s") + chk_call StoreCondition(cond) + + } + +} + diff --git a/plugins/arm/v7/opdefs/rrx_A88151.d b/plugins/arm/v7/opdefs/rrx_A88151.d new file mode 100644 index 0000000..4debd42 --- /dev/null +++ b/plugins/arm/v7/opdefs/rrx_A88151.d @@ -0,0 +1,72 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * ##FILE## - traduction d'instructions ARMv7 + * + * Copyright (C) 2015 Cyrille Bagard + * + * This file is part of Chrysalide. + * + * Chrysalide is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Chrysalide is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Foobar. If not, see . + */ + + +@title RRX + +@desc Rotate Right with Extend provides the value of the contents of a register shifted right by one place, with the Carry flag shifted into bit[31]. RRX can optionally update the condition flags based on the result. In that case, bit[0] is shifted into the Carry flag. + +@encoding (T1) { + + @word 1 1 1 0 1 0 1 0 0 1 0 S(1) 1 1 1 1 0 0 0 0 Rd(4) 0 0 1 1 Rm(4) + + @syntax + + @conv { + + reg_D = Register(Rd) + reg_M = Register(Rm) + setflags = (S == '1') + + } + + @rules { + + if (setflags); chk_call ExtendKeyword("s") + + } + +} + +@encoding (A1) { + + @word cond(4) 0 0 0 1 1 0 1 S(1) 0 0 0 0 Rd(4) 0 0 0 0 0 1 1 0 Rm(4) + + @syntax + + @conv { + + reg_D = Register(Rd) + reg_M = Register(Rm) + setflags = (S == '1') + + } + + @rules { + + if (setflags); chk_call ExtendKeyword("s") + chk_call StoreCondition(cond) + + } + +} + diff --git a/plugins/arm/v7/opdefs/rsb_A88152.d b/plugins/arm/v7/opdefs/rsb_A88152.d new file mode 100644 index 0000000..ea53373 --- /dev/null +++ b/plugins/arm/v7/opdefs/rsb_A88152.d @@ -0,0 +1,91 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * ##FILE## - traduction d'instructions ARMv7 + * + * Copyright (C) 2015 Cyrille Bagard + * + * This file is part of Chrysalide. + * + * Chrysalide is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Chrysalide is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Foobar. If not, see . + */ + + +@title RSB (immediate) + +@desc Reverse Subtract (immediate) subtracts a register value from an immediate value, and writes the result to the destination register. It can optionally update the condition flags based on the result. + +@encoding (t1) { + + @half 0 1 0 0 0 0 1 0 0 1 Rn(3) Rd(3) + + @syntax "rsbs" + + @conv { + + reg_D = Register(Rd) + reg_N = Register(Rn) + imm32 = Zeros(32) + + } + +} + +@encoding (T2) { + + @word 1 1 1 1 0 i(1) 0 1 1 1 0 S(1) Rn(4) 0 imm3(3) Rd(4) imm8(8) + + @syntax + + @conv { + + reg_D = Register(Rd) + reg_N = Register(Rn) + setflags = (S == '1') + imm32 = ThumbExpandImm(i:imm3:imm8) + + } + + @rules { + + if (setflags); chk_call ExtendKeyword("s") + chk_call ExtendKeyword(".w") + + } + +} + +@encoding (A1) { + + @word cond(4) 0 0 1 0 0 1 1 S(1) Rn(4) Rd(4) imm12(12) + + @syntax + + @conv { + + reg_D = Register(Rd) + reg_N = Register(Rn) + setflags = (S == '1') + imm32 = ARMExpandImm(imm12) + + } + + @rules { + + if (setflags); chk_call ExtendKeyword("s") + chk_call StoreCondition(cond) + + } + +} + diff --git a/plugins/arm/v7/opdefs/rsb_A88153.d b/plugins/arm/v7/opdefs/rsb_A88153.d new file mode 100644 index 0000000..f4a6d61 --- /dev/null +++ b/plugins/arm/v7/opdefs/rsb_A88153.d @@ -0,0 +1,76 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * ##FILE## - traduction d'instructions ARMv7 + * + * Copyright (C) 2015 Cyrille Bagard + * + * This file is part of Chrysalide. + * + * Chrysalide is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Chrysalide is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Foobar. If not, see . + */ + + +@title RSB (register) + +@desc Reverse Subtract (register) subtracts a register value from an optionally-shifted register value, and writes the result to the destination register. It can optionally update the condition flags based on the result. + +@encoding (T1) { + + @word 1 1 1 0 1 0 1 1 1 1 0 S(1) Rn(4) 0 imm3(3) Rd(4) imm2(2) type(2) Rm(4) + + @syntax + + @conv { + + reg_D = Register(Rd) + reg_N = Register(Rn) + reg_M = Register(Rm) + setflags = (S == '1') + shift = DecodeImmShift(type, imm3:imm2) + + } + + @rules { + + if (setflags); chk_call ExtendKeyword("s") + + } + +} + +@encoding (A1) { + + @word cond(4) 0 0 0 0 0 1 1 S(1) Rn(4) Rd(4) imm5(5) type(2) 0 Rm(4) + + @syntax + + @conv { + + reg_D = Register(Rd) + reg_N = Register(Rn) + reg_M = Register(Rm) + setflags = (S == '1') + shift = DecodeImmShift(type, imm5) + + } + + @rules { + + if (setflags); chk_call ExtendKeyword("s") + chk_call StoreCondition(cond) + + } + +} + diff --git a/plugins/arm/v7/opdefs/rsb_A88154.d b/plugins/arm/v7/opdefs/rsb_A88154.d new file mode 100644 index 0000000..9ccf559 --- /dev/null +++ b/plugins/arm/v7/opdefs/rsb_A88154.d @@ -0,0 +1,52 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * ##FILE## - traduction d'instructions ARMv7 + * + * Copyright (C) 2015 Cyrille Bagard + * + * This file is part of Chrysalide. + * + * Chrysalide is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Chrysalide is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Foobar. If not, see . + */ + + +@title RSB (register-shifted register) + +@desc Reverse Subtract (register-shifted register) subtracts a register value from a register-shifted register value, and writes the result to the destination register. It can optionally update the condition flags based on the result. + +@encoding (A1) { + + @word cond(4) 0 0 0 0 0 1 1 S(1) Rn(4) Rd(4) Rs(4) 0 type(2) 1 Rm(4) + + @syntax + + @conv { + + reg_shift = RegisterShift(type, Rs) + reg_D = Register(Rd) + reg_N = Register(Rn) + reg_M = Register(Rm) + setflags = (S == '1') + + } + + @rules { + + if (setflags); chk_call ExtendKeyword("s") + chk_call StoreCondition(cond) + + } + +} + diff --git a/plugins/arm/v7/opdefs/rsc_A88155.d b/plugins/arm/v7/opdefs/rsc_A88155.d new file mode 100644 index 0000000..fc5f8b6 --- /dev/null +++ b/plugins/arm/v7/opdefs/rsc_A88155.d @@ -0,0 +1,51 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * ##FILE## - traduction d'instructions ARMv7 + * + * Copyright (C) 2015 Cyrille Bagard + * + * This file is part of Chrysalide. + * + * Chrysalide is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Chrysalide is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Foobar. If not, see . + */ + + +@title RSC (immediate) + +@desc Reverse Subtract with Carry (immediate) subtracts a register value and the value of NOT (Carry flag) from an immediate value, and writes the result to the destination register. It can optionally update the condition flags based on the result. + +@encoding (A1) { + + @word cond(4) 0 0 1 0 1 1 1 S(1) Rn(4) Rd(4) imm12(12) + + @syntax + + @conv { + + reg_D = Register(Rd) + reg_N = Register(Rn) + setflags = (S == '1') + imm32 = ARMExpandImm(imm12) + + } + + @rules { + + if (setflags); chk_call ExtendKeyword("s") + chk_call StoreCondition(cond) + + } + +} + diff --git a/plugins/arm/v7/opdefs/rsc_A88156.d b/plugins/arm/v7/opdefs/rsc_A88156.d new file mode 100644 index 0000000..70829cd --- /dev/null +++ b/plugins/arm/v7/opdefs/rsc_A88156.d @@ -0,0 +1,52 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * ##FILE## - traduction d'instructions ARMv7 + * + * Copyright (C) 2015 Cyrille Bagard + * + * This file is part of Chrysalide. + * + * Chrysalide is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Chrysalide is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Foobar. If not, see . + */ + + +@title RSC (register) + +@desc Reverse Subtract with Carry (register) subtracts a register value and the value of NOT (Carry flag) from an optionally-shifted register value, and writes the result to the destination register. It can optionally update the condition flags based on the result. + +@encoding (A1) { + + @word cond(4) 0 0 0 0 1 1 1 S(1) Rn(4) Rd(4) imm5(5) type(2) 0 Rm(4) + + @syntax + + @conv { + + reg_D = Register(Rd) + reg_N = Register(Rn) + reg_M = Register(Rm) + setflags = (S == '1') + shift = DecodeImmShift(type, imm5) + + } + + @rules { + + if (setflags); chk_call ExtendKeyword("s") + chk_call StoreCondition(cond) + + } + +} + diff --git a/plugins/arm/v7/opdefs/rsc_A88157.d b/plugins/arm/v7/opdefs/rsc_A88157.d new file mode 100644 index 0000000..4fa276d --- /dev/null +++ b/plugins/arm/v7/opdefs/rsc_A88157.d @@ -0,0 +1,52 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * ##FILE## - traduction d'instructions ARMv7 + * + * Copyright (C) 2015 Cyrille Bagard + * + * This file is part of Chrysalide. + * + * Chrysalide is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Chrysalide is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Foobar. If not, see . + */ + + +@title RSC (register-shifted register) + +@desc Reverse Subtract (register-shifted register) subtracts a register value and the value of NOT (Carry flag) from a register-shifted register value, and writes the result to the destination register. It can optionally update the condition flags based on the result. + +@encoding (A1) { + + @word cond(4) 0 0 0 0 1 1 1 S(1) Rn(4) Rd(4) Rs(4) 0 type(2) 1 Rm(4) + + @syntax + + @conv { + + reg_shift = RegisterShift(type, Rs) + reg_D = Register(Rd) + reg_N = Register(Rn) + reg_M = Register(Rm) + setflags = (S == '1') + + } + + @rules { + + if (setflags); chk_call ExtendKeyword("s") + chk_call StoreCondition(cond) + + } + +} + diff --git a/plugins/arm/v7/opdefs/sadd16_A88158.d b/plugins/arm/v7/opdefs/sadd16_A88158.d new file mode 100644 index 0000000..51ad948 --- /dev/null +++ b/plugins/arm/v7/opdefs/sadd16_A88158.d @@ -0,0 +1,65 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * ##FILE## - traduction d'instructions ARMv7 + * + * Copyright (C) 2015 Cyrille Bagard + * + * This file is part of Chrysalide. + * + * Chrysalide is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Chrysalide is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Foobar. If not, see . + */ + + +@title SADD16 + +@desc Signed Add 16 performs two 16-bit signed integer additions, and writes the results to the destination register. It sets the APSR.GE bits according to the results of the additions. + +@encoding (T1) { + + @word 1 1 1 1 1 0 1 0 1 0 0 1 Rn(4) 1 1 1 1 Rd(4) 0 0 0 0 Rm(4) + + @syntax + + @conv { + + reg_D = Register(Rd) + reg_N = Register(Rn) + reg_M = Register(Rm) + + } + +} + +@encoding (A1) { + + @word cond(4) 0 1 1 0 0 0 0 1 Rn(4) Rd(4) 1 1 1 1 0 0 0 1 Rm(4) + + @syntax + + @conv { + + reg_D = Register(Rd) + reg_N = Register(Rn) + reg_M = Register(Rm) + + } + + @rules { + + chk_call StoreCondition(cond) + + } + +} + diff --git a/plugins/arm/v7/opdefs/sadd8_A88159.d b/plugins/arm/v7/opdefs/sadd8_A88159.d new file mode 100644 index 0000000..463c968 --- /dev/null +++ b/plugins/arm/v7/opdefs/sadd8_A88159.d @@ -0,0 +1,65 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * ##FILE## - traduction d'instructions ARMv7 + * + * Copyright (C) 2015 Cyrille Bagard + * + * This file is part of Chrysalide. + * + * Chrysalide is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Chrysalide is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Foobar. If not, see . + */ + + +@title SADD8 + +@desc Signed Add 8 performs four 8-bit signed integer additions, and writes the results to the destination register. It sets the APSR.GE bits according to the results of the additions. + +@encoding (T1) { + + @word 1 1 1 1 1 0 1 0 1 0 0 0 Rn(4) 1 1 1 1 Rd(4) 0 0 0 0 Rm(4) + + @syntax + + @conv { + + reg_D = Register(Rd) + reg_N = Register(Rn) + reg_M = Register(Rm) + + } + +} + +@encoding (A1) { + + @word cond(4) 0 1 1 0 0 0 0 1 Rn(4) Rd(4) 1 1 1 1 1 0 0 1 Rm(4) + + @syntax + + @conv { + + reg_D = Register(Rd) + reg_N = Register(Rn) + reg_M = Register(Rm) + + } + + @rules { + + chk_call StoreCondition(cond) + + } + +} + diff --git a/plugins/arm/v7/opdefs/sasx_A88160.d b/plugins/arm/v7/opdefs/sasx_A88160.d new file mode 100644 index 0000000..a0529cb --- /dev/null +++ b/plugins/arm/v7/opdefs/sasx_A88160.d @@ -0,0 +1,65 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * ##FILE## - traduction d'instructions ARMv7 + * + * Copyright (C) 2015 Cyrille Bagard + * + * This file is part of Chrysalide. + * + * Chrysalide is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Chrysalide is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Foobar. If not, see . + */ + + +@title SASX + +@desc Signed Add and Subtract with Exchange exchanges the two halfwords of the second operand, performs one 16-bit integer addition and one 16-bit subtraction, and writes the results to the destination register. It sets the APSR.GE bits according to the results. + +@encoding (T1) { + + @word 1 1 1 1 1 0 1 0 1 0 1 0 Rn(4) 1 1 1 1 Rd(4) 0 0 0 0 Rm(4) + + @syntax + + @conv { + + reg_D = Register(Rd) + reg_N = Register(Rn) + reg_M = Register(Rm) + + } + +} + +@encoding (A1) { + + @word cond(4) 0 1 1 0 0 0 0 1 Rn(4) Rd(4) 1 1 1 1 0 0 1 1 Rm(4) + + @syntax + + @conv { + + reg_D = Register(Rd) + reg_N = Register(Rn) + reg_M = Register(Rm) + + } + + @rules { + + chk_call StoreCondition(cond) + + } + +} + diff --git a/plugins/arm/v7/opdefs/sbc_A88161.d b/plugins/arm/v7/opdefs/sbc_A88161.d new file mode 100644 index 0000000..4ea776a --- /dev/null +++ b/plugins/arm/v7/opdefs/sbc_A88161.d @@ -0,0 +1,74 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * ##FILE## - traduction d'instructions ARMv7 + * + * Copyright (C) 2015 Cyrille Bagard + * + * This file is part of Chrysalide. + * + * Chrysalide is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Chrysalide is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Foobar. If not, see . + */ + + +@title SBC (immediate) + +@desc Subtract with Carry (immediate) subtracts an immediate value and the value of NOT (Carry flag) from a register value, and writes the result to the destination register. It can optionally update the condition flags based on the result. + +@encoding (T1) { + + @word 1 1 1 1 0 i(1) 0 1 0 1 1 S(1) Rn(4) 0 imm3(3) Rd(4) imm8(8) + + @syntax + + @conv { + + reg_D = Register(Rd) + reg_N = Register(Rn) + setflags = (S == '1') + imm32 = ThumbExpandImm(i:imm3:imm8) + + } + + @rules { + + if (setflags); chk_call ExtendKeyword("s") + + } + +} + +@encoding (A1) { + + @word cond(4) 0 0 1 0 1 1 0 S(1) Rn(4) Rd(4) imm12(12) + + @syntax + + @conv { + + reg_D = Register(Rd) + reg_N = Register(Rn) + setflags = (S == '1') + imm32 = ARMExpandImm(imm12) + + } + + @rules { + + if (setflags); chk_call ExtendKeyword("s") + chk_call StoreCondition(cond) + + } + +} + diff --git a/plugins/arm/v7/opdefs/sbc_A88162.d b/plugins/arm/v7/opdefs/sbc_A88162.d new file mode 100644 index 0000000..b6e660a --- /dev/null +++ b/plugins/arm/v7/opdefs/sbc_A88162.d @@ -0,0 +1,92 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * ##FILE## - traduction d'instructions ARMv7 + * + * Copyright (C) 2015 Cyrille Bagard + * + * This file is part of Chrysalide. + * + * Chrysalide is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Chrysalide is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Foobar. If not, see . + */ + + +@title SBC (register) + +@desc Subtract with Carry (register) subtracts an optionally-shifted register value and the value of NOT (Carry flag) from a register value, and writes the result to the destination register. It can optionally update the condition flags based on the result. + +@encoding (t1) { + + @half 0 1 0 0 0 0 0 1 1 0 Rm(3) Rdn(3) + + @syntax "sbcs" + + @conv { + + reg_DN = Register(Rdn) + reg_M = Register(Rm) + + } + +} + +@encoding (T2) { + + @word 1 1 1 0 1 0 1 1 0 1 1 S(1) Rn(4) 0 imm3(3) Rd(4) imm2(2) type(2) Rm(4) + + @syntax + + @conv { + + reg_D = Register(Rd) + reg_N = Register(Rn) + reg_M = Register(Rm) + setflags = (S == '1') + shift = DecodeImmShift(type, imm3:imm2) + + } + + @rules { + + if (setflags); chk_call ExtendKeyword("s") + chk_call ExtendKeyword(".w") + + } + +} + +@encoding (A1) { + + @word cond(4) 0 0 0 0 1 1 0 S(1) Rn(4) Rd(4) imm5(5) type(2) 0 Rm(4) + + @syntax + + @conv { + + reg_D = Register(Rd) + reg_N = Register(Rn) + reg_M = Register(Rm) + setflags = (S == '1') + shift = DecodeImmShift(type, imm5) + + } + + @rules { + + if (setflags); chk_call ExtendKeyword("s") + chk_call StoreCondition(cond) + + } + +} + diff --git a/plugins/arm/v7/opdefs/sbc_A88163.d b/plugins/arm/v7/opdefs/sbc_A88163.d new file mode 100644 index 0000000..0500edc --- /dev/null +++ b/plugins/arm/v7/opdefs/sbc_A88163.d @@ -0,0 +1,52 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * ##FILE## - traduction d'instructions ARMv7 + * + * Copyright (C) 2015 Cyrille Bagard + * + * This file is part of Chrysalide. + * + * Chrysalide is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Chrysalide is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Foobar. If not, see . + */ + + +@title SBC (register-shifted register) + +@desc Subtract with Carry (register-shifted register) subtracts a register-shifted register value and the value of NOT (Carry flag) from a register value, and writes the result to the destination register. It can optionally update the condition flags based on the result. + +@encoding (A1) { + + @word cond(4) 0 0 0 0 1 1 0 S(1) Rn(4) Rd(4) Rs(4) 0 type(2) 1 Rm(4) + + @syntax + + @conv { + + reg_shift = RegisterShift(type, Rs) + reg_D = Register(Rd) + reg_N = Register(Rn) + reg_M = Register(Rm) + setflags = (S == '1') + + } + + @rules { + + if (setflags); chk_call ExtendKeyword("s") + chk_call StoreCondition(cond) + + } + +} + diff --git a/plugins/arm/v7/opdefs/sbfx_A88164.d b/plugins/arm/v7/opdefs/sbfx_A88164.d new file mode 100644 index 0000000..486db3c --- /dev/null +++ b/plugins/arm/v7/opdefs/sbfx_A88164.d @@ -0,0 +1,67 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * ##FILE## - traduction d'instructions ARMv7 + * + * Copyright (C) 2015 Cyrille Bagard + * + * This file is part of Chrysalide. + * + * Chrysalide is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Chrysalide is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Foobar. If not, see . + */ + + +@title SBFX + +@desc Signed Bit Field Extract extracts any number of adjacent bits at any position from a register, sign-extends them to 32 bits, and writes the result to the destination register. + +@encoding (T1) { + + @word 1 1 1 1 0 0 1 1 0 1 0 0 Rn(4) 0 imm3(3) Rd(4) imm2(2) 0 widthm1(5) + + @syntax + + @conv { + + reg_D = Register(Rd) + reg_N = Register(Rn) + lsbit = UInt(imm3:imm2) + width = IncWidth(widthm1) + + } + +} + +@encoding (A1) { + + @word cond(4) 0 1 1 1 1 0 1 widthm1(5) Rd(4) lsb(5) 1 0 1 Rn(4) + + @syntax + + @conv { + + reg_D = Register(Rd) + reg_N = Register(Rn) + lsbit = UInt(lsb) + width = IncWidth(widthm1) + + } + + @rules { + + chk_call StoreCondition(cond) + + } + +} + diff --git a/plugins/arm/v7/opdefs/sdiv_A88165.d b/plugins/arm/v7/opdefs/sdiv_A88165.d new file mode 100644 index 0000000..19ebfa9 --- /dev/null +++ b/plugins/arm/v7/opdefs/sdiv_A88165.d @@ -0,0 +1,65 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * ##FILE## - traduction d'instructions ARMv7 + * + * Copyright (C) 2015 Cyrille Bagard + * + * This file is part of Chrysalide. + * + * Chrysalide is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Chrysalide is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Foobar. If not, see . + */ + + +@title SDIV + +@desc Signed Divide divides a 32-bit signed integer register value by a 32-bit signed integer register value, and writes the result to the destination register. The condition flags are not affected. See ARMv7 implementation requirements and options for the divide instructions on page A4-172 for more information about this instruction. + +@encoding (T1) { + + @word 1 1 1 1 1 0 1 1 1 0 0 1 Rn(4) 1 1 1 1 Rd(4) 1 1 1 1 Rm(4) + + @syntax + + @conv { + + reg_D = Register(Rd) + reg_N = Register(Rn) + reg_M = Register(Rm) + + } + +} + +@encoding (A1) { + + @word cond(4) 0 1 1 1 0 0 0 1 Rd(4) 1 1 1 1 Rm(4) 0 0 0 1 Rn(4) + + @syntax + + @conv { + + reg_D = Register(Rd) + reg_N = Register(Rn) + reg_M = Register(Rm) + + } + + @rules { + + chk_call StoreCondition(cond) + + } + +} + diff --git a/plugins/arm/v7/opdefs/sel_A88166.d b/plugins/arm/v7/opdefs/sel_A88166.d new file mode 100644 index 0000000..cb32ed6 --- /dev/null +++ b/plugins/arm/v7/opdefs/sel_A88166.d @@ -0,0 +1,65 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * ##FILE## - traduction d'instructions ARMv7 + * + * Copyright (C) 2015 Cyrille Bagard + * + * This file is part of Chrysalide. + * + * Chrysalide is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Chrysalide is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Foobar. If not, see . + */ + + +@title SEL + +@desc Select Bytes selects each byte of its result from either its first operand or its second operand, according to the values of the GE flags. + +@encoding (T1) { + + @word 1 1 1 1 1 0 1 0 1 0 1 0 Rn(4) 1 1 1 1 Rd(4) 1 0 0 0 Rm(4) + + @syntax + + @conv { + + reg_D = Register(Rd) + reg_N = Register(Rn) + reg_M = Register(Rm) + + } + +} + +@encoding (A1) { + + @word cond(4) 0 1 1 0 1 0 0 0 Rn(4) Rd(4) 1 1 1 1 1 0 1 1 Rm(4) + + @syntax + + @conv { + + reg_D = Register(Rd) + reg_N = Register(Rn) + reg_M = Register(Rm) + + } + + @rules { + + chk_call StoreCondition(cond) + + } + +} + diff --git a/plugins/arm/v7/opdefs/setend_A88167.d b/plugins/arm/v7/opdefs/setend_A88167.d new file mode 100644 index 0000000..e549c50 --- /dev/null +++ b/plugins/arm/v7/opdefs/setend_A88167.d @@ -0,0 +1,55 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * ##FILE## - traduction d'instructions ARMv7 + * + * Copyright (C) 2015 Cyrille Bagard + * + * This file is part of Chrysalide. + * + * Chrysalide is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Chrysalide is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Foobar. If not, see . + */ + + +@title SETEND + +@desc Set Endianness writes a new value to ENDIANSTATE. + +@encoding (t1) { + + @half 1 0 1 1 0 1 1 0 0 1 0 1 E(1) 0 0 0 + + @syntax + + @conv { + + set_bigend = EndianState(E == '1') + + } + +} + +@encoding (A1) { + + @word 1 1 1 1 0 0 0 1 0 0 0 0 0 0 0 1 0 0 0 0 0 0 E(1) 0 0 0 0 0 0 0 0 0 + + @syntax + + @conv { + + set_bigend = EndianState(E == '1') + + } + +} + diff --git a/plugins/arm/v7/opdefs/sev_A88168.d b/plugins/arm/v7/opdefs/sev_A88168.d new file mode 100644 index 0000000..2bd9af4 --- /dev/null +++ b/plugins/arm/v7/opdefs/sev_A88168.d @@ -0,0 +1,53 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * ##FILE## - traduction d'instructions ARMv7 + * + * Copyright (C) 2015 Cyrille Bagard + * + * This file is part of Chrysalide. + * + * Chrysalide is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Chrysalide is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Foobar. If not, see . + */ + + +@title SEV + +@desc Send Event is a hint instruction. It causes an event to be signaled to all processors in the multiprocessor system. For more information, see Wait For Event and Send Event on page B1-1199. + +@encoding (t1) { + + @half 1 0 1 1 1 1 1 1 0 1 0 0 0 0 0 0 + +} + +@encoding (T2) { + + @word 1 1 1 1 0 0 1 1 1 0 1 0 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 + + @syntax ".W" + +} + +@encoding (A1) { + + @word cond(4) 0 0 1 1 0 0 1 0 0 0 0 0 1 1 1 1 0 0 0 0 0 0 0 0 0 1 0 0 + + @rules { + + chk_call StoreCondition(cond) + + } + +} + diff --git a/plugins/arm/v7/opdefs/shadd16_A88169.d b/plugins/arm/v7/opdefs/shadd16_A88169.d new file mode 100644 index 0000000..22baa05 --- /dev/null +++ b/plugins/arm/v7/opdefs/shadd16_A88169.d @@ -0,0 +1,65 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * ##FILE## - traduction d'instructions ARMv7 + * + * Copyright (C) 2015 Cyrille Bagard + * + * This file is part of Chrysalide. + * + * Chrysalide is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Chrysalide is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Foobar. If not, see . + */ + + +@title SHADD16 + +@desc Signed Halving Add 16 performs two signed 16-bit integer additions, halves the results, and writes the results to the destination register. + +@encoding (T1) { + + @word 1 1 1 1 1 0 1 0 1 0 0 1 Rn(4) 1 1 1 1 Rd(4) 0 0 1 0 Rm(4) + + @syntax + + @conv { + + reg_D = Register(Rd) + reg_N = Register(Rn) + reg_M = Register(Rm) + + } + +} + +@encoding (A1) { + + @word cond(4) 0 1 1 0 0 0 1 1 Rn(4) Rd(4) 1 1 1 1 0 0 0 1 Rm(4) + + @syntax + + @conv { + + reg_D = Register(Rd) + reg_N = Register(Rn) + reg_M = Register(Rm) + + } + + @rules { + + chk_call StoreCondition(cond) + + } + +} + diff --git a/plugins/arm/v7/opdefs/shadd8_A88170.d b/plugins/arm/v7/opdefs/shadd8_A88170.d new file mode 100644 index 0000000..bfc3031 --- /dev/null +++ b/plugins/arm/v7/opdefs/shadd8_A88170.d @@ -0,0 +1,65 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * ##FILE## - traduction d'instructions ARMv7 + * + * Copyright (C) 2015 Cyrille Bagard + * + * This file is part of Chrysalide. + * + * Chrysalide is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Chrysalide is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Foobar. If not, see . + */ + + +@title SHADD8 + +@desc Signed Halving Add 8 performs four signed 8-bit integer additions, halves the results, and writes the results to the destination register. + +@encoding (T1) { + + @word 1 1 1 1 1 0 1 0 1 0 0 0 Rn(4) 1 1 1 1 Rd(4) 0 0 1 0 Rm(4) + + @syntax + + @conv { + + reg_D = Register(Rd) + reg_N = Register(Rn) + reg_M = Register(Rm) + + } + +} + +@encoding (A1) { + + @word cond(4) 0 1 1 0 0 0 1 1 Rn(4) Rd(4) 1 1 1 1 1 0 0 1 Rm(4) + + @syntax + + @conv { + + reg_D = Register(Rd) + reg_N = Register(Rn) + reg_M = Register(Rm) + + } + + @rules { + + chk_call StoreCondition(cond) + + } + +} + diff --git a/plugins/arm/v7/opdefs/shasx_A88171.d b/plugins/arm/v7/opdefs/shasx_A88171.d new file mode 100644 index 0000000..71d241b --- /dev/null +++ b/plugins/arm/v7/opdefs/shasx_A88171.d @@ -0,0 +1,65 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * ##FILE## - traduction d'instructions ARMv7 + * + * Copyright (C) 2015 Cyrille Bagard + * + * This file is part of Chrysalide. + * + * Chrysalide is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Chrysalide is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Foobar. If not, see . + */ + + +@title SHASX + +@desc Signed Halving Add and Subtract with Exchange exchanges the two halfwords of the second operand, performs one signed 16-bit integer addition and one signed 16-bit subtraction, halves the results, and writes the results to the destination register. + +@encoding (T1) { + + @word 1 1 1 1 1 0 1 0 1 0 1 0 Rn(4) 1 1 1 1 Rd(4) 0 0 1 0 Rm(4) + + @syntax + + @conv { + + reg_D = Register(Rd) + reg_N = Register(Rn) + reg_M = Register(Rm) + + } + +} + +@encoding (A1) { + + @word cond(4) 0 1 1 0 0 0 1 1 Rn(4) Rd(4) 1 1 1 1 0 0 1 1 Rm(4) + + @syntax + + @conv { + + reg_D = Register(Rd) + reg_N = Register(Rn) + reg_M = Register(Rm) + + } + + @rules { + + chk_call StoreCondition(cond) + + } + +} + diff --git a/plugins/arm/v7/opdefs/shsax_A88172.d b/plugins/arm/v7/opdefs/shsax_A88172.d new file mode 100644 index 0000000..8794738 --- /dev/null +++ b/plugins/arm/v7/opdefs/shsax_A88172.d @@ -0,0 +1,65 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * ##FILE## - traduction d'instructions ARMv7 + * + * Copyright (C) 2015 Cyrille Bagard + * + * This file is part of Chrysalide. + * + * Chrysalide is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Chrysalide is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Foobar. If not, see . + */ + + +@title SHSAX + +@desc Signed Halving Subtract and Add with Exchange exchanges the two halfwords of the second operand, performs one signed 16-bit integer subtraction and one signed 16-bit addition, halves the results, and writes the results to the destination register. + +@encoding (T1) { + + @word 1 1 1 1 1 0 1 0 1 1 1 0 Rn(4) 1 1 1 1 Rd(4) 0 0 1 0 Rm(4) + + @syntax + + @conv { + + reg_D = Register(Rd) + reg_N = Register(Rn) + reg_M = Register(Rm) + + } + +} + +@encoding (A1) { + + @word cond(4) 0 1 1 0 0 0 1 1 Rn(4) Rd(4) 1 1 1 1 0 1 0 1 Rm(4) + + @syntax + + @conv { + + reg_D = Register(Rd) + reg_N = Register(Rn) + reg_M = Register(Rm) + + } + + @rules { + + chk_call StoreCondition(cond) + + } + +} + diff --git a/plugins/arm/v7/opdefs/shsub16_A88173.d b/plugins/arm/v7/opdefs/shsub16_A88173.d new file mode 100644 index 0000000..f7099f2 --- /dev/null +++ b/plugins/arm/v7/opdefs/shsub16_A88173.d @@ -0,0 +1,65 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * ##FILE## - traduction d'instructions ARMv7 + * + * Copyright (C) 2015 Cyrille Bagard + * + * This file is part of Chrysalide. + * + * Chrysalide is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Chrysalide is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Foobar. If not, see . + */ + + +@title SHSUB16 + +@desc Signed Halving Subtract 16 performs two signed 16-bit integer subtractions, halves the results, and writes the results to the destination register. + +@encoding (T1) { + + @word 1 1 1 1 1 0 1 0 1 1 0 1 Rn(4) 1 1 1 1 Rd(4) 0 0 1 0 Rm(4) + + @syntax + + @conv { + + reg_D = Register(Rd) + reg_N = Register(Rn) + reg_M = Register(Rm) + + } + +} + +@encoding (A1) { + + @word cond(4) 0 1 1 0 0 0 1 1 Rn(4) Rd(4) 1 1 1 1 0 1 1 1 Rm(4) + + @syntax + + @conv { + + reg_D = Register(Rd) + reg_N = Register(Rn) + reg_M = Register(Rm) + + } + + @rules { + + chk_call StoreCondition(cond) + + } + +} + diff --git a/plugins/arm/v7/opdefs/shsub8_A88174.d b/plugins/arm/v7/opdefs/shsub8_A88174.d new file mode 100644 index 0000000..99af65d --- /dev/null +++ b/plugins/arm/v7/opdefs/shsub8_A88174.d @@ -0,0 +1,65 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * ##FILE## - traduction d'instructions ARMv7 + * + * Copyright (C) 2015 Cyrille Bagard + * + * This file is part of Chrysalide. + * + * Chrysalide is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Chrysalide is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Foobar. If not, see . + */ + + +@title SHSUB8 + +@desc Signed Halving Subtract 8 performs four signed 8-bit integer subtractions, halves the results, and writes the results to the destination register. + +@encoding (T1) { + + @word 1 1 1 1 1 0 1 0 1 1 0 0 Rn(4) 1 1 1 1 Rd(4) 0 0 1 0 Rm(4) + + @syntax + + @conv { + + reg_D = Register(Rd) + reg_N = Register(Rn) + reg_M = Register(Rm) + + } + +} + +@encoding (A1) { + + @word cond(4) 0 1 1 0 0 0 1 1 Rn(4) Rd(4) 1 1 1 1 1 1 1 1 Rm(4) + + @syntax + + @conv { + + reg_D = Register(Rd) + reg_N = Register(Rn) + reg_M = Register(Rm) + + } + + @rules { + + chk_call StoreCondition(cond) + + } + +} + diff --git a/plugins/arm/v7/opdefs/smlad_A88177.d b/plugins/arm/v7/opdefs/smlad_A88177.d new file mode 100644 index 0000000..3eabaa9 --- /dev/null +++ b/plugins/arm/v7/opdefs/smlad_A88177.d @@ -0,0 +1,76 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * ##FILE## - traduction d'instructions ARMv7 + * + * Copyright (C) 2015 Cyrille Bagard + * + * This file is part of Chrysalide. + * + * Chrysalide is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Chrysalide is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Foobar. If not, see . + */ + + +@title SMLAD + +@desc Signed Multiply Accumulate Dual performs two signed 16 × 16-bit multiplications. It adds the products to a 32-bit accumulate operand. Optionally, the instruction can exchange the halfwords of the second operand before performing the arithmetic. This produces top × bottom and bottom × top multiplication. This instruction sets the Q flag if the accumulate operation overflows. Overflow cannot occur during the multiplications. + +@encoding (T1) { + + @word 1 1 1 1 1 0 1 1 0 0 1 0 Rn(4) Ra(4) Rd(4) 0 0 0 M(1) Rm(4) + + @syntax + + @conv { + + reg_D = Register(Rd) + reg_N = Register(Rn) + reg_M = Register(Rm) + reg_A = Register(Ra) + m_swap = (M == '1') + + } + + @rules { + + if (m_swap); chk_call ExtendKeyword("x") + + } + +} + +@encoding (A1) { + + @word cond(4) 0 1 1 1 0 0 0 0 Rd(4) Ra(4) Rm(4) 0 0 M(1) 1 Rn(4) + + @syntax + + @conv { + + reg_D = Register(Rd) + reg_N = Register(Rn) + reg_M = Register(Rm) + reg_A = Register(Ra) + m_swap = (M == '1') + + } + + @rules { + + if (m_swap); chk_call ExtendKeyword("x") + chk_call StoreCondition(cond) + + } + +} + diff --git a/plugins/arm/v7/opdefs/smlal_A88178.d b/plugins/arm/v7/opdefs/smlal_A88178.d new file mode 100644 index 0000000..03da53c --- /dev/null +++ b/plugins/arm/v7/opdefs/smlal_A88178.d @@ -0,0 +1,69 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * ##FILE## - traduction d'instructions ARMv7 + * + * Copyright (C) 2015 Cyrille Bagard + * + * This file is part of Chrysalide. + * + * Chrysalide is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Chrysalide is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Foobar. If not, see . + */ + + +@title SMLAL + +@desc Signed Multiply Accumulate Long multiplies two signed 32-bit values to produce a 64-bit value, and accumulates this with a 64-bit value. In ARM instructions, the condition flags can optionally be updated based on the result. Use of this option adversely affects performance on many processor implementations. + +@encoding (T1) { + + @word 1 1 1 1 1 0 1 1 1 1 0 0 Rn(4) RdLo(4) RdHi(4) 0 0 0 0 Rm(4) + + @syntax + + @conv { + + reg_DLO = Register(RdLo) + reg_DHI = Register(RdHi) + reg_N = Register(Rn) + reg_M = Register(Rm) + + } + +} + +@encoding (A1) { + + @word cond(4) 0 0 0 0 1 1 1 S(1) RdHi(4) RdLo(4) Rm(4) 1 0 0 1 Rn(4) + + @syntax + + @conv { + + reg_DLO = Register(RdLo) + reg_DHI = Register(RdHi) + reg_N = Register(Rn) + reg_M = Register(Rm) + setflags = (S == '1') + + } + + @rules { + + if (setflags); chk_call ExtendKeyword("s") + chk_call StoreCondition(cond) + + } + +} + diff --git a/plugins/arm/v7/opdefs/smlald_A88180.d b/plugins/arm/v7/opdefs/smlald_A88180.d new file mode 100644 index 0000000..fa6a473 --- /dev/null +++ b/plugins/arm/v7/opdefs/smlald_A88180.d @@ -0,0 +1,76 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * ##FILE## - traduction d'instructions ARMv7 + * + * Copyright (C) 2015 Cyrille Bagard + * + * This file is part of Chrysalide. + * + * Chrysalide is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Chrysalide is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Foobar. If not, see . + */ + + +@title SMLALD + +@desc Signed Multiply Accumulate Long Dual performs two signed 16 × 16-bit multiplications. It adds the products to a 64-bit accumulate operand. Optionally, the instruction can exchange the halfwords of the second operand before performing the arithmetic. This produces top × bottom and bottom × top multiplication. Overflow is possible during this instruction, but only as a result of the 64-bit addition. This overflow is not detected if it occurs. Instead, the result wraps around modulo 264. + +@encoding (T1) { + + @word 1 1 1 1 1 0 1 1 1 1 0 0 Rn(4) RdLo(4) RdHi(4) 1 1 0 M(1) Rm(4) + + @syntax + + @conv { + + reg_DLO = Register(RdLo) + reg_DHI = Register(RdHi) + reg_N = Register(Rn) + reg_M = Register(Rm) + m_swap = (M == '1') + + } + + @rules { + + if (m_swap); chk_call ExtendKeyword("x") + + } + +} + +@encoding (A1) { + + @word cond(4) 0 1 1 1 0 1 0 0 RdHi(4) RdLo(4) Rm(4) 0 0 M(1) 1 Rn(4) + + @syntax + + @conv { + + reg_DLO = Register(RdLo) + reg_DHI = Register(RdHi) + reg_N = Register(Rn) + reg_M = Register(Rm) + m_swap = (M == '1') + + } + + @rules { + + if (m_swap); chk_call ExtendKeyword("x") + chk_call StoreCondition(cond) + + } + +} + diff --git a/plugins/arm/v7/opdefs/smlsd_A88182.d b/plugins/arm/v7/opdefs/smlsd_A88182.d new file mode 100644 index 0000000..d458fa8 --- /dev/null +++ b/plugins/arm/v7/opdefs/smlsd_A88182.d @@ -0,0 +1,76 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * ##FILE## - traduction d'instructions ARMv7 + * + * Copyright (C) 2015 Cyrille Bagard + * + * This file is part of Chrysalide. + * + * Chrysalide is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Chrysalide is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Foobar. If not, see . + */ + + +@title SMLSD + +@desc Signed Multiply Subtract Dual performs two signed 16 × 16-bit multiplications. It adds the difference of the products to a 32-bit accumulate operand. Optionally, the instruction can exchange the halfwords of the second operand before performing the arithmetic. This produces top × bottom and bottom × top multiplication. This instruction sets the Q flag if the accumulate operation overflows. Overflow cannot occur during the multiplications or subtraction. + +@encoding (T1) { + + @word 1 1 1 1 1 0 1 1 0 1 0 0 Rn(4) Ra(4) Rd(4) 0 0 0 M(1) Rm(4) + + @syntax + + @conv { + + reg_D = Register(Rd) + reg_N = Register(Rn) + reg_M = Register(Rm) + reg_A = Register(Ra) + m_swap = (M == '1') + + } + + @rules { + + if (m_swap); chk_call ExtendKeyword("x") + + } + +} + +@encoding (A1) { + + @word cond(4) 0 1 1 1 0 0 0 0 Rd(4) Ra(4) Rm(4) 0 1 M(1) 1 Rn(4) + + @syntax + + @conv { + + reg_D = Register(Rd) + reg_N = Register(Rn) + reg_M = Register(Rm) + reg_A = Register(Ra) + m_swap = (M == '1') + + } + + @rules { + + if (m_swap); chk_call ExtendKeyword("x") + chk_call StoreCondition(cond) + + } + +} + diff --git a/plugins/arm/v7/opdefs/smlsld_A88183.d b/plugins/arm/v7/opdefs/smlsld_A88183.d new file mode 100644 index 0000000..9f64eed --- /dev/null +++ b/plugins/arm/v7/opdefs/smlsld_A88183.d @@ -0,0 +1,76 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * ##FILE## - traduction d'instructions ARMv7 + * + * Copyright (C) 2015 Cyrille Bagard + * + * This file is part of Chrysalide. + * + * Chrysalide is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Chrysalide is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Foobar. If not, see . + */ + + +@title SMLSLD + +@desc Signed Multiply Subtract Long Dual performs two signed 16 × 16-bit multiplications. It adds the difference of the products to a 64-bit accumulate operand. Optionally, the instruction can exchange the halfwords of the second operand before performing the arithmetic. This produces top × bottom and bottom × top multiplication. Overflow is possible during this instruction, but only as a result of the 64-bit addition. This overflow is not detected if it occurs. Instead, the result wraps around modulo 264. + +@encoding (T1) { + + @word 1 1 1 1 1 0 1 1 1 1 0 1 Rn(4) RdLo(4) RdHi(4) 1 1 0 M(1) Rm(4) + + @syntax + + @conv { + + reg_DLO = Register(RdLo) + reg_DHI = Register(RdHi) + reg_N = Register(Rn) + reg_M = Register(Rm) + m_swap = (M == '1') + + } + + @rules { + + if (m_swap); chk_call ExtendKeyword("x") + + } + +} + +@encoding (A1) { + + @word cond(4) 0 1 1 1 0 1 0 0 RdHi(4) RdLo(4) Rm(4) 0 1 M(1) 1 Rn(4) + + @syntax + + @conv { + + reg_DLO = Register(RdLo) + reg_DHI = Register(RdHi) + reg_N = Register(Rn) + reg_M = Register(Rm) + m_swap = (M == '1') + + } + + @rules { + + if (m_swap); chk_call ExtendKeyword("x") + chk_call StoreCondition(cond) + + } + +} + diff --git a/plugins/arm/v7/opdefs/smmla_A88184.d b/plugins/arm/v7/opdefs/smmla_A88184.d new file mode 100644 index 0000000..a4d29b8 --- /dev/null +++ b/plugins/arm/v7/opdefs/smmla_A88184.d @@ -0,0 +1,76 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * ##FILE## - traduction d'instructions ARMv7 + * + * Copyright (C) 2015 Cyrille Bagard + * + * This file is part of Chrysalide. + * + * Chrysalide is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Chrysalide is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Foobar. If not, see . + */ + + +@title SMMLA + +@desc Signed Most Significant Word Multiply Accumulate multiplies two signed 32-bit values, extracts the most significant 32 bits of the result, and adds an accumulate value. Optionally, the instruction can specify that the result is rounded instead of being truncated. In this case, the constant 0x80000000 is added to the product before the high word is extracted. + +@encoding (T1) { + + @word 1 1 1 1 1 0 1 1 0 1 0 1 Rn(4) Ra(4) Rd(4) 0 0 0 R(1) Rm(4) + + @syntax + + @conv { + + reg_D = Register(Rd) + reg_N = Register(Rn) + reg_M = Register(Rm) + reg_A = Register(Ra) + round = (R == '1') + + } + + @rules { + + if (round); chk_call ExtendKeyword("r") + + } + +} + +@encoding (A1) { + + @word cond(4) 0 1 1 1 0 1 0 1 Rd(4) Ra(4) Rm(4) 0 0 R(1) 1 Rn(4) + + @syntax + + @conv { + + reg_D = Register(Rd) + reg_N = Register(Rn) + reg_M = Register(Rm) + reg_A = Register(Ra) + round = (R == '1') + + } + + @rules { + + if (round); chk_call ExtendKeyword("r") + chk_call StoreCondition(cond) + + } + +} + diff --git a/plugins/arm/v7/opdefs/smmls_A88185.d b/plugins/arm/v7/opdefs/smmls_A88185.d new file mode 100644 index 0000000..d59617b --- /dev/null +++ b/plugins/arm/v7/opdefs/smmls_A88185.d @@ -0,0 +1,76 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * ##FILE## - traduction d'instructions ARMv7 + * + * Copyright (C) 2015 Cyrille Bagard + * + * This file is part of Chrysalide. + * + * Chrysalide is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Chrysalide is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Foobar. If not, see . + */ + + +@title SMMLS + +@desc Signed Most Significant Word Multiply Subtract multiplies two signed 32-bit values, subtracts the result from a 32-bit accumulate value that is shifted left by 32 bits, and extracts the most significant 32 bits of the result of that subtraction. Optionally, the instruction can specify that the result of the instruction is rounded instead of being truncated. In this case, the constant 0x80000000 is added to the result of the subtraction before the high word is extracted. + +@encoding (T1) { + + @word 1 1 1 1 1 0 1 1 0 1 1 0 Rn(4) Ra(4) Rd(4) 0 0 0 R(1) Rm(4) + + @syntax + + @conv { + + reg_D = Register(Rd) + reg_N = Register(Rn) + reg_M = Register(Rm) + reg_A = Register(Ra) + round = (R == '1') + + } + + @rules { + + if (round); chk_call ExtendKeyword("r") + + } + +} + +@encoding (A1) { + + @word cond(4) 0 1 1 1 0 1 0 1 Rd(4) Ra(4) Rm(4) 1 1 R(1) 1 Rn(4) + + @syntax + + @conv { + + reg_D = Register(Rd) + reg_N = Register(Rn) + reg_M = Register(Rm) + reg_A = Register(Ra) + round = (R == '1') + + } + + @rules { + + if (round); chk_call ExtendKeyword("r") + chk_call StoreCondition(cond) + + } + +} + diff --git a/plugins/arm/v7/opdefs/smmul_A88186.d b/plugins/arm/v7/opdefs/smmul_A88186.d new file mode 100644 index 0000000..e02ca52 --- /dev/null +++ b/plugins/arm/v7/opdefs/smmul_A88186.d @@ -0,0 +1,74 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * ##FILE## - traduction d'instructions ARMv7 + * + * Copyright (C) 2015 Cyrille Bagard + * + * This file is part of Chrysalide. + * + * Chrysalide is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Chrysalide is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Foobar. If not, see . + */ + + +@title SMMUL + +@desc Signed Most Significant Word Multiply multiplies two signed 32-bit values, extracts the most significant 32 bits of the result, and writes those bits to the destination register. Optionally, the instruction can specify that the result is rounded instead of being truncated. In this case, the constant 0x80000000 is added to the product before the high word is extracted. + +@encoding (T1) { + + @word 1 1 1 1 1 0 1 1 0 1 0 1 Rn(4) 1 1 1 1 Rd(4) 0 0 0 R(1) Rm(4) + + @syntax + + @conv { + + reg_D = Register(Rd) + reg_N = Register(Rn) + reg_M = Register(Rm) + round = (R == '1') + + } + + @rules { + + if (round); chk_call ExtendKeyword("r") + + } + +} + +@encoding (A1) { + + @word cond(4) 0 1 1 1 0 1 0 1 Rd(4) 1 1 1 1 Rm(4) 0 0 R(1) 1 Rn(4) + + @syntax + + @conv { + + reg_D = Register(Rd) + reg_N = Register(Rn) + reg_M = Register(Rm) + round = (R == '1') + + } + + @rules { + + if (round); chk_call ExtendKeyword("r") + chk_call StoreCondition(cond) + + } + +} + diff --git a/plugins/arm/v7/opdefs/smuad_A88187.d b/plugins/arm/v7/opdefs/smuad_A88187.d new file mode 100644 index 0000000..324e257 --- /dev/null +++ b/plugins/arm/v7/opdefs/smuad_A88187.d @@ -0,0 +1,74 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * ##FILE## - traduction d'instructions ARMv7 + * + * Copyright (C) 2015 Cyrille Bagard + * + * This file is part of Chrysalide. + * + * Chrysalide is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Chrysalide is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Foobar. If not, see . + */ + + +@title SMUAD + +@desc Signed Dual Multiply Add performs two signed 16 × 16-bit multiplications. It adds the products together, and writes the result to the destination register. Optionally, the instruction can exchange the halfwords of the second operand before performing the arithmetic. This produces top × bottom and bottom × top multiplication. This instruction sets the Q flag if the addition overflows. The multiplications cannot overflow. + +@encoding (T1) { + + @word 1 1 1 1 1 0 1 1 0 0 1 0 Rn(4) 1 1 1 1 Rd(4) 0 0 0 M(1) Rm(4) + + @syntax + + @conv { + + reg_D = Register(Rd) + reg_N = Register(Rn) + reg_M = Register(Rm) + m_swap = (M == '1') + + } + + @rules { + + if (m_swap); chk_call ExtendKeyword("x") + + } + +} + +@encoding (A1) { + + @word cond(4) 0 1 1 1 0 0 0 0 Rd(4) 1 1 1 1 Rm(4) 0 0 M(1) 1 Rn(4) + + @syntax + + @conv { + + reg_D = Register(Rd) + reg_N = Register(Rn) + reg_M = Register(Rm) + m_swap = (M == '1') + + } + + @rules { + + if (m_swap); chk_call ExtendKeyword("x") + chk_call StoreCondition(cond) + + } + +} + diff --git a/plugins/arm/v7/opdefs/smull_A88189.d b/plugins/arm/v7/opdefs/smull_A88189.d new file mode 100644 index 0000000..5ab1c54 --- /dev/null +++ b/plugins/arm/v7/opdefs/smull_A88189.d @@ -0,0 +1,69 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * ##FILE## - traduction d'instructions ARMv7 + * + * Copyright (C) 2015 Cyrille Bagard + * + * This file is part of Chrysalide. + * + * Chrysalide is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Chrysalide is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Foobar. If not, see . + */ + + +@title SMULL + +@desc Signed Multiply Long multiplies two 32-bit signed values to produce a 64-bit result. In ARM instructions, the condition flags can optionally be updated based on the result. Use of this option adversely affects performance on many processor implementations. + +@encoding (T1) { + + @word 1 1 1 1 1 0 1 1 1 0 0 0 Rn(4) RdLo(4) RdHi(4) 0 0 0 0 Rm(4) + + @syntax + + @conv { + + reg_DLO = Register(RdLo) + reg_DHI = Register(RdHi) + reg_N = Register(Rn) + reg_M = Register(Rm) + + } + +} + +@encoding (A1) { + + @word cond(4) 0 0 0 0 1 1 0 S(1) RdHi(4) RdLo(4) Rm(4) 1 0 0 1 Rn(4) + + @syntax + + @conv { + + reg_DLO = Register(RdLo) + reg_DHI = Register(RdHi) + reg_N = Register(Rn) + reg_M = Register(Rm) + setflags = (S == '1') + + } + + @rules { + + if (setflags); chk_call ExtendKeyword("s") + chk_call StoreCondition(cond) + + } + +} + diff --git a/plugins/arm/v7/opdefs/str_A88203.d b/plugins/arm/v7/opdefs/str_A88203.d new file mode 100644 index 0000000..e3feaf7 --- /dev/null +++ b/plugins/arm/v7/opdefs/str_A88203.d @@ -0,0 +1,98 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * ##FILE## - traduction d'instructions ARMv7 + * + * Copyright (C) 2015 Cyrille Bagard + * + * This file is part of Chrysalide. + * + * Chrysalide is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Chrysalide is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Foobar. If not, see . + */ + + +@title STR (immediate, Thumb) + +@desc Store Register (immediate) calculates an address from a base register value and an immediate offset, and stores a word from a register to memory. It can use offset, post-indexed, or pre-indexed addressing. For information about memory accesses see Memory accesses on page A8-294. + +@encoding (t1) { + + @half 0 1 1 0 0 imm5(5) Rn(3) Rt(3) + + @syntax + + @conv { + + reg_T = Register(Rt) + reg_N = Register(Rn) + imm32 = ZeroExtend(imm5:'00', 32) + mem_access = MakeMemoryAccess(reg_N, imm32, NULL, true, true, false) + + } + +} + +@encoding (t2) { + + @half 1 0 0 1 0 Rt(3) imm8(8) + + @syntax + + @conv { + + reg_T = Register(Rt) + imm32 = ZeroExtend(imm8:'00', 32) + SP = Register(13) + mem_access = MakeMemoryAccess(SP, imm32, NULL, true, true, false) + + } + +} + +@encoding (T3) { + + @word 1 1 1 1 1 0 0 0 1 1 0 0 Rn(4) Rt(4) imm12(12) + + @syntax ".W" + + @conv { + + reg_T = Register(Rt) + reg_N = Register(Rn) + imm32 = ZeroExtend(imm12, 32) + mem_access = MakeMemoryAccess(reg_N, imm32, NULL, true, true, false) + + } + +} + +@encoding (T4) { + + @word 1 1 1 1 1 0 0 0 0 1 0 0 Rn(4) Rt(4) 1 P(1) U(1) W(1) imm8(8) + + @syntax + + @conv { + + reg_T = Register(Rt) + reg_N = Register(Rn) + imm32 = ZeroExtend(imm8, 32) + index = (P == '1') + add = (U == '1') + wback = (W == '1') + mem_access = MakeMemoryAccess(reg_N, imm32, NULL, index, add, wback) + + } + +} + diff --git a/plugins/arm/v7/opdefs/str_A88204.d b/plugins/arm/v7/opdefs/str_A88204.d new file mode 100644 index 0000000..d780ae3 --- /dev/null +++ b/plugins/arm/v7/opdefs/str_A88204.d @@ -0,0 +1,53 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * ##FILE## - traduction d'instructions ARMv7 + * + * Copyright (C) 2015 Cyrille Bagard + * + * This file is part of Chrysalide. + * + * Chrysalide is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Chrysalide is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Foobar. If not, see . + */ + + +@title STR (immediate, ARM) + +@desc Store Register (immediate) calculates an address from a base register value and an immediate offset, and stores a word from a register to memory. It can use offset, post-indexed, or pre-indexed addressing. For information about memory accesses see Memory accesses on page A8-294. + +@encoding (A1) { + + @word cond(4) 0 1 0 P(1) U(1) 0 W(1) 0 Rn(4) Rt(4) imm12(12) + + @syntax + + @conv { + + reg_T = Register(Rt) + reg_N = Register(Rn) + imm32 = ZeroExtend(imm12, 32) + index = (P == '1') + add = (U == '1') + wback = (P == '0') || (W == '1') + mem_access = MakeMemoryAccess(reg_N, imm32, NULL, index, add, wback) + + } + + @rules { + + chk_call StoreCondition(cond) + + } + +} + diff --git a/plugins/arm/v7/opdefs/str_A88205.d b/plugins/arm/v7/opdefs/str_A88205.d new file mode 100644 index 0000000..55f154c --- /dev/null +++ b/plugins/arm/v7/opdefs/str_A88205.d @@ -0,0 +1,89 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * ##FILE## - traduction d'instructions ARMv7 + * + * Copyright (C) 2015 Cyrille Bagard + * + * This file is part of Chrysalide. + * + * Chrysalide is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Chrysalide is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Foobar. If not, see . + */ + + +@title STR (register) + +@desc Store Register (register) calculates an address from a base register value and an offset register value, stores a word from a register to memory. The offset register value can optionally be shifted. For information about memory accesses see Memory accesses on page A8-294. + +@encoding (t1) { + + @half 0 1 0 1 0 0 0 Rm(3) Rn(3) Rt(3) + + @syntax + + @conv { + + reg_T = Register(Rt) + reg_N = Register(Rn) + reg_M = Register(Rm) + mem_access = MakeMemoryAccess(reg_N, reg_M, NULL, true, true, false) + + } + +} + +@encoding (T2) { + + @word 1 1 1 1 1 0 0 0 0 1 0 0 Rn(4) Rt(4) 0 0 0 0 0 0 imm2(2) Rm(4) + + @syntax ".W" + + @conv { + + reg_T = Register(Rt) + reg_N = Register(Rn) + reg_M = Register(Rm) + shift = DecodeImmShift(0, imm2) + mem_access = MakeMemoryAccess(reg_N, reg_M, shift, true, true, false) + + } + +} + +@encoding (A1) { + + @word cond(4) 0 1 1 P(1) U(1) 0 W(1) 0 Rn(4) Rt(4) imm5(5) type(2) 0 Rm(4) + + @syntax + + @conv { + + reg_T = Register(Rt) + reg_N = Register(Rn) + reg_M = Register(Rm) + index = (P == '1') + add = (U == '1') + wback = (P == '0') || (W == '1') + shift = DecodeImmShift(type, imm5) + mem_access = MakeMemoryAccess(reg_N, reg_M, shift, index, add, wback) + + } + + @rules { + + chk_call StoreCondition(cond) + + } + +} + diff --git a/plugins/arm/v7/opdefs/strb_A88206.d b/plugins/arm/v7/opdefs/strb_A88206.d new file mode 100644 index 0000000..2caf94c --- /dev/null +++ b/plugins/arm/v7/opdefs/strb_A88206.d @@ -0,0 +1,81 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * ##FILE## - traduction d'instructions ARMv7 + * + * Copyright (C) 2015 Cyrille Bagard + * + * This file is part of Chrysalide. + * + * Chrysalide is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Chrysalide is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Foobar. If not, see . + */ + + +@title STRB (immediate, Thumb) + +@desc Store Register Byte (immediate) calculates an address from a base register value and an immediate offset, and stores a byte from a register to memory. It can use offset, post-indexed, or pre-indexed addressing. For information about memory accesses see Memory accesses on page A8-294. + +@encoding (t1) { + + @half 0 1 1 1 0 imm5(5) Rn(3) Rt(3) + + @syntax + + @conv { + + reg_T = Register(Rt) + reg_N = Register(Rn) + imm32 = ZeroExtend(imm5, 32) + mem_access = MakeMemoryAccess(reg_N, imm32, NULL, true, true, false) + + } + +} + +@encoding (T2) { + + @word 1 1 1 1 1 0 0 0 1 0 0 0 Rn(4) Rt(4) imm12(12) + + @syntax ".W" + + @conv { + + reg_T = Register(Rt) + reg_N = Register(Rn) + imm32 = ZeroExtend(imm12, 32) + mem_access = MakeMemoryAccess(reg_N, imm32, NULL, true, true, false) + + } + +} + +@encoding (T3) { + + @word 1 1 1 1 1 0 0 0 0 0 0 0 Rn(4) Rt(4) 1 P(1) U(1) W(1) imm8(8) + + @syntax + + @conv { + + reg_T = Register(Rt) + reg_N = Register(Rn) + imm32 = ZeroExtend(imm8, 32) + index = (P == '1') + add = (U == '1') + wback = (W == '1') + mem_access = MakeMemoryAccess(reg_N, imm32, NULL, index, add, wback) + + } + +} + diff --git a/plugins/arm/v7/opdefs/strb_A88207.d b/plugins/arm/v7/opdefs/strb_A88207.d new file mode 100644 index 0000000..4e893fb --- /dev/null +++ b/plugins/arm/v7/opdefs/strb_A88207.d @@ -0,0 +1,53 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * ##FILE## - traduction d'instructions ARMv7 + * + * Copyright (C) 2015 Cyrille Bagard + * + * This file is part of Chrysalide. + * + * Chrysalide is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Chrysalide is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Foobar. If not, see . + */ + + +@title STRB (immediate, ARM) + +@desc Store Register Byte (immediate) calculates an address from a base register value and an immediate offset, and stores a byte from a register to memory. It can use offset, post-indexed, or pre-indexed addressing. For information about memory accesses see Memory accesses on page A8-294. + +@encoding (A1) { + + @word cond(4) 0 1 0 P(1) U(1) 1 W(1) 0 Rn(4) Rt(4) imm12(12) + + @syntax + + @conv { + + reg_T = Register(Rt) + reg_N = Register(Rn) + imm32 = ZeroExtend(imm12, 32) + index = (P == '1') + add = (U == '1') + wback = (P == '0') || (W == '1') + mem_access = MakeMemoryAccess(reg_N, imm32, NULL, index, add, wback) + + } + + @rules { + + chk_call StoreCondition(cond) + + } + +} + diff --git a/plugins/arm/v7/opdefs/strb_A88208.d b/plugins/arm/v7/opdefs/strb_A88208.d new file mode 100644 index 0000000..36f6134 --- /dev/null +++ b/plugins/arm/v7/opdefs/strb_A88208.d @@ -0,0 +1,89 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * ##FILE## - traduction d'instructions ARMv7 + * + * Copyright (C) 2015 Cyrille Bagard + * + * This file is part of Chrysalide. + * + * Chrysalide is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Chrysalide is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Foobar. If not, see . + */ + + +@title STRB (register) + +@desc Store Register Byte (register) calculates an address from a base register value and an offset register value, and stores a byte from a register to memory. The offset register value can optionally be shifted. For information about memory accesses see Memory accesses on page A8-294. + +@encoding (t1) { + + @half 0 1 0 1 0 1 0 Rm(3) Rn(3) Rt(3) + + @syntax + + @conv { + + reg_T = Register(Rt) + reg_N = Register(Rn) + reg_M = Register(Rm) + mem_access = MakeMemoryAccess(reg_N, reg_M, NULL, true, true, false) + + } + +} + +@encoding (T2) { + + @word 1 1 1 1 1 0 0 0 0 0 0 0 Rn(4) Rt(4) 0 0 0 0 0 0 imm2(2) Rm(4) + + @syntax ".W" + + @conv { + + reg_T = Register(Rt) + reg_N = Register(Rn) + reg_M = Register(Rm) + shift = DecodeImmShift(0, imm2) + mem_access = MakeMemoryAccess(reg_N, reg_M, shift, true, true, false) + + } + +} + +@encoding (A1) { + + @word cond(4) 0 1 1 P(1) U(1) 1 W(1) 0 Rn(4) Rt(4) imm5(5) type(2) 0 Rm(4) + + @syntax + + @conv { + + reg_T = Register(Rt) + reg_N = Register(Rn) + reg_M = Register(Rm) + index = (P == '1') + add = (U == '1') + wback = (P == '0') || (W == '1') + shift = DecodeImmShift(type, imm5) + mem_access = MakeMemoryAccess(reg_N, reg_M, shift, index, add, wback) + + } + + @rules { + + chk_call StoreCondition(cond) + + } + +} + diff --git a/plugins/arm/v7/opdefs/strbt_A88209.d b/plugins/arm/v7/opdefs/strbt_A88209.d new file mode 100644 index 0000000..2bcb260 --- /dev/null +++ b/plugins/arm/v7/opdefs/strbt_A88209.d @@ -0,0 +1,93 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * ##FILE## - traduction d'instructions ARMv7 + * + * Copyright (C) 2015 Cyrille Bagard + * + * This file is part of Chrysalide. + * + * Chrysalide is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Chrysalide is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Foobar. If not, see . + */ + + +@title STRBT + +@desc Store Register Byte Unprivileged stores a byte from a register to memory. For information about memory accesses see Memory accesses on page A8-294. The memory access is restricted as if the processor were running in User mode. This makes no difference if the processor is actually running in User mode. STRBT is UNPREDICTABLE in Hyp mode. The Thumb instruction uses an offset addressing mode, that calculates the address used for the memory access from a base register value and an immediate offset, and leaves the base register unchanged. The ARM instruction uses a post-indexed addressing mode, that uses a base register value as the address for the memory access, and calculates a new address from a base register value and an offset and writes it back to the base register. The offset can be an immediate value or an optionally-shifted register value. + +@encoding (T1) { + + @word 1 1 1 1 1 0 0 0 0 0 0 0 Rn(4) Rt(4) 1 1 1 0 imm8(8) + + @syntax + + @conv { + + reg_T = Register(Rt) + reg_N = Register(Rn) + imm32 = ZeroExtend(imm8, 32) + mem_access = MakeMemoryAccess(reg_N, imm32, NULL, true, true, false) + + } + +} + +@encoding (A1) { + + @word cond(4) 0 1 0 0 U(1) 1 1 0 Rn(4) Rt(4) imm12(12) + + @syntax + + @conv { + + reg_T = Register(Rt) + reg_N = Register(Rn) + add = (U == '1') + imm32 = ZeroExtend(imm12, 32) + mem_access = MakeMemoryAccess(reg_N, imm32, NULL, false, add, false) + + } + + @rules { + + chk_call StoreCondition(cond) + + } + +} + +@encoding (A2) { + + @word cond(4) 0 1 1 0 U(1) 1 1 0 Rn(4) Rt(4) imm5(5) type(2) 0 Rm(4) + + @syntax + + @conv { + + reg_T = Register(Rt) + reg_N = Register(Rn) + reg_M = Register(Rm) + add = (U == '1') + shift = DecodeImmShift(type, imm5) + mem_access = MakeMemoryAccess(reg_N, reg_M, shift, false, add, false) + + } + + @rules { + + chk_call StoreCondition(cond) + + } + +} + diff --git a/plugins/arm/v7/opdefs/strd_A88210.d b/plugins/arm/v7/opdefs/strd_A88210.d new file mode 100644 index 0000000..437bcb3 --- /dev/null +++ b/plugins/arm/v7/opdefs/strd_A88210.d @@ -0,0 +1,75 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * ##FILE## - traduction d'instructions ARMv7 + * + * Copyright (C) 2015 Cyrille Bagard + * + * This file is part of Chrysalide. + * + * Chrysalide is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Chrysalide is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Foobar. If not, see . + */ + + +@title STRD (immediate) + +@desc Store Register Dual (immediate) calculates an address from a base register value and an immediate offset, and stores two words from two registers to memory. It can use offset, post-indexed, or pre-indexed addressing. For information about memory accesses see Memory accesses on page A8-294. + +@encoding (T1) { + + @word 1 1 1 0 1 0 0 P(1) U(1) 1 W(1) 0 Rn(4) Rt(4) Rt2(4) imm8(8) + + @syntax + + @conv { + + reg_T = Register(Rt) + reg_T2 = Register(Rt2) + reg_N = Register(Rn) + imm32 = ZeroExtend(imm8:'00', 32) + index = (P == '1') + add = (U == '1') + wback = (W == '1') + mem_access = MakeMemoryAccess(reg_N, imm32, NULL, index, add, wback) + + } + +} + +@encoding (A1) { + + @word cond(4) 0 0 0 P(1) U(1) 1 W(1) 0 Rn(4) Rt(4) imm4H(4) 1 1 1 1 imm4L(4) + + @syntax + + @conv { + + reg_T = Register(Rt) + reg_T2 = NextRegister(reg_T) + reg_N = Register(Rn) + imm32 = ZeroExtend(imm4H:imm4L, 32) + index = (P == '1') + add = (U == '1') + wback = (P == '0') || (W == '1') + mem_access = MakeMemoryAccess(reg_N, imm32, NULL, index, add, wback) + + } + + @rules { + + chk_call StoreCondition(cond) + + } + +} + diff --git a/plugins/arm/v7/opdefs/strd_A88211.d b/plugins/arm/v7/opdefs/strd_A88211.d new file mode 100644 index 0000000..b30d4a5 --- /dev/null +++ b/plugins/arm/v7/opdefs/strd_A88211.d @@ -0,0 +1,54 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * ##FILE## - traduction d'instructions ARMv7 + * + * Copyright (C) 2015 Cyrille Bagard + * + * This file is part of Chrysalide. + * + * Chrysalide is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Chrysalide is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Foobar. If not, see . + */ + + +@title STRD (register) + +@desc Store Register Dual (register) calculates an address from a base register value and a register offset, and stores two words from two registers to memory. It can use offset, post-indexed, or pre-indexed addressing. For information about memory accesses see Memory accesses on page A8-294. + +@encoding (A1) { + + @word cond(4) 0 0 0 P(1) U(1) 0 W(1) 0 Rn(4) Rt(4) 0 0 0 0 1 1 1 1 Rm(4) + + @syntax + + @conv { + + reg_T = Register(Rt) + reg_T2 = NextRegister(reg_T) + reg_N = Register(Rn) + reg_M = Register(Rm) + index = (P == '1') + add = (U == '1') + wback = (P == '0') || (W == '1') + mem_access = MakeMemoryAccess(reg_N, reg_M, NULL, index, add, wback) + + } + + @rules { + + chk_call StoreCondition(cond) + + } + +} + diff --git a/plugins/arm/v7/opdefs/strex_A88212.d b/plugins/arm/v7/opdefs/strex_A88212.d new file mode 100644 index 0000000..65a7dfe --- /dev/null +++ b/plugins/arm/v7/opdefs/strex_A88212.d @@ -0,0 +1,68 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * ##FILE## - traduction d'instructions ARMv7 + * + * Copyright (C) 2015 Cyrille Bagard + * + * This file is part of Chrysalide. + * + * Chrysalide is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Chrysalide is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Foobar. If not, see . + */ + + +@title STREX + +@desc Store Register Exclusive calculates an address from a base register value and an immediate offset, and stores a word from a register to memory if the executing processor has exclusive access to the memory addressed. For more information about support for shared memory see Synchronization and semaphores on page A3-114. For information about memory accesses see Memory accesses on page A8-294. + +@encoding (T1) { + + @word 1 1 1 0 1 0 0 0 0 1 0 0 Rn(4) Rt(4) Rd(4) imm8(8) + + @syntax + + @conv { + + reg_D = Register(Rd) + reg_T = Register(Rt) + reg_N = Register(Rn) + imm32 = ZeroExtend(imm8:'00', 32) + mem_access = MakeMemoryAccess(reg_N, imm32, NULL, true, false, false) + + } + +} + +@encoding (A1) { + + @word cond(4) 0 0 0 1 1 0 0 0 Rn(4) Rd(4) 1 1 1 1 1 0 0 1 Rt(4) + + @syntax + + @conv { + + reg_D = Register(Rd) + reg_T = Register(Rt) + reg_N = Register(Rn) + mem_access = MakeMemoryAccess(reg_N, NULL, NULL, true, false, false) + + } + + @rules { + + chk_call StoreCondition(cond) + + } + +} + diff --git a/plugins/arm/v7/opdefs/strexb_A88213.d b/plugins/arm/v7/opdefs/strexb_A88213.d new file mode 100644 index 0000000..0197d6c --- /dev/null +++ b/plugins/arm/v7/opdefs/strexb_A88213.d @@ -0,0 +1,67 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * ##FILE## - traduction d'instructions ARMv7 + * + * Copyright (C) 2015 Cyrille Bagard + * + * This file is part of Chrysalide. + * + * Chrysalide is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Chrysalide is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Foobar. If not, see . + */ + + +@title STREXB + +@desc Store Register Exclusive Byte derives an address from a base register value, and stores a byte from a register to memory if the executing processor has exclusive access to the memory addressed. For more information about support for shared memory see Synchronization and semaphores on page A3-114. For information about memory accesses see Memory accesses on page A8-294. + +@encoding (T1) { + + @word 1 1 1 0 1 0 0 0 1 1 0 0 Rn(4) Rt(4) 1 1 1 1 0 1 0 0 Rd(4) + + @syntax + + @conv { + + reg_D = Register(Rd) + reg_T = Register(Rt) + reg_N = Register(Rn) + mem_access = MakeMemoryAccess(reg_N, NULL, NULL, true, false, false) + + } + +} + +@encoding (A1) { + + @word cond(4) 0 0 0 1 1 1 0 0 Rn(4) Rd(4) 1 1 1 1 1 0 0 1 Rt(4) + + @syntax + + @conv { + + reg_D = Register(Rd) + reg_T = Register(Rt) + reg_N = Register(Rn) + mem_access = MakeMemoryAccess(reg_N, NULL, NULL, true, false, false) + + } + + @rules { + + chk_call StoreCondition(cond) + + } + +} + diff --git a/plugins/arm/v7/opdefs/strexd_A88214.d b/plugins/arm/v7/opdefs/strexd_A88214.d new file mode 100644 index 0000000..2867cea --- /dev/null +++ b/plugins/arm/v7/opdefs/strexd_A88214.d @@ -0,0 +1,69 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * ##FILE## - traduction d'instructions ARMv7 + * + * Copyright (C) 2015 Cyrille Bagard + * + * This file is part of Chrysalide. + * + * Chrysalide is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Chrysalide is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Foobar. If not, see . + */ + + +@title STREXD + +@desc Store Register Exclusive Doubleword derives an address from a base register value, and stores a 64-bit doubleword from two registers to memory if the executing processor has exclusive access to the memory addressed. For more information about support for shared memory see Synchronization and semaphores on page A3-114. For information about memory accesses see Memory accesses on page A8-294. + +@encoding (T1) { + + @word 1 1 1 0 1 0 0 0 1 1 0 0 Rn(4) Rt(4) Rt2(4) 0 1 1 1 Rd(4) + + @syntax + + @conv { + + reg_D = Register(Rd) + reg_T = Register(Rt) + reg_T2 = Register(Rt2) + reg_N = Register(Rn) + mem_access = MakeMemoryAccess(reg_N, NULL, NULL, true, false, false) + + } + +} + +@encoding (A1) { + + @word cond(4) 0 0 0 1 1 0 1 0 Rn(4) Rd(4) 1 1 1 1 1 0 0 1 Rt(4) + + @syntax + + @conv { + + reg_D = Register(Rd) + reg_T = Register(Rt) + reg_T2 = NextRegister(reg_T) + reg_N = Register(Rn) + mem_access = MakeMemoryAccess(reg_N, NULL, NULL, true, false, false) + + } + + @rules { + + chk_call StoreCondition(cond) + + } + +} + diff --git a/plugins/arm/v7/opdefs/strexh_A88215.d b/plugins/arm/v7/opdefs/strexh_A88215.d new file mode 100644 index 0000000..4ca0b6f --- /dev/null +++ b/plugins/arm/v7/opdefs/strexh_A88215.d @@ -0,0 +1,67 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * ##FILE## - traduction d'instructions ARMv7 + * + * Copyright (C) 2015 Cyrille Bagard + * + * This file is part of Chrysalide. + * + * Chrysalide is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Chrysalide is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Foobar. If not, see . + */ + + +@title STREXH + +@desc Store Register Exclusive Halfword derives an address from a base register value, and stores a halfword from a register to memory if the executing processor has exclusive access to the memory addressed. For more information about support for shared memory see Synchronization and semaphores on page A3-114. For information about memory accesses see Memory accesses on page A8-294. + +@encoding (T1) { + + @word 1 1 1 0 1 0 0 0 1 1 0 0 Rn(4) Rt(4) 1 1 1 1 0 1 0 1 Rd(4) + + @syntax + + @conv { + + reg_D = Register(Rd) + reg_T = Register(Rt) + reg_N = Register(Rn) + mem_access = MakeMemoryAccess(reg_N, NULL, NULL, true, false, false) + + } + +} + +@encoding (A1) { + + @word cond(4) 0 0 0 1 1 1 1 0 Rn(4) Rd(4) 1 1 1 1 1 0 0 1 Rt(4) + + @syntax + + @conv { + + reg_D = Register(Rd) + reg_T = Register(Rt) + reg_N = Register(Rn) + mem_access = MakeMemoryAccess(reg_N, NULL, NULL, true, false, false) + + } + + @rules { + + chk_call StoreCondition(cond) + + } + +} + diff --git a/plugins/arm/v7/opdefs/strh_A88216.d b/plugins/arm/v7/opdefs/strh_A88216.d new file mode 100644 index 0000000..624b483 --- /dev/null +++ b/plugins/arm/v7/opdefs/strh_A88216.d @@ -0,0 +1,81 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * ##FILE## - traduction d'instructions ARMv7 + * + * Copyright (C) 2015 Cyrille Bagard + * + * This file is part of Chrysalide. + * + * Chrysalide is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Chrysalide is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Foobar. If not, see . + */ + + +@title STRH (immediate, Thumb) + +@desc Store Register Halfword (immediate) calculates an address from a base register value and an immediate offset, and stores a halfword from a register to memory. It can use offset, post-indexed, or pre-indexed addressing. For information about memory accesses see Memory accesses on page A8-294. + +@encoding (t1) { + + @half 1 0 0 0 0 imm5(5) Rn(3) Rt(3) + + @syntax + + @conv { + + reg_T = Register(Rt) + reg_N = Register(Rn) + imm32 = ZeroExtend(imm5:'0', 32) + mem_access = MakeMemoryAccess(reg_N, imm32, NULL, true, true, false) + + } + +} + +@encoding (T2) { + + @word 1 1 1 1 1 0 0 0 1 0 1 0 Rn(4) Rt(4) imm12(12) + + @syntax ".W" + + @conv { + + reg_T = Register(Rt) + reg_N = Register(Rn) + imm32 = ZeroExtend(imm12, 32) + mem_access = MakeMemoryAccess(reg_N, imm32, NULL, true, true, false) + + } + +} + +@encoding (T3) { + + @word 1 1 1 1 1 0 0 0 0 0 1 0 Rn(4) Rt(4) 1 P(1) U(1) W(1) imm8(8) + + @syntax + + @conv { + + reg_T = Register(Rt) + reg_N = Register(Rn) + imm32 = ZeroExtend(imm8, 32) + index = (P == '1') + add = (U == '1') + wback = (W == '1') + mem_access = MakeMemoryAccess(reg_N, imm32, NULL, index, add, wback) + + } + +} + diff --git a/plugins/arm/v7/opdefs/strh_A88217.d b/plugins/arm/v7/opdefs/strh_A88217.d new file mode 100644 index 0000000..3b5f97c --- /dev/null +++ b/plugins/arm/v7/opdefs/strh_A88217.d @@ -0,0 +1,53 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * ##FILE## - traduction d'instructions ARMv7 + * + * Copyright (C) 2015 Cyrille Bagard + * + * This file is part of Chrysalide. + * + * Chrysalide is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Chrysalide is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Foobar. If not, see . + */ + + +@title STRH (immediate, ARM) + +@desc Store Register Halfword (immediate) calculates an address from a base register value and an immediate offset, and stores a halfword from a register to memory. It can use offset, post-indexed, or pre-indexed addressing. For information about memory accesses see Memory accesses on page A8-294. + +@encoding (A1) { + + @word cond(4) 0 0 0 P(1) U(1) 1 W(1) 0 Rn(4) Rt(4) imm4H(4) 1 0 1 1 imm4L(4) + + @syntax + + @conv { + + reg_T = Register(Rt) + reg_N = Register(Rn) + imm32 = ZeroExtend(imm4H:imm4L, 32) + index = (P == '1') + add = (U == '1') + wback = (P == '0') || (W == '1') + mem_access = MakeMemoryAccess(reg_N, imm32, NULL, index, add, wback) + + } + + @rules { + + chk_call StoreCondition(cond) + + } + +} + diff --git a/plugins/arm/v7/opdefs/strh_A88218.d b/plugins/arm/v7/opdefs/strh_A88218.d new file mode 100644 index 0000000..1e9dc1f --- /dev/null +++ b/plugins/arm/v7/opdefs/strh_A88218.d @@ -0,0 +1,88 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * ##FILE## - traduction d'instructions ARMv7 + * + * Copyright (C) 2015 Cyrille Bagard + * + * This file is part of Chrysalide. + * + * Chrysalide is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Chrysalide is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Foobar. If not, see . + */ + + +@title STRH (register) + +@desc Store Register Halfword (register) calculates an address from a base register value and an offset register value, and stores a halfword from a register to memory. The offset register value can be shifted left by 0, 1, 2, or 3 bits. For information about memory accesses see Memory accesses on page A8-294. + +@encoding (t1) { + + @half 0 1 0 1 0 0 1 Rm(3) Rn(3) Rt(3) + + @syntax + + @conv { + + reg_T = Register(Rt) + reg_N = Register(Rn) + reg_M = Register(Rm) + mem_access = MakeMemoryAccess(reg_N, reg_M, NULL, true, true, false) + + } + +} + +@encoding (T2) { + + @word 1 1 1 1 1 0 0 0 0 0 1 0 Rn(4) Rt(4) 0 0 0 0 0 0 imm2(2) Rm(4) + + @syntax ".W" + + @conv { + + reg_T = Register(Rt) + reg_N = Register(Rn) + reg_M = Register(Rm) + shift = DecodeImmShift(0, imm2) + mem_access = MakeMemoryAccess(reg_N, reg_M, shift, true, true, false) + + } + +} + +@encoding (A1) { + + @word cond(4) 0 0 0 P(1) U(1) 0 W(1) 0 Rn(4) Rt(4) 0 0 0 0 1 0 1 1 Rm(4) + + @syntax + + @conv { + + reg_T = Register(Rt) + reg_N = Register(Rn) + reg_M = Register(Rm) + index = (P == '1') + add = (U == '1') + wback = (P == '0') || (W == '1') + mem_access = MakeMemoryAccess(reg_N, reg_M, NULL, index, add, wback) + + } + + @rules { + + chk_call StoreCondition(cond) + + } + +} + diff --git a/plugins/arm/v7/opdefs/strht_A88219.d b/plugins/arm/v7/opdefs/strht_A88219.d new file mode 100644 index 0000000..3811572 --- /dev/null +++ b/plugins/arm/v7/opdefs/strht_A88219.d @@ -0,0 +1,92 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * ##FILE## - traduction d'instructions ARMv7 + * + * Copyright (C) 2015 Cyrille Bagard + * + * This file is part of Chrysalide. + * + * Chrysalide is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Chrysalide is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Foobar. If not, see . + */ + + +@title STRHT + +@desc Store Register Halfword Unprivileged stores a halfword from a register to memory. For information about memory accesses see Memory accesses on page A8-294. The memory access is restricted as if the processor were running in User mode. This makes no difference if the processor is actually running in User mode. STRHT is UNPREDICTABLE in Hyp mode. The Thumb instruction uses an offset addressing mode, that calculates the address used for the memory access from a base register value and an immediate offset, and leaves the base register unchanged. The ARM instruction uses a post-indexed addressing mode, that uses a base register value as the address for the memory access, and calculates a new address from a base register value and an offset and writes it back to the base register. The offset can be an immediate value or a register value. + +@encoding (T1) { + + @word 1 1 1 1 1 0 0 0 0 0 1 0 Rn(4) Rt(4) 1 1 1 0 imm8(8) + + @syntax + + @conv { + + reg_T = Register(Rt) + reg_N = Register(Rn) + imm32 = ZeroExtend(imm8, 32) + mem_access = MakeMemoryAccess(reg_N, imm32, NULL, true, true, false) + + } + +} + +@encoding (A1) { + + @word cond(4) 0 0 0 0 U(1) 1 1 0 Rn(4) Rt(4) imm4H(4) 1 0 1 1 imm4L(4) + + @syntax + + @conv { + + reg_T = Register(Rt) + reg_N = Register(Rn) + add = (U == '1') + imm32 = ZeroExtend(imm4H:imm4L, 32) + mem_access = MakeMemoryAccess(reg_N, imm32, NULL, false, add, false) + + } + + @rules { + + chk_call StoreCondition(cond) + + } + +} + +@encoding (A2) { + + @word cond(4) 0 0 0 0 U(1) 0 1 0 Rn(4) Rt(4) 0 0 0 0 1 0 1 1 Rm(4) + + @syntax + + @conv { + + reg_T = Register(Rt) + reg_N = Register(Rn) + reg_M = Register(Rm) + add = (U == '1') + mem_access = MakeMemoryAccess(reg_N, reg_M, NULL, false, add, false) + + } + + @rules { + + chk_call StoreCondition(cond) + + } + +} + diff --git a/plugins/arm/v7/opdefs/strt_A88220.d b/plugins/arm/v7/opdefs/strt_A88220.d new file mode 100644 index 0000000..794a0fa --- /dev/null +++ b/plugins/arm/v7/opdefs/strt_A88220.d @@ -0,0 +1,93 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * ##FILE## - traduction d'instructions ARMv7 + * + * Copyright (C) 2015 Cyrille Bagard + * + * This file is part of Chrysalide. + * + * Chrysalide is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Chrysalide is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Foobar. If not, see . + */ + + +@title STRT + +@desc Store Register Unprivileged stores a word from a register to memory. For information about memory accesses see Memory accesses on page A8-294. The memory access is restricted as if the processor were running in User mode. This makes no difference if the processor is actually running in User mode. STRT is UNPREDICTABLE in Hyp mode. The Thumb instruction uses an offset addressing mode, that calculates the address used for the memory access from a base register value and an immediate offset, and leaves the base register unchanged. The ARM instruction uses a post-indexed addressing mode, that uses a base register value as the address for the memory access, and calculates a new address from a base register value and an offset and writes it back to the base register. The offset can be an immediate value or an optionally-shifted register value. + +@encoding (T1) { + + @word 1 1 1 1 1 0 0 0 0 1 0 0 Rn(4) Rt(4) 1 1 1 0 imm8(8) + + @syntax + + @conv { + + reg_T = Register(Rt) + reg_N = Register(Rn) + imm32 = ZeroExtend(imm8, 32) + mem_access = MakeMemoryAccess(reg_N, imm32, NULL, true, true, false) + + } + +} + +@encoding (A1) { + + @word cond(4) 0 1 0 0 U(1) 0 1 0 Rn(4) Rt(4) imm12(12) + + @syntax + + @conv { + + reg_T = Register(Rt) + reg_N = Register(Rn) + add = (U == '1') + imm32 = ZeroExtend(imm12, 32) + mem_access = MakeMemoryAccess(reg_N, imm32, NULL, false, add, false) + + } + + @rules { + + chk_call StoreCondition(cond) + + } + +} + +@encoding (A2) { + + @word cond(4) 0 1 1 0 U(1) 0 1 0 Rn(4) Rt(4) imm5(5) type(2) 0 Rm(4) + + @syntax + + @conv { + + reg_T = Register(Rt) + reg_N = Register(Rn) + reg_M = Register(Rm) + add = (U == '1') + shift = DecodeImmShift(type, imm5) + mem_access = MakeMemoryAccess(reg_N, reg_M, shift, false, add, false) + + } + + @rules { + + chk_call StoreCondition(cond) + + } + +} + diff --git a/plugins/arm/v7/opdefs/sub_A88221.d b/plugins/arm/v7/opdefs/sub_A88221.d new file mode 100644 index 0000000..41ce6b3 --- /dev/null +++ b/plugins/arm/v7/opdefs/sub_A88221.d @@ -0,0 +1,98 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * ##FILE## - traduction d'instructions ARMv7 + * + * Copyright (C) 2015 Cyrille Bagard + * + * This file is part of Chrysalide. + * + * Chrysalide is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Chrysalide is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Foobar. If not, see . + */ + + +@title SUB (immediate, Thumb) + +@desc This instruction subtracts an immediate value from a register value, and writes the result to the destination register. It can optionally update the condition flags based on the result. + +@encoding (t1) { + + @half 0 0 0 1 1 1 1 imm3(3) Rn(3) Rd(3) + + @syntax "subs" + + @conv { + + reg_D = Register(Rd) + reg_N = Register(Rn) + imm32 = ZeroExtend(imm3, 32) + + } + +} + +@encoding (t2) { + + @half 0 0 1 1 1 Rdn(3) imm8(8) + + @syntax "subs" + + @conv { + + reg_DN = Register(Rdn) + imm32 = ZeroExtend(imm8, 32) + + } + +} + +@encoding (T3) { + + @word 1 1 1 1 0 i(1) 0 1 1 0 1 S(1) Rn(4) 0 imm3(3) Rd(4) imm8(8) + + @syntax + + @conv { + + reg_D = Register(Rd) + reg_N = Register(Rn) + setflags = (S == '1') + imm32 = ThumbExpandImm(i:imm3:imm8) + + } + + @rules { + + if (setflags); chk_call ExtendKeyword("s") + chk_call ExtendKeyword(".w") + + } + +} + +@encoding (T4) { + + @word 1 1 1 1 0 i(1) 1 0 1 0 1 0 Rn(4) 0 imm3(3) Rd(4) imm8(8) + + @syntax "subw" + + @conv { + + reg_D = Register(Rd) + reg_N = Register(Rn) + imm32 = ZeroExtend(i:imm3:imm8, 32) + + } + +} + diff --git a/plugins/arm/v7/opdefs/sub_A88222.d b/plugins/arm/v7/opdefs/sub_A88222.d new file mode 100644 index 0000000..ef326b8 --- /dev/null +++ b/plugins/arm/v7/opdefs/sub_A88222.d @@ -0,0 +1,51 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * ##FILE## - traduction d'instructions ARMv7 + * + * Copyright (C) 2015 Cyrille Bagard + * + * This file is part of Chrysalide. + * + * Chrysalide is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Chrysalide is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Foobar. If not, see . + */ + + +@title SUB (immediate, ARM) + +@desc This instruction subtracts an immediate value from a register value, and writes the result to the destination register. It can optionally update the condition flags based on the result. + +@encoding (A1) { + + @word cond(4) 0 0 1 0 0 1 0 S(1) Rn(4) Rd(4) imm12(12) + + @syntax + + @conv { + + reg_D = Register(Rd) + reg_N = Register(Rn) + setflags = (S == '1') + imm32 = ARMExpandImm(imm12) + + } + + @rules { + + if (setflags); chk_call ExtendKeyword("s") + chk_call StoreCondition(cond) + + } + +} + diff --git a/plugins/arm/v7/opdefs/sub_A88223.d b/plugins/arm/v7/opdefs/sub_A88223.d new file mode 100644 index 0000000..a629250 --- /dev/null +++ b/plugins/arm/v7/opdefs/sub_A88223.d @@ -0,0 +1,93 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * ##FILE## - traduction d'instructions ARMv7 + * + * Copyright (C) 2015 Cyrille Bagard + * + * This file is part of Chrysalide. + * + * Chrysalide is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Chrysalide is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Foobar. If not, see . + */ + + +@title SUB (register) + +@desc This instruction subtracts an optionally-shifted register value from a register value, and writes the result to the destination register. It can optionally update the condition flags based on the result. + +@encoding (t1) { + + @half 0 0 0 1 1 0 1 Rm(3) Rn(3) Rd(3) + + @syntax "subs" + + @conv { + + reg_D = Register(Rd) + reg_N = Register(Rn) + reg_M = Register(Rm) + + } + +} + +@encoding (T2) { + + @word 1 1 1 0 1 0 1 1 1 0 1 S(1) Rn(4) 0 imm3(3) Rd(4) imm2(2) type(2) Rm(4) + + @syntax + + @conv { + + reg_D = Register(Rd) + reg_N = Register(Rn) + reg_M = Register(Rm) + setflags = (S == '1') + shift = DecodeImmShift(type, imm3:imm2) + + } + + @rules { + + if (setflags); chk_call ExtendKeyword("s") + chk_call ExtendKeyword(".w") + + } + +} + +@encoding (A1) { + + @word cond(4) 0 0 0 0 0 1 0 S(1) Rn(4) Rd(4) imm5(5) type(2) 0 Rm(4) + + @syntax + + @conv { + + reg_D = Register(Rd) + reg_N = Register(Rn) + reg_M = Register(Rm) + setflags = (S == '1') + shift = DecodeImmShift(type, imm5) + + } + + @rules { + + if (setflags); chk_call ExtendKeyword("s") + chk_call StoreCondition(cond) + + } + +} + diff --git a/plugins/arm/v7/opdefs/sub_A88224.d b/plugins/arm/v7/opdefs/sub_A88224.d new file mode 100644 index 0000000..5ef4e4d --- /dev/null +++ b/plugins/arm/v7/opdefs/sub_A88224.d @@ -0,0 +1,52 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * ##FILE## - traduction d'instructions ARMv7 + * + * Copyright (C) 2015 Cyrille Bagard + * + * This file is part of Chrysalide. + * + * Chrysalide is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Chrysalide is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Foobar. If not, see . + */ + + +@title SUB (register-shifted register) + +@desc This instruction subtracts a register-shifted register value from a register value, and writes the result to the destination register. It can optionally update the condition flags based on the result. + +@encoding (A1) { + + @word cond(4) 0 0 0 0 0 1 0 S(1) Rn(4) Rd(4) Rs(4) 0 type(2) 1 Rm(4) + + @syntax + + @conv { + + reg_shift = RegisterShift(type, Rs) + reg_D = Register(Rd) + reg_N = Register(Rn) + reg_M = Register(Rm) + setflags = (S == '1') + + } + + @rules { + + if (setflags); chk_call ExtendKeyword("s") + chk_call StoreCondition(cond) + + } + +} + diff --git a/plugins/arm/v7/opdefs/sub_A88225.d b/plugins/arm/v7/opdefs/sub_A88225.d new file mode 100644 index 0000000..dc54c6b --- /dev/null +++ b/plugins/arm/v7/opdefs/sub_A88225.d @@ -0,0 +1,107 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * ##FILE## - traduction d'instructions ARMv7 + * + * Copyright (C) 2015 Cyrille Bagard + * + * This file is part of Chrysalide. + * + * Chrysalide is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Chrysalide is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Foobar. If not, see . + */ + + +@title SUB (SP minus immediate) + +@desc This instruction subtracts an immediate value from the SP value, and writes the result to the destination register. + +@encoding (t1) { + + @half 1 0 1 1 0 0 0 0 1 imm7(7) + + @syntax + + @conv { + + imm32 = ZeroExtend(imm7:'00', 32) + SP_0 = Register(13) + SP_1 = Register(13) + + } + +} + +@encoding (T2) { + + @word 1 1 1 1 0 i(1) 0 1 1 0 1 S(1) 1 1 0 1 0 imm3(3) Rd(4) imm8(8) + + @syntax + + @conv { + + reg_D = Register(Rd) + setflags = (S == '1') + imm32 = ThumbExpandImm(i:imm3:imm8) + SP = Register(13) + + } + + @rules { + + if (setflags); chk_call ExtendKeyword("s") + chk_call ExtendKeyword(".w") + + } + +} + +@encoding (T3) { + + @word 1 1 1 1 0 i(1) 1 0 1 0 1 0 1 1 0 1 0 imm3(3) Rd(4) imm8(8) + + @syntax "subw" + + @conv { + + reg_D = Register(Rd) + imm32 = ZeroExtend(i:imm3:imm8, 32) + SP = Register(13) + + } + +} + +@encoding (A1) { + + @word cond(4) 0 0 1 0 0 1 0 S(1) 1 1 0 1 Rd(4) imm12(12) + + @syntax + + @conv { + + reg_D = Register(Rd) + setflags = (S == '1') + imm32 = ARMExpandImm(imm12) + SP = Register(13) + + } + + @rules { + + if (setflags); chk_call ExtendKeyword("s") + chk_call StoreCondition(cond) + + } + +} + diff --git a/plugins/arm/v7/opdefs/sub_A88226.d b/plugins/arm/v7/opdefs/sub_A88226.d new file mode 100644 index 0000000..02ecada --- /dev/null +++ b/plugins/arm/v7/opdefs/sub_A88226.d @@ -0,0 +1,76 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * ##FILE## - traduction d'instructions ARMv7 + * + * Copyright (C) 2015 Cyrille Bagard + * + * This file is part of Chrysalide. + * + * Chrysalide is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Chrysalide is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Foobar. If not, see . + */ + + +@title SUB (SP minus register) + +@desc This instruction subtracts an optionally-shifted register value from the SP value, and writes the result to the destination register. + +@encoding (T1) { + + @word 1 1 1 0 1 0 1 1 1 0 1 S(1) 1 1 0 1 0 imm3(3) Rd(4) imm2(2) type(2) Rm(4) + + @syntax + + @conv { + + reg_D = Register(Rd) + reg_M = Register(Rm) + setflags = (S == '1') + shift = DecodeImmShift(type, imm3:imm2) + SP = Register(13) + + } + + @rules { + + if (setflags); chk_call ExtendKeyword("s") + + } + +} + +@encoding (A1) { + + @word cond(4) 0 0 0 0 0 1 0 S(1) 1 1 0 1 Rd(4) imm5(5) type(2) 0 Rm(4) + + @syntax + + @conv { + + reg_D = Register(Rd) + reg_M = Register(Rm) + setflags = (S == '1') + shift = DecodeImmShift(type, imm5) + SP = Register(13) + + } + + @rules { + + if (setflags); chk_call ExtendKeyword("s") + chk_call StoreCondition(cond) + + } + +} + diff --git a/plugins/arm/v7/opdefs/subs_B9320.d b/plugins/arm/v7/opdefs/subs_B9320.d new file mode 100644 index 0000000..335e614 --- /dev/null +++ b/plugins/arm/v7/opdefs/subs_B9320.d @@ -0,0 +1,44 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * ##FILE## - traduction d'instructions ARMv7 + * + * Copyright (C) 2014 Cyrille Bagard + * + * This file is part of Chrysalide. + * + * Chrysalide is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Chrysalide is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Foobar. If not, see . + */ + + +@title SUBS PC, LR and related instructions (ARM) + +@encoding(A1) { + + @word cond(4) 0 0 1 opcode(4) 1 Rn(4) 1 1 1 1 imm12(12) + + @syntax {c} <#const> + + @conv { + + c = Condition(cond) + Rn = Register(Rn) + const = ExpandImmC32(imm12) + + } + + @rules { + + } + +} diff --git a/plugins/arm/v7/opdefs/svc_A88228.d b/plugins/arm/v7/opdefs/svc_A88228.d new file mode 100644 index 0000000..be48545 --- /dev/null +++ b/plugins/arm/v7/opdefs/svc_A88228.d @@ -0,0 +1,61 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * ##FILE## - traduction d'instructions ARMv7 + * + * Copyright (C) 2015 Cyrille Bagard + * + * This file is part of Chrysalide. + * + * Chrysalide is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Chrysalide is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Foobar. If not, see . + */ + + +@title SVC (previously SWI) + +@desc Supervisor Call, previously called Software Interrupt, causes a Supervisor Call exception. For more information, see Supervisor Call (SVC) exception on page B1-1209. Software can use this instruction as a call to an operating system to provide a service. In the following cases, the Supervisor Call exception generated by the SVC instruction is taken to Hyp mode: • If the SVC is executed in Hyp mode. • If HCR.TGE is set to 1, and the SVC is executed in Non-secure User mode. For more information, see Supervisor Call exception, when HCR.TGE is set to 1 on page B1-1191 In these cases, the HSR identifies that the exception entry was caused by a Supervisor Call exception, EC value 0x11, see Use of the HSR on page B3-1424. The immediate field in the HSR: • if the SVC is unconditional: — for the Thumb instruction, is the zero-extended value of the imm8 field — for the ARM instruction, is the least-significant 16 bits the imm24 field • if the SVC is conditional, is UNKNOWN. + +@encoding (t1) { + + @half 1 1 0 1 1 1 1 1 imm8(8) + + @syntax + + @conv { + + imm32 = ZeroExtend(imm8, 32) + + } + +} + +@encoding (A1) { + + @word cond(4) 1 1 1 1 imm24(24) + + @syntax + + @conv { + + imm32 = ZeroExtend(imm24, 32) + + } + + @rules { + + chk_call StoreCondition(cond) + + } + +} + diff --git a/plugins/arm/v7/opdefs/swp_A88229.d b/plugins/arm/v7/opdefs/swp_A88229.d new file mode 100644 index 0000000..2e39015 --- /dev/null +++ b/plugins/arm/v7/opdefs/swp_A88229.d @@ -0,0 +1,52 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * ##FILE## - traduction d'instructions ARMv7 + * + * Copyright (C) 2015 Cyrille Bagard + * + * This file is part of Chrysalide. + * + * Chrysalide is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Chrysalide is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Foobar. If not, see . + */ + + +@title SWP, SWPB + +@desc SWP (Swap) swaps a word between registers and memory. SWP loads a word from the memory address given by the value of register . The value of register is then stored to the memory address given by the value of , and the original loaded value is written to register . If the same register is specified for and , this instruction swaps the value of the register and the value at the memory address. SWPB (Swap Byte) swaps a byte between registers and memory. SWPB loads a byte from the memory address given by the value of register . The value of the least significant byte of register is stored to the memory address given by , the original loaded value is zero-extended to a 32-bit word, and the word is written to register . If the same register is specified for and , this instruction swaps the value of the least significant byte of the register and the byte value at the memory address, and clears the most significant three bytes of the register. For both instructions, the memory system ensures that no other memory access can occur to the memory location between the load access and the store access. Note • The SWP and SWPB instructions rely on the properties of the system beyond the processor to ensure that no stores from other observers can occur between the load access and the store access, and this might not be implemented for all regions of memory on some system implementations. In all cases, SWP and SWPB do ensure that no stores from the processor that executed the SWP or SWPB instruction can occur between the load access and the store access of the SWP or SWPB. • ARM deprecates the use of SWP and SWPB, and strongly recommends that new software uses: LDREX/STREX in preference to SWP — LDREXB/STREXB in preference to SWPB. — • If the translation table entries that relate to a memory location accessed by the SWP or SWPB instruction change, or are seen to change by the executing processor as a result of TLB eviction, this might mean that the translation table attributes, permissions or addresses for the load are different to those for the store. In this case, the architecture makes no guarantee that no memory access occur to these memory locations between the load and store. The Virtualization Extensions make the SWP and SWPB instructions OPTIONAL and deprecated: • If an implementation does not include the SWP and SWPB instructions, the ID_ISAR0.Swap_instrs and ID_ISAR4.SWP_frac fields are zero, see About the Instruction Set Attribute registers on page B7-1950. • In an implementation that includes SWP and SWPB, both instructions are UNDEFINED in Hyp mode. + +@encoding (A1) { + + @word cond(4) 0 0 0 1 0 B(1) 0 0 Rn(4) Rt(4) 0 0 0 0 1 0 0 1 Rt2(4) + + @syntax + + @conv { + + reg_T = Register(Rt) + reg_T2 = Register(Rt2) + reg_N = Register(Rn) + size = (B != 4) + mem_access = MakeMemoryAccess(reg_N, NULL, NULL, true, false, false) + + } + + @rules { + + if (size); chk_call ExtendKeyword("b") + chk_call StoreCondition(cond) + + } + +} + diff --git a/plugins/arm/v7/opdefs/teq_A88237.d b/plugins/arm/v7/opdefs/teq_A88237.d new file mode 100644 index 0000000..89073f6 --- /dev/null +++ b/plugins/arm/v7/opdefs/teq_A88237.d @@ -0,0 +1,63 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * ##FILE## - traduction d'instructions ARMv7 + * + * Copyright (C) 2015 Cyrille Bagard + * + * This file is part of Chrysalide. + * + * Chrysalide is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Chrysalide is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Foobar. If not, see . + */ + + +@title TEQ (immediate) + +@desc Test Equivalence (immediate) performs a bitwise exclusive OR operation on a register value and an immediate value. It updates the condition flags based on the result, and discards the result. + +@encoding (T1) { + + @word 1 1 1 1 0 i(1) 0 0 1 0 0 1 Rn(4) 0 imm3(3) 1 1 1 1 imm8(8) + + @syntax + + @conv { + + reg_N = Register(Rn) + imm32 = ThumbExpandImm_C(i:imm3:imm8, 0) + + } + +} + +@encoding (A1) { + + @word cond(4) 0 0 1 1 0 0 1 1 Rn(4) 0 0 0 0 imm12(12) + + @syntax + + @conv { + + reg_N = Register(Rn) + imm32 = ARMExpandImm_C(imm12, 0) + + } + + @rules { + + chk_call StoreCondition(cond) + + } + +} + diff --git a/plugins/arm/v7/opdefs/teq_A88238.d b/plugins/arm/v7/opdefs/teq_A88238.d new file mode 100644 index 0000000..8187d81 --- /dev/null +++ b/plugins/arm/v7/opdefs/teq_A88238.d @@ -0,0 +1,65 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * ##FILE## - traduction d'instructions ARMv7 + * + * Copyright (C) 2015 Cyrille Bagard + * + * This file is part of Chrysalide. + * + * Chrysalide is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Chrysalide is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Foobar. If not, see . + */ + + +@title TEQ (register) + +@desc Test Equivalence (register) performs a bitwise exclusive OR operation on a register value and an optionally-shifted register value. It updates the condition flags based on the result, and discards the result. + +@encoding (T1) { + + @word 1 1 1 0 1 0 1 0 1 0 0 1 Rn(4) 0 imm3(3) 1 1 1 1 imm2(2) type(2) Rm(4) + + @syntax + + @conv { + + reg_N = Register(Rn) + reg_M = Register(Rm) + shift = DecodeImmShift(type, imm3:imm2) + + } + +} + +@encoding (A1) { + + @word cond(4) 0 0 0 1 0 0 1 1 Rn(4) 0 0 0 0 imm5(5) type(2) 0 Rm(4) + + @syntax + + @conv { + + reg_N = Register(Rn) + reg_M = Register(Rm) + shift = DecodeImmShift(type, imm5) + + } + + @rules { + + chk_call StoreCondition(cond) + + } + +} + diff --git a/plugins/arm/v7/opdefs/teq_A88239.d b/plugins/arm/v7/opdefs/teq_A88239.d new file mode 100644 index 0000000..986a7f0 --- /dev/null +++ b/plugins/arm/v7/opdefs/teq_A88239.d @@ -0,0 +1,49 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * ##FILE## - traduction d'instructions ARMv7 + * + * Copyright (C) 2015 Cyrille Bagard + * + * This file is part of Chrysalide. + * + * Chrysalide is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Chrysalide is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Foobar. If not, see . + */ + + +@title TEQ (register-shifted register) + +@desc Test Equivalence (register-shifted register) performs a bitwise exclusive OR operation on a register value and a register-shifted register value. It updates the condition flags based on the result, and discards the result. + +@encoding (A1) { + + @word cond(4) 0 0 0 1 0 0 1 1 Rn(4) 0 0 0 0 Rs(4) 0 type(2) 1 Rm(4) + + @syntax + + @conv { + + reg_shift = RegisterShift(type, Rs) + reg_N = Register(Rn) + reg_M = Register(Rm) + + } + + @rules { + + chk_call StoreCondition(cond) + + } + +} + diff --git a/plugins/arm/v7/opdefs/tst_A88240.d b/plugins/arm/v7/opdefs/tst_A88240.d new file mode 100644 index 0000000..0ff5121 --- /dev/null +++ b/plugins/arm/v7/opdefs/tst_A88240.d @@ -0,0 +1,63 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * ##FILE## - traduction d'instructions ARMv7 + * + * Copyright (C) 2015 Cyrille Bagard + * + * This file is part of Chrysalide. + * + * Chrysalide is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Chrysalide is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Foobar. If not, see . + */ + + +@title TST (immediate) + +@desc Test (immediate) performs a bitwise AND operation on a register value and an immediate value. It updates the condition flags based on the result, and discards the result. + +@encoding (T1) { + + @word 1 1 1 1 0 i(1) 0 0 0 0 0 1 Rn(4) 0 imm3(3) 1 1 1 1 imm8(8) + + @syntax + + @conv { + + reg_N = Register(Rn) + imm32 = ThumbExpandImm_C(i:imm3:imm8, 0) + + } + +} + +@encoding (A1) { + + @word cond(4) 0 0 1 1 0 0 0 1 Rn(4) 0 0 0 0 imm12(12) + + @syntax + + @conv { + + reg_N = Register(Rn) + imm32 = ARMExpandImm_C(imm12, 0) + + } + + @rules { + + chk_call StoreCondition(cond) + + } + +} + diff --git a/plugins/arm/v7/opdefs/tst_A88241.d b/plugins/arm/v7/opdefs/tst_A88241.d new file mode 100644 index 0000000..8777d06 --- /dev/null +++ b/plugins/arm/v7/opdefs/tst_A88241.d @@ -0,0 +1,80 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * ##FILE## - traduction d'instructions ARMv7 + * + * Copyright (C) 2015 Cyrille Bagard + * + * This file is part of Chrysalide. + * + * Chrysalide is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Chrysalide is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Foobar. If not, see . + */ + + +@title TST (register) + +@desc Test (register) performs a bitwise AND operation on a register value and an optionally-shifted register value. It updates the condition flags based on the result, and discards the result. + +@encoding (t1) { + + @half 0 1 0 0 0 0 1 0 0 0 Rm(3) Rn(3) + + @syntax + + @conv { + + reg_N = Register(Rn) + reg_M = Register(Rm) + + } + +} + +@encoding (T2) { + + @word 1 1 1 0 1 0 1 0 0 0 0 1 Rn(4) 0 imm3(3) 1 1 1 1 imm2(2) type(2) Rm(4) + + @syntax ".W" + + @conv { + + reg_N = Register(Rn) + reg_M = Register(Rm) + shift = DecodeImmShift(type, imm3:imm2) + + } + +} + +@encoding (A1) { + + @word cond(4) 0 0 0 1 0 0 0 1 Rn(4) 0 0 0 0 imm5(5) type(2) 0 Rm(4) + + @syntax + + @conv { + + reg_N = Register(Rn) + reg_M = Register(Rm) + shift = DecodeImmShift(type, imm5) + + } + + @rules { + + chk_call StoreCondition(cond) + + } + +} + diff --git a/plugins/arm/v7/opdefs/tst_A88242.d b/plugins/arm/v7/opdefs/tst_A88242.d new file mode 100644 index 0000000..d3fdd9c --- /dev/null +++ b/plugins/arm/v7/opdefs/tst_A88242.d @@ -0,0 +1,49 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * ##FILE## - traduction d'instructions ARMv7 + * + * Copyright (C) 2015 Cyrille Bagard + * + * This file is part of Chrysalide. + * + * Chrysalide is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Chrysalide is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Foobar. If not, see . + */ + + +@title TST (register-shifted register) + +@desc Test (register-shifted register) performs a bitwise AND operation on a register value and a register-shifted register value. It updates the condition flags based on the result, and discards the result. + +@encoding (A1) { + + @word cond(4) 0 0 0 1 0 0 0 1 Rn(4) 0 0 0 0 Rs(4) 0 type(2) 1 Rm(4) + + @syntax + + @conv { + + reg_shift = RegisterShift(type, Rs) + reg_N = Register(Rn) + reg_M = Register(Rm) + + } + + @rules { + + chk_call StoreCondition(cond) + + } + +} + diff --git a/plugins/arm/v7/opdefs/uadd16_A88243.d b/plugins/arm/v7/opdefs/uadd16_A88243.d new file mode 100644 index 0000000..fcaadee --- /dev/null +++ b/plugins/arm/v7/opdefs/uadd16_A88243.d @@ -0,0 +1,65 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * ##FILE## - traduction d'instructions ARMv7 + * + * Copyright (C) 2015 Cyrille Bagard + * + * This file is part of Chrysalide. + * + * Chrysalide is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Chrysalide is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Foobar. If not, see . + */ + + +@title UADD16 + +@desc Unsigned Add 16 performs two 16-bit unsigned integer additions, and writes the results to the destination register. It sets the APSR.GE bits according to the results of the additions. + +@encoding (T1) { + + @word 1 1 1 1 1 0 1 0 1 0 0 1 Rn(4) 1 1 1 1 Rd(4) 0 1 0 0 Rm(4) + + @syntax + + @conv { + + reg_D = Register(Rd) + reg_N = Register(Rn) + reg_M = Register(Rm) + + } + +} + +@encoding (A1) { + + @word cond(4) 0 1 1 0 0 1 0 1 Rn(4) Rd(4) 1 1 1 1 0 0 0 1 Rm(4) + + @syntax + + @conv { + + reg_D = Register(Rd) + reg_N = Register(Rn) + reg_M = Register(Rm) + + } + + @rules { + + chk_call StoreCondition(cond) + + } + +} + diff --git a/plugins/arm/v7/opdefs/uadd8_A88244.d b/plugins/arm/v7/opdefs/uadd8_A88244.d new file mode 100644 index 0000000..451ca79 --- /dev/null +++ b/plugins/arm/v7/opdefs/uadd8_A88244.d @@ -0,0 +1,65 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * ##FILE## - traduction d'instructions ARMv7 + * + * Copyright (C) 2015 Cyrille Bagard + * + * This file is part of Chrysalide. + * + * Chrysalide is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Chrysalide is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Foobar. If not, see . + */ + + +@title UADD8 + +@desc Unsigned Add 8 performs four unsigned 8-bit integer additions, and writes the results to the destination register. It sets the APSR.GE bits according to the results of the additions. + +@encoding (T1) { + + @word 1 1 1 1 1 0 1 0 1 0 0 0 Rn(4) 1 1 1 1 Rd(4) 0 1 0 0 Rm(4) + + @syntax + + @conv { + + reg_D = Register(Rd) + reg_N = Register(Rn) + reg_M = Register(Rm) + + } + +} + +@encoding (A1) { + + @word cond(4) 0 1 1 0 0 1 0 1 Rn(4) Rd(4) 1 1 1 1 1 0 0 1 Rm(4) + + @syntax + + @conv { + + reg_D = Register(Rd) + reg_N = Register(Rn) + reg_M = Register(Rm) + + } + + @rules { + + chk_call StoreCondition(cond) + + } + +} + diff --git a/plugins/arm/v7/opdefs/uasx_A88245.d b/plugins/arm/v7/opdefs/uasx_A88245.d new file mode 100644 index 0000000..f968527 --- /dev/null +++ b/plugins/arm/v7/opdefs/uasx_A88245.d @@ -0,0 +1,65 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * ##FILE## - traduction d'instructions ARMv7 + * + * Copyright (C) 2015 Cyrille Bagard + * + * This file is part of Chrysalide. + * + * Chrysalide is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Chrysalide is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Foobar. If not, see . + */ + + +@title UASX + +@desc Unsigned Add and Subtract with Exchange exchanges the two halfwords of the second operand, performs one unsigned 16-bit integer addition and one unsigned 16-bit subtraction, and writes the results to the destination register. It sets the APSR.GE bits according to the results. + +@encoding (T1) { + + @word 1 1 1 1 1 0 1 0 1 0 1 0 Rn(4) 1 1 1 1 Rd(4) 0 1 0 0 Rm(4) + + @syntax + + @conv { + + reg_D = Register(Rd) + reg_N = Register(Rn) + reg_M = Register(Rm) + + } + +} + +@encoding (A1) { + + @word cond(4) 0 1 1 0 0 1 0 1 Rn(4) Rd(4) 1 1 1 1 0 0 1 1 Rm(4) + + @syntax + + @conv { + + reg_D = Register(Rd) + reg_N = Register(Rn) + reg_M = Register(Rm) + + } + + @rules { + + chk_call StoreCondition(cond) + + } + +} + diff --git a/plugins/arm/v7/opdefs/ubfx_A88246.d b/plugins/arm/v7/opdefs/ubfx_A88246.d new file mode 100644 index 0000000..1f9488e --- /dev/null +++ b/plugins/arm/v7/opdefs/ubfx_A88246.d @@ -0,0 +1,67 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * ##FILE## - traduction d'instructions ARMv7 + * + * Copyright (C) 2015 Cyrille Bagard + * + * This file is part of Chrysalide. + * + * Chrysalide is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Chrysalide is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Foobar. If not, see . + */ + + +@title UBFX + +@desc Unsigned Bit Field Extract extracts any number of adjacent bits at any position from a register, zero-extends them to 32 bits, and writes the result to the destination register. + +@encoding (T1) { + + @word 1 1 1 1 0 0 1 1 1 1 0 0 Rn(4) 0 imm3(3) Rd(4) imm2(2) 0 widthm1(5) + + @syntax + + @conv { + + reg_D = Register(Rd) + reg_N = Register(Rn) + lsbit = UInt(imm3:imm2) + width = IncWidth(widthm1) + + } + +} + +@encoding (A1) { + + @word cond(4) 0 1 1 1 1 1 1 widthm1(5) Rd(4) lsb(5) 1 0 1 Rn(4) + + @syntax + + @conv { + + reg_D = Register(Rd) + reg_N = Register(Rn) + lsbit = UInt(lsb) + width = IncWidth(widthm1) + + } + + @rules { + + chk_call StoreCondition(cond) + + } + +} + diff --git a/plugins/arm/v7/opdefs/udf_A88247.d b/plugins/arm/v7/opdefs/udf_A88247.d new file mode 100644 index 0000000..38f818c --- /dev/null +++ b/plugins/arm/v7/opdefs/udf_A88247.d @@ -0,0 +1,69 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * ##FILE## - traduction d'instructions ARMv7 + * + * Copyright (C) 2015 Cyrille Bagard + * + * This file is part of Chrysalide. + * + * Chrysalide is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Chrysalide is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Foobar. If not, see . + */ + + +@title UDF + +@desc Permanently Undefined generates an Undefined Instruction exception. The encodings for UDF used in this section are defined as permanently UNDEFINED in the versions of the architecture specified in this section. Issue C.a of this manual first defines an assembler mnemonic for these encodings. However: • with the Thumb instruction set, ARM deprecates using the UDF instruction in an IT block • in the ARM instruction set, UDF is not conditional. + +@encoding (t1) { + + @half 1 1 0 1 1 1 1 0 imm8(8) + + @syntax + + @conv { + + imm32 = ZeroExtend(imm8, 32) + + } + +} + +@encoding (T2) { + + @word 1 1 1 1 0 1 1 1 1 1 1 1 imm4(4) 1 0 1 0 imm12(12) + + @syntax ".W" + + @conv { + + imm32 = ZeroExtend(imm4:imm12, 32) + + } + +} + +@encoding (A1) { + + @word 1 1 1 0 0 1 1 1 1 1 1 1 imm12(12) 1 1 1 1 imm4(4) + + @syntax + + @conv { + + imm32 = ZeroExtend(imm12:imm4, 32) + + } + +} + diff --git a/plugins/arm/v7/opdefs/udiv_A88248.d b/plugins/arm/v7/opdefs/udiv_A88248.d new file mode 100644 index 0000000..eea7947 --- /dev/null +++ b/plugins/arm/v7/opdefs/udiv_A88248.d @@ -0,0 +1,65 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * ##FILE## - traduction d'instructions ARMv7 + * + * Copyright (C) 2015 Cyrille Bagard + * + * This file is part of Chrysalide. + * + * Chrysalide is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Chrysalide is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Foobar. If not, see . + */ + + +@title UDIV + +@desc Unsigned Divide divides a 32-bit unsigned integer register value by a 32-bit unsigned integer register value, and writes the result to the destination register. The condition flags are not affected. See ARMv7 implementation requirements and options for the divide instructions on page A4-172 for more information about this instruction. + +@encoding (T1) { + + @word 1 1 1 1 1 0 1 1 1 0 1 1 Rn(4) 1 1 1 1 Rd(4) 1 1 1 1 Rm(4) + + @syntax + + @conv { + + reg_D = Register(Rd) + reg_N = Register(Rn) + reg_M = Register(Rm) + + } + +} + +@encoding (A1) { + + @word cond(4) 0 1 1 1 0 0 1 1 Rd(4) 1 1 1 1 Rm(4) 0 0 0 1 Rn(4) + + @syntax + + @conv { + + reg_D = Register(Rd) + reg_N = Register(Rn) + reg_M = Register(Rm) + + } + + @rules { + + chk_call StoreCondition(cond) + + } + +} + diff --git a/plugins/arm/v7/opdefs/uhadd16_A88249.d b/plugins/arm/v7/opdefs/uhadd16_A88249.d new file mode 100644 index 0000000..54da5b0 --- /dev/null +++ b/plugins/arm/v7/opdefs/uhadd16_A88249.d @@ -0,0 +1,65 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * ##FILE## - traduction d'instructions ARMv7 + * + * Copyright (C) 2015 Cyrille Bagard + * + * This file is part of Chrysalide. + * + * Chrysalide is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Chrysalide is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Foobar. If not, see . + */ + + +@title UHADD16 + +@desc Unsigned Halving Add 16 performs two unsigned 16-bit integer additions, halves the results, and writes the results to the destination register. + +@encoding (T1) { + + @word 1 1 1 1 1 0 1 0 1 0 0 1 Rn(4) 1 1 1 1 Rd(4) 0 1 1 0 Rm(4) + + @syntax + + @conv { + + reg_D = Register(Rd) + reg_N = Register(Rn) + reg_M = Register(Rm) + + } + +} + +@encoding (A1) { + + @word cond(4) 0 1 1 0 0 1 1 1 Rn(4) Rd(4) 1 1 1 1 0 0 0 1 Rm(4) + + @syntax + + @conv { + + reg_D = Register(Rd) + reg_N = Register(Rn) + reg_M = Register(Rm) + + } + + @rules { + + chk_call StoreCondition(cond) + + } + +} + diff --git a/plugins/arm/v7/opdefs/uhadd8_A88250.d b/plugins/arm/v7/opdefs/uhadd8_A88250.d new file mode 100644 index 0000000..759a0a7 --- /dev/null +++ b/plugins/arm/v7/opdefs/uhadd8_A88250.d @@ -0,0 +1,65 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * ##FILE## - traduction d'instructions ARMv7 + * + * Copyright (C) 2015 Cyrille Bagard + * + * This file is part of Chrysalide. + * + * Chrysalide is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Chrysalide is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Foobar. If not, see . + */ + + +@title UHADD8 + +@desc Unsigned Halving Add 8 performs four unsigned 8-bit integer additions, halves the results, and writes the results to the destination register. + +@encoding (T1) { + + @word 1 1 1 1 1 0 1 0 1 0 0 0 Rn(4) 1 1 1 1 Rd(4) 0 1 1 0 Rm(4) + + @syntax + + @conv { + + reg_D = Register(Rd) + reg_N = Register(Rn) + reg_M = Register(Rm) + + } + +} + +@encoding (A1) { + + @word cond(4) 0 1 1 0 0 1 1 1 Rn(4) Rd(4) 1 1 1 1 1 0 0 1 Rm(4) + + @syntax + + @conv { + + reg_D = Register(Rd) + reg_N = Register(Rn) + reg_M = Register(Rm) + + } + + @rules { + + chk_call StoreCondition(cond) + + } + +} + diff --git a/plugins/arm/v7/opdefs/uhasx_A88251.d b/plugins/arm/v7/opdefs/uhasx_A88251.d new file mode 100644 index 0000000..3751394 --- /dev/null +++ b/plugins/arm/v7/opdefs/uhasx_A88251.d @@ -0,0 +1,65 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * ##FILE## - traduction d'instructions ARMv7 + * + * Copyright (C) 2015 Cyrille Bagard + * + * This file is part of Chrysalide. + * + * Chrysalide is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Chrysalide is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Foobar. If not, see . + */ + + +@title UHASX + +@desc Unsigned Halving Add and Subtract with Exchange exchanges the two halfwords of the second operand, performs one unsigned 16-bit integer addition and one unsigned 16-bit subtraction, halves the results, and writes the results to the destination register. + +@encoding (T1) { + + @word 1 1 1 1 1 0 1 0 1 0 1 0 Rn(4) 1 1 1 1 Rd(4) 0 1 1 0 Rm(4) + + @syntax + + @conv { + + reg_D = Register(Rd) + reg_N = Register(Rn) + reg_M = Register(Rm) + + } + +} + +@encoding (A1) { + + @word cond(4) 0 1 1 0 0 1 1 1 Rn(4) Rd(4) 1 1 1 1 0 0 1 1 Rm(4) + + @syntax + + @conv { + + reg_D = Register(Rd) + reg_N = Register(Rn) + reg_M = Register(Rm) + + } + + @rules { + + chk_call StoreCondition(cond) + + } + +} + diff --git a/plugins/arm/v7/opdefs/uhsax_A88252.d b/plugins/arm/v7/opdefs/uhsax_A88252.d new file mode 100644 index 0000000..f06b2ba --- /dev/null +++ b/plugins/arm/v7/opdefs/uhsax_A88252.d @@ -0,0 +1,65 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * ##FILE## - traduction d'instructions ARMv7 + * + * Copyright (C) 2015 Cyrille Bagard + * + * This file is part of Chrysalide. + * + * Chrysalide is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Chrysalide is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Foobar. If not, see . + */ + + +@title UHSAX + +@desc Unsigned Halving Subtract and Add with Exchange exchanges the two halfwords of the second operand, performs one unsigned 16-bit integer subtraction and one unsigned 16-bit addition, halves the results, and writes the results to the destination register. + +@encoding (T1) { + + @word 1 1 1 1 1 0 1 0 1 1 1 0 Rn(4) 1 1 1 1 Rd(4) 0 1 1 0 Rm(4) + + @syntax + + @conv { + + reg_D = Register(Rd) + reg_N = Register(Rn) + reg_M = Register(Rm) + + } + +} + +@encoding (A1) { + + @word cond(4) 0 1 1 0 0 1 1 1 Rn(4) Rd(4) 1 1 1 1 0 1 0 1 Rm(4) + + @syntax + + @conv { + + reg_D = Register(Rd) + reg_N = Register(Rn) + reg_M = Register(Rm) + + } + + @rules { + + chk_call StoreCondition(cond) + + } + +} + diff --git a/plugins/arm/v7/opdefs/uhsub16_A88253.d b/plugins/arm/v7/opdefs/uhsub16_A88253.d new file mode 100644 index 0000000..93f92f7 --- /dev/null +++ b/plugins/arm/v7/opdefs/uhsub16_A88253.d @@ -0,0 +1,65 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * ##FILE## - traduction d'instructions ARMv7 + * + * Copyright (C) 2015 Cyrille Bagard + * + * This file is part of Chrysalide. + * + * Chrysalide is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Chrysalide is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Foobar. If not, see . + */ + + +@title UHSUB16 + +@desc Unsigned Halving Subtract 16 performs two unsigned 16-bit integer subtractions, halves the results, and writes the results to the destination register. + +@encoding (T1) { + + @word 1 1 1 1 1 0 1 0 1 1 0 1 Rn(4) 1 1 1 1 Rd(4) 0 1 1 0 Rm(4) + + @syntax + + @conv { + + reg_D = Register(Rd) + reg_N = Register(Rn) + reg_M = Register(Rm) + + } + +} + +@encoding (A1) { + + @word cond(4) 0 1 1 0 0 1 1 1 Rn(4) Rd(4) 1 1 1 1 0 1 1 1 Rm(4) + + @syntax + + @conv { + + reg_D = Register(Rd) + reg_N = Register(Rn) + reg_M = Register(Rm) + + } + + @rules { + + chk_call StoreCondition(cond) + + } + +} + diff --git a/plugins/arm/v7/opdefs/uhsub8_A88254.d b/plugins/arm/v7/opdefs/uhsub8_A88254.d new file mode 100644 index 0000000..198a095 --- /dev/null +++ b/plugins/arm/v7/opdefs/uhsub8_A88254.d @@ -0,0 +1,65 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * ##FILE## - traduction d'instructions ARMv7 + * + * Copyright (C) 2015 Cyrille Bagard + * + * This file is part of Chrysalide. + * + * Chrysalide is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Chrysalide is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Foobar. If not, see . + */ + + +@title UHSUB8 + +@desc Unsigned Halving Subtract 8 performs four unsigned 8-bit integer subtractions, halves the results, and writes the results to the destination register. + +@encoding (T1) { + + @word 1 1 1 1 1 0 1 0 1 1 0 0 Rn(4) 1 1 1 1 Rd(4) 0 1 1 0 Rm(4) + + @syntax + + @conv { + + reg_D = Register(Rd) + reg_N = Register(Rn) + reg_M = Register(Rm) + + } + +} + +@encoding (A1) { + + @word cond(4) 0 1 1 0 0 1 1 1 Rn(4) Rd(4) 1 1 1 1 1 1 1 1 Rm(4) + + @syntax + + @conv { + + reg_D = Register(Rd) + reg_N = Register(Rn) + reg_M = Register(Rm) + + } + + @rules { + + chk_call StoreCondition(cond) + + } + +} + diff --git a/plugins/arm/v7/opdefs/umaal_A88255.d b/plugins/arm/v7/opdefs/umaal_A88255.d new file mode 100644 index 0000000..34cb707 --- /dev/null +++ b/plugins/arm/v7/opdefs/umaal_A88255.d @@ -0,0 +1,67 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * ##FILE## - traduction d'instructions ARMv7 + * + * Copyright (C) 2015 Cyrille Bagard + * + * This file is part of Chrysalide. + * + * Chrysalide is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Chrysalide is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Foobar. If not, see . + */ + + +@title UMAAL + +@desc Unsigned Multiply Accumulate Accumulate Long multiplies two unsigned 32-bit values to produce a 64-bit value, adds two unsigned 32-bit values, and writes the 64-bit result to two registers. + +@encoding (T1) { + + @word 1 1 1 1 1 0 1 1 1 1 1 0 Rn(4) RdLo(4) RdHi(4) 0 1 1 0 Rm(4) + + @syntax + + @conv { + + reg_DLO = Register(RdLo) + reg_DHI = Register(RdHi) + reg_N = Register(Rn) + reg_M = Register(Rm) + + } + +} + +@encoding (A1) { + + @word cond(4) 0 0 0 0 0 1 0 0 RdHi(4) RdLo(4) Rm(4) 1 0 0 1 Rn(4) + + @syntax + + @conv { + + reg_DLO = Register(RdLo) + reg_DHI = Register(RdHi) + reg_N = Register(Rn) + reg_M = Register(Rm) + + } + + @rules { + + chk_call StoreCondition(cond) + + } + +} + diff --git a/plugins/arm/v7/opdefs/umlal_A88256.d b/plugins/arm/v7/opdefs/umlal_A88256.d new file mode 100644 index 0000000..00d1903 --- /dev/null +++ b/plugins/arm/v7/opdefs/umlal_A88256.d @@ -0,0 +1,69 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * ##FILE## - traduction d'instructions ARMv7 + * + * Copyright (C) 2015 Cyrille Bagard + * + * This file is part of Chrysalide. + * + * Chrysalide is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Chrysalide is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Foobar. If not, see . + */ + + +@title UMLAL + +@desc Unsigned Multiply Accumulate Long multiplies two unsigned 32-bit values to produce a 64-bit value, and accumulates this with a 64-bit value. In ARM instructions, the condition flags can optionally be updated based on the result. Use of this option adversely affects performance on many processor implementations. + +@encoding (T1) { + + @word 1 1 1 1 1 0 1 1 1 1 1 0 Rn(4) RdLo(4) RdHi(4) 0 0 0 0 Rm(4) + + @syntax + + @conv { + + reg_DLO = Register(RdLo) + reg_DHI = Register(RdHi) + reg_N = Register(Rn) + reg_M = Register(Rm) + + } + +} + +@encoding (A1) { + + @word cond(4) 0 0 0 0 1 0 1 S(1) RdHi(4) RdLo(4) Rm(4) 1 0 0 1 Rn(4) + + @syntax + + @conv { + + reg_DLO = Register(RdLo) + reg_DHI = Register(RdHi) + reg_N = Register(Rn) + reg_M = Register(Rm) + setflags = (S == '1') + + } + + @rules { + + if (setflags); chk_call ExtendKeyword("s") + chk_call StoreCondition(cond) + + } + +} + diff --git a/plugins/arm/v7/opdefs/umull_A88257.d b/plugins/arm/v7/opdefs/umull_A88257.d new file mode 100644 index 0000000..d2cc321 --- /dev/null +++ b/plugins/arm/v7/opdefs/umull_A88257.d @@ -0,0 +1,69 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * ##FILE## - traduction d'instructions ARMv7 + * + * Copyright (C) 2015 Cyrille Bagard + * + * This file is part of Chrysalide. + * + * Chrysalide is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Chrysalide is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Foobar. If not, see . + */ + + +@title UMULL + +@desc Unsigned Multiply Long multiplies two 32-bit unsigned values to produce a 64-bit result. In ARM instructions, the condition flags can optionally be updated based on the result. Use of this option adversely affects performance on many processor implementations. + +@encoding (T1) { + + @word 1 1 1 1 1 0 1 1 1 0 1 0 Rn(4) RdLo(4) RdHi(4) 0 0 0 0 Rm(4) + + @syntax + + @conv { + + reg_DLO = Register(RdLo) + reg_DHI = Register(RdHi) + reg_N = Register(Rn) + reg_M = Register(Rm) + + } + +} + +@encoding (A1) { + + @word cond(4) 0 0 0 0 1 0 0 S(1) RdHi(4) RdLo(4) Rm(4) 1 0 0 1 Rn(4) + + @syntax + + @conv { + + reg_DLO = Register(RdLo) + reg_DHI = Register(RdHi) + reg_N = Register(Rn) + reg_M = Register(Rm) + setflags = (S == '1') + + } + + @rules { + + if (setflags); chk_call ExtendKeyword("s") + chk_call StoreCondition(cond) + + } + +} + diff --git a/plugins/arm/v7/opdefs/uqadd16_A88258.d b/plugins/arm/v7/opdefs/uqadd16_A88258.d new file mode 100644 index 0000000..14528c8 --- /dev/null +++ b/plugins/arm/v7/opdefs/uqadd16_A88258.d @@ -0,0 +1,65 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * ##FILE## - traduction d'instructions ARMv7 + * + * Copyright (C) 2015 Cyrille Bagard + * + * This file is part of Chrysalide. + * + * Chrysalide is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Chrysalide is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Foobar. If not, see . + */ + + +@title UQADD16 + +@desc Unsigned Saturating Add 16 performs two unsigned 16-bit integer additions, saturates the results to the 16-bit unsigned integer range 0 ≤ x ≤ 216 – 1, and writes the results to the destination register. + +@encoding (T1) { + + @word 1 1 1 1 1 0 1 0 1 0 0 1 Rn(4) 1 1 1 1 Rd(4) 0 1 0 1 Rm(4) + + @syntax + + @conv { + + reg_D = Register(Rd) + reg_N = Register(Rn) + reg_M = Register(Rm) + + } + +} + +@encoding (A1) { + + @word cond(4) 0 1 1 0 0 1 1 0 Rn(4) Rd(4) 1 1 1 1 0 0 0 1 Rm(4) + + @syntax + + @conv { + + reg_D = Register(Rd) + reg_N = Register(Rn) + reg_M = Register(Rm) + + } + + @rules { + + chk_call StoreCondition(cond) + + } + +} + diff --git a/plugins/arm/v7/opdefs/uqadd8_A88259.d b/plugins/arm/v7/opdefs/uqadd8_A88259.d new file mode 100644 index 0000000..94b8e39 --- /dev/null +++ b/plugins/arm/v7/opdefs/uqadd8_A88259.d @@ -0,0 +1,65 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * ##FILE## - traduction d'instructions ARMv7 + * + * Copyright (C) 2015 Cyrille Bagard + * + * This file is part of Chrysalide. + * + * Chrysalide is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Chrysalide is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Foobar. If not, see . + */ + + +@title UQADD8 + +@desc Unsigned Saturating Add 8 performs four unsigned 8-bit integer additions, saturates the results to the 8-bit unsigned integer range 0 ≤ x ≤ 28 – 1, and writes the results to the destination register. + +@encoding (T1) { + + @word 1 1 1 1 1 0 1 0 1 0 0 0 Rn(4) 1 1 1 1 Rd(4) 0 1 0 1 Rm(4) + + @syntax + + @conv { + + reg_D = Register(Rd) + reg_N = Register(Rn) + reg_M = Register(Rm) + + } + +} + +@encoding (A1) { + + @word cond(4) 0 1 1 0 0 1 1 0 Rn(4) Rd(4) 1 1 1 1 1 0 0 1 Rm(4) + + @syntax + + @conv { + + reg_D = Register(Rd) + reg_N = Register(Rn) + reg_M = Register(Rm) + + } + + @rules { + + chk_call StoreCondition(cond) + + } + +} + diff --git a/plugins/arm/v7/opdefs/uqasx_A88260.d b/plugins/arm/v7/opdefs/uqasx_A88260.d new file mode 100644 index 0000000..174b08c --- /dev/null +++ b/plugins/arm/v7/opdefs/uqasx_A88260.d @@ -0,0 +1,65 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * ##FILE## - traduction d'instructions ARMv7 + * + * Copyright (C) 2015 Cyrille Bagard + * + * This file is part of Chrysalide. + * + * Chrysalide is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Chrysalide is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Foobar. If not, see . + */ + + +@title UQASX + +@desc Unsigned Saturating Add and Subtract with Exchange exchanges the two halfwords of the second operand, performs one unsigned 16-bit integer addition and one unsigned 16-bit subtraction, saturates the results to the 16-bit unsigned integer range 0 ≤ x ≤ 216 – 1, and writes the results to the destination register. + +@encoding (T1) { + + @word 1 1 1 1 1 0 1 0 1 0 1 0 Rn(4) 1 1 1 1 Rd(4) 0 1 0 1 Rm(4) + + @syntax + + @conv { + + reg_D = Register(Rd) + reg_N = Register(Rn) + reg_M = Register(Rm) + + } + +} + +@encoding (A1) { + + @word cond(4) 0 1 1 0 0 1 1 0 Rn(4) Rd(4) 1 1 1 1 0 0 1 1 Rm(4) + + @syntax + + @conv { + + reg_D = Register(Rd) + reg_N = Register(Rn) + reg_M = Register(Rm) + + } + + @rules { + + chk_call StoreCondition(cond) + + } + +} + diff --git a/plugins/arm/v7/opdefs/uqsax_A88261.d b/plugins/arm/v7/opdefs/uqsax_A88261.d new file mode 100644 index 0000000..6092e51 --- /dev/null +++ b/plugins/arm/v7/opdefs/uqsax_A88261.d @@ -0,0 +1,65 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * ##FILE## - traduction d'instructions ARMv7 + * + * Copyright (C) 2015 Cyrille Bagard + * + * This file is part of Chrysalide. + * + * Chrysalide is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Chrysalide is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Foobar. If not, see . + */ + + +@title UQSAX + +@desc Unsigned Saturating Subtract and Add with Exchange exchanges the two halfwords of the second operand, performs one unsigned 16-bit integer subtraction and one unsigned 16-bit addition, saturates the results to the 16-bit unsigned integer range 0 ≤ x ≤ 216 – 1, and writes the results to the destination register. + +@encoding (T1) { + + @word 1 1 1 1 1 0 1 0 1 1 1 0 Rn(4) 1 1 1 1 Rd(4) 0 1 0 1 Rm(4) + + @syntax + + @conv { + + reg_D = Register(Rd) + reg_N = Register(Rn) + reg_M = Register(Rm) + + } + +} + +@encoding (A1) { + + @word cond(4) 0 1 1 0 0 1 1 0 Rn(4) Rd(4) 1 1 1 1 0 1 0 1 Rm(4) + + @syntax + + @conv { + + reg_D = Register(Rd) + reg_N = Register(Rn) + reg_M = Register(Rm) + + } + + @rules { + + chk_call StoreCondition(cond) + + } + +} + diff --git a/plugins/arm/v7/opdefs/uqsub16_A88262.d b/plugins/arm/v7/opdefs/uqsub16_A88262.d new file mode 100644 index 0000000..1f458ff --- /dev/null +++ b/plugins/arm/v7/opdefs/uqsub16_A88262.d @@ -0,0 +1,65 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * ##FILE## - traduction d'instructions ARMv7 + * + * Copyright (C) 2015 Cyrille Bagard + * + * This file is part of Chrysalide. + * + * Chrysalide is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Chrysalide is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Foobar. If not, see . + */ + + +@title UQSUB16 + +@desc Unsigned Saturating Subtract 16 performs two unsigned 16-bit integer subtractions, saturates the results to the 16-bit unsigned integer range 0 ≤ x ≤ 216 – 1, and writes the results to the destination register. + +@encoding (T1) { + + @word 1 1 1 1 1 0 1 0 1 1 0 1 Rn(4) 1 1 1 1 Rd(4) 0 1 0 1 Rm(4) + + @syntax + + @conv { + + reg_D = Register(Rd) + reg_N = Register(Rn) + reg_M = Register(Rm) + + } + +} + +@encoding (A1) { + + @word cond(4) 0 1 1 0 0 1 1 0 Rn(4) Rd(4) 1 1 1 1 0 1 1 1 Rm(4) + + @syntax + + @conv { + + reg_D = Register(Rd) + reg_N = Register(Rn) + reg_M = Register(Rm) + + } + + @rules { + + chk_call StoreCondition(cond) + + } + +} + diff --git a/plugins/arm/v7/opdefs/uqsub8_A88263.d b/plugins/arm/v7/opdefs/uqsub8_A88263.d new file mode 100644 index 0000000..37d96e7 --- /dev/null +++ b/plugins/arm/v7/opdefs/uqsub8_A88263.d @@ -0,0 +1,65 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * ##FILE## - traduction d'instructions ARMv7 + * + * Copyright (C) 2015 Cyrille Bagard + * + * This file is part of Chrysalide. + * + * Chrysalide is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Chrysalide is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Foobar. If not, see . + */ + + +@title UQSUB8 + +@desc Unsigned Saturating Subtract 8 performs four unsigned 8-bit integer subtractions, saturates the results to the 8-bit unsigned integer range 0 ≤ x ≤ 28 – 1, and writes the results to the destination register. + +@encoding (T1) { + + @word 1 1 1 1 1 0 1 0 1 1 0 0 Rn(4) 1 1 1 1 Rd(4) 0 1 0 1 Rm(4) + + @syntax + + @conv { + + reg_D = Register(Rd) + reg_N = Register(Rn) + reg_M = Register(Rm) + + } + +} + +@encoding (A1) { + + @word cond(4) 0 1 1 0 0 1 1 0 Rn(4) Rd(4) 1 1 1 1 1 1 1 1 Rm(4) + + @syntax + + @conv { + + reg_D = Register(Rd) + reg_N = Register(Rn) + reg_M = Register(Rm) + + } + + @rules { + + chk_call StoreCondition(cond) + + } + +} + diff --git a/plugins/arm/v7/opdefs/usad8_A88264.d b/plugins/arm/v7/opdefs/usad8_A88264.d new file mode 100644 index 0000000..09d7ece --- /dev/null +++ b/plugins/arm/v7/opdefs/usad8_A88264.d @@ -0,0 +1,65 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * ##FILE## - traduction d'instructions ARMv7 + * + * Copyright (C) 2015 Cyrille Bagard + * + * This file is part of Chrysalide. + * + * Chrysalide is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Chrysalide is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Foobar. If not, see . + */ + + +@title USAD8 + +@desc Unsigned Sum of Absolute Differences performs four unsigned 8-bit subtractions, and adds the absolute values of the differences together. + +@encoding (T1) { + + @word 1 1 1 1 1 0 1 1 0 1 1 1 Rn(4) 1 1 1 1 Rd(4) 0 0 0 0 Rm(4) + + @syntax + + @conv { + + reg_D = Register(Rd) + reg_N = Register(Rn) + reg_M = Register(Rm) + + } + +} + +@encoding (A1) { + + @word cond(4) 0 1 1 1 1 0 0 0 Rd(4) 1 1 1 1 Rm(4) 0 0 0 1 Rn(4) + + @syntax + + @conv { + + reg_D = Register(Rd) + reg_N = Register(Rn) + reg_M = Register(Rm) + + } + + @rules { + + chk_call StoreCondition(cond) + + } + +} + diff --git a/plugins/arm/v7/opdefs/usada8_A88265.d b/plugins/arm/v7/opdefs/usada8_A88265.d new file mode 100644 index 0000000..dd1efdb --- /dev/null +++ b/plugins/arm/v7/opdefs/usada8_A88265.d @@ -0,0 +1,67 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * ##FILE## - traduction d'instructions ARMv7 + * + * Copyright (C) 2015 Cyrille Bagard + * + * This file is part of Chrysalide. + * + * Chrysalide is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Chrysalide is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Foobar. If not, see . + */ + + +@title USADA8 + +@desc Unsigned Sum of Absolute Differences and Accumulate performs four unsigned 8-bit subtractions, and adds the absolute values of the differences to a 32-bit accumulate operand. + +@encoding (T1) { + + @word 1 1 1 1 1 0 1 1 0 1 1 1 Rn(4) Ra(4) Rd(4) 0 0 0 0 Rm(4) + + @syntax + + @conv { + + reg_D = Register(Rd) + reg_N = Register(Rn) + reg_M = Register(Rm) + reg_A = Register(Ra) + + } + +} + +@encoding (A1) { + + @word cond(4) 0 1 1 1 1 0 0 0 Rd(4) Ra(4) Rm(4) 0 0 0 1 Rn(4) + + @syntax + + @conv { + + reg_D = Register(Rd) + reg_N = Register(Rn) + reg_M = Register(Rm) + reg_A = Register(Ra) + + } + + @rules { + + chk_call StoreCondition(cond) + + } + +} + diff --git a/plugins/arm/v7/opdefs/usat16_A88267.d b/plugins/arm/v7/opdefs/usat16_A88267.d new file mode 100644 index 0000000..c091dc6 --- /dev/null +++ b/plugins/arm/v7/opdefs/usat16_A88267.d @@ -0,0 +1,65 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * ##FILE## - traduction d'instructions ARMv7 + * + * Copyright (C) 2015 Cyrille Bagard + * + * This file is part of Chrysalide. + * + * Chrysalide is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Chrysalide is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Foobar. If not, see . + */ + + +@title USAT16 + +@desc Unsigned Saturate 16 saturates two signed 16-bit values to a selected unsigned range. The Q flag is set if the operation saturates. + +@encoding (T1) { + + @word 1 1 1 1 0 0 1 1 1 0 1 0 Rn(4) 0 0 0 0 Rd(4) 0 0 0 0 sat_imm(4) + + @syntax + + @conv { + + reg_D = Register(Rd) + reg_N = Register(Rn) + saturate_to = UInt(sat_imm) + + } + +} + +@encoding (A1) { + + @word cond(4) 0 1 1 0 1 1 1 0 sat_imm(4) Rd(4) 1 1 1 1 0 0 1 1 Rn(4) + + @syntax + + @conv { + + reg_D = Register(Rd) + reg_N = Register(Rn) + saturate_to = UInt(sat_imm) + + } + + @rules { + + chk_call StoreCondition(cond) + + } + +} + diff --git a/plugins/arm/v7/opdefs/usat_A88266.d b/plugins/arm/v7/opdefs/usat_A88266.d new file mode 100644 index 0000000..55de21a --- /dev/null +++ b/plugins/arm/v7/opdefs/usat_A88266.d @@ -0,0 +1,67 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * ##FILE## - traduction d'instructions ARMv7 + * + * Copyright (C) 2015 Cyrille Bagard + * + * This file is part of Chrysalide. + * + * Chrysalide is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Chrysalide is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Foobar. If not, see . + */ + + +@title USAT + +@desc Unsigned Saturate saturates an optionally-shifted signed value to a selected unsigned range. The Q flag is set if the operation saturates. + +@encoding (T1) { + + @word 1 1 1 1 0 0 1 1 1 0 sh(1) 0 Rn(4) 0 imm3(3) Rd(4) imm2(2) 0 sat_imm(5) + + @syntax + + @conv { + + reg_D = Register(Rd) + reg_N = Register(Rn) + saturate_to = UInt(sat_imm) + shift = DecodeImmShift(sh:'0', imm3:imm2) + + } + +} + +@encoding (A1) { + + @word cond(4) 0 1 1 0 1 1 1 sat_imm(5) Rd(4) imm5(5) sh(1) 0 1 Rn(4) + + @syntax + + @conv { + + reg_D = Register(Rd) + reg_N = Register(Rn) + saturate_to = UInt(sat_imm) + shift = DecodeImmShift(sh:'0', imm5) + + } + + @rules { + + chk_call StoreCondition(cond) + + } + +} + diff --git a/plugins/arm/v7/opdefs/usax_A88268.d b/plugins/arm/v7/opdefs/usax_A88268.d new file mode 100644 index 0000000..040eedc --- /dev/null +++ b/plugins/arm/v7/opdefs/usax_A88268.d @@ -0,0 +1,65 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * ##FILE## - traduction d'instructions ARMv7 + * + * Copyright (C) 2015 Cyrille Bagard + * + * This file is part of Chrysalide. + * + * Chrysalide is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Chrysalide is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Foobar. If not, see . + */ + + +@title USAX + +@desc Unsigned Subtract and Add with Exchange exchanges the two halfwords of the second operand, performs one unsigned 16-bit integer subtraction and one unsigned 16-bit addition, and writes the results to the destination register. It sets the APSR.GE bits according to the results. + +@encoding (T1) { + + @word 1 1 1 1 1 0 1 0 1 1 1 0 Rn(4) 1 1 1 1 Rd(4) 0 1 0 0 Rm(4) + + @syntax + + @conv { + + reg_D = Register(Rd) + reg_N = Register(Rn) + reg_M = Register(Rm) + + } + +} + +@encoding (A1) { + + @word cond(4) 0 1 1 0 0 1 0 1 Rn(4) Rd(4) 1 1 1 1 0 1 0 1 Rm(4) + + @syntax + + @conv { + + reg_D = Register(Rd) + reg_N = Register(Rn) + reg_M = Register(Rm) + + } + + @rules { + + chk_call StoreCondition(cond) + + } + +} + diff --git a/plugins/arm/v7/opdefs/usub16_A88269.d b/plugins/arm/v7/opdefs/usub16_A88269.d new file mode 100644 index 0000000..31796d9 --- /dev/null +++ b/plugins/arm/v7/opdefs/usub16_A88269.d @@ -0,0 +1,65 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * ##FILE## - traduction d'instructions ARMv7 + * + * Copyright (C) 2015 Cyrille Bagard + * + * This file is part of Chrysalide. + * + * Chrysalide is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Chrysalide is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Foobar. If not, see . + */ + + +@title USUB16 + +@desc Unsigned Subtract 16 performs two 16-bit unsigned integer subtractions, and writes the results to the destination register. It sets the APSR.GE bits according to the results of the subtractions. + +@encoding (T1) { + + @word 1 1 1 1 1 0 1 0 1 1 0 1 Rn(4) 1 1 1 1 Rd(4) 0 1 0 0 Rm(4) + + @syntax + + @conv { + + reg_D = Register(Rd) + reg_N = Register(Rn) + reg_M = Register(Rm) + + } + +} + +@encoding (A1) { + + @word cond(4) 0 1 1 0 0 1 0 1 Rn(4) Rd(4) 1 1 1 1 0 1 1 1 Rm(4) + + @syntax + + @conv { + + reg_D = Register(Rd) + reg_N = Register(Rn) + reg_M = Register(Rm) + + } + + @rules { + + chk_call StoreCondition(cond) + + } + +} + diff --git a/plugins/arm/v7/opdefs/usub8_A88270.d b/plugins/arm/v7/opdefs/usub8_A88270.d new file mode 100644 index 0000000..576894c --- /dev/null +++ b/plugins/arm/v7/opdefs/usub8_A88270.d @@ -0,0 +1,65 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * ##FILE## - traduction d'instructions ARMv7 + * + * Copyright (C) 2015 Cyrille Bagard + * + * This file is part of Chrysalide. + * + * Chrysalide is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Chrysalide is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Foobar. If not, see . + */ + + +@title USUB8 + +@desc Unsigned Subtract 8 performs four 8-bit unsigned integer subtractions, and writes the results to the destination register. It sets the APSR.GE bits according to the results of the subtractions. + +@encoding (T1) { + + @word 1 1 1 1 1 0 1 0 1 1 0 0 Rn(4) 1 1 1 1 Rd(4) 0 1 0 0 Rm(4) + + @syntax + + @conv { + + reg_D = Register(Rd) + reg_N = Register(Rn) + reg_M = Register(Rm) + + } + +} + +@encoding (A1) { + + @word cond(4) 0 1 1 0 0 1 0 1 Rn(4) Rd(4) 1 1 1 1 1 1 1 1 Rm(4) + + @syntax + + @conv { + + reg_D = Register(Rd) + reg_N = Register(Rn) + reg_M = Register(Rm) + + } + + @rules { + + chk_call StoreCondition(cond) + + } + +} + diff --git a/plugins/arm/v7/opdefs/uxtab16_A88272.d b/plugins/arm/v7/opdefs/uxtab16_A88272.d new file mode 100644 index 0000000..4fc61d2 --- /dev/null +++ b/plugins/arm/v7/opdefs/uxtab16_A88272.d @@ -0,0 +1,67 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * ##FILE## - traduction d'instructions ARMv7 + * + * Copyright (C) 2015 Cyrille Bagard + * + * This file is part of Chrysalide. + * + * Chrysalide is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Chrysalide is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Foobar. If not, see . + */ + + +@title UXTAB16 + +@desc Unsigned Extend and Add Byte 16 extracts two 8-bit values from a register, zero-extends them to 16 bits each, adds the results to two 16-bit values from another register, and writes the final results to the destination register. The instruction can specify a rotation by 0, 8, 16, or 24 bits before extracting the 8-bit values. + +@encoding (T1) { + + @word 1 1 1 1 1 0 1 0 0 0 1 1 Rn(4) 1 1 1 1 Rd(4) 1 0 rotate(2) Rm(4) + + @syntax + + @conv { + + reg_D = Register(Rd) + reg_N = Register(Rn) + reg_M = Register(Rm) + rotation = Rotation(rotate:'000') + + } + +} + +@encoding (A1) { + + @word cond(4) 0 1 1 0 1 1 0 0 Rn(4) Rd(4) rotate(2) 0 0 0 1 1 1 Rm(4) + + @syntax + + @conv { + + reg_D = Register(Rd) + reg_N = Register(Rn) + reg_M = Register(Rm) + rotation = Rotation(rotate:'000') + + } + + @rules { + + chk_call StoreCondition(cond) + + } + +} + diff --git a/plugins/arm/v7/opdefs/uxtab_A88271.d b/plugins/arm/v7/opdefs/uxtab_A88271.d new file mode 100644 index 0000000..fe27d4b --- /dev/null +++ b/plugins/arm/v7/opdefs/uxtab_A88271.d @@ -0,0 +1,67 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * ##FILE## - traduction d'instructions ARMv7 + * + * Copyright (C) 2015 Cyrille Bagard + * + * This file is part of Chrysalide. + * + * Chrysalide is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Chrysalide is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Foobar. If not, see . + */ + + +@title UXTAB + +@desc Unsigned Extend and Add Byte extracts an 8-bit value from a register, zero-extends it to 32 bits, adds the result to the value in another register, and writes the final result to the destination register. The instruction can specify a rotation by 0, 8, 16, or 24 bits before extracting the 8-bit value. + +@encoding (T1) { + + @word 1 1 1 1 1 0 1 0 0 1 0 1 Rn(4) 1 1 1 1 Rd(4) 1 0 rotate(2) Rm(4) + + @syntax + + @conv { + + reg_D = Register(Rd) + reg_N = Register(Rn) + reg_M = Register(Rm) + rotation = Rotation(rotate:'000') + + } + +} + +@encoding (A1) { + + @word cond(4) 0 1 1 0 1 1 1 0 Rn(4) Rd(4) rotate(2) 0 0 0 1 1 1 Rm(4) + + @syntax + + @conv { + + reg_D = Register(Rd) + reg_N = Register(Rn) + reg_M = Register(Rm) + rotation = Rotation(rotate:'000') + + } + + @rules { + + chk_call StoreCondition(cond) + + } + +} + diff --git a/plugins/arm/v7/opdefs/uxtah_A88273.d b/plugins/arm/v7/opdefs/uxtah_A88273.d new file mode 100644 index 0000000..3c587d9 --- /dev/null +++ b/plugins/arm/v7/opdefs/uxtah_A88273.d @@ -0,0 +1,67 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * ##FILE## - traduction d'instructions ARMv7 + * + * Copyright (C) 2015 Cyrille Bagard + * + * This file is part of Chrysalide. + * + * Chrysalide is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Chrysalide is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Foobar. If not, see . + */ + + +@title UXTAH + +@desc Unsigned Extend and Add Halfword extracts a 16-bit value from a register, zero-extends it to 32 bits, adds the result to a value from another register, and writes the final result to the destination register. The instruction can specify a rotation by 0, 8, 16, or 24 bits before extracting the 16-bit value. + +@encoding (T1) { + + @word 1 1 1 1 1 0 1 0 0 0 0 1 Rn(4) 1 1 1 1 Rd(4) 1 0 rotate(2) Rm(4) + + @syntax + + @conv { + + reg_D = Register(Rd) + reg_N = Register(Rn) + reg_M = Register(Rm) + rotation = Rotation(rotate:'000') + + } + +} + +@encoding (A1) { + + @word cond(4) 0 1 1 0 1 1 1 1 Rn(4) Rd(4) rotate(2) 0 0 0 1 1 1 Rm(4) + + @syntax + + @conv { + + reg_D = Register(Rd) + reg_N = Register(Rn) + reg_M = Register(Rm) + rotation = Rotation(rotate:'000') + + } + + @rules { + + chk_call StoreCondition(cond) + + } + +} + diff --git a/plugins/arm/v7/opdefs/uxtb16_A88275.d b/plugins/arm/v7/opdefs/uxtb16_A88275.d new file mode 100644 index 0000000..a30d133 --- /dev/null +++ b/plugins/arm/v7/opdefs/uxtb16_A88275.d @@ -0,0 +1,65 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * ##FILE## - traduction d'instructions ARMv7 + * + * Copyright (C) 2015 Cyrille Bagard + * + * This file is part of Chrysalide. + * + * Chrysalide is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Chrysalide is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Foobar. If not, see . + */ + + +@title UXTB16 + +@desc Unsigned Extend Byte 16 extracts two 8-bit values from a register, zero-extends them to 16 bits each, and writes the results to the destination register. The instruction can specify a rotation by 0, 8, 16, or 24 bits before extracting the 8-bit values. + +@encoding (T1) { + + @word 1 1 1 1 1 0 1 0 0 0 1 1 1 1 1 1 1 1 1 1 Rd(4) 1 0 rotate(2) Rm(4) + + @syntax + + @conv { + + reg_D = Register(Rd) + reg_M = Register(Rm) + rotation = Rotation(rotate:'000') + + } + +} + +@encoding (A1) { + + @word cond(4) 0 1 1 0 1 1 0 0 1 1 1 1 Rd(4) rotate(2) 0 0 0 1 1 1 Rm(4) + + @syntax + + @conv { + + reg_D = Register(Rd) + reg_M = Register(Rm) + rotation = Rotation(rotate:'000') + + } + + @rules { + + chk_call StoreCondition(cond) + + } + +} + diff --git a/plugins/arm/v7/opdefs/uxtb_A88274.d b/plugins/arm/v7/opdefs/uxtb_A88274.d new file mode 100644 index 0000000..f49ba83 --- /dev/null +++ b/plugins/arm/v7/opdefs/uxtb_A88274.d @@ -0,0 +1,80 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * ##FILE## - traduction d'instructions ARMv7 + * + * Copyright (C) 2015 Cyrille Bagard + * + * This file is part of Chrysalide. + * + * Chrysalide is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Chrysalide is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Foobar. If not, see . + */ + + +@title UXTB + +@desc Unsigned Extend Byte extracts an 8-bit value from a register, zero-extends it to 32 bits, and writes the result to the destination register. The instruction can specify a rotation by 0, 8, 16, or 24 bits before extracting the 8-bit value. + +@encoding (t1) { + + @half 1 0 1 1 0 0 1 0 1 1 Rm(3) Rd(3) + + @syntax + + @conv { + + reg_D = Register(Rd) + reg_M = Register(Rm) + + } + +} + +@encoding (T2) { + + @word 1 1 1 1 1 0 1 0 0 1 0 1 1 1 1 1 1 1 1 1 Rd(4) 1 0 rotate(2) Rm(4) + + @syntax ".W" + + @conv { + + reg_D = Register(Rd) + reg_M = Register(Rm) + rotation = Rotation(rotate:'000') + + } + +} + +@encoding (A1) { + + @word cond(4) 0 1 1 0 1 1 1 0 1 1 1 1 Rd(4) rotate(2) 0 0 0 1 1 1 Rm(4) + + @syntax + + @conv { + + reg_D = Register(Rd) + reg_M = Register(Rm) + rotation = Rotation(rotate:'000') + + } + + @rules { + + chk_call StoreCondition(cond) + + } + +} + diff --git a/plugins/arm/v7/opdefs/uxth_A88276.d b/plugins/arm/v7/opdefs/uxth_A88276.d new file mode 100644 index 0000000..5ae4f4f --- /dev/null +++ b/plugins/arm/v7/opdefs/uxth_A88276.d @@ -0,0 +1,80 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * ##FILE## - traduction d'instructions ARMv7 + * + * Copyright (C) 2015 Cyrille Bagard + * + * This file is part of Chrysalide. + * + * Chrysalide is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Chrysalide is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Foobar. If not, see . + */ + + +@title UXTH + +@desc Unsigned Extend Halfword extracts a 16-bit value from a register, zero-extends it to 32 bits, and writes the result to the destination register. The instruction can specify a rotation by 0, 8, 16, or 24 bits before extracting the 16-bit value. + +@encoding (t1) { + + @half 1 0 1 1 0 0 1 0 1 0 Rm(3) Rd(3) + + @syntax + + @conv { + + reg_D = Register(Rd) + reg_M = Register(Rm) + + } + +} + +@encoding (T2) { + + @word 1 1 1 1 1 0 1 0 0 0 0 1 1 1 1 1 1 1 1 1 Rd(4) 1 0 rotate(2) Rm(4) + + @syntax ".W" + + @conv { + + reg_D = Register(Rd) + reg_M = Register(Rm) + rotation = Rotation(rotate:'000') + + } + +} + +@encoding (A1) { + + @word cond(4) 0 1 1 0 1 1 1 1 1 1 1 1 Rd(4) rotate(2) 0 0 0 1 1 1 Rm(4) + + @syntax + + @conv { + + reg_D = Register(Rd) + reg_M = Register(Rm) + rotation = Rotation(rotate:'000') + + } + + @rules { + + chk_call StoreCondition(cond) + + } + +} + diff --git a/plugins/arm/v7/opdefs/wfi_A88425.d b/plugins/arm/v7/opdefs/wfi_A88425.d new file mode 100644 index 0000000..f11d033 --- /dev/null +++ b/plugins/arm/v7/opdefs/wfi_A88425.d @@ -0,0 +1,53 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * ##FILE## - traduction d'instructions ARMv7 + * + * Copyright (C) 2015 Cyrille Bagard + * + * This file is part of Chrysalide. + * + * Chrysalide is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Chrysalide is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Foobar. If not, see . + */ + + +@title WFI + +@desc Wait For Interrupt is a hint instruction that permits the processor to enter a low-power state until one of a number of asynchronous events occurs. For more information, see Wait For Interrupt on page B1-1202. In an implementation that includes the Virtualization Extensions, if HCR.TWI is set to 1, execution of a WFI instruction in a Non-secure mode other than Hyp mode generates a Hyp Trap exception if, ignoring the value of the HCR.TWI bit, conditions permit the processor to suspend execution. For more information see Trapping use of the WFI and WFE instructions on page B1-1255. + +@encoding (t1) { + + @half 1 0 1 1 1 1 1 1 0 0 1 1 0 0 0 0 + +} + +@encoding (T2) { + + @word 1 1 1 1 0 0 1 1 1 0 1 0 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 + + @syntax ".W" + +} + +@encoding (A1) { + + @word cond(4) 0 0 1 1 0 0 1 0 0 0 0 0 1 1 1 1 0 0 0 0 0 0 0 0 0 0 1 1 + + @rules { + + chk_call StoreCondition(cond) + + } + +} + diff --git a/plugins/arm/v7/opdefs/yield_A88426.d b/plugins/arm/v7/opdefs/yield_A88426.d new file mode 100644 index 0000000..252c018 --- /dev/null +++ b/plugins/arm/v7/opdefs/yield_A88426.d @@ -0,0 +1,53 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * ##FILE## - traduction d'instructions ARMv7 + * + * Copyright (C) 2015 Cyrille Bagard + * + * This file is part of Chrysalide. + * + * Chrysalide is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Chrysalide is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Foobar. If not, see . + */ + + +@title YIELD + +@desc YIELD is a hint instruction. Software with a multithreading capability can use a YIELD instruction to indicate to the hardware that it is performing a task, for example a spin-lock, that could be swapped out to improve overall system performance. Hardware can use this hint to suspend and resume multiple software threads if it supports the capability. For more information about the recommended use of this instruction see The Yield instruction on page A4-178. + +@encoding (t1) { + + @half 1 0 1 1 1 1 1 1 0 0 0 1 0 0 0 0 + +} + +@encoding (T2) { + + @word 1 1 1 1 0 0 1 1 1 0 1 0 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 + + @syntax ".W" + +} + +@encoding (A1) { + + @word cond(4) 0 0 1 1 0 0 1 0 0 0 0 0 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 1 + + @rules { + + chk_call StoreCondition(cond) + + } + +} + diff --git a/plugins/arm/v7/operands/Makefile.am b/plugins/arm/v7/operands/Makefile.am new file mode 100644 index 0000000..5b2d245 --- /dev/null +++ b/plugins/arm/v7/operands/Makefile.am @@ -0,0 +1,21 @@ + +noinst_LTLIBRARIES = libarmv7operands.la + +libarmv7operands_la_SOURCES = \ + coproc.h coproc.c \ + estate.h estate.c \ + limitation.h limitation.c \ + maccess.h maccess.c \ + offset.h offset.c \ + reglist.h reglist.c \ + rotation.h rotation.c \ + shift.h shift.c + +libarmv7operands_la_LIBADD = + +libarmv7operands_la_CFLAGS = $(AM_CFLAGS) + + +AM_CPPFLAGS = $(LIBGTK_CFLAGS) $(LIBXML_CFLAGS) -I$(top_srcdir)/src + +AM_CFLAGS = $(DEBUG_CFLAGS) $(WARNING_FLAGS) $(COMPLIANCE_FLAGS) diff --git a/plugins/arm/v7/operands/coproc.c b/plugins/arm/v7/operands/coproc.c new file mode 100644 index 0000000..abe27c4 --- /dev/null +++ b/plugins/arm/v7/operands/coproc.c @@ -0,0 +1,250 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * coproc.c - décallages de valeurs + * + * Copyright (C) 2016-2017 Cyrille Bagard + * + * This file is part of Chrysalide. + * + * Chrysalide is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Chrysalide is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Foobar. If not, see . + */ + + +#include "coproc.h" + + +#include +#include + + + +/* Définition d'un opérande représentant un co-processeur (instance) */ +struct _GArmV7CoprocOperand +{ + GArchOperand parent; /* Instance parente */ + + uint8_t index; /* Indice du co-processeur */ + +}; + + +/* Définition d'un opérande représentant un co-processeur (classe) */ +struct _GArmV7CoprocOperandClass +{ + GArchOperandClass parent; /* Classe parente */ + +}; + + +/* Initialise la classe des coprocs de domaine et d'accès. */ +static void g_armv7_coproc_operand_class_init(GArmV7CoprocOperandClass *); + +/* Initialise une instance de coproc de domaine et d'accès. */ +static void g_armv7_coproc_operand_init(GArmV7CoprocOperand *); + +/* Supprime toutes les références externes. */ +static void g_armv7_coproc_operand_dispose(GArmV7CoprocOperand *); + +/* Procède à la libération totale de la mémoire. */ +static void g_armv7_coproc_operand_finalize(GArmV7CoprocOperand *); + +/* Compare un opérande avec un autre. */ +static int g_armv7_coproc_operand_compare(const GArmV7CoprocOperand *, const GArmV7CoprocOperand *); + +/* Traduit un opérande en version humainement lisible. */ +static void g_armv7_coproc_operand_print(const GArmV7CoprocOperand *, GBufferLine *, AsmSyntax); + + + +/* Indique le type défini par la GLib pour un co-processeur ARM. */ +G_DEFINE_TYPE(GArmV7CoprocOperand, g_armv7_coproc_operand, G_TYPE_ARCH_OPERAND); + + +/****************************************************************************** +* * +* Paramètres : klass = classe à initialiser. * +* * +* Description : Initialise la classe des co-processeurs ARM. * +* * +* Retour : - * +* * +* Remarques : - * +* * +******************************************************************************/ + +static void g_armv7_coproc_operand_class_init(GArmV7CoprocOperandClass *klass) +{ + GObjectClass *object; /* Autre version de la classe */ + GArchOperandClass *operand; /* Version de classe parente */ + + object = G_OBJECT_CLASS(klass); + operand = G_ARCH_OPERAND_CLASS(klass); + + object->dispose = (GObjectFinalizeFunc/* ! */)g_armv7_coproc_operand_dispose; + object->finalize = (GObjectFinalizeFunc)g_armv7_coproc_operand_finalize; + + operand->compare = (operand_compare_fc)g_armv7_coproc_operand_compare; + operand->print = (operand_print_fc)g_armv7_coproc_operand_print; + +} + + +/****************************************************************************** +* * +* Paramètres : operand = instance à initialiser. * +* * +* Description : Initialise une instance de co-processeur ARM. * +* * +* Retour : - * +* * +* Remarques : - * +* * +******************************************************************************/ + +static void g_armv7_coproc_operand_init(GArmV7CoprocOperand *operand) +{ + +} + + +/****************************************************************************** +* * +* Paramètres : operand = instance d'objet GLib à traiter. * +* * +* Description : Supprime toutes les références externes. * +* * +* Retour : - * +* * +* Remarques : - * +* * +******************************************************************************/ + +static void g_armv7_coproc_operand_dispose(GArmV7CoprocOperand *operand) +{ + G_OBJECT_CLASS(g_armv7_coproc_operand_parent_class)->dispose(G_OBJECT(operand)); + +} + + +/****************************************************************************** +* * +* Paramètres : operand = instance d'objet GLib à traiter. * +* * +* Description : Procède à la libération totale de la mémoire. * +* * +* Retour : - * +* * +* Remarques : - * +* * +******************************************************************************/ + +static void g_armv7_coproc_operand_finalize(GArmV7CoprocOperand *operand) +{ + G_OBJECT_CLASS(g_armv7_coproc_operand_parent_class)->finalize(G_OBJECT(operand)); + +} + + +/****************************************************************************** +* * +* Paramètres : a = premier opérande à consulter. * +* b = second opérande à consulter. * +* * +* Description : Compare un opérande avec un autre. * +* * +* Retour : Bilan de la comparaison. * +* * +* Remarques : - * +* * +******************************************************************************/ + +static int g_armv7_coproc_operand_compare(const GArmV7CoprocOperand *a, const GArmV7CoprocOperand *b) +{ + int result; /* Bilan à faire remonter */ + + result = sort_unsigned_long(a->index, b->index); + + return result; + +} + + +/****************************************************************************** +* * +* Paramètres : operand = opérande à traiter. * +* line = ligne tampon où imprimer l'opérande donné. * +* syntax = type de représentation demandée. * +* * +* Description : Traduit un opérande en version humainement lisible. * +* * +* Retour : - * +* * +* Remarques : - * +* * +******************************************************************************/ + +static void g_armv7_coproc_operand_print(const GArmV7CoprocOperand *operand, GBufferLine *line, AsmSyntax syntax) +{ + char name[5]; /* Mot clef principal */ + size_t nlen; /* Taille de ce mot clef */ + + nlen = snprintf(name, sizeof(name), "p%hhu", operand->index); + + g_buffer_line_append_text(line, BLC_ASSEMBLY, name, nlen, RTT_REGISTER, NULL); + +} + + +/****************************************************************************** +* * +* Paramètres : raw = valeur brute du co-processeur à considérer. * +* * +* Description : Crée une représentation d'un co-processeur ARM. * +* * +* Retour : Opérande mis en place. * +* * +* Remarques : - * +* * +******************************************************************************/ + +GArchOperand *g_armv7_coproc_operand_new(uint8_t raw) +{ + GArmV7CoprocOperand *result; /* Structure à retourner */ + + result = g_object_new(G_TYPE_ARMV7_COPROC_OPERAND, NULL); + + result->index = raw; + + return G_ARCH_OPERAND(result); + +} + + +/****************************************************************************** +* * +* Paramètres : operand = opérande à consulter. * +* * +* Description : Fournit l'indice d'un co-processeur ARM. * +* * +* Retour : Inditifiant représentant le co-processeur. * +* * +* Remarques : - * +* * +******************************************************************************/ + +uint8_t g_armv7_coproc_operand_get_index(const GArmV7CoprocOperand *operand) +{ + return operand->index; + +} diff --git a/plugins/arm/v7/operands/coproc.h b/plugins/arm/v7/operands/coproc.h new file mode 100644 index 0000000..bb85024 --- /dev/null +++ b/plugins/arm/v7/operands/coproc.h @@ -0,0 +1,61 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * coproc.h - prototypes pour les décallages de valeurs + * + * Copyright (C) 2016-2017 Cyrille Bagard + * + * This file is part of Chrysalide. + * + * Chrysalide is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Chrysalide is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Foobar. If not, see . + */ + + +#ifndef _PLUGINS_ARM_V7_OPERANDS_COPROC_H +#define _PLUGINS_ARM_V7_OPERANDS_COPROC_H + + +#include + + +#include + + + +#define G_TYPE_ARMV7_COPROC_OPERAND g_armv7_coproc_operand_get_type() +#define G_ARMV7_COPROC_OPERAND(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), g_armv7_coproc_operand_get_type(), GArmV7CoprocOperand)) +#define G_IS_ARMV7_COPROC_OPERAND(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), g_armv7_coproc_operand_get_type())) +#define G_ARMV7_COPROC_OPERAND_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), G_TYPE_ARMV7_COPROC_OPERAND, GArmV7CoprocOperandClass)) +#define G_IS_ARMV7_COPROC_OPERAND_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), G_TYPE_ARMV7_COPROC_OPERAND)) +#define G_ARMV7_COPROC_OPERAND_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), G_TYPE_ARMV7_COPROC_OPERAND, GArmV7CoprocOperandClass)) + + +/* Définition d'un opérande représentant un co-processeur (instance) */ +typedef struct _GArmV7CoprocOperand GArmV7CoprocOperand; + +/* Définition d'un opérande représentant un co-processeur (classe) */ +typedef struct _GArmV7CoprocOperandClass GArmV7CoprocOperandClass; + + +/* Indique le type défini par la GLib pour un co-processeur ARM. */ +GType g_armv7_coproc_operand_get_type(void); + +/* Crée une représentation d'un co-processeur ARM. */ +GArchOperand *g_armv7_coproc_operand_new(uint8_t); + +/* Fournit l'indice d'un co-processeur ARM. */ +uint8_t g_armv7_coproc_operand_get_index(const GArmV7CoprocOperand *); + + + +#endif /* _PLUGINS_ARM_V7_OPERANDS_COPROC_H */ diff --git a/plugins/arm/v7/operands/estate.c b/plugins/arm/v7/operands/estate.c new file mode 100644 index 0000000..cdadb76 --- /dev/null +++ b/plugins/arm/v7/operands/estate.c @@ -0,0 +1,248 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * endian.c - décallages de valeurs + * + * Copyright (C) 2016-2017 Cyrille Bagard + * + * This file is part of Chrysalide. + * + * Chrysalide is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Chrysalide is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Foobar. If not, see . + */ + + +#include "estate.h" + + +#include +#include + + + +/* Définition d'un opérande affichant le choix d'un boutisme (instance) */ +struct _GArmV7EndianOperand +{ + GArchOperand parent; /* Instance parente */ + + bool big; /* Grand boutisme à afficher ? */ + +}; + + +/* Définition d'un opérande affichant le choix d'un boutisme (classe) */ +struct _GArmV7EndianOperandClass +{ + GArchOperandClass parent; /* Classe parente */ + +}; + + +/* Initialise la classe des affichages de boutisme. */ +static void g_armv7_endian_operand_class_init(GArmV7EndianOperandClass *); + +/* Initialise une instance d'affichage de boutisme. */ +static void g_armv7_endian_operand_init(GArmV7EndianOperand *); + +/* Supprime toutes les références externes. */ +static void g_armv7_endian_operand_dispose(GArmV7EndianOperand *); + +/* Procède à la libération totale de la mémoire. */ +static void g_armv7_endian_operand_finalize(GArmV7EndianOperand *); + +/* Compare un opérande avec un autre. */ +static int g_armv7_endian_operand_compare(const GArmV7EndianOperand *, const GArmV7EndianOperand *); + +/* Traduit un opérande en version humainement lisible. */ +static void g_armv7_endian_operand_print(const GArmV7EndianOperand *, GBufferLine *, AsmSyntax); + + + +/* Indique le type défini par la GLib pour une endian de domaine et d'accès. */ +G_DEFINE_TYPE(GArmV7EndianOperand, g_armv7_endian_operand, G_TYPE_ARCH_OPERAND); + + +/****************************************************************************** +* * +* Paramètres : klass = classe à initialiser. * +* * +* Description : Initialise la classe des affichages de boutisme. * +* * +* Retour : - * +* * +* Remarques : - * +* * +******************************************************************************/ + +static void g_armv7_endian_operand_class_init(GArmV7EndianOperandClass *klass) +{ + GObjectClass *object; /* Autre version de la classe */ + GArchOperandClass *operand; /* Version de classe parente */ + + object = G_OBJECT_CLASS(klass); + operand = G_ARCH_OPERAND_CLASS(klass); + + object->dispose = (GObjectFinalizeFunc/* ! */)g_armv7_endian_operand_dispose; + object->finalize = (GObjectFinalizeFunc)g_armv7_endian_operand_finalize; + + operand->compare = (operand_compare_fc)g_armv7_endian_operand_compare; + operand->print = (operand_print_fc)g_armv7_endian_operand_print; + +} + + +/****************************************************************************** +* * +* Paramètres : operand = instance à initialiser. * +* * +* Description : Initialise une instance d'affichage de boutisme. * +* * +* Retour : - * +* * +* Remarques : - * +* * +******************************************************************************/ + +static void g_armv7_endian_operand_init(GArmV7EndianOperand *operand) +{ + +} + + +/****************************************************************************** +* * +* Paramètres : operand = instance d'objet GLib à traiter. * +* * +* Description : Supprime toutes les références externes. * +* * +* Retour : - * +* * +* Remarques : - * +* * +******************************************************************************/ + +static void g_armv7_endian_operand_dispose(GArmV7EndianOperand *operand) +{ + G_OBJECT_CLASS(g_armv7_endian_operand_parent_class)->dispose(G_OBJECT(operand)); + +} + + +/****************************************************************************** +* * +* Paramètres : operand = instance d'objet GLib à traiter. * +* * +* Description : Procède à la libération totale de la mémoire. * +* * +* Retour : - * +* * +* Remarques : - * +* * +******************************************************************************/ + +static void g_armv7_endian_operand_finalize(GArmV7EndianOperand *operand) +{ + G_OBJECT_CLASS(g_armv7_endian_operand_parent_class)->finalize(G_OBJECT(operand)); + +} + + +/****************************************************************************** +* * +* Paramètres : a = premier opérande à consulter. * +* b = second opérande à consulter. * +* * +* Description : Compare un opérande avec un autre. * +* * +* Retour : Bilan de la comparaison. * +* * +* Remarques : - * +* * +******************************************************************************/ + +static int g_armv7_endian_operand_compare(const GArmV7EndianOperand *a, const GArmV7EndianOperand *b) +{ + int result; /* Bilan à faire remonter */ + + result = sort_boolean(a->big, b->big); + + return result; + +} + + +/****************************************************************************** +* * +* Paramètres : operand = opérande à traiter. * +* line = ligne tampon où imprimer l'opérande donné. * +* syntax = type de représentation demandée. * +* * +* Description : Traduit un opérande en version humainement lisible. * +* * +* Retour : - * +* * +* Remarques : - * +* * +******************************************************************************/ + +static void g_armv7_endian_operand_print(const GArmV7EndianOperand *operand, GBufferLine *line, AsmSyntax syntax) +{ + if (operand->big) + g_buffer_line_append_text(line, BLC_ASSEMBLY, "BE", 2, RTT_KEY_WORD, NULL); + else + g_buffer_line_append_text(line, BLC_ASSEMBLY, "LE", 2, RTT_KEY_WORD, NULL); + +} + + +/****************************************************************************** +* * +* Paramètres : big = indication sur le boutisme à représenter. * +* * +* Description : Crée une représentation de boutisme ARMv7. * +* * +* Retour : Opérande mis en place. * +* * +* Remarques : - * +* * +******************************************************************************/ + +GArchOperand *g_armv7_endian_operand_new(bool big) +{ + GArmV7EndianOperand *result; /* Structure à retourner */ + + result = g_object_new(G_TYPE_ARMV7_ENDIAN_OPERAND, NULL); + + result->big = big; + + return G_ARCH_OPERAND(result); + +} + + +/****************************************************************************** +* * +* Paramètres : operand = opérande à consulter. * +* * +* Description : Indique le type de boutisme représenté. * +* * +* Retour : Type de boutisme. * +* * +* Remarques : - * +* * +******************************************************************************/ + +bool g_armv7_endian_operand_is_big_endian(const GArmV7EndianOperand *operand) +{ + return operand->big; + +} diff --git a/plugins/arm/v7/operands/estate.h b/plugins/arm/v7/operands/estate.h new file mode 100644 index 0000000..6407ed1 --- /dev/null +++ b/plugins/arm/v7/operands/estate.h @@ -0,0 +1,61 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * estate.h - prototypes pour le basculement de boutisme + * + * Copyright (C) 2016-2017 Cyrille Bagard + * + * This file is part of Chrysalide. + * + * Chrysalide is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Chrysalide is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Foobar. If not, see . + */ + + +#ifndef _PLUGINS_ARM_V7_OPERANDS_ESTATE_H +#define _PLUGINS_ARM_V7_OPERANDS_ESTATE_H + + +#include + + +#include + + + +#define G_TYPE_ARMV7_ENDIAN_OPERAND g_armv7_endian_operand_get_type() +#define G_ARMV7_ENDIAN_OPERAND(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), g_armv7_endian_operand_get_type(), GArmV7EndianOperand)) +#define G_IS_ARMV7_ENDIAN_OPERAND(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), g_armv7_endian_operand_get_type())) +#define G_ARMV7_ENDIAN_OPERAND_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), G_TYPE_ARMV7_ENDIAN_OPERAND, GArmV7EndianOperandClass)) +#define G_IS_ARMV7_ENDIAN_OPERAND_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), G_TYPE_ARMV7_ENDIAN_OPERAND)) +#define G_ARMV7_ENDIAN_OPERAND_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), G_TYPE_ARMV7_ENDIAN_OPERAND, GArmV7EndianOperandClass)) + + +/* Définition d'un opérande affichant le choix d'un boutisme (instance) */ +typedef struct _GArmV7EndianOperand GArmV7EndianOperand; + +/* Définition d'un opérande affichant le choix d'un boutisme (classe) */ +typedef struct _GArmV7EndianOperandClass GArmV7EndianOperandClass; + + +/* Indique le type défini par la GLib pour une endian de domaine et d'accès. */ +GType g_armv7_endian_operand_get_type(void); + +/* Crée une représentation de boutisme ARMv7. */ +GArchOperand *g_armv7_endian_operand_new(bool); + +/* Indique le type de boutisme représenté. */ +bool g_armv7_endian_operand_is_big_endian(const GArmV7EndianOperand *); + + + +#endif /* _PLUGINS_ARM_V7_OPERANDS_ESTATE_H */ diff --git a/plugins/arm/v7/operands/limitation.c b/plugins/arm/v7/operands/limitation.c new file mode 100644 index 0000000..1515101 --- /dev/null +++ b/plugins/arm/v7/operands/limitation.c @@ -0,0 +1,287 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * limitation.c - décallages de valeurs + * + * Copyright (C) 2016-2017 Cyrille Bagard + * + * This file is part of Chrysalide. + * + * Chrysalide is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Chrysalide is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Foobar. If not, see . + */ + + +#include "limitation.h" + + +#include +#include + + + +/* Définition d'un opérande déterminant une limitation de domaine et d'accès (instance) */ +struct _GArmV7LimitationOperand +{ + GArchOperand parent; /* Instance parente */ + + BarrierLimitationType type; /* Type de limitation */ + +}; + + +/* Définition d'un opérande déterminant une limitation de domaine et d'accès (classe) */ +struct _GArmV7LimitationOperandClass +{ + GArchOperandClass parent; /* Classe parente */ + +}; + + +/* Initialise la classe des co-processeurs ARM. */ +static void g_armv7_limitation_operand_class_init(GArmV7LimitationOperandClass *); + +/* Initialise une instance de co-processeur ARM. */ +static void g_armv7_limitation_operand_init(GArmV7LimitationOperand *); + +/* Supprime toutes les références externes. */ +static void g_armv7_limitation_operand_dispose(GArmV7LimitationOperand *); + +/* Procède à la libération totale de la mémoire. */ +static void g_armv7_limitation_operand_finalize(GArmV7LimitationOperand *); + +/* Compare un opérande avec un autre. */ +static int g_armv7_limitation_operand_compare(const GArmV7LimitationOperand *, const GArmV7LimitationOperand *); + +/* Traduit un opérande en version humainement lisible. */ +static void g_armv7_limitation_operand_print(const GArmV7LimitationOperand *, GBufferLine *, AsmSyntax); + + + +/* Indique le type défini par la GLib pour une limitation de domaine et d'accès. */ +G_DEFINE_TYPE(GArmV7LimitationOperand, g_armv7_limitation_operand, G_TYPE_ARCH_OPERAND); + + +/****************************************************************************** +* * +* Paramètres : klass = classe à initialiser. * +* * +* Description : Initialise la classe des limitations de domaine et d'accès. * +* * +* Retour : - * +* * +* Remarques : - * +* * +******************************************************************************/ + +static void g_armv7_limitation_operand_class_init(GArmV7LimitationOperandClass *klass) +{ + GObjectClass *object; /* Autre version de la classe */ + GArchOperandClass *operand; /* Version de classe parente */ + + object = G_OBJECT_CLASS(klass); + operand = G_ARCH_OPERAND_CLASS(klass); + + object->dispose = (GObjectFinalizeFunc/* ! */)g_armv7_limitation_operand_dispose; + object->finalize = (GObjectFinalizeFunc)g_armv7_limitation_operand_finalize; + + operand->compare = (operand_compare_fc)g_armv7_limitation_operand_compare; + operand->print = (operand_print_fc)g_armv7_limitation_operand_print; + +} + + +/****************************************************************************** +* * +* Paramètres : operand = instance à initialiser. * +* * +* Description : Initialise une instance de limitation de domaine et d'accès. * +* * +* Retour : - * +* * +* Remarques : - * +* * +******************************************************************************/ + +static void g_armv7_limitation_operand_init(GArmV7LimitationOperand *operand) +{ + +} + + +/****************************************************************************** +* * +* Paramètres : operand = instance d'objet GLib à traiter. * +* * +* Description : Supprime toutes les références externes. * +* * +* Retour : - * +* * +* Remarques : - * +* * +******************************************************************************/ + +static void g_armv7_limitation_operand_dispose(GArmV7LimitationOperand *operand) +{ + G_OBJECT_CLASS(g_armv7_limitation_operand_parent_class)->dispose(G_OBJECT(operand)); + +} + + +/****************************************************************************** +* * +* Paramètres : operand = instance d'objet GLib à traiter. * +* * +* Description : Procède à la libération totale de la mémoire. * +* * +* Retour : - * +* * +* Remarques : - * +* * +******************************************************************************/ + +static void g_armv7_limitation_operand_finalize(GArmV7LimitationOperand *operand) +{ + G_OBJECT_CLASS(g_armv7_limitation_operand_parent_class)->finalize(G_OBJECT(operand)); + +} + + +/****************************************************************************** +* * +* Paramètres : a = premier opérande à consulter. * +* b = second opérande à consulter. * +* * +* Description : Compare un opérande avec un autre. * +* * +* Retour : Bilan de la comparaison. * +* * +* Remarques : - * +* * +******************************************************************************/ + +static int g_armv7_limitation_operand_compare(const GArmV7LimitationOperand *a, const GArmV7LimitationOperand *b) +{ + int result; /* Bilan à faire remonter */ + + result = sort_unsigned_long(a->type, b->type); + + return result; + +} + + +/****************************************************************************** +* * +* Paramètres : operand = opérande à traiter. * +* line = ligne tampon où imprimer l'opérande donné. * +* syntax = type de représentation demandée. * +* * +* Description : Traduit un opérande en version humainement lisible. * +* * +* Retour : - * +* * +* Remarques : - * +* * +******************************************************************************/ + +static void g_armv7_limitation_operand_print(const GArmV7LimitationOperand *operand, GBufferLine *line, AsmSyntax syntax) +{ + switch (operand->type) + { + case BLT_SY: + g_buffer_line_append_text(line, BLC_ASSEMBLY, "SY", 2, RTT_KEY_WORD, NULL); + break; + + case BLT_ST: + g_buffer_line_append_text(line, BLC_ASSEMBLY, "ST", 2, RTT_KEY_WORD, NULL); + break; + + case BLT_ISH: + g_buffer_line_append_text(line, BLC_ASSEMBLY, "ISH", 3, RTT_KEY_WORD, NULL); + break; + + case BLT_ISHST: + g_buffer_line_append_text(line, BLC_ASSEMBLY, "ISHST", 5, RTT_KEY_WORD, NULL); + break; + + case BLT_NSH: + g_buffer_line_append_text(line, BLC_ASSEMBLY, "NSH", 3, RTT_KEY_WORD, NULL); + break; + + case BLT_NSHST: + g_buffer_line_append_text(line, BLC_ASSEMBLY, "NSHST", 5, RTT_KEY_WORD, NULL); + break; + + case BLT_OSH: + g_buffer_line_append_text(line, BLC_ASSEMBLY, "OSH", 3, RTT_KEY_WORD, NULL); + break; + + case BLT_OSHST: + g_buffer_line_append_text(line, BLC_ASSEMBLY, "OSHST", 5, RTT_KEY_WORD, NULL); + break; + + default: + g_buffer_line_append_text(line, BLC_ASSEMBLY, "(reserved)", 10, RTT_KEY_WORD, NULL); + break; + + } + +} + + +/****************************************************************************** +* * +* Paramètres : raw = valeur brute de la limitation à considérer. * +* * +* Description : Crée une représentation d'une limitation pour barrière. * +* * +* Retour : Opérande mis en place. * +* * +* Remarques : - * +* * +******************************************************************************/ + +GArchOperand *g_armv7_limitation_operand_new(uint8_t raw) +{ + GArmV7LimitationOperand *result; /* Structure à retourner */ + + result = g_object_new(G_TYPE_ARMV7_LIMITATION_OPERAND, NULL); + + if (raw < 0b0010 || raw > 0b1111) + result->type = BLT_RESERVED; + + else + result->type = raw; + + return G_ARCH_OPERAND(result); + +} + + +/****************************************************************************** +* * +* Paramètres : operand = opérande à consulter. * +* * +* Description : Indique le type de limitation représentée. * +* * +* Retour : Type de limitation d'accès et de domaine. * +* * +* Remarques : - * +* * +******************************************************************************/ + +BarrierLimitationType g_armv7_limitation_operand_get_value(const GArmV7LimitationOperand *operand) +{ + return operand->type; + +} diff --git a/plugins/arm/v7/operands/limitation.h b/plugins/arm/v7/operands/limitation.h new file mode 100644 index 0000000..2a2b52d --- /dev/null +++ b/plugins/arm/v7/operands/limitation.h @@ -0,0 +1,77 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * limitation.h - prototypes pour les décallages de valeurs + * + * Copyright (C) 2016-2017 Cyrille Bagard + * + * This file is part of Chrysalide. + * + * Chrysalide is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Chrysalide is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Foobar. If not, see . + */ + + +#ifndef _PLUGINS_ARM_V7_OPERANDS_LIMITATION_H +#define _PLUGINS_ARM_V7_OPERANDS_LIMITATION_H + + +#include + + +#include + + + +#define G_TYPE_ARMV7_LIMITATION_OPERAND g_armv7_limitation_operand_get_type() +#define G_ARMV7_LIMITATION_OPERAND(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), g_armv7_limitation_operand_get_type(), GArmV7LimitationOperand)) +#define G_IS_ARMV7_LIMITATION_OPERAND(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), g_armv7_limitation_operand_get_type())) +#define G_ARMV7_LIMITATION_OPERAND_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), G_TYPE_ARMV7_LIMITATION_OPERAND, GArmV7LimitationOperandClass)) +#define G_IS_ARMV7_LIMITATION_OPERAND_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), G_TYPE_ARMV7_LIMITATION_OPERAND)) +#define G_ARMV7_LIMITATION_OPERAND_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), G_TYPE_ARMV7_LIMITATION_OPERAND, GArmV7LimitationOperandClass)) + + +/* Définition d'un opérande déterminant une limitation de domaine et d'accès (instance) */ +typedef struct _GArmV7LimitationOperand GArmV7LimitationOperand; + +/* Définition d'un opérande déterminant une limitation de domaine et d'accès (classe) */ +typedef struct _GArmV7LimitationOperandClass GArmV7LimitationOperandClass; + + +/* Types de limitation domaine & accès */ +typedef enum _BarrierLimitationType +{ + BLT_RESERVED = 0, + BLT_SY = 0b1111, + BLT_ST = 0b1110, + BLT_ISH = 0b1011, + BLT_ISHST = 0b1010, + BLT_NSH = 0b0111, + BLT_NSHST = 0b0110, + BLT_OSH = 0b0011, + BLT_OSHST = 0b0010 + +} BarrierLimitationType; + + +/* Indique le type défini par la GLib pour une limitation de domaine et d'accès. */ +GType g_armv7_limitation_operand_get_type(void); + +/* Crée une représentation d'une limitation pour barrière. */ +GArchOperand *g_armv7_limitation_operand_new(uint8_t); + +/* Indique le type de limitation représentée. */ +BarrierLimitationType g_armv7_limitation_operand_get_value(const GArmV7LimitationOperand *); + + + +#endif /* _PLUGINS_ARM_V7_OPERANDS_LIMITATION_H */ diff --git a/plugins/arm/v7/operands/maccess.c b/plugins/arm/v7/operands/maccess.c new file mode 100644 index 0000000..07192b2 --- /dev/null +++ b/plugins/arm/v7/operands/maccess.c @@ -0,0 +1,385 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * maccess.c - accès à la mémorie à partir d'un registre et d'un décallage + * + * Copyright (C) 2014-2017 Cyrille Bagard + * + * This file is part of Chrysalide. + * + * Chrysalide is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Chrysalide is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Foobar. If not, see . + */ + + +#include "maccess.h" + + +#include +#include + + + +/* Définition d'un opérande offrant un accès à la mémoire depuis une base (instance) */ +struct _GArmV7MAccessOperand +{ + GArchOperand parent; /* Instance parente */ + + GArchOperand *base; /* Base de l'accès en mémoire */ + GArchOperand *offset; /* Décallage pour l'adresse */ + GArchOperand *shift; /* Décallage pour le décallage */ + bool not_post_indexed; /* Positio du décallage */ + bool write_back; /* Mise à jour de la base */ + +}; + + +/* Définition d'un opérande offrant un accès à la mémoire depuis une base (classe) */ +struct _GArmV7MAccessOperandClass +{ + GArchOperandClass parent; /* Classe parente */ + +}; + + +/* Initialise la classe des accès à la mémoire chez ARM. */ +static void g_armv7_maccess_operand_class_init(GArmV7MAccessOperandClass *); + +/* Initialise une instance d'accès à la mémoire chez ARM. */ +static void g_armv7_maccess_operand_init(GArmV7MAccessOperand *); + +/* Supprime toutes les références externes. */ +static void g_armv7_maccess_operand_dispose(GArmV7MAccessOperand *); + +/* Procède à la libération totale de la mémoire. */ +static void g_armv7_maccess_operand_finalize(GArmV7MAccessOperand *); + +/* Compare un opérande avec un autre. */ +static int g_armv7_maccess_operand_compare(const GArmV7MAccessOperand *, const GArmV7MAccessOperand *); + +/* Traduit un opérande en version humainement lisible. */ +static void g_armv7_maccess_operand_print(const GArmV7MAccessOperand *, GBufferLine *, AsmSyntax); + + + +/* Indique le type défini par la GLib pour un accès à la mémoire depuis une base. */ +G_DEFINE_TYPE(GArmV7MAccessOperand, g_armv7_maccess_operand, G_TYPE_ARCH_OPERAND); + + +/****************************************************************************** +* * +* Paramètres : klass = classe à initialiser. * +* * +* Description : Initialise la classe des accès à la mémoire chez ARM. * +* * +* Retour : - * +* * +* Remarques : - * +* * +******************************************************************************/ + +static void g_armv7_maccess_operand_class_init(GArmV7MAccessOperandClass *klass) +{ + GObjectClass *object; /* Autre version de la classe */ + GArchOperandClass *operand; /* Version de classe parente */ + + object = G_OBJECT_CLASS(klass); + operand = G_ARCH_OPERAND_CLASS(klass); + + object->dispose = (GObjectFinalizeFunc/* ! */)g_armv7_maccess_operand_dispose; + object->finalize = (GObjectFinalizeFunc)g_armv7_maccess_operand_finalize; + + operand->compare = (operand_compare_fc)g_armv7_maccess_operand_compare; + operand->print = (operand_print_fc)g_armv7_maccess_operand_print; + +} + + +/****************************************************************************** +* * +* Paramètres : operand = instance à initialiser. * +* * +* Description : Initialise une instance d'accès à la mémoire chez ARM. * +* * +* Retour : - * +* * +* Remarques : - * +* * +******************************************************************************/ + +static void g_armv7_maccess_operand_init(GArmV7MAccessOperand *operand) +{ + +} + + +/****************************************************************************** +* * +* Paramètres : operand = instance d'objet GLib à traiter. * +* * +* Description : Supprime toutes les références externes. * +* * +* Retour : - * +* * +* Remarques : - * +* * +******************************************************************************/ + +static void g_armv7_maccess_operand_dispose(GArmV7MAccessOperand *operand) +{ + g_object_unref(G_OBJECT(operand->base)); + + if (operand->offset != NULL) + g_object_unref(G_OBJECT(operand->offset)); + + if (operand->shift != NULL) + g_object_unref(G_OBJECT(operand->shift)); + + G_OBJECT_CLASS(g_armv7_maccess_operand_parent_class)->dispose(G_OBJECT(operand)); + +} + + +/****************************************************************************** +* * +* Paramètres : operand = instance d'objet GLib à traiter. * +* * +* Description : Procède à la libération totale de la mémoire. * +* * +* Retour : - * +* * +* Remarques : - * +* * +******************************************************************************/ + +static void g_armv7_maccess_operand_finalize(GArmV7MAccessOperand *operand) +{ + G_OBJECT_CLASS(g_armv7_maccess_operand_parent_class)->finalize(G_OBJECT(operand)); + +} + + +/****************************************************************************** +* * +* Paramètres : a = premier opérande à consulter. * +* b = second opérande à consulter. * +* * +* Description : Compare un opérande avec un autre. * +* * +* Retour : Bilan de la comparaison. * +* * +* Remarques : - * +* * +******************************************************************************/ + +static int g_armv7_maccess_operand_compare(const GArmV7MAccessOperand *a, const GArmV7MAccessOperand *b) +{ + int result; /* Bilan à faire remonter */ + + result = g_arch_operand_compare(a->base, b->base); + if (result != 0) goto gamoc_done; + + result = sort_pointer(a->offset, b->offset, (__compar_fn_t)g_arch_operand_compare); + if (result != 0) goto gamoc_done; + + result = sort_pointer(a->shift, b->shift, (__compar_fn_t)g_arch_operand_compare); + if (result != 0) goto gamoc_done; + + result = sort_boolean(a->not_post_indexed, b->not_post_indexed); + if (result != 0) goto gamoc_done; + + result = sort_boolean(a->write_back, b->write_back); + + gamoc_done: + + return result; + +} + + +/****************************************************************************** +* * +* Paramètres : operand = opérande à traiter. * +* line = ligne tampon où imprimer l'opérande donné. * +* syntax = type de représentation demandée. * +* * +* Description : Traduit un opérande en version humainement lisible. * +* * +* Retour : - * +* * +* Remarques : - * +* * +******************************************************************************/ + +static void g_armv7_maccess_operand_print(const GArmV7MAccessOperand *operand, GBufferLine *line, AsmSyntax syntax) +{ + g_buffer_line_append_text(line, BLC_ASSEMBLY, "[", 1, RTT_HOOK, NULL); + + g_arch_operand_print(operand->base, line, syntax); + + if (!operand->not_post_indexed) + g_buffer_line_append_text(line, BLC_ASSEMBLY, "]", 1, RTT_HOOK, NULL); + + if (operand->offset != NULL) + { + g_buffer_line_append_text(line, BLC_ASSEMBLY, ",", 1, RTT_PUNCT, NULL); + g_buffer_line_append_text(line, BLC_ASSEMBLY, " ", 1, RTT_RAW, NULL); + + g_arch_operand_print(operand->offset, line, syntax); + + } + + if (operand->shift != NULL) + { + g_buffer_line_append_text(line, BLC_ASSEMBLY, ",", 1, RTT_PUNCT, NULL); + g_buffer_line_append_text(line, BLC_ASSEMBLY, " ", 1, RTT_RAW, NULL); + + g_arch_operand_print(operand->shift, line, syntax); + + } + + if (operand->not_post_indexed) + g_buffer_line_append_text(line, BLC_ASSEMBLY, "]", 1, RTT_HOOK, NULL); + + if (operand->write_back) + g_buffer_line_append_text(line, BLC_ASSEMBLY, "!", 1, RTT_PUNCT, NULL); + +} + + +/****************************************************************************** +* * +* Paramètres : base = représente le registre de la base d'accès. * +* offset = détermine le décallage entre l'adresse et la base. * +* shift = opération de décallage pour jouer sur le décallage.* +* indexed = précise la forme donnée au décallage à appliquer. * +* wback = indique une mise à jour de la base après usage. * +* * +* Description : Crée un accès à la mémoire depuis une base et un décallage. * +* * +* Retour : Opérande mis en place. * +* * +* Remarques : - * +* * +******************************************************************************/ + +GArchOperand *g_armv7_maccess_operand_new(GArchOperand *base, GArchOperand *offset, GArchOperand *shift, bool indexed, bool wback) +{ + GArmV7MAccessOperand *result; /* Structure à retourner */ + + result = g_object_new(G_TYPE_ARMV7_MACCESS_OPERAND, NULL); + + result->base = base; + result->offset = offset; + result->shift = shift; + + result->not_post_indexed = indexed; + result->write_back = wback; + + return G_ARCH_OPERAND(result); + +} + + +/****************************************************************************** +* * +* Paramètres : operand = opérande à consulter. * +* * +* Description : Founit la base d'un accès à la mémoire. * +* * +* Retour : Opérande en place. * +* * +* Remarques : - * +* * +******************************************************************************/ + +GArchOperand *g_armv7_maccess_operand_get_base(const GArmV7MAccessOperand *operand) +{ + return operand->base; + +} + + +/****************************************************************************** +* * +* Paramètres : operand = opérande à consulter. * +* * +* Description : Founit le décallage d'un accès à la mémoire depuis la base. * +* * +* Retour : Opérande en place. * +* * +* Remarques : - * +* * +******************************************************************************/ + +GArchOperand *g_armv7_maccess_operand_get_offset(const GArmV7MAccessOperand *operand) +{ + return operand->offset; + +} + + +/****************************************************************************** +* * +* Paramètres : operand = opérande à consulter. * +* * +* Description : Founit le décallage d'un décallage pour un accès mémoire. * +* * +* Retour : Opérande en place. * +* * +* Remarques : - * +* * +******************************************************************************/ + +GArchOperand *g_armv7_maccess_operand_get_shift(const GArmV7MAccessOperand *operand) +{ + return operand->shift; + +} + + +/****************************************************************************** +* * +* Paramètres : operand = opérande à consulter. * +* * +* Description : Indique si le décallage est post-indexé. * +* * +* Retour : Statut des opérations menées. * +* * +* Remarques : - * +* * +******************************************************************************/ + +bool g_armv7_maccess_operand_is_post_indexed(const GArmV7MAccessOperand *operand) +{ + return !operand->not_post_indexed; + +} + + +/****************************************************************************** +* * +* Paramètres : operand = opérande à consulter. * +* * +* Description : Indique si la base est mise à jour après usage. * +* * +* Retour : Statut des opérations menées. * +* * +* Remarques : - * +* * +******************************************************************************/ + +bool g_armv7_maccess_operand_has_to_write_back(const GArmV7MAccessOperand *operand) +{ + return operand->write_back; + +} diff --git a/plugins/arm/v7/operands/maccess.h b/plugins/arm/v7/operands/maccess.h new file mode 100644 index 0000000..25cbe9e --- /dev/null +++ b/plugins/arm/v7/operands/maccess.h @@ -0,0 +1,77 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * maccess.h - prototypes pour les accès à la mémorie à partir d'un registre et d'un décallage + * + * Copyright (C) 2014-2017 Cyrille Bagard + * + * This file is part of Chrysalide. + * + * Chrysalide is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Chrysalide is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Foobar. If not, see . + */ + + +#ifndef _PLUGINS_ARM_V7_OPERANDS_MACCESS_H +#define _PLUGINS_ARM_V7_OPERANDS_MACCESS_H + + +#include +#include + + +#include + + +#include "../pseudo.h" + + + +#define G_TYPE_ARMV7_MACCESS_OPERAND g_armv7_maccess_operand_get_type() +#define G_ARMV7_MACCESS_OPERAND(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), g_armv7_maccess_operand_get_type(), GArmV7MAccessOperand)) +#define G_IS_ARMV7_MACCESS_OPERAND(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), g_armv7_maccess_operand_get_type())) +#define G_ARMV7_MACCESS_OPERAND_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), G_TYPE_ARMV7_MACCESS_OPERAND, GArmV7MAccessOperandClass)) +#define G_IS_ARMV7_MACCESS_OPERAND_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), G_TYPE_ARMV7_MACCESS_OPERAND)) +#define G_ARMV7_MACCESS_OPERAND_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), G_TYPE_ARMV7_MACCESS_OPERAND, GArmV7MAccessOperandClass)) + + +/* Définition d'un opérande offrant un accès à la mémoire depuis une base (instance) */ +typedef struct _GArmV7MAccessOperand GArmV7MAccessOperand; + +/* Définition d'un opérande offrant un accès à la mémoire depuis une base (classe) */ +typedef struct _GArmV7MAccessOperandClass GArmV7MAccessOperandClass; + + +/* Indique le type défini par la GLib pour un accès à la mémoire depuis une base. */ +GType g_armv7_maccess_operand_get_type(void); + +/* Crée un accès à la mémoire depuis une base et un décallage. */ +GArchOperand *g_armv7_maccess_operand_new(GArchOperand *, GArchOperand *, GArchOperand *, bool, bool); + +/* Founit la base d'un accès à la mémoire. */ +GArchOperand *g_armv7_maccess_operand_get_base(const GArmV7MAccessOperand *); + +/* Founit le décallage d'un accès à la mémoire depuis la base. */ +GArchOperand *g_armv7_maccess_operand_get_offset(const GArmV7MAccessOperand *); + +/* Founit le décallage d'un décallage pour un accès mémoire. */ +GArchOperand *g_armv7_maccess_operand_get_shift(const GArmV7MAccessOperand *); + +/* Indique si le décallage est post-indexé. */ +bool g_armv7_maccess_operand_is_post_indexed(const GArmV7MAccessOperand *); + +/* Indique si la base est mise à jour après usage. */ +bool g_armv7_maccess_operand_has_to_write_back(const GArmV7MAccessOperand *); + + + +#endif /* _PLUGINS_ARM_V7_OPERANDS_MACCESS_H */ diff --git a/plugins/arm/v7/operands/offset.c b/plugins/arm/v7/operands/offset.c new file mode 100644 index 0000000..5b0b1f0 --- /dev/null +++ b/plugins/arm/v7/operands/offset.c @@ -0,0 +1,283 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * offset.c - constitution d'un décallage positif ou négatif + * + * Copyright (C) 2014-2017 Cyrille Bagard + * + * This file is part of Chrysalide. + * + * Chrysalide is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Chrysalide is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Foobar. If not, see . + */ + + +#include "offset.h" + + +#include +#include + + + +/* Définition d'un opérande visant à constituer un décallage relatif ARMv7 (instance) */ +struct _GArmV7OffsetOperand +{ + GArchOperand parent; /* Instance parente */ + + bool positive; /* Sens du décallage */ + GArchOperand *value; /* Valeur du décallage */ + +}; + + +/* Définition d'un opérande visant à constituer un décallage relatif ARMv7 (classe) */ +struct _GArmV7OffsetOperandClass +{ + GArchOperandClass parent; /* Classe parente */ + +}; + + +/* Initialise la classe des décallages relatifs ARMv7. */ +static void g_armv7_offset_operand_class_init(GArmV7OffsetOperandClass *); + +/* Initialise une instance de décallage relatif ARMv7. */ +static void g_armv7_offset_operand_init(GArmV7OffsetOperand *); + +/* Supprime toutes les références externes. */ +static void g_armv7_offset_operand_dispose(GArmV7OffsetOperand *); + +/* Procède à la libération totale de la mémoire. */ +static void g_armv7_offset_operand_finalize(GArmV7OffsetOperand *); + +/* Compare un opérande avec un autre. */ +static int g_armv7_offset_operand_compare(const GArmV7OffsetOperand *, const GArmV7OffsetOperand *); + +/* Traduit un opérande en version humainement lisible. */ +static void g_armv7_offset_operand_print(const GArmV7OffsetOperand *, GBufferLine *, AsmSyntax); + + + +/* Indique le type défini par la GLib pour un décallage relatif ARMv7. */ +G_DEFINE_TYPE(GArmV7OffsetOperand, g_armv7_offset_operand, G_TYPE_ARCH_OPERAND); + + +/****************************************************************************** +* * +* Paramètres : klass = classe à initialiser. * +* * +* Description : Initialise la classe des décallages relatifs ARMv7. * +* * +* Retour : - * +* * +* Remarques : - * +* * +******************************************************************************/ + +static void g_armv7_offset_operand_class_init(GArmV7OffsetOperandClass *klass) +{ + GObjectClass *object; /* Autre version de la classe */ + GArchOperandClass *operand; /* Version de classe parente */ + + object = G_OBJECT_CLASS(klass); + operand = G_ARCH_OPERAND_CLASS(klass); + + object->dispose = (GObjectFinalizeFunc/* ! */)g_armv7_offset_operand_dispose; + object->finalize = (GObjectFinalizeFunc)g_armv7_offset_operand_finalize; + + operand->compare = (operand_compare_fc)g_armv7_offset_operand_compare; + operand->print = (operand_print_fc)g_armv7_offset_operand_print; + +} + + +/****************************************************************************** +* * +* Paramètres : operand = instance à initialiser. * +* * +* Description : Initialise une instance de décallage relatif ARMv7. * +* * +* Retour : - * +* * +* Remarques : - * +* * +******************************************************************************/ + +static void g_armv7_offset_operand_init(GArmV7OffsetOperand *operand) +{ + +} + + +/****************************************************************************** +* * +* Paramètres : operand = instance d'objet GLib à traiter. * +* * +* Description : Supprime toutes les références externes. * +* * +* Retour : - * +* * +* Remarques : - * +* * +******************************************************************************/ + +static void g_armv7_offset_operand_dispose(GArmV7OffsetOperand *operand) +{ + g_object_unref(G_OBJECT(operand->value)); + + G_OBJECT_CLASS(g_armv7_offset_operand_parent_class)->dispose(G_OBJECT(operand)); + +} + + +/****************************************************************************** +* * +* Paramètres : operand = instance d'objet GLib à traiter. * +* * +* Description : Procède à la libération totale de la mémoire. * +* * +* Retour : - * +* * +* Remarques : - * +* * +******************************************************************************/ + +static void g_armv7_offset_operand_finalize(GArmV7OffsetOperand *operand) +{ + G_OBJECT_CLASS(g_armv7_offset_operand_parent_class)->finalize(G_OBJECT(operand)); + +} + + +/****************************************************************************** +* * +* Paramètres : a = premier opérande à consulter. * +* b = second opérande à consulter. * +* * +* Description : Compare un opérande avec un autre. * +* * +* Retour : Bilan de la comparaison. * +* * +* Remarques : - * +* * +******************************************************************************/ + +static int g_armv7_offset_operand_compare(const GArmV7OffsetOperand *a, const GArmV7OffsetOperand *b) +{ + int result; /* Bilan à faire remonter */ + + result = sort_boolean(a->positive, b->positive); + if (result != 0) goto gaooc_done; + + result = g_arch_operand_compare(a->value, b->value); + + gaooc_done: + + return result; + +} + + +/****************************************************************************** +* * +* Paramètres : operand = opérande à traiter. * +* line = ligne tampon où imprimer l'opérande donné. * +* syntax = type de représentation demandée. * +* * +* Description : Traduit un opérande en version humainement lisible. * +* * +* Retour : - * +* * +* Remarques : - * +* * +******************************************************************************/ + +static void g_armv7_offset_operand_print(const GArmV7OffsetOperand *operand, GBufferLine *line, AsmSyntax syntax) +{ + if (!operand->positive) + g_buffer_line_append_text(line, BLC_ASSEMBLY, "-", 1, RTT_KEY_WORD, NULL); + + g_arch_operand_print(operand->value, line, syntax); + +} + + +/****************************************************************************** +* * +* Paramètres : positive = indique si la quantité doit être ajoutée ou non. * +* value = valeur du décallage à appliquer. * +* * +* Description : Crée un décallage selon un sens et une valeur donnés. * +* * +* Retour : Opérande mis en place. * +* * +* Remarques : - * +* * +******************************************************************************/ + +GArchOperand *g_armv7_offset_operand_new(bool positive, GArchOperand *value) +{ + GArmV7OffsetOperand *result; /* Structure à retourner */ + + result = g_object_new(G_TYPE_ARMV7_OFFSET_OPERAND, NULL); + + result->positive = positive; + result->value = value; + + return G_ARCH_OPERAND(result); + +} + + +/****************************************************************************** +* * +* Paramètres : operand = opérande à consulter. * +* * +* Description : Indique le sens du décallage représenté. * +* * +* Retour : Indication d'ajout ou de retrait. * +* * +* Remarques : - * +* * +******************************************************************************/ + +bool g_armv7_offset_operand_is_positive(const GArmV7OffsetOperand *operand) +{ + return operand->positive; + +} + + +/****************************************************************************** +* * +* Paramètres : operand = opérande à consulter. * +* * +* Description : Founit la valeur utilisée pour un décallage. * +* * +* Retour : Opérande en place. * +* * +* Remarques : - * +* * +******************************************************************************/ + +GArchOperand *g_armv7_offset_operand_get_value(const GArmV7OffsetOperand *operand) +{ + GArchOperand *result; /* Instance à retourner */ + + result = operand->value; + + g_object_ref(G_OBJECT(result)); + + return result; + +} diff --git a/plugins/arm/v7/operands/offset.h b/plugins/arm/v7/operands/offset.h new file mode 100644 index 0000000..e5f967e --- /dev/null +++ b/plugins/arm/v7/operands/offset.h @@ -0,0 +1,68 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * offset.h - prototypes pour la constitution d'un décallage positif ou négatif + * + * Copyright (C) 2014-2017 Cyrille Bagard + * + * This file is part of Chrysalide. + * + * Chrysalide is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Chrysalide is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Foobar. If not, see . + */ + + +#ifndef _PLUGINS_ARM_V7_OPERANDS_OFFSET_H +#define _PLUGINS_ARM_V7_OPERANDS_OFFSET_H + + +#include +#include + + +#include + + +#include "../pseudo.h" + + + +#define G_TYPE_ARMV7_OFFSET_OPERAND g_armv7_offset_operand_get_type() +#define G_ARMV7_OFFSET_OPERAND(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), g_armv7_offset_operand_get_type(), GArmV7OffsetOperand)) +#define G_IS_ARMV7_OFFSET_OPERAND(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), g_armv7_offset_operand_get_type())) +#define G_ARMV7_OFFSET_OPERAND_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), G_TYPE_ARMV7_OFFSET_OPERAND, GArmV7OffsetOperandClass)) +#define G_IS_ARMV7_OFFSET_OPERAND_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), G_TYPE_ARMV7_OFFSET_OPERAND)) +#define G_ARMV7_OFFSET_OPERAND_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), G_TYPE_ARMV7_OFFSET_OPERAND, GArmV7OffsetOperandClass)) + + +/* Définition d'un opérande visant à constituer un décallage relatif ARMv7 (instance) */ +typedef struct _GArmV7OffsetOperand GArmV7OffsetOperand; + +/* Définition d'un opérande visant à constituer un décallage relatif ARMv7 (classe) */ +typedef struct _GArmV7OffsetOperandClass GArmV7OffsetOperandClass; + + +/* Indique le type défini par la GLib pour un décallage relatif ARMv7. */ +GType g_armv7_offset_operand_get_type(void); + +/* Crée un décallage selon un sens et une valeur donnés. */ +GArchOperand *g_armv7_offset_operand_new(bool, GArchOperand *); + +/* Indique le sens du décallage représenté. */ +bool g_armv7_offset_operand_is_positive(const GArmV7OffsetOperand *); + +/* Founit la valeur utilisée pour un décallage. */ +GArchOperand *g_armv7_offset_operand_get_value(const GArmV7OffsetOperand *); + + + +#endif /* _PLUGINS_ARM_V7_OPERANDS_OFFSET_H */ diff --git a/plugins/arm/v7/operands/reglist.c b/plugins/arm/v7/operands/reglist.c new file mode 100644 index 0000000..25981eb --- /dev/null +++ b/plugins/arm/v7/operands/reglist.c @@ -0,0 +1,376 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * reglist.c - accès à la mémorie à partir d'un registre et d'un décallage + * + * Copyright (C) 2014-2017 Cyrille Bagard + * + * This file is part of Chrysalide. + * + * Chrysalide is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Chrysalide is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Foobar. If not, see . + */ + + +#include "reglist.h" + + +#include +#include + + +#include +#include +#include + + + +/* Définition d'un opérande listant une série de registres ARM (instance) */ +struct _GArmV7RegListOperand +{ + GArchOperand parent; /* Instance parente */ + + GArmV7Register **registers; /* Liste de registres intégrés */ + size_t count; /* Taille de cette liste */ + +}; + + +/* Définition d'un opérande listant une série de registres ARM (classe) */ +struct _GArmV7RegListOperandClass +{ + GArchOperandClass parent; /* Classe parente */ + +}; + + +/* Initialise la classe des listes de registres ARM. */ +static void g_armv7_reglist_operand_class_init(GArmV7RegListOperandClass *); + +/* Initialise une instance de liste de registres ARM. */ +static void g_armv7_reglist_operand_init(GArmV7RegListOperand *); + +/* Supprime toutes les références externes. */ +static void g_armv7_reglist_operand_dispose(GArmV7RegListOperand *); + +/* Procède à la libération totale de la mémoire. */ +static void g_armv7_reglist_operand_finalize(GArmV7RegListOperand *); + +/* Compare un opérande avec un autre. */ +static int g_armv7_reglist_operand_compare(const GArmV7RegListOperand *, const GArmV7RegListOperand *); + +/* Traduit un opérande en version humainement lisible. */ +static void g_armv7_reglist_operand_print(const GArmV7RegListOperand *, GBufferLine *, AsmSyntax); + + + +/* Indique le type défini par la GLib pour une liste de registres ARM. */ +G_DEFINE_TYPE(GArmV7RegListOperand, g_armv7_reglist_operand, G_TYPE_ARCH_OPERAND); + + +/****************************************************************************** +* * +* Paramètres : klass = classe à initialiser. * +* * +* Description : Initialise la classe des listes de registres ARM. * +* * +* Retour : - * +* * +* Remarques : - * +* * +******************************************************************************/ + +static void g_armv7_reglist_operand_class_init(GArmV7RegListOperandClass *klass) +{ + GObjectClass *object; /* Autre version de la classe */ + GArchOperandClass *operand; /* Version de classe parente */ + + object = G_OBJECT_CLASS(klass); + operand = G_ARCH_OPERAND_CLASS(klass); + + object->dispose = (GObjectFinalizeFunc/* ! */)g_armv7_reglist_operand_dispose; + object->finalize = (GObjectFinalizeFunc)g_armv7_reglist_operand_finalize; + + operand->compare = (operand_compare_fc)g_armv7_reglist_operand_compare; + operand->print = (operand_print_fc)g_armv7_reglist_operand_print; + +} + + +/****************************************************************************** +* * +* Paramètres : operand = instance à initialiser. * +* * +* Description : Initialise une instance de liste de registres ARM. * +* * +* Retour : - * +* * +* Remarques : - * +* * +******************************************************************************/ + +static void g_armv7_reglist_operand_init(GArmV7RegListOperand *operand) +{ + +} + + +/****************************************************************************** +* * +* Paramètres : operand = instance d'objet GLib à traiter. * +* * +* Description : Supprime toutes les références externes. * +* * +* Retour : - * +* * +* Remarques : - * +* * +******************************************************************************/ + +static void g_armv7_reglist_operand_dispose(GArmV7RegListOperand *operand) +{ + size_t i; /* Boucle de parcours */ + + for (i = 0; i < operand->count; i++) + g_object_unref(G_OBJECT(operand->registers[i])); + + G_OBJECT_CLASS(g_armv7_reglist_operand_parent_class)->dispose(G_OBJECT(operand)); + +} + + +/****************************************************************************** +* * +* Paramètres : operand = instance d'objet GLib à traiter. * +* * +* Description : Procède à la libération totale de la mémoire. * +* * +* Retour : - * +* * +* Remarques : - * +* * +******************************************************************************/ + +static void g_armv7_reglist_operand_finalize(GArmV7RegListOperand *operand) +{ + if (operand->registers != NULL) + free(operand->registers); + + G_OBJECT_CLASS(g_armv7_reglist_operand_parent_class)->finalize(G_OBJECT(operand)); + +} + + +/****************************************************************************** +* * +* Paramètres : a = premier opérande à consulter. * +* b = second opérande à consulter. * +* * +* Description : Compare un opérande avec un autre. * +* * +* Retour : Bilan de la comparaison. * +* * +* Remarques : - * +* * +******************************************************************************/ + +static int g_armv7_reglist_operand_compare(const GArmV7RegListOperand *a, const GArmV7RegListOperand *b) +{ + int result; /* Bilan à faire remonter */ + size_t i; /* Boucle de parcours */ + GArchRegister *ra; /* Registre de la liste A */ + GArchRegister *rb; /* Registre de la liste B */ + + /* Création de l'objet... */ + if (b == NULL) + { + result = 1; + goto garoc_done; + } + + result = sort_unsigned_long(a->count, b->count); + if (result != 0) goto garoc_done; + + for (i = 0; i < a->count && result == 0; i++) + { + ra = G_ARCH_REGISTER(a->registers[i]); + rb = G_ARCH_REGISTER(b->registers[i]); + + result = g_arch_register_compare(ra, rb); + + } + + garoc_done: + + return result; + +} + + +/****************************************************************************** +* * +* Paramètres : operand = opérande à traiter. * +* line = ligne tampon où imprimer l'opérande donné. * +* syntax = type de représentation demandée. * +* * +* Description : Traduit un opérande en version humainement lisible. * +* * +* Retour : - * +* * +* Remarques : - * +* * +******************************************************************************/ + +static void g_armv7_reglist_operand_print(const GArmV7RegListOperand *operand, GBufferLine *line, AsmSyntax syntax) +{ + size_t i; /* Boucle de parcours */ + + g_buffer_line_append_text(line, BLC_ASSEMBLY, "{", 1, RTT_HOOK, NULL); + + for (i = 0; i < operand->count; i++) + { + if (i > 0) + { + g_buffer_line_append_text(line, BLC_ASSEMBLY, ",", 1, RTT_PUNCT, NULL); + g_buffer_line_append_text(line, BLC_ASSEMBLY, " ", 1, RTT_RAW, NULL); + } + + g_arch_register_print(G_ARCH_REGISTER(operand->registers[i]), line, syntax); + + } + + g_buffer_line_append_text(line, BLC_ASSEMBLY, "}", 1, RTT_HOOK, NULL); + +} + + +/****************************************************************************** +* * +* Paramètres : - * +* * +* Description : Crée une liste vierge de registres ARM. * +* * +* Retour : Opérande mis en place. * +* * +* Remarques : - * +* * +******************************************************************************/ + +GArchOperand *g_armv7_reglist_operand_new(void) +{ + GArchOperand *result; /* Structure à retourner */ + + result = g_object_new(G_TYPE_ARMV7_REGLIST_OPERAND, NULL); + + return G_ARCH_OPERAND(result); + +} + + +/****************************************************************************** +* * +* Paramètres : operand = liste de registres à compléter. * +* selected = masque de bits pour les registres à intégrer. * +* * +* Description : Remplit une liste de registres de registres ARM. * +* * +* Retour : Bilan de l'opération. * +* * +* Remarques : - * +* * +******************************************************************************/ + +bool g_armv7_reglist_load_registers(GArmV7RegListOperand *operand, uint32_t selected) +{ + uint8_t i; /* Boucle de parcours */ + GArmV7Register *reg; /* Nouveau registre à intégrer */ + + for (i = 18; i < 32; i++) + if (selected & (1 << i)) return false; + + for (i = 0; i < 18; i++) + { + if ((selected & (1 << i)) == 0) continue; + + reg = g_armv7_register_new(i); + g_armv7_reglist_add_register(operand, reg); + + } + + return true; + +} + + +/****************************************************************************** +* * +* Paramètres : operand = liste de registres à compléter. * +* reg = nouveau registre à intégrer. * +* * +* Description : Ajoute un registre à une liste de registres ARM. * +* * +* Retour : - * +* * +* Remarques : - * +* * +******************************************************************************/ + +void g_armv7_reglist_add_register(GArmV7RegListOperand *operand, GArmV7Register *reg) +{ + operand->registers = (GArmV7Register **)realloc(operand->registers, + ++operand->count * sizeof(GArmV7Register *)); + + operand->registers[operand->count - 1] = reg; + +} + + + +/****************************************************************************** +* * +* Paramètres : operand = opérande à consulter. * +* * +* Description : Compte le nombre de registres ARM composant la liste. * +* * +* Retour : Nombre positif ou nul. * +* * +* Remarques : - * +* * +******************************************************************************/ + +size_t g_armv7_reglist_count_registers(const GArmV7RegListOperand *operand) +{ + return operand->count; + +} + + +/****************************************************************************** +* * +* Paramètres : operand = opérande à consulter. * +* index = indice de l'élément à fournier. * +* * +* Description : Founit un élément donné d'une liste de registres ARM. * +* * +* Retour : Registre intégré à la liste manipulée. * +* * +* Remarques : - * +* * +******************************************************************************/ + +GArmV7Register *g_armv7_reglist_operand_get_register(const GArmV7RegListOperand *operand, size_t index) +{ + assert(index < operand->count); + + return operand->registers[index]; + +} diff --git a/plugins/arm/v7/operands/reglist.h b/plugins/arm/v7/operands/reglist.h new file mode 100644 index 0000000..5cba197 --- /dev/null +++ b/plugins/arm/v7/operands/reglist.h @@ -0,0 +1,74 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * reglist.h - prototypes pour les accès à la mémorie à partir d'un registre et d'un décallage + * + * Copyright (C) 2014-2017 Cyrille Bagard + * + * This file is part of Chrysalide. + * + * Chrysalide is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Chrysalide is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Foobar. If not, see . + */ + + +#ifndef _PLUGINS_ARM_V7_OPERANDS_REGLIST_H +#define _PLUGINS_ARM_V7_OPERANDS_REGLIST_H + + +#include +#include + + +#include + + +#include "../register.h" + + + +#define G_TYPE_ARMV7_REGLIST_OPERAND g_armv7_reglist_operand_get_type() +#define G_ARMV7_REGLIST_OPERAND(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), g_armv7_reglist_operand_get_type(), GArmV7RegListOperand)) +#define G_IS_ARMV7_REGLIST_OPERAND(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), g_armv7_reglist_operand_get_type())) +#define G_ARMV7_REGLIST_OPERAND_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), G_TYPE_ARMV7_REGLIST_OPERAND, GArmV7RegListOperandClass)) +#define G_IS_ARMV7_REGLIST_OPERAND_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), G_TYPE_ARMV7_REGLIST_OPERAND)) +#define G_ARMV7_REGLIST_OPERAND_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), G_TYPE_ARMV7_REGLIST_OPERAND, GArmV7RegListOperandClass)) + + +/* Définition d'un opérande listant une série de registres ARM (instance) */ +typedef struct _GArmV7RegListOperand GArmV7RegListOperand; + +/* Définition d'un opérande listant une série de registres ARM (classe) */ +typedef struct _GArmV7RegListOperandClass GArmV7RegListOperandClass; + + +/* Indique le type défini par la GLib pour une liste de registres ARM. */ +GType g_armv7_reglist_operand_get_type(void); + +/* Crée une liste vierge de registres ARM. */ +GArchOperand *g_armv7_reglist_operand_new(void); + +/* Remplit une liste de registres de registres ARM. */ +bool g_armv7_reglist_load_registers(GArmV7RegListOperand *, uint32_t); + +/* Ajoute un registre à une liste de registres ARM. */ +void g_armv7_reglist_add_register(GArmV7RegListOperand *, GArmV7Register *); + +/* Compte le nombre de registres ARM composant la liste. */ +size_t g_armv7_reglist_count_registers(const GArmV7RegListOperand *); + +/* Founit un élément donné d'une liste de registres ARM. */ +GArmV7Register *g_armv7_reglist_operand_get_register(const GArmV7RegListOperand *, size_t ); + + + +#endif /* _PLUGINS_ARM_V7_OPERANDS_REGLIST_H */ diff --git a/plugins/arm/v7/operands/rotation.c b/plugins/arm/v7/operands/rotation.c new file mode 100644 index 0000000..3858426 --- /dev/null +++ b/plugins/arm/v7/operands/rotation.c @@ -0,0 +1,256 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * rotation.c - rotations de valeurs + * + * Copyright (C) 2015-2017 Cyrille Bagard + * + * This file is part of Chrysalide. + * + * Chrysalide is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Chrysalide is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Foobar. If not, see . + */ + + +#include "rotation.h" + + +#include + + + +/* Définition d'un opérande visant une opérande de rotation ARMv7 (instance) */ +struct _GArmV7RotationOperand +{ + GArchOperand parent; /* Instance parente */ + + GArchOperand *value; /* Valeur du décallage */ + +}; + + +/* Définition d'un opérande visant une opérande de rotation ARMv7 (classe) */ +struct _GArmV7RotationOperandClass +{ + GArchOperandClass parent; /* Classe parente */ + +}; + + +/* Initialise la classe des opérandes de rotation ARMv7. */ +static void g_armv7_rotation_operand_class_init(GArmV7RotationOperandClass *); + +/* Initialise une instance d'opérande de rotation ARMv7. */ +static void g_armv7_rotation_operand_init(GArmV7RotationOperand *); + +/* Supprime toutes les références externes. */ +static void g_armv7_rotation_operand_dispose(GArmV7RotationOperand *); + +/* Procède à la libération totale de la mémoire. */ +static void g_armv7_rotation_operand_finalize(GArmV7RotationOperand *); + +/* Compare un opérande avec un autre. */ +static int g_armv7_rotation_operand_compare(const GArmV7RotationOperand *, const GArmV7RotationOperand *); + +/* Traduit un opérande en version humainement lisible. */ +static void g_armv7_rotation_operand_print(const GArmV7RotationOperand *, GBufferLine *, AsmSyntax); + + + +/* Indique le type défini par la GLib pour une opérande de rotation ARMv7. */ +G_DEFINE_TYPE(GArmV7RotationOperand, g_armv7_rotation_operand, G_TYPE_ARCH_OPERAND); + + +/****************************************************************************** +* * +* Paramètres : klass = classe à initialiser. * +* * +* Description : Initialise la classe des opérandes de rotation ARMv7. * +* * +* Retour : - * +* * +* Remarques : - * +* * +******************************************************************************/ + +static void g_armv7_rotation_operand_class_init(GArmV7RotationOperandClass *klass) +{ + GObjectClass *object; /* Autre version de la classe */ + GArchOperandClass *operand; /* Version de classe parente */ + + object = G_OBJECT_CLASS(klass); + operand = G_ARCH_OPERAND_CLASS(klass); + + object->dispose = (GObjectFinalizeFunc/* ! */)g_armv7_rotation_operand_dispose; + object->finalize = (GObjectFinalizeFunc)g_armv7_rotation_operand_finalize; + + operand->compare = (operand_compare_fc)g_armv7_rotation_operand_compare; + operand->print = (operand_print_fc)g_armv7_rotation_operand_print; + +} + + +/****************************************************************************** +* * +* Paramètres : operand = instance à initialiser. * +* * +* Description : Initialise une instance d'opérande de rotation ARMv7. * +* * +* Retour : - * +* * +* Remarques : - * +* * +******************************************************************************/ + +static void g_armv7_rotation_operand_init(GArmV7RotationOperand *operand) +{ + +} + + +/****************************************************************************** +* * +* Paramètres : operand = instance d'objet GLib à traiter. * +* * +* Description : Supprime toutes les références externes. * +* * +* Retour : - * +* * +* Remarques : - * +* * +******************************************************************************/ + +static void g_armv7_rotation_operand_dispose(GArmV7RotationOperand *operand) +{ + g_object_unref(G_OBJECT(operand->value)); + + G_OBJECT_CLASS(g_armv7_rotation_operand_parent_class)->dispose(G_OBJECT(operand)); + +} + + +/****************************************************************************** +* * +* Paramètres : operand = instance d'objet GLib à traiter. * +* * +* Description : Procède à la libération totale de la mémoire. * +* * +* Retour : - * +* * +* Remarques : - * +* * +******************************************************************************/ + +static void g_armv7_rotation_operand_finalize(GArmV7RotationOperand *operand) +{ + G_OBJECT_CLASS(g_armv7_rotation_operand_parent_class)->finalize(G_OBJECT(operand)); + +} + + +/****************************************************************************** +* * +* Paramètres : a = premier opérande à consulter. * +* b = second opérande à consulter. * +* * +* Description : Compare un opérande avec un autre. * +* * +* Retour : Bilan de la comparaison. * +* * +* Remarques : - * +* * +******************************************************************************/ + +static int g_armv7_rotation_operand_compare(const GArmV7RotationOperand *a, const GArmV7RotationOperand *b) +{ + int result; /* Bilan à faire remonter */ + + result = g_arch_operand_compare(a->value, b->value); + + return result; + +} + + +/****************************************************************************** +* * +* Paramètres : operand = opérande à traiter. * +* line = ligne tampon où imprimer l'opérande donné. * +* syntax = type de représentation demandée. * +* * +* Description : Traduit un opérande en version humainement lisible. * +* * +* Retour : - * +* * +* Remarques : - * +* * +******************************************************************************/ + +static void g_armv7_rotation_operand_print(const GArmV7RotationOperand *operand, GBufferLine *line, AsmSyntax syntax) +{ + g_buffer_line_append_text(line, BLC_ASSEMBLY, "ror", 3, RTT_KEY_WORD, NULL); + + g_buffer_line_append_text(line, BLC_ASSEMBLY, " ", 1, RTT_RAW, NULL); + + g_arch_operand_print(operand->value, line, syntax); + +} + + +/****************************************************************************** +* * +* Paramètres : - * +* * +* Description : Crée un réceptacle pour opérandes de rotation ARMv7. * +* * +* Retour : Opérande mis en place. * +* * +* Remarques : - * +* * +******************************************************************************/ + +GArchOperand *g_armv7_rotation_operand_new(GArchOperand *value) +{ + GArmV7RotationOperand *result; /* Structure à retourner */ + + result = g_object_new(G_TYPE_ARMV7_ROTATION_OPERAND, NULL); + + result->value = value; + + return G_ARCH_OPERAND(result); + +} + + +/****************************************************************************** +* * +* Paramètres : operand = opérande à consulter. * +* * +* Description : Founit la valeur utilisée pour une rotation. * +* * +* Retour : Opérande en place. * +* * +* Remarques : - * +* * +******************************************************************************/ + +GArchOperand *g_armv7_rotation_operand_get_value(const GArmV7RotationOperand *operand) +{ + GArchOperand *result; /* Instance à retourner */ + + result = operand->value; + + g_object_ref(G_OBJECT(result)); + + return result; + +} diff --git a/plugins/arm/v7/operands/rotation.h b/plugins/arm/v7/operands/rotation.h new file mode 100644 index 0000000..952f0e4 --- /dev/null +++ b/plugins/arm/v7/operands/rotation.h @@ -0,0 +1,61 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * rotation.h - prototypes pour les rotations de valeurs + * + * Copyright (C) 2015-2017 Cyrille Bagard + * + * This file is part of Chrysalide. + * + * Chrysalide is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Chrysalide is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Foobar. If not, see . + */ + + +#ifndef _PLUGINS_ARM_V7_OPERANDS_ROTATION_H +#define _PLUGINS_ARM_V7_OPERANDS_ROTATION_H + + +#include + + +#include + + + +#define G_TYPE_ARMV7_ROTATION_OPERAND g_armv7_rotation_operand_get_type() +#define G_ARMV7_ROTATION_OPERAND(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), g_armv7_rotation_operand_get_type(), GArmV7RotationOperand)) +#define G_IS_ARMV7_ROTATION_OPERAND(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), g_armv7_rotation_operand_get_type())) +#define G_ARMV7_ROTATION_OPERAND_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), G_TYPE_ARMV7_ROTATION_OPERAND, GArmV7RotationOperandClass)) +#define G_IS_ARMV7_ROTATION_OPERAND_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), G_TYPE_ARMV7_ROTATION_OPERAND)) +#define G_ARMV7_ROTATION_OPERAND_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), G_TYPE_ARMV7_ROTATION_OPERAND, GArmV7RotationOperandClass)) + + +/* Définition d'un opérande visant une opérande de rotation ARMv7 (instance) */ +typedef struct _GArmV7RotationOperand GArmV7RotationOperand; + +/* Définition d'un opérande visant une opérande de rotation ARMv7 (classe) */ +typedef struct _GArmV7RotationOperandClass GArmV7RotationOperandClass; + + +/* Indique le type défini par la GLib pour une opérande de rotation ARMv7. */ +GType g_armv7_rotation_operand_get_type(void); + +/* Crée un réceptacle pour opérandes de rotation ARMv7. */ +GArchOperand *g_armv7_rotation_operand_new(GArchOperand *); + +/* Founit la valeur utilisée pour une rotation. */ +GArchOperand *g_armv7_rotation_operand_get_value(const GArmV7RotationOperand *); + + + +#endif /* _PLUGINS_ARM_V7_OPERANDS_ROTATION_H */ diff --git a/plugins/arm/v7/operands/shift.c b/plugins/arm/v7/operands/shift.c new file mode 100644 index 0000000..3dfdf12 --- /dev/null +++ b/plugins/arm/v7/operands/shift.c @@ -0,0 +1,300 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * shift.c - décallages de valeurs + * + * Copyright (C) 2014-2017 Cyrille Bagard + * + * This file is part of Chrysalide. + * + * Chrysalide is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Chrysalide is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Foobar. If not, see . + */ + + +#include "shift.h" + + +#include +#include + + + +/* Définition d'un opérande visant une opérande de décallage ARMv7 (instance) */ +struct _GArmV7ShiftOperand +{ + GArchOperand parent; /* Instance parente */ + + SRType shift_type; /* Type de décallage */ + GArchOperand *shift_value; /* Valeur du décallage */ + +}; + + +/* Définition d'un opérande visant une opérande de décallage ARMv7 (classe) */ +struct _GArmV7ShiftOperandClass +{ + GArchOperandClass parent; /* Classe parente */ + +}; + + +/* Initialise la classe des opérandes de décallage ARMv7. */ +static void g_armv7_shift_operand_class_init(GArmV7ShiftOperandClass *); + +/* Initialise une instance d'opérande de décallage ARMv7. */ +static void g_armv7_shift_operand_init(GArmV7ShiftOperand *); + +/* Supprime toutes les références externes. */ +static void g_armv7_shift_operand_dispose(GArmV7ShiftOperand *); + +/* Procède à la libération totale de la mémoire. */ +static void g_armv7_shift_operand_finalize(GArmV7ShiftOperand *); + +/* Compare un opérande avec un autre. */ +static int g_armv7_shift_operand_compare(const GArmV7ShiftOperand *, const GArmV7ShiftOperand *); + +/* Traduit un opérande en version humainement lisible. */ +static void g_armv7_shift_operand_print(const GArmV7ShiftOperand *, GBufferLine *, AsmSyntax); + + + +/* Indique le type défini par la GLib pour une opérande de décallage ARMv7. */ +G_DEFINE_TYPE(GArmV7ShiftOperand, g_armv7_shift_operand, G_TYPE_ARCH_OPERAND); + + +/****************************************************************************** +* * +* Paramètres : klass = classe à initialiser. * +* * +* Description : Initialise la classe des opérandes de décallage ARMv7. * +* * +* Retour : - * +* * +* Remarques : - * +* * +******************************************************************************/ + +static void g_armv7_shift_operand_class_init(GArmV7ShiftOperandClass *klass) +{ + GObjectClass *object; /* Autre version de la classe */ + GArchOperandClass *operand; /* Version de classe parente */ + + object = G_OBJECT_CLASS(klass); + operand = G_ARCH_OPERAND_CLASS(klass); + + object->dispose = (GObjectFinalizeFunc/* ! */)g_armv7_shift_operand_dispose; + object->finalize = (GObjectFinalizeFunc)g_armv7_shift_operand_finalize; + + operand->compare = (operand_compare_fc)g_armv7_shift_operand_compare; + operand->print = (operand_print_fc)g_armv7_shift_operand_print; + +} + + +/****************************************************************************** +* * +* Paramètres : operand = instance à initialiser. * +* * +* Description : Initialise une instance d'opérande de décallage ARMv7. * +* * +* Retour : - * +* * +* Remarques : - * +* * +******************************************************************************/ + +static void g_armv7_shift_operand_init(GArmV7ShiftOperand *operand) +{ + +} + + +/****************************************************************************** +* * +* Paramètres : operand = instance d'objet GLib à traiter. * +* * +* Description : Supprime toutes les références externes. * +* * +* Retour : - * +* * +* Remarques : - * +* * +******************************************************************************/ + +static void g_armv7_shift_operand_dispose(GArmV7ShiftOperand *operand) +{ + g_object_unref(G_OBJECT(operand->shift_value)); + + G_OBJECT_CLASS(g_armv7_shift_operand_parent_class)->dispose(G_OBJECT(operand)); + +} + + +/****************************************************************************** +* * +* Paramètres : operand = instance d'objet GLib à traiter. * +* * +* Description : Procède à la libération totale de la mémoire. * +* * +* Retour : - * +* * +* Remarques : - * +* * +******************************************************************************/ + +static void g_armv7_shift_operand_finalize(GArmV7ShiftOperand *operand) +{ + G_OBJECT_CLASS(g_armv7_shift_operand_parent_class)->finalize(G_OBJECT(operand)); + +} + + +/****************************************************************************** +* * +* Paramètres : a = premier opérande à consulter. * +* b = second opérande à consulter. * +* * +* Description : Compare un opérande avec un autre. * +* * +* Retour : Bilan de la comparaison. * +* * +* Remarques : - * +* * +******************************************************************************/ + +static int g_armv7_shift_operand_compare(const GArmV7ShiftOperand *a, const GArmV7ShiftOperand *b) +{ + int result; /* Bilan à faire remonter */ + + result = sort_unsigned_long(a->shift_type, b->shift_type); + if (result != 0) goto gasoc_done; + + result = g_arch_operand_compare(a->shift_value, b->shift_value); + + gasoc_done: + + return result; + +} + + +/****************************************************************************** +* * +* Paramètres : operand = opérande à traiter. * +* line = ligne tampon où imprimer l'opérande donné. * +* syntax = type de représentation demandée. * +* * +* Description : Traduit un opérande en version humainement lisible. * +* * +* Retour : - * +* * +* Remarques : - * +* * +******************************************************************************/ + +static void g_armv7_shift_operand_print(const GArmV7ShiftOperand *operand, GBufferLine *line, AsmSyntax syntax) +{ + switch (operand->shift_type) + { + case SRType_LSL: + g_buffer_line_append_text(line, BLC_ASSEMBLY, "lsl", 3, RTT_KEY_WORD, NULL); + break; + case SRType_LSR: + g_buffer_line_append_text(line, BLC_ASSEMBLY, "lsr", 3, RTT_KEY_WORD, NULL); + break; + case SRType_ASR: + g_buffer_line_append_text(line, BLC_ASSEMBLY, "asr", 3, RTT_KEY_WORD, NULL); + break; + case SRType_ROR: + g_buffer_line_append_text(line, BLC_ASSEMBLY, "ror", 3, RTT_KEY_WORD, NULL); + break; + case SRType_RRX: + g_buffer_line_append_text(line, BLC_ASSEMBLY, "rrx", 3, RTT_KEY_WORD, NULL); + break; + } + + g_buffer_line_append_text(line, BLC_ASSEMBLY, " ", 1, RTT_RAW, NULL); + + g_arch_operand_print(operand->shift_value, line, syntax); + +} + + +/****************************************************************************** +* * +* Paramètres : - * +* * +* Description : Crée un réceptacle pour opérande de décallage ARMv7. * +* * +* Retour : Opérande mis en place. * +* * +* Remarques : - * +* * +******************************************************************************/ + +GArchOperand *g_armv7_shift_operand_new(SRType type, GArchOperand *value) +{ + GArmV7ShiftOperand *result; /* Structure à retourner */ + + result = g_object_new(G_TYPE_ARMV7_SHIFT_OPERAND, NULL); + + result->shift_type = type; + result->shift_value = value; + + return G_ARCH_OPERAND(result); + +} + + +/****************************************************************************** +* * +* Paramètres : operand = opérande à consulter. * +* * +* Description : Indique la forme de décallage représenté. * +* * +* Retour : Type de décallage. * +* * +* Remarques : - * +* * +******************************************************************************/ + +SRType g_armv7_shift_operand_get_shift_type(const GArmV7ShiftOperand *operand) +{ + return operand->shift_type; + +} + + +/****************************************************************************** +* * +* Paramètres : operand = opérande à consulter. * +* * +* Description : Founit la valeur utilisée pour un décallage. * +* * +* Retour : Opérande en place. * +* * +* Remarques : - * +* * +******************************************************************************/ + +GArchOperand *g_armv7_shift_operand_get_shift_value(const GArmV7ShiftOperand *operand) +{ + GArchOperand *result; /* Instance à retourner */ + + result = operand->shift_value; + + g_object_ref(G_OBJECT(result)); + + return result; + +} diff --git a/plugins/arm/v7/operands/shift.h b/plugins/arm/v7/operands/shift.h new file mode 100644 index 0000000..d3c8001 --- /dev/null +++ b/plugins/arm/v7/operands/shift.h @@ -0,0 +1,67 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * shift.h - prototypes pour les décallages de valeurs + * + * Copyright (C) 2014-2017 Cyrille Bagard + * + * This file is part of Chrysalide. + * + * Chrysalide is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Chrysalide is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Foobar. If not, see . + */ + + +#ifndef _PLUGINS_ARM_V7_OPERANDS_SHIFT_H +#define _PLUGINS_ARM_V7_OPERANDS_SHIFT_H + + +#include + + +#include + + +#include "../pseudo.h" + + + +#define G_TYPE_ARMV7_SHIFT_OPERAND g_armv7_shift_operand_get_type() +#define G_ARMV7_SHIFT_OPERAND(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), g_armv7_shift_operand_get_type(), GArmV7ShiftOperand)) +#define G_IS_ARMV7_SHIFT_OPERAND(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), g_armv7_shift_operand_get_type())) +#define G_ARMV7_SHIFT_OPERAND_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), G_TYPE_ARMV7_SHIFT_OPERAND, GArmV7ShiftOperandClass)) +#define G_IS_ARMV7_SHIFT_OPERAND_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), G_TYPE_ARMV7_SHIFT_OPERAND)) +#define G_ARMV7_SHIFT_OPERAND_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), G_TYPE_ARMV7_SHIFT_OPERAND, GArmV7ShiftOperandClass)) + + +/* Définition d'un opérande visant une opérande de décallage ARMv7 (instance) */ +typedef struct _GArmV7ShiftOperand GArmV7ShiftOperand; + +/* Définition d'un opérande visant une opérande de décallage ARMv7 (classe) */ +typedef struct _GArmV7ShiftOperandClass GArmV7ShiftOperandClass; + + +/* Indique le type défini par la GLib pour une opérande de décallage ARMv7. */ +GType g_armv7_shift_operand_get_type(void); + +/* Crée un réceptacle pour opérande de décallage ARMv7. */ +GArchOperand *g_armv7_shift_operand_new(SRType, GArchOperand *); + +/* Indique la forme de décallage représenté. */ +SRType g_armv7_shift_operand_get_shift_type(const GArmV7ShiftOperand *); + +/* Founit la valeur utilisée pour un décallage. */ +GArchOperand *g_armv7_shift_operand_get_shift_value(const GArmV7ShiftOperand *); + + + +#endif /* _PLUGINS_ARM_V7_OPERANDS_SHIFT_H */ diff --git a/plugins/arm/v7/post.c b/plugins/arm/v7/post.c new file mode 100644 index 0000000..10941a3 --- /dev/null +++ b/plugins/arm/v7/post.c @@ -0,0 +1,99 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * post.c - traitements complémentaires à la phase de désassemblage + * + * Copyright (C) 2014-2017 Cyrille Bagard + * + * This file is part of Chrysalide. + * + * Chrysalide is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Chrysalide is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Foobar. If not, see . + */ + + +#include "post.h" + + +#include + + + +/****************************************************************************** +* * +* Paramètres : instr = instruction ARMv7 à traiter. * +* proc = représentation de l'architecture utilisée. * +* context = contexte associé à la phase de désassemblage. * +* format = accès aux données du binaire d'origine. * +* * +* Description : Complète un désassemblage accompli pour une instruction. * +* * +* Retour : - * +* * +* Remarques : - * +* * +******************************************************************************/ + +void post_process_ldr_instructions(GArchInstruction *instr, GArchProcessor *proc, GProcContext *context, GExeFormat *format) +{ + GArchOperand *op; /* Opérande numérique en place */ + uint32_t addr; /* Adresse visée par le saut */ + GBinFormat *bfmt; /* Version basique du format */ + GTargetOperand *new; /* Instruction de ciblage */ + vmpa2t target; /* Défination finale précise */ + mrange_t trange; /* Etendue du symbole à créer */ + VMPA_BUFFER(loc); /* Espace pour une conversion */ + char name[5 + VMPA_MAX_LEN]; /* Etiquette à constituer */ + GBinSymbol *symbol; /* Nouveau symbole construit */ + + g_arch_instruction_lock_operands(instr); + + op = _g_arch_instruction_get_operand(instr, 1); + + if (!G_IS_IMM_OPERAND(op)) + goto ppli_release; + + if (g_imm_operand_get_value(G_IMM_OPERAND(op), MDS_32_BITS_UNSIGNED, &addr) + && g_exe_format_translate_address_into_vmpa(format, addr, &target)) + { + bfmt = G_BIN_FORMAT(format); + + new = G_TARGET_OPERAND(g_target_operand_new(MDS_32_BITS_UNSIGNED, &target)); + + if (!g_target_operand_resolve(new, bfmt, true)) + { + addr &= ~0x1; + + init_mrange(&trange, &target, 0); + + vmpa2_virt_to_string(&target, MDS_UNDEFINED, loc, NULL); + snprintf(name, sizeof(name), "loc_%s", loc + 2); + + symbol = g_binary_symbol_new(&trange, STP_CODE_LABEL); + g_binary_symbol_set_alt_label(symbol, name); + g_binary_format_add_symbol(bfmt, symbol); + + g_target_operand_resolve(new, bfmt, true); + + } + + _g_arch_instruction_replace_operand(instr, op, G_ARCH_OPERAND(new)); + + } + + ppli_release: + + g_object_unref(G_OBJECT(op)); + + g_arch_instruction_unlock_operands(instr); + +} diff --git a/plugins/arm/v7/post.h b/plugins/arm/v7/post.h new file mode 100644 index 0000000..33a80fd --- /dev/null +++ b/plugins/arm/v7/post.h @@ -0,0 +1,57 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * post.h - prototypes pour les traitements complémentaires à la phase de désassemblage + * + * Copyright (C) 2014-2017 Cyrille Bagard + * + * This file is part of Chrysalide. + * + * Chrysalide is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Chrysalide is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Foobar. If not, see . + */ + + +#ifndef _PLUGINS_ARM_V7_POST_H +#define _PLUGINS_ARM_V7_POST_H + + +#include +#include + + + +static inline void post_process_branch_instructions(GArchInstruction *ins, GArchProcessor *proc, GProcContext *ctx, GExeFormat *fmt) +{ + post_process_target_resolution(ins, proc, ctx, fmt, 0, STP_CODE_LABEL); + +} + +static inline void post_process_branch_and_link_instructions(GArchInstruction *ins, GArchProcessor *proc, GProcContext *ctx, GExeFormat *fmt) +{ + post_process_target_resolution(ins, proc, ctx, fmt, 0, STP_ROUTINE); + +} + +static inline void post_process_comp_and_branch_instructions(GArchInstruction *ins, GArchProcessor *proc, GProcContext *ctx, GExeFormat *fmt) +{ + post_process_target_resolution(ins, proc, ctx, fmt, 1, STP_CODE_LABEL); + +} + + +/* Complète un désassemblage accompli pour une instruction. */ +void post_process_ldr_instructions(GArchInstruction *, GArchProcessor *, GProcContext *, GExeFormat *); + + + +#endif /* _PLUGINS_ARM_V7_POST_H */ diff --git a/plugins/arm/v7/processor.c b/plugins/arm/v7/processor.c new file mode 100644 index 0000000..4295b51 --- /dev/null +++ b/plugins/arm/v7/processor.c @@ -0,0 +1,297 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * processor.c - manipulation du processeur ARMv7 + * + * Copyright (C) 2014-2017 Cyrille Bagard + * + * This file is part of Chrysalide. + * + * Chrysalide is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Chrysalide is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Foobar. If not, see . + */ + + +#include "processor.h" + + +#include + + +#include + + +#include "arm.h" +#include "context.h" +#include "thumb_16.h" +#include "thumb_32.h" +#include "../processor-int.h" + + + +/* Définition du processeur ARMv7 (instance) */ +struct _GArmV7Processor +{ + GArmProcessor parent; /* Instance parente */ + +}; + + +/* Définition du processeur ARMv7 (classe) */ +struct _GArmV7ProcessorClass +{ + GArmProcessorClass parent; /* Classe parente */ + +}; + + +/* Initialise la classe des registres ARMv7. */ +static void g_armv7_processor_class_init(GArmV7ProcessorClass *); + +/* Initialise une instance de registre ARMv7. */ +static void g_armv7_processor_init(GArmV7Processor *); + +/* Supprime toutes les références externes. */ +static void g_armv7_processor_dispose(GArmV7Processor *); + +/* Procède à la libération totale de la mémoire. */ +static void g_armv7_processor_finalize(GArmV7Processor *); + +/* Fournit un contexte pour l'exécution du processeur ARM. */ +static GArmV7Context *g_armv7_processor_get_context(const GArmV7Processor *); + +/* Décode une instruction dans un flux de données. */ +static GArchInstruction *g_armv7_processor_disassemble(const GArmV7Processor *, GArmV7Context *, const GBinContent *, vmpa2t *, GExeFormat *); + + + +/* Indique le type défini par la GLib pour le processeur ARMv7. */ +G_DEFINE_TYPE(GArmV7Processor, g_armv7_processor, G_TYPE_ARM_PROCESSOR); + + +/****************************************************************************** +* * +* Paramètres : klass = classe à initialiser. * +* * +* Description : Initialise la classe des processeurs ARMv7. * +* * +* Retour : - * +* * +* Remarques : - * +* * +******************************************************************************/ + +static void g_armv7_processor_class_init(GArmV7ProcessorClass *klass) +{ + GObjectClass *object_class; /* Autre version de la classe */ + GArchProcessorClass *proc; /* Encore une autre vision... */ + + object_class = G_OBJECT_CLASS(klass); + proc = G_ARCH_PROCESSOR_CLASS(klass); + + object_class->dispose = (GObjectFinalizeFunc/* ! */)g_armv7_processor_dispose; + object_class->finalize = (GObjectFinalizeFunc)g_armv7_processor_finalize; + + proc->disassemble = (disass_instr_fc)g_armv7_processor_disassemble; + +} + + +/****************************************************************************** +* * +* Paramètres : proc = instance à initialiser. * +* * +* Description : Initialise une instance de processeur ARMv7. * +* * +* Retour : - * +* * +* Remarques : - * +* * +******************************************************************************/ + +static void g_armv7_processor_init(GArmV7Processor *proc) +{ + + GArchProcessor *parent; /* Instance parente */ + + parent = G_ARCH_PROCESSOR(proc); + + parent->endianness = SRE_LITTLE; + parent->memsize = MDS_32_BITS; + parent->inssize = MDS_32_BITS; + + + + + parent->get_ctx = (get_processor_context_fc)g_armv7_processor_get_context; + + +} + + +/****************************************************************************** +* * +* Paramètres : proc = instance d'objet GLib à traiter. * +* * +* Description : Supprime toutes les références externes. * +* * +* Retour : - * +* * +* Remarques : - * +* * +******************************************************************************/ + +static void g_armv7_processor_dispose(GArmV7Processor *proc) +{ + G_OBJECT_CLASS(g_armv7_processor_parent_class)->dispose(G_OBJECT(proc)); + +} + + +/****************************************************************************** +* * +* Paramètres : proc = instance d'objet GLib à traiter. * +* * +* Description : Procède à la libération totale de la mémoire. * +* * +* Retour : - * +* * +* Remarques : - * +* * +******************************************************************************/ + +static void g_armv7_processor_finalize(GArmV7Processor *proc) +{ + G_OBJECT_CLASS(g_armv7_processor_parent_class)->finalize(G_OBJECT(proc)); + +} + + +/****************************************************************************** +* * +* Paramètres : - * +* * +* Description : Crée le support de l'architecture ARMv7. * +* * +* Retour : Adresse de la structure mise en place. * +* * +* Remarques : - * +* * +******************************************************************************/ + +GArmV7Processor *g_armv7_processor_new(void) +{ + GArmV7Processor *result; /* Structure à retourner */ + + result = g_object_new(G_TYPE_ARMV7_PROCESSOR, NULL); + + return result; + +} + + +/****************************************************************************** +* * +* Paramètres : proc = architecture, spectatrice ici. * +* * +* Description : Fournit un contexte pour l'exécution du processeur Arm. * +* * +* Retour : Contexte mis en place. * +* * +* Remarques : - * +* * +******************************************************************************/ + +static GArmV7Context *g_armv7_processor_get_context(const GArmV7Processor *proc) +{ + return g_armv7_context_new(); + +} + + +/****************************************************************************** +* * +* Paramètres : proc = architecture visée par la procédure. * +* ctx = contexte lié à l'exécution du processeur. * +* content = flux de données à analyser. * +* pos = position courante dans ce flux. [OUT] * +* format = format du fichier contenant le code. * +* * +* Description : Désassemble une instruction dans un flux de données. * +* * +* Retour : Instruction mise en place ou NULL en cas d'échec. * +* * +* Remarques : - * +* * +******************************************************************************/ + +static GArchInstruction *g_armv7_processor_disassemble(const GArmV7Processor *proc, GArmV7Context *ctx, const GBinContent *content, vmpa2t *pos, GExeFormat *format) +{ + GArchInstruction *result; /* Instruction à renvoyer */ + SourceEndian endian; /* Boutisme des données lues */ + uint16_t raw16; /* Donnée 16 bits à analyser */ + uint32_t raw32; /* Donnée 32 bits à analyser */ + ArmV7InstrSet iset; /* Type de jeu d'instructions */ + + endian = G_ARCH_PROCESSOR(proc)->endianness; + + iset = g_armv7_context_find_encoding(ctx, get_virt_addr(pos)); + + switch (iset) + { + case AV7IS_ARM: + + if (!g_binary_content_read_u32(content, pos, endian, &raw32)) + return NULL; + + result = process_armv7_arm_instruction_set_encoding(raw32); + + break; + + case AV7IS_THUMB: + + if (!g_binary_content_read_u16(content, pos, endian, &raw16)) + return NULL; + + switch (raw16 >> 11) + { + case 0b11101: + case 0b11110: + case 0b11111: + + raw32 = raw16 << 16; + + if (!g_binary_content_read_u16(content, pos, endian, &raw16)) + return NULL; + + raw32 |= raw16; + + result = process_armv7_thumb_32_instruction_set_encoding(raw32); + break; + + default: + result = process_armv7_thumb_16_instruction_set_encoding(raw16); + break; + + } + + break; + + default: + assert(0); + break; + + } + + return result; + +} diff --git a/plugins/arm/v7/processor.h b/plugins/arm/v7/processor.h new file mode 100644 index 0000000..84e64f4 --- /dev/null +++ b/plugins/arm/v7/processor.h @@ -0,0 +1,56 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * processor.h - prototypes pour la manipulation du processeur ARMv7 + * + * Copyright (C) 2014-2017 Cyrille Bagard + * + * This file is part of Chrysalide. + * + * Chrysalide is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Chrysalide is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Foobar. If not, see . + */ + + +#ifndef _PLUGINS_ARM_V7_PROCESSOR_H +#define _PLUGINS_ARM_V7_PROCESSOR_H + + +#include +#include + + + +#define G_TYPE_ARMV7_PROCESSOR g_armv7_processor_get_type() +#define G_ARMV7_PROCESSOR(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), g_armv7_processor_get_type(), GArmV7Processor)) +#define G_IS_ARMV7_PROCESSOR(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), g_armv7_processor_get_type())) +#define G_ARMV7_PROCESSOR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), G_TYPE_ARMV7_PROCESSOR, GArmV7ProcessorClass)) +#define G_IS_ARMV7_PROCESSOR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), G_TYPE_ARMV7_PROCESSOR)) +#define G_ARMV7_PROCESSOR_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), G_TYPE_ARMV7_PROCESSOR, GArmV7ProcessorClass)) + + +/* Définition du processeur ARMv7 (instance) */ +typedef struct _GArmV7Processor GArmV7Processor; + +/* Définition du processeur ARMv7 (classe) */ +typedef struct _GArmV7ProcessorClass GArmV7ProcessorClass; + + +/* Indique le type défini par la GLib pour le processeur ARMv7. */ +GType g_armv7_processor_get_type(void); + +/* Crée le support de l'architecture ARMv7. */ +GArmV7Processor *g_armv7_processor_new(void); + + + +#endif /* _PLUGINS_ARM_V7_PROCESSOR_H */ diff --git a/plugins/arm/v7/pseudo.c b/plugins/arm/v7/pseudo.c new file mode 100644 index 0000000..f06e6a9 --- /dev/null +++ b/plugins/arm/v7/pseudo.c @@ -0,0 +1,683 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * pseudo.c - implémentation des pseudo-fonctions de spécification + * + * Copyright (C) 2014-2017 Cyrille Bagard + * + * This file is part of Chrysalide. + * + * Chrysalide is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Chrysalide is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Foobar. If not, see . + */ + + +#include "pseudo.h" + + +#include + + +#include + + + +/****************************************************************************** +* * +* Paramètres : x = valeur sur 32 bits maximum à traiter. * +* n = nombre de bits à prendre en compte. * +* shift = nombre de décallages visés. * +* carry = retenue enventuelle à constituer. [OUT] * +* value = nouvelle valeur calculée. [OUT] * +* * +* Description : Traduit la fonction 'LSL_C'. * +* * +* Retour : Bilan de l'opération. * +* * +* Remarques : - * +* * +******************************************************************************/ + +bool armv7_lsl_c(uint32_t x, unsigned int n, unsigned int shift, bool *carry, uint32_t *value) +{ + if (n > 32) return false; + if (shift == 0) return false; + + if (carry != NULL) + *carry = x & (1 << (n - 1)); + + *value = x << shift; + + return true; + +} + + +/****************************************************************************** +* * +* Paramètres : x = valeur sur 32 bits maximum à traiter. * +* n = nombre de bits à prendre en compte. * +* shift = nombre de décallages visés. * +* value = nouvelle valeur calculée. [OUT] * +* * +* Description : Traduit la fonction 'LSL'. * +* * +* Retour : Bilan de l'opération. * +* * +* Remarques : - * +* * +******************************************************************************/ + +bool armv7_lsl(uint32_t x, unsigned int n, unsigned int shift, uint32_t *value) +{ + bool result; /* Bilan final à retourner */ + + if (shift == 0) + result = true; + + else + result = armv7_lsl_c(x, n, shift, NULL, value); + + return result; + +} + + +/****************************************************************************** +* * +* Paramètres : x = valeur sur 32 bits maximum à traiter. * +* n = nombre de bits à prendre en compte. * +* shift = nombre de décallages visés. * +* carry = retenue enventuelle à constituer. [OUT] * +* value = nouvelle valeur calculée. [OUT] * +* * +* Description : Traduit la fonction 'LSR_C'. * +* * +* Retour : Bilan de l'opération. * +* * +* Remarques : - * +* * +******************************************************************************/ + +bool armv7_lsr_c(uint32_t x, unsigned int n, unsigned int shift, bool *carry, uint32_t *value) +{ + if (n > 32) return false; + if (shift == 0) return false; + + if (carry != NULL) + *carry = x & (1 << (shift - 1)); + + *value = x >> shift; + + return true; + +} + + +/****************************************************************************** +* * +* Paramètres : x = valeur sur 32 bits maximum à traiter. * +* n = nombre de bits à prendre en compte. * +* shift = nombre de décallages visés. * +* value = nouvelle valeur calculée. [OUT] * +* * +* Description : Traduit la fonction 'LSR'. * +* * +* Retour : Bilan de l'opération. * +* * +* Remarques : - * +* * +******************************************************************************/ + +bool armv7_lsr(uint32_t x, unsigned int n, unsigned int shift, uint32_t *value) +{ + bool result; /* Bilan final à retourner */ + + if (shift == 0) + result = x; + + else + result = armv7_lsr_c(x, n, shift, NULL, value); + + return result; + +} + + +/****************************************************************************** +* * +* Paramètres : x = valeur sur 32 bits maximum à traiter. * +* n = nombre de bits à prendre en compte. * +* shift = nombre de décallages visés. * +* carry = retenue enventuelle à constituer. [OUT] * +* value = nouvelle valeur calculée. [OUT] * +* * +* Description : Traduit la fonction 'ASR_C'. * +* * +* Retour : Bilan de l'opération. * +* * +* Remarques : - * +* * +******************************************************************************/ + +bool armv7_asr_c(uint32_t x, unsigned int n, unsigned int shift, bool *carry, uint32_t *value) +{ + if (n > 32) return false; + if (shift == 0) return false; + + if (carry != NULL) + *carry = x & (1 << (shift - 1)); + + *value = ((int32_t)x) >> shift; + + return true; + +} + + +/****************************************************************************** +* * +* Paramètres : x = valeur sur 32 bits maximum à traiter. * +* n = nombre de bits à prendre en compte. * +* shift = nombre de décallages visés. * +* value = nouvelle valeur calculée. [OUT] * +* * +* Description : Traduit la fonction 'ASR'. * +* * +* Retour : Bilan de l'opération. * +* * +* Remarques : - * +* * +******************************************************************************/ + +bool armv7_asr(uint32_t x, unsigned int n, unsigned int shift, uint32_t *value) +{ + bool result; /* Bilan final à retourner */ + + if (shift == 0) + result = true; + + else + result = armv7_asr_c(x, n, shift, NULL, value); + + return result; + +} + + +/****************************************************************************** +* * +* Paramètres : x = valeur sur 32 bits maximum à traiter. * +* n = nombre de bits à prendre en compte. * +* shift = nombre de décallages visés. * +* carry = retenue enventuelle à constituer. [OUT] * +* value = nouvelle valeur calculée. [OUT] * +* * +* Description : Traduit la fonction 'ROR_C'. * +* * +* Retour : Bilan de l'opération. * +* * +* Remarques : - * +* * +******************************************************************************/ + +bool armv7_ror_c(uint32_t x, unsigned int n, unsigned int shift, bool *carry, uint32_t *value) +{ + if (n > 32) return false; + if (shift == 0) return false; + + *value = (x >> shift) | (x << (32 - shift)); + + if (carry != NULL) + *carry = *value & (1 << (n - 1)); + + return true; + +} + + +/****************************************************************************** +* * +* Paramètres : x = valeur sur 32 bits maximum à traiter. * +* n = nombre de bits à prendre en compte. * +* shift = nombre de décallages visés. * +* value = nouvelle valeur calculée. [OUT] * +* * +* Description : Traduit la fonction 'ROR'. * +* * +* Retour : Bilan de l'opération. * +* * +* Remarques : - * +* * +******************************************************************************/ + +bool armv7_ror(uint32_t x, unsigned int n, unsigned int shift, uint32_t *value) +{ + bool result; /* Bilan final à retourner */ + + if (shift == 0) + result = true; + + else + result = armv7_ror_c(x, n, shift, NULL, value); + + return result; + +} + + +/****************************************************************************** +* * +* Paramètres : x = valeur sur 32 bits maximum à traiter. * +* n = nombre de bits à prendre en compte. * +* carry = retenue enventuelle à utiliser puis constituer. [OUT]* +* value = nouvelle valeur calculée. [OUT] * +* * +* Description : Traduit la fonction 'RRX_C'. * +* * +* Retour : Bilan de l'opération. * +* * +* Remarques : - * +* * +******************************************************************************/ + +bool armv7_rrx_c(uint32_t x, unsigned int n, bool *carry, uint32_t *value) +{ + bool new_c; /* Nouvelle retenue à retenir */ + + new_c = x & 0x1; + + *value = (*carry ? 1 : 0) << (n - 1) | x >> 1; + + *carry = new_c; + + return true; + +} + + +/****************************************************************************** +* * +* Paramètres : x = valeur sur 32 bits maximum à traiter. * +* n = nombre de bits à prendre en compte. * +* carry = retenue enventuelle à utiliser. * +* value = nouvelle valeur calculée. [OUT] * +* * +* Description : Traduit la fonction 'RRX'. * +* * +* Retour : Bilan de l'opération. * +* * +* Remarques : - * +* * +******************************************************************************/ + +bool armv7_rrx(uint32_t x, unsigned int n, bool carry, uint32_t *value) +{ + return armv7_rrx_c(x, n, &carry, value); + +} + + +/****************************************************************************** +* * +* Paramètres : imm12 = valeur sur 32 bits maximum à traiter. * +* carry = retenue enventuelle à utiliser / constituer. [OUT] * +* value = nouvelle valeur calculée. [OUT] * +* * +* Description : Traduit la fonction 'ARMExpandImm_C'. * +* * +* Retour : Bilan de l'opération. * +* * +* Remarques : - * +* * +******************************************************************************/ + +bool armv7_arm_expand_imm_c(uint32_t imm12, bool *carry, uint32_t *value) +{ + bool result; /* Bilan final à retourner */ + uint32_t unrotated; /* Transformation à décaller */ + + /** + * Selon les spécifications, x contient toujours 12 bits utiles seulement. + */ + + unrotated = armv7_zero_extend(imm12 & 0xff, 8, 32); + + result = armv7_shift(unrotated, 32, SRType_ROR, 2 * ((imm12 >> 8) & 0xf), carry, value); + + return result; + +} + + +/****************************************************************************** +* * +* Paramètres : imm12 = valeur sur 32 bits maximum à traiter. * +* carry = retenue enventuelle à utiliser / constituer. [OUT] * +* value = nouvelle valeur calculée. [OUT] * +* * +* Description : Traduit la fonction 'ARMExpandImm'. * +* * +* Retour : Bilan de l'opération. * +* * +* Remarques : - * +* * +******************************************************************************/ + +bool armv7_arm_expand_imm(uint32_t imm12, uint32_t *value) +{ + return armv7_arm_expand_imm_c(imm12, (bool []) { false /* FIXME : APSR.C */ }, value); + +} + + +/****************************************************************************** +* * +* Paramètres : imm12 = valeur sur 32 bits maximum à traiter. * +* carry = retenue enventuelle à utiliser / constituer. [OUT] * +* value = nouvelle valeur calculée. [OUT] * +* * +* Description : Traduit la fonction 'ThumbExpandImm_C'. * +* * +* Retour : Bilan de l'opération. * +* * +* Remarques : - * +* * +******************************************************************************/ + +bool armv7_thumb_expand_imm_c(uint32_t imm12, bool *carry, uint32_t *value) +{ + bool result; /* Conclusion à faire remonter */ + uint8_t byte; /* Octet à reproduire */ + uint32_t unrotated; /* Transformation à décaller */ + + result = true; + + if (((imm12 >> 10) & b11) == b00) + { + byte = imm12 & 0xff; + + switch ((imm12 >> 8) & b11) + { + case b00: + *value = armv7_zero_extend(byte, 8, 32); + break; + + case b01: + if (byte == 0) + result = false; + else + *value = byte << 16 | byte; + break; + + case b10: + if (byte == 0) + result = false; + else + *value = byte << 24 | byte << 8; + break; + + case b11: + if (byte == 0) + result = false; + else + *value = byte << 24 | byte << 16 | byte << 8 | byte; + break; + + } + + } + else + { + unrotated = 1 << 7 | (imm12 & 0x3f); + result = armv7_ror_c(unrotated, 32, (imm12 >> 7) & 0x1f, carry, value); + } + + return result; + +} + + +/****************************************************************************** +* * +* Paramètres : imm12 = valeur sur 32 bits maximum à traiter. * +* carry = retenue enventuelle à utiliser / constituer. [OUT] * +* value = nouvelle valeur calculée. [OUT] * +* * +* Description : Traduit la fonction 'ThumbExpandImm'. * +* * +* Retour : Bilan de l'opération. * +* * +* Remarques : - * +* * +******************************************************************************/ + +bool armv7_thumb_expand_imm(uint32_t imm12, uint32_t *value) +{ + return armv7_thumb_expand_imm_c(imm12, (bool []) { false /* FIXME : APSR.C */ }, value); + +} + + +/****************************************************************************** +* * +* Paramètres : type2 = type de décallage encodé sur 2 bits. * +* imm5 = valeur de décallage entière sur 5 bits. * +* type = type de décallage à constituer. [OUT] * +* value = valeur pleine et entière à utiliser. [OUT] * +* * +* Description : Traduit la fonction 'DecodeImmShift'. * +* * +* Retour : Bilan de l'opération. * +* * +* Remarques : - * +* * +******************************************************************************/ + +bool armv7_decode_imm_shift(uint8_t type2, uint8_t imm5, SRType *type, uint32_t *value) +{ + bool result; /* Bilan à retourner */ + + result = true; + + switch (type2) + { + case b00: + *type = SRType_LSL; + *value = imm5; + break; + + case b01: + *type = SRType_LSR; + *value = (imm5 == 0 ? 32 : imm5); + break; + + case b10: + *type = SRType_ASR; + *value = (imm5 == 0 ? 32 : imm5); + break; + + case b11: + if (imm5 == 0) + { + *type = SRType_RRX; + *value = 1; + } + else + { + *type = SRType_ROR; + *value = imm5; + } + break; + + default: + result = false; + break; + + } + + return result; + +} + + +/****************************************************************************** +* * +* Paramètres : type2 = type de décallage encodé sur 2 bits. * +* type = type de décallage à constituer. [OUT] * +* * +* Description : Traduit la fonction 'DecodeRegShift'. * +* * +* Retour : Bilan de l'opération. * +* * +* Remarques : - * +* * +******************************************************************************/ + +bool armv7_decode_reg_shift(uint8_t type2, SRType *type) +{ + bool result; /* Bilan à retourner */ + + result = true; + + switch (type2) + { + case b00: + *type = SRType_LSL; + break; + + case b01: + *type = SRType_LSR; + break; + + case b10: + *type = SRType_ASR; + break; + + case b11: + *type = SRType_ROR; + break; + + default: + result = false; + break; + + } + + return result; + +} + + +/****************************************************************************** +* * +* Paramètres : x = valeur sur 32 bits maximum à traiter. * +* n = nombre de bits à prendre en compte. * +* type = type d'opération à mener. * +* amount = quantité liée à l'opération à mener. * +* carry = retenue enventuelle à utiliser / constituer. [OUT] * +* value = nouvelle valeur calculée. [OUT] * +* * +* Description : Traduit la fonction 'Shift_C'. * +* * +* Retour : Bilan de l'opération. * +* * +* Remarques : - * +* * +******************************************************************************/ + +bool armv7_shift_c(uint32_t x, unsigned int n, SRType type, unsigned int amount, bool *carry, uint32_t *value) +{ + bool result; /* Bilan final à retourner */ + + if (type == SRType_RRX && amount != 1) return false; + + if (amount == 0) + { + *value = x; + return true; + } + + result = true; /* Pour GCC... */ + + switch (type) + { + case SRType_LSL: + result = armv7_lsl_c(x, n, amount, carry, value); + break; + + case SRType_LSR: + result = armv7_lsr_c(x, n, amount, carry, value); + break; + + case SRType_ASR: + result = armv7_asr_c(x, n, amount, carry, value); + break; + + case SRType_ROR: + result = armv7_ror_c(x, n, amount, carry, value); + break; + + case SRType_RRX: + result = armv7_rrx_c(x, n, carry, value); + break; + + } + + return result; + +} + + +/****************************************************************************** +* * +* Paramètres : x = valeur sur 32 bits maximum à traiter. * +* n = nombre de bits à prendre en compte. * +* type = type d'opération à mener. * +* amount = quantité liée à l'opération à mener. * +* carry = retenue enventuelle à utiliser. * +* value = nouvelle valeur calculée. [OUT] * +* * +* Description : Traduit la fonction 'Shift'. * +* * +* Retour : Bilan de l'opération. * +* * +* Remarques : - * +* * +******************************************************************************/ + +bool armv7_shift(uint32_t x, unsigned int n, SRType type, unsigned int amount, bool carry, uint32_t *value) +{ + return armv7_shift_c(x, n, type, amount, &carry, value); + +} + + +/****************************************************************************** +* * +* Paramètres : x = valeur sur 32 bits maximum à traiter. * +* n = nombre de bits à prendre en compte. * +* i = taille finale à obtenir. * +* * +* Description : Traduit la fonction 'ZeroExtend'. * +* * +* Retour : Nouvelle valeur calculée. * +* * +* Remarques : - * +* * +******************************************************************************/ + +uint32_t armv7_zero_extend(uint32_t x, unsigned int n, unsigned int i) +{ + return x; + +} diff --git a/plugins/arm/v7/pseudo.h b/plugins/arm/v7/pseudo.h new file mode 100644 index 0000000..c918d57 --- /dev/null +++ b/plugins/arm/v7/pseudo.h @@ -0,0 +1,136 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * pseudo.h - prototypes pour l'implémentation des pseudo-fonctions de spécification + * + * Copyright (C) 2014-2017 Cyrille Bagard + * + * This file is part of Chrysalide. + * + * Chrysalide is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Chrysalide is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Foobar. If not, see . + */ + + +#ifndef _PLUGINS_ARM_V7_PSEUDO_H +#define _PLUGINS_ARM_V7_PSEUDO_H + + +#include +#include + + + +/** + * § A2.2.1 - Integer arithmetic + */ + + +/* Traduit la fonction 'LSL_C'. */ +bool armv7_lsl_c(uint32_t, unsigned int, unsigned int, bool *, uint32_t *); + +/* Traduit la fonction 'LSL'. */ +bool armv7_lsl(uint32_t, unsigned int, unsigned int, uint32_t *); + +/* Traduit la fonction 'LSR_C'. */ +bool armv7_lsr_c(uint32_t, unsigned int, unsigned int, bool *, uint32_t *); + +/* Traduit la fonction 'LSR'. */ +bool armv7_lsr(uint32_t, unsigned int, unsigned int, uint32_t *); + +/* Traduit la fonction 'ASR_C'. */ +bool armv7_asr_c(uint32_t, unsigned int, unsigned int, bool *, uint32_t *); + +/* Traduit la fonction 'ASR'. */ +bool armv7_asr(uint32_t, unsigned int, unsigned int, uint32_t *); + +/* Traduit la fonction 'ROR_C'. */ +bool armv7_ror_c(uint32_t, unsigned int, unsigned int, bool *, uint32_t *); + +/* Traduit la fonction 'ROR'. */ +bool armv7_ror(uint32_t, unsigned int, unsigned int, uint32_t *); + +/* Traduit la fonction 'RRX_C'. */ +bool armv7_rrx_c(uint32_t, unsigned int, bool *, uint32_t *); + +/* Traduit la fonction 'RRX'. */ +bool armv7_rrx(uint32_t, unsigned int, bool, uint32_t *); + + + +/** + * § A5.2.4 - Modified immediate constants in ARM instructions + */ + + +/* Traduit la fonction 'ARMExpandImm_C'. */ +bool armv7_arm_expand_imm_c(uint32_t, bool *, uint32_t *); + +/* Traduit la fonction 'ARMExpandImm'. */ +bool armv7_arm_expand_imm(uint32_t, uint32_t *); + + + +/** + * § A6.3.2 - Modified immediate constants in Thumb instructions + */ + + +/* Traduit la fonction 'ThumbExpandImm_C'. */ +bool armv7_thumb_expand_imm_c(uint32_t, bool *, uint32_t *); + +/* Traduit la fonction 'ThumbExpandImm'. */ +bool armv7_thumb_expand_imm(uint32_t, uint32_t *); + + + +/** + * § A8.4.3 - Pseudocode details of instruction-specified shifts and rotates + */ + + +typedef enum _SRType +{ + SRType_LSL, + SRType_LSR, + SRType_ASR, + SRType_ROR, + SRType_RRX + +} SRType; + + +/* Traduit la fonction 'DecodeImmShift'. */ +bool armv7_decode_imm_shift(uint8_t, uint8_t, SRType *, uint32_t *); + +/* Traduit la fonction 'DecodeRegShift'. */ +bool armv7_decode_reg_shift(uint8_t, SRType *); + +/* Traduit la fonction 'Shift_C'. */ +bool armv7_shift_c(uint32_t, unsigned int, SRType, unsigned int, bool *, uint32_t *); + +/* Traduit la fonction 'Shift'. */ +bool armv7_shift(uint32_t, unsigned int, SRType, unsigned int, bool, uint32_t *); + + + +/** + * § P.5.3 - Bitstring manipulation + */ + + +/* Traduit la fonction 'ZeroExtend'. */ +uint32_t armv7_zero_extend(uint32_t, unsigned int, unsigned int); + + + +#endif /* _PLUGINS_ARM_V7_PSEUDO_H */ diff --git a/plugins/arm/v7/register.c b/plugins/arm/v7/register.c new file mode 100644 index 0000000..3cd9e0f --- /dev/null +++ b/plugins/arm/v7/register.c @@ -0,0 +1,229 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * registers.c - aides auxiliaires relatives aux registres ARMv7 + * + * Copyright (C) 2014-2017 Cyrille Bagard + * + * This file is part of Chrysalide. + * + * Chrysalide is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Chrysalide is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Foobar. If not, see . + */ + + +#include "register.h" + + +#include + + +#include "../register-int.h" + + + +/* Représentation d'un registre ARMv7 (instance) */ +struct _GArmV7Register +{ + GArmRegister parent; /* Instance parente */ + +}; + + +/* Représentation d'un registre ARMv7 (classe) */ +struct _GArmV7RegisterClass +{ + GArmRegisterClass parent; /* Classe parente */ + +}; + + +#define MAX_REGNAME_LEN 8 + + +/* Initialise la classe des registres ARMv7. */ +static void g_armv7_register_class_init(GArmV7RegisterClass *); + +/* Initialise une instance de registre ARMv7. */ +static void g_armv7_register_init(GArmV7Register *); + +/* Supprime toutes les références externes. */ +static void g_armv7_register_dispose(GArmV7Register *); + +/* Procède à la libération totale de la mémoire. */ +static void g_armv7_register_finalize(GArmV7Register *); + +/* Traduit un registre en version humainement lisible. */ +static void g_armv7_register_print(const GArmV7Register *, GBufferLine *, AsmSyntax); + + + +/* Indique le type défini pour une représentation d'un registre ARMv7. */ +G_DEFINE_TYPE(GArmV7Register, g_armv7_register, G_TYPE_ARM_REGISTER); + + +/****************************************************************************** +* * +* Paramètres : klass = classe à initialiser. * +* * +* Description : Initialise la classe des registres ARMv7. * +* * +* Retour : - * +* * +* Remarques : - * +* * +******************************************************************************/ + +static void g_armv7_register_class_init(GArmV7RegisterClass *klass) +{ + GObjectClass *object_class; /* Autre version de la classe */ + GArchRegisterClass *reg_class; /* Classe de haut niveau */ + + object_class = G_OBJECT_CLASS(klass); + reg_class = G_ARCH_REGISTER_CLASS(klass); + + object_class->dispose = (GObjectFinalizeFunc/* ! */)g_armv7_register_dispose; + object_class->finalize = (GObjectFinalizeFunc)g_armv7_register_finalize; + + reg_class->print = (reg_print_fc)g_armv7_register_print; + +} + + +/****************************************************************************** +* * +* Paramètres : reg = instance à initialiser. * +* * +* Description : Initialise une instance de registre ARMv7. * +* * +* Retour : - * +* * +* Remarques : - * +* * +******************************************************************************/ + +static void g_armv7_register_init(GArmV7Register *reg) +{ + +} + + +/****************************************************************************** +* * +* Paramètres : reg = instance d'objet GLib à traiter. * +* * +* Description : Supprime toutes les références externes. * +* * +* Retour : - * +* * +* Remarques : - * +* * +******************************************************************************/ + +static void g_armv7_register_dispose(GArmV7Register *reg) +{ + G_OBJECT_CLASS(g_armv7_register_parent_class)->dispose(G_OBJECT(reg)); + +} + + +/****************************************************************************** +* * +* Paramètres : reg = instance d'objet GLib à traiter. * +* * +* Description : Procède à la libération totale de la mémoire. * +* * +* Retour : - * +* * +* Remarques : - * +* * +******************************************************************************/ + +static void g_armv7_register_finalize(GArmV7Register *reg) +{ + G_OBJECT_CLASS(g_armv7_register_parent_class)->finalize(G_OBJECT(reg)); + +} + + +/****************************************************************************** +* * +* Paramètres : reg = registre à transcrire. * +* line = ligne tampon où imprimer l'opérande donné. * +* syntax = type de représentation demandée. * +* * +* Description : Traduit un registre en version humainement lisible. * +* * +* Retour : - * +* * +* Remarques : - * +* * +******************************************************************************/ + +static void g_armv7_register_print(const GArmV7Register *reg, GBufferLine *line, AsmSyntax syntax) +{ + char key[MAX_REGNAME_LEN]; /* Mot clef principal */ + size_t klen; /* Taille de ce mot clef */ + + switch (G_ARM_REGISTER(reg)->index) + { + case 0 ... 12: + klen = snprintf(key, MAX_REGNAME_LEN, "r%hhu", G_ARM_REGISTER(reg)->index); + break; + case 13: + klen = snprintf(key, MAX_REGNAME_LEN, "sp"); + break; + case 14: + klen = snprintf(key, MAX_REGNAME_LEN, "lr"); + break; + case 15: + klen = snprintf(key, MAX_REGNAME_LEN, "pc"); + break; + case 16: + klen = snprintf(key, MAX_REGNAME_LEN, "cpsr"); + break; + case 17: + klen = snprintf(key, MAX_REGNAME_LEN, "spsr"); + break; + default: + klen = snprintf(key, MAX_REGNAME_LEN, "r??"); + break; + } + + g_buffer_line_append_text(line, BLC_ASSEMBLY, key, klen, RTT_REGISTER, NULL); + +} + + +/****************************************************************************** +* * +* Paramètres : index = indice du registre correspondant. * +* * +* Description : Crée une réprésentation de registre ARMv7. * +* * +* Retour : Adresse de la structure mise en place. * +* * +* Remarques : - * +* * +******************************************************************************/ + +GArmV7Register *g_armv7_register_new(uint8_t index) +{ + GArmV7Register *result; /* Structure à retourner */ + + result = g_object_new(G_TYPE_ARMV7_REGISTER, NULL); + + G_ARM_REGISTER(result)->index = index; + + return result; + +} diff --git a/plugins/arm/v7/register.h b/plugins/arm/v7/register.h new file mode 100644 index 0000000..6f09f5d --- /dev/null +++ b/plugins/arm/v7/register.h @@ -0,0 +1,57 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * registers.h - prototypes pour les aides auxiliaires relatives aux registres ARMv7 + * + * Copyright (C) 2014-2017 Cyrille Bagard + * + * This file is part of Chrysalide. + * + * Chrysalide is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Chrysalide is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Foobar. If not, see . + */ + + +#ifndef _PLUGINS_ARM_V7_REGISTER_H +#define _PLUGINS_ARM_V7_REGISTER_H + + +#include +#include +#include + + + +#define G_TYPE_ARMV7_REGISTER g_armv7_register_get_type() +#define G_ARMV7_REGISTER(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), g_armv7_register_get_type(), GArmV7Register)) +#define G_IS_ARMV7_REGISTER(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), g_armv7_register_get_type())) +#define G_ARMV7_REGISTER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), G_TYPE_ARMV7_REGISTER, GArmV7RegisterClass)) +#define G_IS_ARMV7_REGISTER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), G_TYPE_ARMV7_REGISTER)) +#define G_ARMV7_REGISTER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), G_TYPE_ARMV7_REGISTER, GArmV7RegisterClass)) + + +/* Représentation d'un registre ARMv7 (instance) */ +typedef struct _GArmV7Register GArmV7Register; + +/* Représentation d'un registre ARMv7 (classe) */ +typedef struct _GArmV7RegisterClass GArmV7RegisterClass; + + +/* Indique le type défini pour une représentation d'un registre ARMv7. */ +GType g_armv7_register_get_type(void); + +/* Crée une réprésentation de registre ARMv7. */ +GArmV7Register *g_armv7_register_new(uint8_t); + + + +#endif /* _PLUGINS_ARM_V7_REGISTER_H */ diff --git a/plugins/arm/v7/simd.c b/plugins/arm/v7/simd.c new file mode 100644 index 0000000..0fdca7d --- /dev/null +++ b/plugins/arm/v7/simd.c @@ -0,0 +1,1541 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * simd.c - désassemblage des instructions ARMv7 SIMD + * + * Copyright (C) 2016-2017 Cyrille Bagard + * + * This file is part of Chrysalide. + * + * Chrysalide is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Chrysalide is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Foobar. If not, see . + */ + + +#include "simd.h" + + +#include + + +#include +#include + + +//#include "opcodes/simd_opcodes.h" +#include "opcodes/opcodes_tmp_simd.h" + + + +/* Désassemble une instruction ARMv7 liées au chapitre A7.4.1. */ +static GArchInstruction *process_armv7_simd_three_registers_of_the_same_length(uint32_t, bool); + +/* Désassemble une instruction ARMv7 liées au chapitre A7.4.2. */ +static GArchInstruction *process_armv7_simd_three_registers_of_different_lengths(uint32_t, bool); + +/* Désassemble une instruction ARMv7 liées au chapitre A7.4.3. */ +static GArchInstruction *process_armv7_simd_two_registers_and_a_scalar(uint32_t, bool); + +/* Désassemble une instruction ARMv7 liées au chapitre A7.4.4. */ +static GArchInstruction *process_armv7_simd_two_registers_and_a_shift_amount(uint32_t, bool); + +/* Désassemble une instruction ARMv7 liées au chapitre A7.4.5. */ +static GArchInstruction *process_armv7_simd_two_registers_miscellaneous(uint32_t, bool); + +/* Désassemble une instruction ARMv7 liées au chapitre A7.4.6. */ +static GArchInstruction *process_armv7_simd_one_register_and_a_modified_immediate_value(uint32_t, bool); + + + +/****************************************************************************** +* * +* Paramètres : raw = donnée brute de 16 bits à désassembler. * +* arm = précise si l'encodage est en mode ARM ou Thumb. * +* * +* Description : Désassemble une instruction ARMv7 liées au chapitre A7.4. * +* * +* Retour : Instruction mise en place ou NULL en cas d'échec. * +* * +* Remarques : - * +* * +******************************************************************************/ + +GArchInstruction *process_armv7_simd_advanced_simd_data_processing_instructions(uint32_t raw, bool arm) +{ + GArchInstruction *result; /* Instruction à renvoyer */ + uint32_t u; /* Champ 'u' à retrouver */ + uint32_t a; /* Champ 'a' à retrouver */ + uint32_t b; /* Champ 'b' à retrouver */ + uint32_t c; /* Champ 'c' à retrouver */ + + /** + * Suit les directives de : + * § A7.4 Advanced SIMD data-processing instructions + */ + + if (arm) + { + if ((raw & 0xfe000000) != 0xf2000000) return NULL; + } + else + { + if ((raw & 0xef000000) != 0xef000000) return NULL; + } + + result = NULL; + + if (arm) + { + u = (raw >> 24) & b1; + a = (raw >> 19) & b11111; + b = (raw >> 8) & b1111; + c = (raw >> 4) & b1111; + } + else + { + u = (raw >> 28) & b1; + a = (raw >> 19) & b11111; + b = (raw >> 8) & b1111; + c = (raw >> 4) & b1111; + } + + if ((a & b10000) == b00000) + result = process_armv7_simd_three_registers_of_the_same_length(raw, arm); + + else if ((a & b10111) == b10000 && (c & b1001) == b0001) + result = process_armv7_simd_one_register_and_a_modified_immediate_value(raw, arm); + + else if ((a & b10111) == b10001 && (c & b1001) == b0001) + result = process_armv7_simd_two_registers_and_a_shift_amount(raw, arm); + + else if ((a & b10110) == b10010 && (c & b1001) == b0001) + result = process_armv7_simd_two_registers_and_a_shift_amount(raw, arm); + + else if ((a & b10100) == b10100 && (c & b1001) == b0001) + result = process_armv7_simd_two_registers_and_a_shift_amount(raw, arm); + + else if ((a & b10000) == b10000 && (c & b1001) == b1001) + result = process_armv7_simd_two_registers_and_a_shift_amount(raw, arm); + + else if ((a & b10100) == b10000 && (c & b0101) == b0000) + result = process_armv7_simd_three_registers_of_different_lengths(raw, arm); + + else if ((a & b10110) == b10100 && (c & b0101) == b0000) + result = process_armv7_simd_three_registers_of_different_lengths(raw, arm); + + else if ((a & b10100) == b10000 && (c & b0101) == b0100) + result = process_armv7_simd_two_registers_and_a_scalar(raw, arm); + + else if ((a & b10110) == b10100 && (c & b0101) == b0100) + result = process_armv7_simd_two_registers_and_a_scalar(raw, arm); + + else if (u == b0 && (a & b10110) == b10110 && (c & b0001) == b0000) + result = armv7_read_simd_instr_vext(raw, arm); + + else if (u == b1 && (a & b10110) == b10110) + { + if ((b & b1000) == b0000 && (c & b0001) == b0000) + result = process_armv7_simd_two_registers_miscellaneous(raw, arm); + + else if ((b & b1100) == b1000 && (c & b0001) == b0000) + result = armv7_read_simd_instr_vtbl_vtbx(raw, arm); + + else if (b == b1100 && (c & b1001) == b0000) + result = armv7_read_simd_instr_vdup_scalar(raw, arm); + + } + + return result; + +} + + +/****************************************************************************** +* * +* Paramètres : raw = donnée brute de 16 bits à désassembler. * +* arm = précise si l'encodage est en mode ARM ou Thumb. * +* * +* Description : Désassemble une instruction ARMv7 liées au chapitre A7.4.1. * +* * +* Retour : Instruction mise en place ou NULL en cas d'échec. * +* * +* Remarques : - * +* * +******************************************************************************/ + +static GArchInstruction *process_armv7_simd_three_registers_of_the_same_length(uint32_t raw, bool arm) +{ + GArchInstruction *result; /* Instruction à renvoyer */ + uint32_t u; /* Champ 'u' à retrouver */ + uint32_t c; /* Champ 'c' à retrouver */ + uint32_t a; /* Champ 'a' à retrouver */ + uint32_t b; /* Champ 'b' à retrouver */ + + /** + * Suit les directives de : + * § A7.4.1 Three registers of the same length + */ + + if (arm) + { + if ((raw & 0xfe800000) != 0xf2000000) return NULL; + } + else + { + if ((raw & 0xef800000) != 0xef000000) return NULL; + } + + result = NULL; + + if (arm) + { + u = (raw >> 24) & b1; + c = (raw >> 20) & b11; + a = (raw >> 8) & b1111; + b = (raw >> 4) & b1; + } + else + { + u = (raw >> 28) & b1; + c = (raw >> 20) & b11; + a = (raw >> 8) & b1111; + b = (raw >> 4) & b1; + } + + if (a == b0000) + { + if (b == b0) + result = armv7_read_simd_instr_vhadd_vhsub(raw, arm); + + else/* if (b == b1)*/ + result = armv7_read_simd_instr_vqadd(raw, arm); + + } + + else if (a == b0001) + { + if (b == b0) + result = armv7_read_simd_instr_vrhadd(raw, arm); + + else/* if (b == b1)*/ + { + if (u == b0) + switch (c) + { + case b00: + result = armv7_read_simd_instr_vand_register(raw, arm); + break; + + case b01: + result = armv7_read_simd_instr_vbic_register(raw, arm); + break; + + case b10: + /* Cf. vmov_register aussi */ + result = armv7_read_simd_instr_vorr_register(raw, arm); + break; + + case b11: + result = armv7_read_simd_instr_vorn_register(raw, arm); + break; + + } + + else/* if (u == b1)*/ + switch (c) + { + case b00: + result = armv7_read_simd_instr_veor(raw, arm); + break; + + case b01: + result = armv7_read_simd_instr_vbif_vbit_vbsl(raw, arm); + break; + + case b10: + result = armv7_read_simd_instr_vbif_vbit_vbsl(raw, arm); + break; + + case b11: + result = armv7_read_simd_instr_vbif_vbit_vbsl(raw, arm); + break; + + } + + } + + } + + else if (a == b0010) + { + if (b == b0) + result = armv7_read_simd_instr_vhadd_vhsub(raw, arm); + + else/* if (b == b1)*/ + result = armv7_read_simd_instr_vqsub(raw, arm); + + } + + else if (a == b0011) + { + if (b == b0) + result = armv7_read_simd_instr_vcgt_register(raw, arm); + + else/* if (b == b1)*/ + result = armv7_read_simd_instr_vcge_register(raw, arm); + + } + + else if (a == b0100) + { + if (b == b0) + result = armv7_read_simd_instr_vshl_register(raw, arm); + + else/* if (b == b1)*/ + result = armv7_read_simd_instr_vqshl_register(raw, arm); + + } + + else if (a == b0101) + { + if (b == b0) + result = armv7_read_simd_instr_vrshl(raw, arm); + + else/* if (b == b1)*/ + result = armv7_read_simd_instr_vqrshl(raw, arm); + + } + + else if (a == b0110) + result = armv7_read_simd_instr_vmax_vmin_integer(raw, arm); + + else if (a == b0111) + { + if (b == b0) + result = armv7_read_simd_instr_vabd_vabdl_integer(raw, arm); + + else/* if (b == b1)*/ + result = armv7_read_simd_instr_vaba_vabal(raw, arm); + + } + + else if (a == b1000) + { + if (b == b0) + { + if (u == b0) + result = armv7_read_simd_instr_vadd_integer(raw, arm); + + else/* if (u == b1)*/ + result = armv7_read_simd_instr_vsub_integer(raw, arm); + + } + + else/* if (b == b1)*/ + { + if (u == b0) + result = armv7_read_simd_instr_vtst(raw, arm); + + else/* if (u == b1)*/ + result = armv7_read_simd_instr_vceq_register(raw, arm); + + } + + } + + else if (a == b1001) + { + if (b == b0) + result = armv7_read_simd_instr_vmla_vmlal_vmls_vmlsl_integer(raw, arm); + + else/* if (b == b1)*/ + result = armv7_read_simd_instr_vmul_vmull_integer_and_polynomial(raw, arm); + + } + + else if (a == b1010) + result = armv7_read_simd_instr_vpmax_vpmin_integer(raw, arm); + + else if (a == b1011) + { + if (b == b0) + { + if (u == b0) + result = armv7_read_simd_instr_vqdmulh(raw, arm); + + else/* if (u == b1)*/ + result = armv7_read_simd_instr_vqrdmulh(raw, arm); + + } + + else/* if (b == b1)*/ + { + if (u == b0) + result = armv7_read_simd_instr_vpadd_integer(raw, arm); + + } + + } + + else if (a == b1100) + { + if (b == b1 && u == b0) + result = armv7_read_simd_instr_vfma_vfms(raw, arm); + + } + + else if (a == b1101) + { + if (b == b0) + { + if (u == b0) + { + if ((c & b10) == b00) + result = armv7_read_simd_instr_vadd_floating_point(raw, arm); + + else/* if ((c & b10) == b10)*/ + result = armv7_read_simd_instr_vsub_floating_point(raw, arm); + + } + + else/* if (u == b1)*/ + { + if ((c & b10) == b00) + result = armv7_read_simd_instr_vpadd_floating_point(raw, arm); + + else/* if ((c & b10) == b10)*/ + result = armv7_read_simd_instr_vabd_floating_point(raw, arm); + + } + + } + + else/* if (b == b1)*/ + { + if (u == b0) + result = armv7_read_simd_instr_vmla_vmls_floating_point(raw, arm); + + else/* if (u == b1)*/ + { + if ((c & b10) == b00) + result = armv7_read_simd_instr_vmul_floating_point(raw, arm); + + } + + } + + } + + else if (a == b1110) + { + if (b == b0) + { + if (u == b0) + { + if ((c & b10) == b00) + result = armv7_read_simd_instr_vceq_register(raw, arm); + + } + + else/* if (u == b1)*/ + { + if ((c & b10) == b00) + result = armv7_read_simd_instr_vcge_register(raw, arm); + + else/* if ((c & b10) == b10)*/ + result = armv7_read_simd_instr_vcgt_register(raw, arm); + + } + + } + + else/* if (b == b1)*/ + { + if (u == b1) + result = armv7_read_simd_instr_vacge_vacgt_vacle_vaclt(raw, arm); + + } + + } + + else if (a == b1111) + { + if (b == b0) + { + if (u == b0) + result = armv7_read_simd_instr_vmax_vmin_floating_point(raw, arm); + + else/* if (u == b1)*/ + result = armv7_read_simd_instr_vpmax_vpmin_floating_point(raw, arm); + + } + + else/* if (b == b1)*/ + { + if (u == b0) + { + if ((c & b10) == b00) + result = armv7_read_simd_instr_vrecps(raw, arm); + + else/* if ((c & b10) == b10)*/ + result = armv7_read_simd_instr_vrsqrts(raw, arm); + + } + + } + + } + + return result; + +} + + +/****************************************************************************** +* * +* Paramètres : raw = donnée brute de 16 bits à désassembler. * +* arm = précise si l'encodage est en mode ARM ou Thumb. * +* * +* Description : Désassemble une instruction ARMv7 liées au chapitre A7.4.2. * +* * +* Retour : Instruction mise en place ou NULL en cas d'échec. * +* * +* Remarques : - * +* * +******************************************************************************/ + +static GArchInstruction *process_armv7_simd_three_registers_of_different_lengths(uint32_t raw, bool arm) +{ + GArchInstruction *result; /* Instruction à renvoyer */ + uint32_t u; /* Champ 'u' à retrouver */ + uint32_t a; /* Champ 'a' à retrouver */ + + /** + * Suit les directives de : + * § A7.4.2 Three registers of different lengths + */ + + if (arm) + { + if ((raw & 0xfe800050) != 0xf2800000) return NULL; + } + else + { + if ((raw & 0xef800050) != 0xef800000) return NULL; + } + + result = NULL; + + if (arm) + { + u = (raw >> 24) & b1; + a = (raw >> 8) & b1111; + } + else + { + u = (raw >> 28) & b1; + a = (raw >> 8) & b1111; + } + + if ((a & b1110) == b0000) + result = armv7_read_simd_instr_vaddl_vaddw(raw, arm); + + else if ((a & b1110) == b0010) + result = armv7_read_simd_instr_vsubl_vsubw(raw, arm); + + else if (a == b0100) + { + if (u == b0) + result = armv7_read_simd_instr_vaddhn(raw, arm); + + else/* if (u == b1)*/ + result = armv7_read_simd_instr_vraddhn(raw, arm); + + } + + else if (a == b0101) + result = armv7_read_simd_instr_vaba_vabal(raw, arm); + + else if (a == b0110) + { + if (u == b0) + result = armv7_read_simd_instr_vsubhn(raw, arm); + + else/* if (u == b1)*/ + result = armv7_read_simd_instr_vrsubhn(raw, arm); + + } + + else if (a == b0111) + result = armv7_read_simd_instr_vabd_vabdl_integer(raw, arm); + + else if ((a & b1101) == b1000) + result = armv7_read_simd_instr_vmla_vmlal_vmls_vmlsl_integer(raw, arm); + + else if ((a & b1101) == b1001) + { + if (u == b0) + result = armv7_read_simd_instr_vqdmlal_vqdmlsl(raw, arm); + + } + + else if (a == b1100) + result = armv7_read_simd_instr_vmul_vmull_integer_and_polynomial(raw, arm); + + else if (a == b1101) + { + if (u == b0) + result = armv7_read_simd_instr_vqdmull(raw, arm); + + } + + else if (a == b1110) + result = armv7_read_simd_instr_vmul_vmull_integer_and_polynomial(raw, arm); + + return result; + +} + + +/****************************************************************************** +* * +* Paramètres : raw = donnée brute de 16 bits à désassembler. * +* arm = précise si l'encodage est en mode ARM ou Thumb. * +* * +* Description : Désassemble une instruction ARMv7 liées au chapitre A7.4.3. * +* * +* Retour : Instruction mise en place ou NULL en cas d'échec. * +* * +* Remarques : - * +* * +******************************************************************************/ + +static GArchInstruction *process_armv7_simd_two_registers_and_a_scalar(uint32_t raw, bool arm) +{ + GArchInstruction *result; /* Instruction à renvoyer */ + uint32_t u; /* Champ 'u' à retrouver */ + uint32_t a; /* Champ 'a' à retrouver */ + + /** + * Suit les directives de : + * § A7.4.3 Two registers and a scalar + */ + + if (arm) + { + if ((raw & 0xfe800050) != 0xf2800040) return NULL; + } + else + { + if ((raw & 0xef800050) != 0xef800040) return NULL; + } + + result = NULL; + + if (arm) + { + u = (raw >> 24) & b1; + a = (raw >> 8) & b1111; + } + else + { + u = (raw >> 28) & b1; + a = (raw >> 8) & b1111; + } + + if ((a & b1010) == b0000) + result = armv7_read_simd_instr_vmla_vmlal_vmls_vmlsl_by_scalar(raw, arm); + + else if ((a & b1010) == b0010) + result = armv7_read_simd_instr_vmla_vmlal_vmls_vmlsl_by_scalar(raw, arm); + + else if ((a & b1011) == b0011 && u == b0) + result = armv7_read_simd_instr_vqdmlal_vqdmlsl(raw, arm); + + else if ((a & b1110) == b1000) + result = armv7_read_simd_instr_vmul_vmull_by_scalar(raw, arm); + + else if (a == b1010) + result = armv7_read_simd_instr_vmul_vmull_by_scalar(raw, arm); + + else if (a == b1011 && u == b0) + result = armv7_read_simd_instr_vqdmull(raw, arm); + + else if (a == b1100) + result = armv7_read_simd_instr_vqdmulh(raw, arm); + + else if (a == b1101) + result = armv7_read_simd_instr_vqrdmulh(raw, arm); + + return result; + +} + + +/****************************************************************************** +* * +* Paramètres : raw = donnée brute de 16 bits à désassembler. * +* arm = précise si l'encodage est en mode ARM ou Thumb. * +* * +* Description : Désassemble une instruction ARMv7 liées au chapitre A7.4.4. * +* * +* Retour : Instruction mise en place ou NULL en cas d'échec. * +* * +* Remarques : - * +* * +******************************************************************************/ + +static GArchInstruction *process_armv7_simd_two_registers_and_a_shift_amount(uint32_t raw, bool arm) +{ + GArchInstruction *result; /* Instruction à renvoyer */ + uint32_t u; /* Champ 'u' à retrouver */ + uint32_t a; /* Champ 'a' à retrouver */ + uint32_t l; /* Champ 'l' à retrouver */ + uint32_t b; /* Champ 'b' à retrouver */ + + /** + * Suit les directives de : + * § A7.4.4 Two registers and a shift amount + */ + + if (arm) + { + if ((raw & 0xfe800010) != 0xf2800010) return NULL; + } + else + { + if ((raw & 0xef800010) != 0xef800010) return NULL; + } + + result = NULL; + + if (arm) + { + u = (raw >> 24) & b1; + a = (raw >> 8) & b1111; + l = (raw >> 7) & b1; + b = (raw >> 6) & b1; + } + else + { + u = (raw >> 28) & b1; + a = (raw >> 8) & b1111; + l = (raw >> 7) & b1; + b = (raw >> 6) & b1; + } + + if (a == b0000) + result = armv7_read_simd_instr_vshr(raw, arm); + + else if (a == b0001) + result = armv7_read_simd_instr_vsra(raw, arm); + + else if (a == b0010) + result = armv7_read_simd_instr_vrshr(raw, arm); + + else if (a == b0011) + result = armv7_read_simd_instr_vrsra(raw, arm); + + else if (a == b0100 && u == b1) + result = armv7_read_simd_instr_vsri(raw, arm); + + else if (a == b0101) + { + if (u == b0) + result = armv7_read_simd_instr_vshl_immediate(raw, arm); + + else/* if (u == b1)*/ + result = armv7_read_simd_instr_vsli(raw, arm); + + } + + else if ((a & b1110) == b0110) + result = armv7_read_simd_instr_vqshl_vqshlu_immediate(raw, arm); + + else if (a == b1000) + { + if (u == b0) + { + if (b == b0 && l == b0) + result = armv7_read_simd_instr_vshrn(raw, arm); + + else if (b == b1 && l == b0) + result = armv7_read_simd_instr_vrshrn(raw, arm); + + } + else/* if (u == b1)*/ + { + if (b == b0 && l == b0) + result = armv7_read_simd_instr_vqshrn_vqshrun(raw, arm); + + else if (b == b1 && l == b0) + result = armv7_read_simd_instr_vqrshrn_vqrshrun(raw, arm); + + } + + } + + else if (a == b1001) + { + if (b == b0 && l == b0) + result = armv7_read_simd_instr_vqshrn_vqshrun(raw, arm); + + else if (b == b1 && l == b0) + result = armv7_read_simd_instr_vqrshrn_vqrshrun(raw, arm); + + } + + else if (a == b1010 && b == b0 && l == b0) + { + result = armv7_read_simd_instr_vshll(raw, arm); + + /* ??? */ + if (result == NULL) + result = armv7_read_simd_instr_vmovl(raw, arm); + + } + + else if ((a & b1110) == b1110 && l == b0) + result = armv7_read_simd_instr_vcvt_between_floating_point_and_fixed_point_advanced_simd(raw, arm); + + return result; + +} + + +/****************************************************************************** +* * +* Paramètres : raw = donnée brute de 16 bits à désassembler. * +* arm = précise si l'encodage est en mode ARM ou Thumb. * +* * +* Description : Désassemble une instruction ARMv7 liées au chapitre A7.4.5. * +* * +* Retour : Instruction mise en place ou NULL en cas d'échec. * +* * +* Remarques : - * +* * +******************************************************************************/ + +static GArchInstruction *process_armv7_simd_two_registers_miscellaneous(uint32_t raw, bool arm) +{ + GArchInstruction *result; /* Instruction à renvoyer */ + uint32_t a; /* Champ 'a' à retrouver */ + uint32_t b; /* Champ 'b' à retrouver */ + + /** + * Suit les directives de : + * § A7.4.5 Two registers, miscellaneous + */ + + if (arm) + { + if ((raw & 0xffb00810) != 0xf3b00000) return NULL; + } + else + { + if ((raw & 0xffb00810) != 0xffb00000) return NULL; + } + + result = NULL; + + a = (raw >> 16) & b11; + b = (raw >> 6) & b11111; + + if (a == b00) + { + if ((b & b11110) == b00000) + result = armv7_read_simd_instr_vrev16_vrev32_vrev64(raw, arm); + + else if ((b & b11110) == b00010) + result = armv7_read_simd_instr_vrev16_vrev32_vrev64(raw, arm); + + else if ((b & b11110) == b00100) + result = armv7_read_simd_instr_vrev16_vrev32_vrev64(raw, arm); + + else if ((b & b11100) == b01000) + result = armv7_read_simd_instr_vpaddl(raw, arm); + + else if ((b & b11110) == b10000) + result = armv7_read_simd_instr_vcls(raw, arm); + + else if ((b & b11110) == b10010) + result = armv7_read_simd_instr_vclz(raw, arm); + + else if ((b & b11110) == b10100) + result = armv7_read_simd_instr_vcnt(raw, arm); + + else if ((b & b11110) == b10110) + result = armv7_read_simd_instr_vmvn_register(raw, arm); + + else if ((b & b11100) == b11000) + result = armv7_read_simd_instr_vpadal(raw, arm); + + else if ((b & b11110) == b11100) + result = armv7_read_simd_instr_vqabs(raw, arm); + + else if ((b & b11110) == b11110) + result = armv7_read_simd_instr_vqneg(raw, arm); + + } + + else if (a == b01) + { + if ((b & b01110) == b00000) + result = armv7_read_simd_instr_vcgt_immediate_0(raw, arm); + + else if ((b & b01110) == b00010) + result = armv7_read_simd_instr_vcge_immediate_0(raw, arm); + + else if ((b & b01110) == b00100) + result = armv7_read_simd_instr_vceq_immediate_0(raw, arm); + + else if ((b & b01110) == b00110) + result = armv7_read_simd_instr_vcle_immediate_0(raw, arm); + + else if ((b & b01110) == b01000) + result = armv7_read_simd_instr_vclt_immediate_0(raw, arm); + + else if ((b & b01110) == b01100) + result = armv7_read_simd_instr_vabs(raw, arm); + + else if ((b & b01110) == b01110) + result = armv7_read_simd_instr_vneg(raw, arm); + + } + + return result; + +} + + +/****************************************************************************** +* * +* Paramètres : raw = donnée brute de 16 bits à désassembler. * +* arm = précise si l'encodage est en mode ARM ou Thumb. * +* * +* Description : Désassemble une instruction ARMv7 liées au chapitre A7.4.6. * +* * +* Retour : Instruction mise en place ou NULL en cas d'échec. * +* * +* Remarques : - * +* * +******************************************************************************/ + +static GArchInstruction *process_armv7_simd_one_register_and_a_modified_immediate_value(uint32_t raw, bool arm) +{ + GArchInstruction *result; /* Instruction à renvoyer */ + uint32_t cmode; /* Champ 'cmode' à retrouver */ + uint32_t op; /* Champ 'op' à retrouver */ + + /** + * Suit les directives de : + * § A7.4.6 One register and a modified immediate value + */ + + if (arm) + { + if ((raw & 0xfeb80090) != 0xf2800010) return NULL; + } + else + { + if ((raw & 0xefb80090) != 0xef800010) return NULL; + } + + result = NULL; + + cmode = (raw >> 8) & b1111; + op = (raw >> 5) & b1; + + if (op == b0) + { + if ((cmode & b1001) == b0000) + result = armv7_read_simd_instr_vmov_immediate(raw, arm); + + else if ((cmode & b1001) == b0001) + result = armv7_read_simd_instr_vorr_immediate(raw, arm); + + else if ((cmode & b1101) == b1000) + result = armv7_read_simd_instr_vmov_immediate(raw, arm); + + else if ((cmode & b1101) == b1001) + result = armv7_read_simd_instr_vorr_immediate(raw, arm); + + else if ((cmode & b1100) == b1100) + result = armv7_read_simd_instr_vmov_immediate(raw, arm); + + } + + else/* if (op == b1)*/ + { + if ((cmode & b1001) == b0000) + result = armv7_read_simd_instr_vmvn_immediate(raw, arm); + + else if ((cmode & b1001) == b0001) + result = armv7_read_simd_instr_vbic_immediate(raw, arm); + + else if ((cmode & b1101) == b1000) + result = armv7_read_simd_instr_vmvn_immediate(raw, arm); + + else if ((cmode & b1101) == b1001) + result = armv7_read_simd_instr_vbic_immediate(raw, arm); + + else if ((cmode & b1110) == b1100) + result = armv7_read_simd_instr_vmvn_immediate(raw, arm); + + else if (cmode == b1110) + result = armv7_read_simd_instr_vmov_immediate(raw, arm); + + else if (cmode == b1111) + result = g_undef_instruction_new(IBS_UNDEFINED); + + } + + return result; + +} + + +/****************************************************************************** +* * +* Paramètres : raw = donnée brute de 16 bits à désassembler. * +* arm = précise si l'encodage est en mode ARM ou Thumb. * +* * +* Description : Désassemble une instruction ARMv7 liées au chapitre A7.5. * +* * +* Retour : Instruction mise en place ou NULL en cas d'échec. * +* * +* Remarques : - * +* * +******************************************************************************/ + +GArchInstruction *process_armv7_simd_floating_point_data_processing_instructions(uint32_t raw, bool arm) +{ + GArchInstruction *result; /* Instruction à renvoyer */ + uint32_t opc1; /* Champ 'opc1' à retrouver */ + uint32_t opc2; /* Champ 'opc2' à retrouver */ + uint32_t opc3; /* Champ 'opc3' à retrouver */ + + /** + * Suit les directives de : + * § A7.5 Floating-point data-processing instructions + */ + + if (arm) + { + if ((raw & 0x0f000e10) != 0xee000a00) return NULL; + } + else + { + if ((raw & 0xef000e10) != 0x0e000a00) return NULL; + } + + result = NULL; + + opc1 = (raw >> 20) & b1111; + opc2 = (raw >> 16) & b1111; + opc3 = (raw >> 6) & b11; + + + if ((opc1 & b1011) == b0000) + result = armv7_read_simd_instr_vmla_vmls_floating_point(raw, arm); + + else if ((opc1 & b1011) == b0001) + result = armv7_read_simd_instr_vnmla_vnmls_vnmul(raw, arm); + + else if ((opc1 & b1011) == b0010) + { + if ((opc3 & b01) == b01) + result = armv7_read_simd_instr_vnmla_vnmls_vnmul(raw, arm); + + else/* if ((opc3 & b01) == b00)*/ + result = armv7_read_simd_instr_vmul_floating_point(raw, arm); + + } + + else if ((opc1 & b1011) == b0011) + { + if ((opc3 & b01) == b00) + result = armv7_read_simd_instr_vadd_floating_point(raw, arm); + + else/* if ((opc3 & b01) == b01)*/ + result = armv7_read_simd_instr_vsub_floating_point(raw, arm); + + } + + else if ((opc1 & b1011) == b1000) + { + if ((opc3 & b01) == b00) + result = armv7_read_simd_instr_vdiv(raw, arm); + + } + + else if ((opc1 & b1011) == b1001) + result = armv7_read_simd_instr_vfnma_vfnms(raw, arm); + + else if ((opc1 & b1011) == b1010) + result = armv7_read_simd_instr_vfma_vfms(raw, arm); + + else if ((opc1 & b1011) == b1011) + { + if ((opc3 & b01) == b00) + result = armv7_read_simd_instr_vmov_immediate(raw, arm); + + else if (opc2 == b0000) + { + if (opc3 == b01) + result = armv7_read_simd_instr_vmov_register(raw, arm); + + else if (opc3 == b11) + result = armv7_read_simd_instr_vabs(raw, arm); + + } + + else if (opc2 == b0001) + { + if (opc3 == b01) + result = armv7_read_simd_instr_vneg(raw, arm); + + else if (opc3 == b11) + result = armv7_read_simd_instr_vsqrt(raw, arm); + + } + + else if ((opc2 & b1110) == b0010 && (opc3 & b01) == b01) + result = armv7_read_simd_instr_vcvtb_vcvtt(raw, arm); + + else if ((opc2 & b1110) == b0100 && (opc3 & b01) == b01) + result = armv7_read_simd_instr_vcmp_vcmpe(raw, arm); + + else if (opc2 == b0111 && opc3 == b11) + result = armv7_read_simd_instr_vcvt_between_double_precision_and_single_precision(raw, arm); + + else if (opc2 == b1000 && (opc3 & b01) == b01) + result = armv7_read_simd_instr_vcvt_vcvtr_between_floating_point_and_integer_floating_point(raw, arm); + + else if ((opc2 & b1110) == b1010 && (opc3 & b01) == b01) + result = armv7_read_simd_instr_vcvt_between_floating_point_and_fixed_point_floating_point(raw, arm); + + else if ((opc2 & b1110) == b1100 && (opc3 & b01) == b01) + result = armv7_read_simd_instr_vcvt_vcvtr_between_floating_point_and_integer_floating_point(raw, arm); + + else if ((opc2 & b1110) == b1110 && (opc3 & b01) == b01) + result = armv7_read_simd_instr_vcvt_between_floating_point_and_fixed_point_floating_point(raw, arm); + + } + + return result; + +} + + +/****************************************************************************** +* * +* Paramètres : raw = donnée brute de 16 bits à désassembler. * +* arm = précise si l'encodage est en mode ARM ou Thumb. * +* * +* Description : Désassemble une instruction ARMv7 liées au chapitre A7.6. * +* * +* Retour : Instruction mise en place ou NULL en cas d'échec. * +* * +* Remarques : - * +* * +******************************************************************************/ + +GArchInstruction *process_armv7_simd_extension_register_load_store_instructions(uint32_t raw, bool arm) +{ + GArchInstruction *result; /* Instruction à renvoyer */ + uint32_t opcode; /* Champ 'opcode' à retrouver */ + uint32_t rn; /* Champ 'rn' à retrouver */ + + /** + * Suit les directives de : + * § A7.6 Extension register load/store instructions + */ + + if (arm) + { + if ((raw & 0x0e000e00) != 0x0c000a00) return NULL; + } + else + { + if ((raw & 0xee000e00) != 0xec000a00) return NULL; + } + + result = NULL; + + opcode = (raw >> 20) & b11111; + rn = (raw >> 16) & b1111; + + if ((opcode & b11110) == b00100) + result = process_armv7_simd_64_bit_transfers_between_arm_core_and_extension_registers(raw, arm); + + else if ((opcode & b11011) == b01000) + result = armv7_read_simd_instr_vstm(raw, arm); + + else if ((opcode & b11011) == b01010) + result = armv7_read_simd_instr_vstm(raw, arm); + + else if ((opcode & b10011) == b10000) + result = armv7_read_simd_instr_vstr(raw, arm); + + else if ((opcode & b11011) == b10010) + { + if (rn != b1101) + result = armv7_read_simd_instr_vstm(raw, arm); + + else/* if (rn == b1101)*/ + result = armv7_read_simd_instr_vpush(raw, arm); + + } + + else if ((opcode & b11011) == b01001) + result = armv7_read_simd_instr_vldm(raw, arm); + + else if ((opcode & b11011) == b01011) + { + if (rn != 1101) + result = armv7_read_simd_instr_vldm(raw, arm); + + else/* if (rn == 1101)*/ + result = armv7_read_simd_instr_vpop(raw, arm); + + } + + else if ((opcode & b10011) == b10001) + result = armv7_read_simd_instr_vldr(raw, arm); + + else if ((opcode & b11011) == b10011) + result = armv7_read_simd_instr_vldm(raw, arm); + + return result; + +} + + +/****************************************************************************** +* * +* Paramètres : raw = donnée brute de 16 bits à désassembler. * +* arm = précise si l'encodage est en mode ARM ou Thumb. * +* * +* Description : Désassemble une instruction ARMv7 liées au chapitre A7.7. * +* * +* Retour : Instruction mise en place ou NULL en cas d'échec. * +* * +* Remarques : - * +* * +******************************************************************************/ + +GArchInstruction *process_armv7_simd_advanced_simd_element_or_structure_load_store_instructions(uint32_t raw, bool arm) +{ + GArchInstruction *result; /* Instruction à renvoyer */ + uint32_t a; /* Champ 'a' à retrouver */ + uint32_t l; /* Champ 'l' à retrouver */ + uint32_t b; /* Champ 'b' à retrouver */ + + /** + * Suit les directives de : + * § A7.7 Advanced SIMD element or structure load/store instructions + */ + + if (arm) + { + if ((raw & 0xff100000) != 0xf4000000) return NULL; + } + else + { + if ((raw & 0xff100000) != 0xf9000000) return NULL; + } + + result = NULL; + + a = (raw >> 23) & b1; + l = (raw >> 21) & b1; + b = (raw >> 8) & b1111; + + if (l == b0) + { + if (a == b0) + { + if (b == b0010) + result = armv7_read_simd_instr_vst1_multiple_single_elements(raw, arm); + + else if ((b & b1110) == b0110) + result = armv7_read_simd_instr_vst1_multiple_single_elements(raw, arm); + + else if (b == b1010) + result = armv7_read_simd_instr_vst1_multiple_single_elements(raw, arm); + + else if (b == b0011) + result = armv7_read_simd_instr_vst2_multiple_2_element_structures(raw, arm); + + else if ((b & b1110) == b1000) + result = armv7_read_simd_instr_vst2_multiple_2_element_structures(raw, arm); + + else if ((b & b1110) == b0100) + result = armv7_read_simd_instr_vst3_multiple_3_element_structures(raw, arm); + + else if ((b & b1110) == b0000) + result = armv7_read_simd_instr_vst4_multiple_4_element_structures(raw, arm); + + } + + else/* if (a == b1)*/ + { + if ((b & b1011) == b0000) + result = armv7_read_simd_instr_vst1_single_element_from_one_lane(raw, arm); + + else if (b == b1000) + result = armv7_read_simd_instr_vst1_single_element_from_one_lane(raw, arm); + + else if ((b & b1011) == b0001) + result = armv7_read_simd_instr_vst2_single_2_element_structure_from_one_lane(raw, arm); + + else if (b == b1001) + result = armv7_read_simd_instr_vst2_single_2_element_structure_from_one_lane(raw, arm); + + else if ((b & b1011) == b0010) + result = armv7_read_simd_instr_vst3_single_3_element_structure_from_one_lane(raw, arm); + + else if (b == b1010) + result = armv7_read_simd_instr_vst3_single_3_element_structure_from_one_lane(raw, arm); + + else if ((b & b1011) == b0011) + result = armv7_read_simd_instr_vst4_single_4_element_structure_from_one_lane(raw, arm); + + else if (b == b1011) + result = armv7_read_simd_instr_vst4_single_4_element_structure_from_one_lane(raw, arm); + + } + + } + + else/* if (l == b1)*/ + { + if (a == b0) + { + if (b == b0010) + result = armv7_read_simd_instr_vld1_multiple_single_elements(raw, arm); + + else if ((b & b1110) == b0110) + result = armv7_read_simd_instr_vld1_multiple_single_elements(raw, arm); + + else if (b == b1010) + result = armv7_read_simd_instr_vld1_multiple_single_elements(raw, arm); + + else if (b == b0011) + result = armv7_read_simd_instr_vld2_multiple_2_element_structures(raw, arm); + + else if ((b & b1110) == b1000) + result = armv7_read_simd_instr_vld2_multiple_2_element_structures(raw, arm); + + else if ((b & b1110) == b0100) + result = armv7_read_simd_instr_vld3_multiple_3_element_structures(raw, arm); + + else if ((b & b1110) == b0000) + result = armv7_read_simd_instr_vld4_multiple_4_element_structures(raw, arm); + + } + + else/* if (a == b1)*/ + { + if ((b & b1011) == b0000) + result = armv7_read_simd_instr_vld1_single_element_to_one_lane(raw, arm); + + else if (b == b1000) + result = armv7_read_simd_instr_vld1_single_element_to_one_lane(raw, arm); + + else if (b == b1100) + result = armv7_read_simd_instr_vld1_single_element_to_all_lanes(raw, arm); + + else if ((b & b1011) == b0001) + result = armv7_read_simd_instr_vld2_single_2_element_structure_to_one_lane(raw, arm); + + else if (b == b1001) + result = armv7_read_simd_instr_vld2_single_2_element_structure_to_one_lane(raw, arm); + + else if (b == b1101) + result = armv7_read_simd_instr_vld2_single_2_element_structure_to_all_lanes(raw, arm); + + else if ((b & b1011) == b0010) + result = armv7_read_simd_instr_vld3_single_3_element_structure_to_one_lane(raw, arm); + + else if (b == b1010) + result = armv7_read_simd_instr_vld3_single_3_element_structure_to_one_lane(raw, arm); + + else if (b == b1110) + result = armv7_read_simd_instr_vld3_single_3_element_structure_to_all_lanes(raw, arm); + + else if ((b & b1011) == b0011) + result = armv7_read_simd_instr_vld4_single_4_element_structure_to_one_lane(raw, arm); + + else if (b == b1011) + result = armv7_read_simd_instr_vld4_single_4_element_structure_to_one_lane(raw, arm); + + else if (b == b1111) + result = armv7_read_simd_instr_vld4_single_4_element_structure_to_all_lanes(raw, arm); + + } + + } + + return result; + +} + + +/****************************************************************************** +* * +* Paramètres : raw = donnée brute de 16 bits à désassembler. * +* arm = précise si l'encodage est en mode ARM ou Thumb. * +* * +* Description : Désassemble une instruction ARMv7 liées au chapitre A7.8. * +* * +* Retour : Instruction mise en place ou NULL en cas d'échec. * +* * +* Remarques : - * +* * +******************************************************************************/ + +GArchInstruction *process_armv7_simd_8_16_and_32_bit_transfer_between_arm_core_and_extension_registers(uint32_t raw, bool arm) +{ + GArchInstruction *result; /* Instruction à renvoyer */ + uint32_t a; /* Champ 'a' à retrouver */ + uint32_t l; /* Champ 'l' à retrouver */ + uint32_t c; /* Champ 'c' à retrouver */ + uint32_t b; /* Champ 'b' à retrouver */ + + /** + * Suit les directives de : + * § A7.8 8, 16, and 32-bit transfer between ARM core and extension registers + */ + + if (arm) + { + if ((raw & 0x0f000e10) != 0x0e000a10) return NULL; + } + else + { + if ((raw & 0xef000e10) != 0xee000a10) return NULL; + } + + result = NULL; + + a = (raw >> 21) & b111; + l = (raw >> 20) & b1; + c = (raw >> 8) & b1; + b = (raw >> 5) & b11; + + if (l == b0) + { + if (c == b0) + { + if (a == b000) + result = armv7_read_simd_instr_vmov_between_arm_core_register_and_single_precision_register(raw, arm); + + else if (a == b111) + { + result = armv7_read_simd_instr_vmsr(raw, arm); + + if (result == NULL /* ! */) + result = armv7_read_simd_instr_vmsr_b9(raw, arm); + + } + + } + + else/* if (c == b1)*/ + { + if ((a & b100) == b000) + result = armv7_read_simd_instr_vmov_arm_core_register_to_scalar(raw, arm); + + else if (/*(a & b100) == b000) && */(b & b10) == b00) + result = armv7_read_simd_instr_vdup_arm_core_register(raw, arm); + + } + + } + + else/* if (l == b1)*/ + { + if (c == b0) + { + if (a == b000) + result = armv7_read_simd_instr_vmov_between_arm_core_register_and_single_precision_register(raw, arm); + + else if (a == b111) + { + result = armv7_read_simd_instr_vmrs(raw, arm); + + if (result == NULL /* ! */) + result = armv7_read_simd_instr_vmrs_b9(raw, arm); + + } + + } + + else/* if (c == b1)*/ + result = armv7_read_simd_instr_vmov_scalar_to_arm_core_register(raw, arm); + + } + + return result; + +} + + +/****************************************************************************** +* * +* Paramètres : raw = donnée brute de 16 bits à désassembler. * +* arm = précise si l'encodage est en mode ARM ou Thumb. * +* * +* Description : Désassemble une instruction ARMv7 liées au chapitre A7.9. * +* * +* Retour : Instruction mise en place ou NULL en cas d'échec. * +* * +* Remarques : - * +* * +******************************************************************************/ + +GArchInstruction *process_armv7_simd_64_bit_transfers_between_arm_core_and_extension_registers(uint32_t raw, bool arm) +{ + GArchInstruction *result; /* Instruction à renvoyer */ + uint32_t c; /* Champ 'c' à retrouver */ + uint32_t op; /* Champ 'op' à retrouver */ + + /** + * Suit les directives de : + * § A7.9 64-bit transfers between ARM core and extension registers + */ + + if (arm) + { + if ((raw & 0x0fe00e00) != 0x0c400a00) return NULL; + } + else + { + if ((raw & 0xefe00e00) != 0xec400a00) return NULL; + } + + result = NULL; + + c = (raw >> 8) & b1; + op = (raw >> 4) & b1111; + + if (c == b0 && (op & b1101) == 0001) + result = armv7_read_simd_instr_vmov_between_two_arm_core_registers_and_two_single_precision_registers(raw, arm); + + else if (c == b1 && (op & b1101) == 0001) + result = armv7_read_simd_instr_vmov_between_two_arm_core_registers_and_a_doubleword_extension_register(raw, arm); + + return result; + +} diff --git a/plugins/arm/v7/simd.h b/plugins/arm/v7/simd.h new file mode 100644 index 0000000..4a32dba --- /dev/null +++ b/plugins/arm/v7/simd.h @@ -0,0 +1,55 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * simd.h - prototypes pour le désassemblage des instructions ARMv7 SIMD + * + * Copyright (C) 2016-2017 Cyrille Bagard + * + * This file is part of Chrysalide. + * + * Chrysalide is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Chrysalide is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Foobar. If not, see . + */ + + +#ifndef _PLUGINS_ARM_V7_SIMD_H +#define _PLUGINS_ARM_V7_SIMD_H + + +#include + + +#include + + + +/* Désassemble une instruction ARMv7 liées au chapitre A7.4. */ +GArchInstruction *process_armv7_simd_advanced_simd_data_processing_instructions(uint32_t, bool); + +/* Désassemble une instruction ARMv7 liées au chapitre A7.5. */ +GArchInstruction *process_armv7_simd_floating_point_data_processing_instructions(uint32_t, bool); + +/* Désassemble une instruction ARMv7 liées au chapitre A7.6. */ +GArchInstruction *process_armv7_simd_extension_register_load_store_instructions(uint32_t, bool); + +/* Désassemble une instruction ARMv7 liées au chapitre A7.7. */ +GArchInstruction *process_armv7_simd_advanced_simd_element_or_structure_load_store_instructions(uint32_t, bool); + +/* Désassemble une instruction ARMv7 liées au chapitre A7.8. */ +GArchInstruction *process_armv7_simd_8_16_and_32_bit_transfer_between_arm_core_and_extension_registers(uint32_t, bool); + +/* Désassemble une instruction ARMv7 liées au chapitre A7.9. */ +GArchInstruction *process_armv7_simd_64_bit_transfers_between_arm_core_and_extension_registers(uint32_t, bool); + + + +#endif /* _PLUGINS_ARM_V7_SIMD_H */ diff --git a/plugins/arm/v7/thumb_16.c b/plugins/arm/v7/thumb_16.c new file mode 100644 index 0000000..666c15e --- /dev/null +++ b/plugins/arm/v7/thumb_16.c @@ -0,0 +1,672 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * thumb_16.c - désassemblage des instructions ARMv7 Thumb 16 bits + * + * Copyright (C) 2014-2017 Cyrille Bagard + * + * This file is part of Chrysalide. + * + * Chrysalide is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Chrysalide is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Foobar. If not, see . + */ + + +#include "thumb_16.h" + + +#include + + +#include + + +#include "opcodes/thumb_16_opcodes.h" +#include "opcodes/opcodes_tmp_thumb_16.h" + + + +/* Désassemble une instruction ARMv7 liées au chapitre A6.2.1 */ +static GArchInstruction *process_armv7_thumb_16_shift_immediate_add_subtract_move_and_compare(uint16_t); + +/* Désassemble une instruction ARMv7 liées au chapitre A6.2.2. */ +static GArchInstruction *process_armv7_thumb_16_data_processing(uint16_t); + +/* Désassemble une instruction ARMv7 liées au chapitre A6.2.3. */ +static GArchInstruction *process_armv7_thumb_16_special_data_instructions_and_branch_and_exchange(uint16_t); + +/* Désassemble une instruction ARMv7 liées au chapitre A6.2.4. */ +static GArchInstruction *process_armv7_thumb_16_load_store_single_data_item(uint16_t); + +/* Désassemble une instruction ARMv7 liées au chapitre A6.2.5. */ +static GArchInstruction *process_armv7_thumb_16_miscellaneous_16_bit_instructions(uint16_t); + +/* Désassemble une instruction ARMv7 liées au chapitre A6.2.5.b. */ +static GArchInstruction *process_armv7_thumb_16_miscellaneous_16_bit_instructions_if_then_and_hints(uint16_t); + +/* Désassemble une instruction ARMv7 liées au chapitre A6.2.6. */ +static GArchInstruction *process_armv7_thumb_16_conditional_branch_and_supervisor_call(uint16_t); + + + +/****************************************************************************** +* * +* Paramètres : raw = donnée brute de 16 bits à désassembler. * +* * +* Description : Désassemble une instruction ARMv7 liées au chapitre A6.2. * +* * +* Retour : Instruction mise en place ou NULL en cas d'échec. * +* * +* Remarques : - * +* * +******************************************************************************/ + +GArchInstruction *process_armv7_thumb_16_instruction_set_encoding(uint16_t raw) +{ + GArchInstruction *result; /* Instruction à renvoyer */ + uint16_t opcode; /* Champ 'opcode' à retrouver */ + + /** + * Suit les directives de : + * § A6.2 16-bit Thumb instruction encoding + */ + + result = NULL; + + opcode = (raw >> 10) & b111111; + + if ((opcode & b110000) == b000000) + result = process_armv7_thumb_16_shift_immediate_add_subtract_move_and_compare(raw); + + else if (opcode == b010000) + result = process_armv7_thumb_16_data_processing(raw); + + else if (opcode == b010001) + result = process_armv7_thumb_16_special_data_instructions_and_branch_and_exchange(raw); + + else if ((opcode & b111110) == b010010) + result = armv7_read_thumb_16_instr_ldr_literal(raw); + + else if ((opcode & b111100) == b010100) + result = process_armv7_thumb_16_load_store_single_data_item(raw); + + else if ((opcode & b111000) == b011000) + result = process_armv7_thumb_16_load_store_single_data_item(raw); + + else if ((opcode & b111000) == b100000) + result = process_armv7_thumb_16_load_store_single_data_item(raw); + + else if ((opcode & b111110) == b101000) + result = armv7_read_thumb_16_instr_adr(raw); + + else if ((opcode & b111110) == b101010) + result = armv7_read_thumb_16_instr_add_sp_plus_immediate(raw); + + else if ((opcode & b111100) == b101100) + result = process_armv7_thumb_16_miscellaneous_16_bit_instructions(raw); + + else if ((opcode & b111110) == b110000) + result = armv7_read_thumb_16_instr_stm_stmia_stmea(raw); + + else if ((opcode & b111110) == b110010) + result = armv7_read_thumb_16_instr_ldm_ldmia_ldmfd_thumb(raw); + + else if ((opcode & b111100) == b110100) + result = process_armv7_thumb_16_conditional_branch_and_supervisor_call(raw); + + else if ((opcode & b111110) == b111000) + result = armv7_read_thumb_16_instr_b(raw); + + return result; + +} + + +/****************************************************************************** +* * +* Paramètres : raw = donnée brute de 16 bits à désassembler. * +* * +* Description : Désassemble une instruction ARMv7 liées au chapitre A6.2.1. * +* * +* Retour : Instruction mise en place ou NULL en cas d'échec. * +* * +* Remarques : - * +* * +******************************************************************************/ + +static GArchInstruction *process_armv7_thumb_16_shift_immediate_add_subtract_move_and_compare(uint16_t raw) +{ + GArchInstruction *result; /* Instruction à renvoyer */ + uint16_t opcode; /* Champ 'opcode' à retrouver */ + + /** + * Suit les directives de : + * § A6.2.1 Shift (immediate), add, subtract, move, and compare + */ + + if ((raw & 0xc000) != 0x0000) return NULL; + + result = NULL; + + opcode = (raw >> 9) & b11111; + + if ((opcode & b11100) == b00000) + result = armv7_read_thumb_16_instr_lsl_immediate(raw); + + else if ((opcode & b11100) == b00100) + result = armv7_read_thumb_16_instr_lsr_immediate(raw); + + else if ((opcode & b11100) == b01000) + result = armv7_read_thumb_16_instr_asr_immediate(raw); + + else if (opcode == b01100) + result = armv7_read_thumb_16_instr_add_register_thumb(raw); + + else if (opcode == b01101) + result = armv7_read_thumb_16_instr_sub_register(raw); + + else if (opcode == b01110) + result = armv7_read_thumb_16_instr_add_immediate_thumb(raw); + + else if (opcode == b01111) + result = armv7_read_thumb_16_instr_sub_immediate_thumb(raw); + + else if ((opcode & b11100) == b10000) + result = armv7_read_thumb_16_instr_mov_immediate(raw); + + else if ((opcode & b11100) == b10100) + result = armv7_read_thumb_16_instr_cmp_immediate(raw); + + else if ((opcode & b11100) == b11000) + result = armv7_read_thumb_16_instr_add_immediate_thumb(raw); + + else if ((opcode & b11100) == b11100) + result = armv7_read_thumb_16_instr_sub_immediate_thumb(raw); + + return result; + +} + + +/****************************************************************************** +* * +* Paramètres : raw = donnée brute de 16 bits à désassembler. * +* * +* Description : Désassemble une instruction ARMv7 liées au chapitre A6.2.2. * +* * +* Retour : Instruction mise en place ou NULL en cas d'échec. * +* * +* Remarques : - * +* * +******************************************************************************/ + +static GArchInstruction *process_armv7_thumb_16_data_processing(uint16_t raw) +{ + GArchInstruction *result; /* Instruction à renvoyer */ + uint16_t opcode; /* Champ 'opcode' à retrouver */ + + /** + * Suit les directives de : + * § A6.2.2 Data-processing + */ + + if ((raw & 0xfc00) != 0x4000) return NULL; + + result = NULL; + + opcode = (raw >> 6) & b1111; + + switch (opcode) + { + case b0000: + result = armv7_read_thumb_16_instr_and_register(raw); + break; + + case b0001: + result = armv7_read_thumb_16_instr_eor_register(raw); + break; + + case b0010: + result = armv7_read_thumb_16_instr_lsl_register(raw); + break; + + case b0011: + result = armv7_read_thumb_16_instr_lsr_register(raw); + break; + + case b0100: + result = armv7_read_thumb_16_instr_asr_register(raw); + break; + + case b0101: + result = armv7_read_thumb_16_instr_adc_register(raw); + break; + + case b0110: + result = armv7_read_thumb_16_instr_sbc_register(raw); + break; + + case b0111: + result = armv7_read_thumb_16_instr_ror_register(raw); + break; + + case b1000: + result = armv7_read_thumb_16_instr_tst_register(raw); + break; + + case b1001: + result = armv7_read_thumb_16_instr_rsb_immediate(raw); + break; + + case b1010: + result = armv7_read_thumb_16_instr_cmp_register(raw); + break; + + case b1011: + result = armv7_read_thumb_16_instr_cmn_register(raw); + break; + + case b1100: + result = armv7_read_thumb_16_instr_orr_register(raw); + break; + + case b1101: + result = armv7_read_thumb_16_instr_mul(raw); + break; + + case b1110: + result = armv7_read_thumb_16_instr_bic_register(raw); + break; + + case b1111: + result = armv7_read_thumb_16_instr_mvn_register(raw); + break; + + } + + return result; + +} + + +/****************************************************************************** +* * +* Paramètres : raw = donnée brute de 16 bits à désassembler. * +* * +* Description : Désassemble une instruction ARMv7 liées au chapitre A6.2.3. * +* * +* Retour : Instruction mise en place ou NULL en cas d'échec. * +* * +* Remarques : - * +* * +******************************************************************************/ + +static GArchInstruction *process_armv7_thumb_16_special_data_instructions_and_branch_and_exchange(uint16_t raw) +{ + GArchInstruction *result; /* Instruction à renvoyer */ + uint16_t opcode; /* Champ 'opcode' à retrouver */ + + /** + * Suit les directives de : + * § A6.2.3 Special data instructions and branch and exchange + */ + + if ((raw & 0xfc00) != 0x4400) return NULL; + + result = NULL; + + opcode = (raw >> 6) & b1111; + + if (opcode == b0000) + result = armv7_read_thumb_16_instr_add_register_thumb(raw); + + else if (opcode == b0001) + result = armv7_read_thumb_16_instr_add_register_thumb(raw); + + else if ((opcode & b1110) == b0010) + result = armv7_read_thumb_16_instr_add_register_thumb(raw); + + else if ((opcode & b1100) == b0100) + result = armv7_read_thumb_16_instr_cmp_register(raw); + + else if (opcode == b1000) + result = armv7_read_thumb_16_instr_mov_register_thumb(raw); + + else if (opcode == b1001) + result = armv7_read_thumb_16_instr_mov_register_thumb(raw); + + else if ((opcode & b1110) == b1010) + result = armv7_read_thumb_16_instr_mov_register_thumb(raw); + + else if ((opcode & b1110) == b1100) + result = armv7_read_thumb_16_instr_bx(raw); + + else if ((opcode & b1110) == b1110) + result = armv7_read_thumb_16_instr_blx_register(raw); + + return result; + +} + + +/****************************************************************************** +* * +* Paramètres : raw = donnée brute de 16 bits à désassembler. * +* * +* Description : Désassemble une instruction ARMv7 liées au chapitre A6.2.4. * +* * +* Retour : Instruction mise en place ou NULL en cas d'échec. * +* * +* Remarques : - * +* * +******************************************************************************/ + +static GArchInstruction *process_armv7_thumb_16_load_store_single_data_item(uint16_t raw) +{ + GArchInstruction *result; /* Instruction à renvoyer */ + uint16_t opa; /* Champ 'opa' à retrouver */ + uint16_t opb; /* Champ 'opb' à retrouver */ + + /** + * Suit les directives de : + * § A6.2.4 Load/store single data item + */ + + result = NULL; + + opa = (raw >> 12) & b1111; + opb = (raw >> 9) & b111; + + switch (opa) + { + case b0101: + switch (opb) + { + case b000: + result = armv7_read_thumb_16_instr_str_register(raw); + break; + + case b001: + result = armv7_read_thumb_16_instr_strh_register(raw); + break; + + case b010: + result = armv7_read_thumb_16_instr_strb_register(raw); + break; + + case b011: + result = armv7_read_thumb_16_instr_ldrsb_register(raw); + break; + + case b100: + result = armv7_read_thumb_16_instr_ldr_register_thumb(raw); + break; + + case b101: + result = armv7_read_thumb_16_instr_ldrh_register(raw); + break; + + case b110: + result = armv7_read_thumb_16_instr_ldrb_register(raw); + break; + + case b111: + result = armv7_read_thumb_16_instr_ldrsh_register(raw); + break; + + } + break; + + case b0110: + + if ((opb & b100) == b000) + result = armv7_read_thumb_16_instr_str_immediate_thumb(raw); + else /*if ((opb & b100) == b100)*/ + result = armv7_read_thumb_16_instr_ldr_immediate_thumb(raw); + + break; + + case b0111: + + if ((opb & b100) == b000) + result = armv7_read_thumb_16_instr_strb_immediate_thumb(raw); + else /*if ((opb & b100) == b100)*/ + result = armv7_read_thumb_16_instr_ldrb_immediate_thumb(raw); + + break; + + case b1000: + + if ((opb & b100) == b000) + result = armv7_read_thumb_16_instr_strh_immediate_thumb(raw); + else /*if ((opb & b100) == b100)*/ + result = armv7_read_thumb_16_instr_ldrh_immediate_thumb(raw); + + break; + + case b1001: + + if ((opb & b100) == b000) + result = armv7_read_thumb_16_instr_str_immediate_thumb(raw); + else /*if ((opb & b100) == b100)*/ + result = armv7_read_thumb_16_instr_ldr_immediate_thumb(raw); + + break; + + } + + return result; + +} + + +/****************************************************************************** +* * +* Paramètres : raw = donnée brute de 16 bits à désassembler. * +* * +* Description : Désassemble une instruction ARMv7 liées au chapitre A6.2.5. * +* * +* Retour : Instruction mise en place ou NULL en cas d'échec. * +* * +* Remarques : - * +* * +******************************************************************************/ + +static GArchInstruction *process_armv7_thumb_16_miscellaneous_16_bit_instructions(uint16_t raw) +{ + GArchInstruction *result; /* Instruction à renvoyer */ + uint16_t opcode; /* Champ 'opcode' à retrouver */ + + /** + * Suit les directives de : + * § A6.2.5 Miscellaneous 16-bit instructions + */ + + if ((raw & 0xf000) != 0xb000) return NULL; + + result = NULL; + + opcode = (raw >> 5) & b1111111; + + if ((opcode & b1111100) == b0000000) + result = armv7_read_thumb_16_instr_add_sp_plus_immediate(raw); + + else if ((opcode & b1111100) == b0000100) + result = armv7_read_thumb_16_instr_sub_sp_minus_immediate(raw); + + else if ((opcode & b1111000) == b0001000) + result = armv7_read_thumb_16_instr_cbnz_cbz(raw); + + else if ((opcode & b1111110) == b0010000) + result = armv7_read_thumb_16_instr_sxth(raw); + + else if ((opcode & b1111110) == b0010010) + result = armv7_read_thumb_16_instr_sxtb(raw); + + else if ((opcode & b1111110) == b0010100) + result = armv7_read_thumb_16_instr_uxth(raw); + + else if ((opcode & b1111110) == b0010110) + result = armv7_read_thumb_16_instr_uxtb(raw); + + else if ((opcode & b1111000) == b0011000) + result = armv7_read_thumb_16_instr_cbnz_cbz(raw); + + else if ((opcode & b1110000) == b0100000) + result = armv7_read_thumb_16_instr_push(raw); + + else if (opcode == b0110010) + result = armv7_read_thumb_16_instr_setend(raw); + + else if (opcode == b0110011) + result = armv7_read_thumb_16_instr_cps_thumb(raw); + + else if ((opcode & b1111000) == b1001000) + result = armv7_read_thumb_16_instr_cbnz_cbz(raw); + + else if ((opcode & b1111110) == b1010000) + result = armv7_read_thumb_16_instr_rev(raw); + + else if ((opcode & b1111110) == b1010010) + result = armv7_read_thumb_16_instr_rev16(raw); + + else if ((opcode & b1111110) == b1010110) + result = armv7_read_thumb_16_instr_revsh(raw); + + else if ((opcode & b1111000) == b1011000) + result = armv7_read_thumb_16_instr_cbnz_cbz(raw); + + else if ((opcode & b1110000) == b1100000) + result = armv7_read_thumb_16_instr_pop_thumb(raw); + + else if ((opcode & b1111000) == b1110000) + result = armv7_read_thumb_16_instr_bkpt(raw); + + else if ((opcode & b1111000) == b1111000) + result = process_armv7_thumb_16_miscellaneous_16_bit_instructions_if_then_and_hints(raw); + + return result; + +} + + +/****************************************************************************** +* * +* Paramètres : raw = donnée brute de 16 bits à désassembler. * +* * +* Description : Désassemble une instruction ARMv7 liées au chapitre A6.2.5.b.* +* * +* Retour : Instruction mise en place ou NULL en cas d'échec. * +* * +* Remarques : - * +* * +******************************************************************************/ + +static GArchInstruction *process_armv7_thumb_16_miscellaneous_16_bit_instructions_if_then_and_hints(uint16_t raw) +{ + GArchInstruction *result; /* Instruction à renvoyer */ + uint16_t opa; /* Champ 'opa' à retrouver */ + uint16_t opb; /* Champ 'opb' à retrouver */ + + /** + * Suit les directives de : + * § A6.2.5 Miscellaneous 16-bit instructions + * |-> If-Then, and hints + */ + + if ((raw & 0xff00) != 0xbf00) return NULL; + + result = NULL; + + opa = (raw >> 4) & b1111; + opb = (raw >> 0) & b1111; + + if (opb != b0000) + result = armv7_read_thumb_16_instr_it(raw); + + else + switch (opa) + { + case b0000: + result = armv7_read_thumb_16_instr_nop(raw); + break; + + case b0001: + result = armv7_read_thumb_16_instr_yield(raw); + break; + + case b0010: + result = armv7_read_thumb_16_instr_wfe(raw); + break; + + case b0011: + result = armv7_read_thumb_16_instr_wfi(raw); + break; + + case b0100: + result = armv7_read_thumb_16_instr_sev(raw); + break; + + } + + return result; + +} + + +/****************************************************************************** +* * +* Paramètres : raw = donnée brute de 16 bits à désassembler. * +* * +* Description : Désassemble une instruction ARMv7 liées au chapitre A6.2.6. * +* * +* Retour : Instruction mise en place ou NULL en cas d'échec. * +* * +* Remarques : - * +* * +******************************************************************************/ + +static GArchInstruction *process_armv7_thumb_16_conditional_branch_and_supervisor_call(uint16_t raw) +{ + GArchInstruction *result; /* Instruction à renvoyer */ + uint16_t opcode; /* Champ 'opcode' à retrouver */ + + /** + * Suit les directives de : + * § A6.2.6 Conditional branch, and Supervisor Call + */ + + if ((raw & 0xf000) != 0xd000) return NULL; + + result = NULL; + + opcode = (raw >> 8) & b1111; + + switch (opcode) + { + case b1110: + result = armv7_read_thumb_16_instr_udf(raw); + break; + + case b1111: + result = armv7_read_thumb_16_instr_svc_previously_swi(raw); + break; + + default: + result = armv7_read_thumb_16_instr_b(raw); + break; + + } + + return result; + +} diff --git a/plugins/arm/v7/thumb_16.h b/plugins/arm/v7/thumb_16.h new file mode 100644 index 0000000..4dc8866 --- /dev/null +++ b/plugins/arm/v7/thumb_16.h @@ -0,0 +1,37 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * thumb_16.h - prototypes pour le désassemblage des instructions ARMv7 Thumb 16 bits + * + * Copyright (C) 2014-2017 Cyrille Bagard + * + * This file is part of Chrysalide. + * + * Chrysalide is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Chrysalide is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Foobar. If not, see . + */ + + +#ifndef _PLUGINS_ARM_V7_THUMB_16_H +#define _PLUGINS_ARM_V7_THUMB_16_H + + +#include + + + +/* Désassemble une instruction ARMv7 liées au chapitre A6.2. */ +GArchInstruction *process_armv7_thumb_16_instruction_set_encoding(uint16_t); + + + +#endif /* _PLUGINS_ARM_V7_THUMB_16_H */ diff --git a/plugins/arm/v7/thumb_32.c b/plugins/arm/v7/thumb_32.c new file mode 100644 index 0000000..2ea33fc --- /dev/null +++ b/plugins/arm/v7/thumb_32.c @@ -0,0 +1,2270 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * thumb_32.c - désassemblage des instructions ARMv7 Thumb 32 bits + * + * Copyright (C) 2014-2017 Cyrille Bagard + * + * This file is part of Chrysalide. + * + * Chrysalide is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Chrysalide is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Foobar. If not, see . + */ + + +#include "thumb_32.h" + + +#include + + +#include +#include + + +#include "simd.h" +#include "opcodes/thumb_32_opcodes.h" +#include "opcodes/opcodes_tmp_thumb_32.h" + + + +/* Désassemble une instruction ARMv7 liées au chapitre A6.3.1. */ +static GArchInstruction *process_armv7_thumb_32_data_processing_modified_immediate(uint32_t); + +/* Désassemble une instruction ARMv7 liées au chapitre A6.3.3. */ +static GArchInstruction *process_armv7_thumb_32_data_processing_plain_binary_immediate(uint32_t); + +/* Désassemble une instruction ARMv7 liées au chapitre A6.3.4. */ +static GArchInstruction *process_armv7_thumb_32_branches_and_miscellaneous_control(uint32_t); + +/* Désassemble une instruction ARMv7 liées au chapitre A6.3.4b. */ +static GArchInstruction *process_armv7_thumb_32_change_processor_state_and_hints(uint32_t); + +/* Désassemble une instruction ARMv7 liées au chapitre A6.3.4t. */ +static GArchInstruction *process_armv7_thumb_32_miscellaneous_control_instructions(uint32_t); + +/* Désassemble une instruction ARMv7 liées au chapitre A6.3.5. */ +static GArchInstruction *process_armv7_thumb_32_load_store_multiple(uint32_t); + +/* Désassemble une instruction ARMv7 liées au chapitre A6.3.6. */ +static GArchInstruction *process_armv7_thumb_32_load_store_dual_load_store_exclusive_table_branch(uint32_t); + +/* Désassemble une instruction ARMv7 liées au chapitre A6.3.7. */ +static GArchInstruction *process_armv7_thumb_32_load_word(uint32_t); + +/* Désassemble une instruction ARMv7 liées au chapitre A6.3.8. */ +static GArchInstruction *process_armv7_thumb_32_load_halfword_memory_hints(uint32_t); + +/* Désassemble une instruction ARMv7 liées au chapitre A6.3.9. */ +static GArchInstruction *process_armv7_thumb_32_load_byte_memory_hints(uint32_t); + +/* Désassemble une instruction ARMv7 liées au chapitre A6.3.10. */ +static GArchInstruction *process_armv7_thumb_32_store_single_data_item(uint32_t); + +/* Désassemble une instruction ARMv7 liées au chapitre A6.3.11. */ +static GArchInstruction *process_armv7_thumb_32_data_processing_shifted_register(uint32_t); + +/* Désassemble une instruction ARMv7 liées au chapitre A6.3.11b. */ +static GArchInstruction *process_armv7_thumb_32_move_register_and_immediate_shifts(uint32_t); + +/* Désassemble une instruction ARMv7 liées au chapitre A6.3.12. */ +static GArchInstruction *process_armv7_thumb_32_data_processing_register(uint32_t); + +/* Désassemble une instruction ARMv7 liées au chapitre A6.3.13. */ +static GArchInstruction *process_armv7_thumb_32_parallel_addition_and_subtraction_signed(uint32_t); + +/* Désassemble une instruction ARMv7 liées au chapitre A6.3.14. */ +static GArchInstruction *process_armv7_thumb_32_parallel_addition_and_subtraction_unsigned(uint32_t); + +/* Désassemble une instruction ARMv7 liées au chapitre A6.3.15. */ +static GArchInstruction *process_armv7_thumb_32_miscellaneous_operations(uint32_t); + +/* Désassemble une instruction ARMv7 liées au chapitre A6.3.16. */ +static GArchInstruction *process_armv7_thumb_32_multiply_multiply_accumulate_and_absolute_difference(uint32_t); + +/* Désassemble une instruction ARMv7 liées au chapitre A6.3.17. */ +static GArchInstruction *process_armv7_thumb_32_long_multiply_long_multiply_accumulate_and_divide(uint32_t); + +/* Désassemble une instruction ARMv7 liées au chapitre A6.3.18. */ +static GArchInstruction *process_armv7_thumb_32_coprocessor_advanced_simd_and_floating_point_instructions(uint32_t); + + + +/****************************************************************************** +* * +* Paramètres : raw = donnée brute de 32 bits à désassembler. * +* * +* Description : Désassemble une instruction ARMv7 liées au chapitre A6.3. * +* * +* Retour : Instruction mise en place ou NULL en cas d'échec. * +* * +* Remarques : - * +* * +******************************************************************************/ + +GArchInstruction *process_armv7_thumb_32_instruction_set_encoding(uint32_t raw) +{ + GArchInstruction *result; /* Instruction à renvoyer */ + uint32_t op1; /* Champ 'op1' à retrouver */ + uint32_t op2; /* Champ 'op2' à retrouver */ + uint32_t op; /* Champ 'op' à retrouver */ + + /** + * Suit les directives de : + * § A6.3 32-bit Thumb instruction encoding + */ + + if (((raw >> 29) & b111) != b111) return NULL; + + result = NULL; + + op1 = (raw >> 27) & b11; + op2 = (raw >> 20) & b1111111; + op = (raw >> 15) & b1; + + switch (op1) + { + case b01: + + if ((op2 & b1100100) == b0000000) + result = process_armv7_thumb_32_load_store_multiple(raw); + + else if ((op2 & b1100100) == b0000100) + result = process_armv7_thumb_32_load_store_dual_load_store_exclusive_table_branch(raw); + + else if ((op2 & b1100000) == b0100000) + result = process_armv7_thumb_32_data_processing_shifted_register(raw); + + else if ((op2 & b1000000) == b1000000) + result = process_armv7_thumb_32_coprocessor_advanced_simd_and_floating_point_instructions(raw); + + break; + + case b10: + + if (op == 1) + result = process_armv7_thumb_32_branches_and_miscellaneous_control(raw); + + else + { + if ((op2 & b0100000) == b0000000) + result = process_armv7_thumb_32_data_processing_modified_immediate(raw); + + else if ((op2 & b0100000) == b0100000) + result = process_armv7_thumb_32_data_processing_plain_binary_immediate(raw); + + } + + break; + + case b11: + + if ((op2 & b1110001) == b0000000) + result = process_armv7_thumb_32_store_single_data_item(raw); + + else if ((op2 & b1100111) == b0000001) + result = process_armv7_thumb_32_load_byte_memory_hints(raw); + + else if ((op2 & b1100111) == b0000011) + result = process_armv7_thumb_32_load_halfword_memory_hints(raw); + + else if ((op2 & b1100111) == b0000101) + result = process_armv7_thumb_32_load_word(raw); + + else if ((op2 & b1100111) == b0000111) + result = g_undef_instruction_new(IBS_UNDEFINED); + + else if ((op2 & b1110001) == b0010000) + result = process_armv7_simd_advanced_simd_element_or_structure_load_store_instructions(raw, false); + + else if ((op2 & b1110000) == b0100000) + result = process_armv7_thumb_32_data_processing_register(raw); + + else if ((op2 & b1111000) == b0110000) + result = process_armv7_thumb_32_multiply_multiply_accumulate_and_absolute_difference(raw); + + else if ((op2 & b1111000) == b0111000) + result = process_armv7_thumb_32_long_multiply_long_multiply_accumulate_and_divide(raw); + + else if ((op2 & b1000000) == b1000000) + result = process_armv7_thumb_32_coprocessor_advanced_simd_and_floating_point_instructions(raw); + + break; + + } + + return result; + +} + + +/****************************************************************************** +* * +* Paramètres : raw = donnée brute de 32 bits à désassembler. * +* * +* Description : Désassemble une instruction ARMv7 liées au chapitre A6.3.1. * +* * +* Retour : Instruction mise en place ou NULL en cas d'échec. * +* * +* Remarques : - * +* * +******************************************************************************/ + +static GArchInstruction *process_armv7_thumb_32_data_processing_modified_immediate(uint32_t raw) +{ + GArchInstruction *result; /* Instruction à renvoyer */ + uint32_t op; /* Champ 'op' à retrouver */ + uint32_t rn; /* Champ 'rn' à retrouver */ + uint32_t rds; /* Champ 'rds' à retrouver */ + + /** + * Suit les directives de : + * § A6.3.1 Data-processing (modified immediate) + */ + + if ((raw & 0xfa008000) != 0xf0000000) return NULL; + + result = NULL; + + op = (raw >> 21) & b1111; + rn = (raw >> 16) & b1111; + rds = (((raw >> 8) & b1111) << 1) | ((raw >> 20) & b1); + + switch (op) + { + case b0000: + + if (rds == b11111) + result = armv7_read_thumb_32_instr_tst_immediate(raw); + + else + result = armv7_read_thumb_32_instr_and_immediate(raw); + + break; + + case b0001: + result = armv7_read_thumb_32_instr_bic_immediate(raw); + break; + + case b0010: + + if (rn == b1111) + result = armv7_read_thumb_32_instr_mov_immediate(raw); + + else + result = armv7_read_thumb_32_instr_orr_immediate(raw); + + break; + + case b0011: + + if (rn == b1111) + result = armv7_read_thumb_32_instr_mvn_immediate(raw); + + else + result = armv7_read_thumb_32_instr_orn_immediate(raw); + + break; + + case b0100: + + if (rds == b11111) + result = armv7_read_thumb_32_instr_teq_immediate(raw); + + else + result = armv7_read_thumb_32_instr_eor_immediate(raw); + + break; + + case b1000: + + if (rds == b11111) + result = armv7_read_thumb_32_instr_cmn_immediate(raw); + + else + result = armv7_read_thumb_32_instr_add_immediate_thumb(raw); + + break; + + case b1010: + result = armv7_read_thumb_32_instr_adc_immediate(raw); + break; + + case b1011: + result = armv7_read_thumb_32_instr_sbc_immediate(raw); + break; + + case b1101: + + if (rds == b11111) + result = armv7_read_thumb_32_instr_cmp_immediate(raw); + + else + result = armv7_read_thumb_32_instr_sub_immediate_thumb(raw); + + break; + + case b1110: + result = armv7_read_thumb_32_instr_rsb_immediate(raw); + break; + + } + + return result; + +} + + +/****************************************************************************** +* * +* Paramètres : raw = donnée brute de 32 bits à désassembler. * +* * +* Description : Désassemble une instruction ARMv7 liées au chapitre A6.3.3. * +* * +* Retour : Instruction mise en place ou NULL en cas d'échec. * +* * +* Remarques : - * +* * +******************************************************************************/ + +static GArchInstruction *process_armv7_thumb_32_data_processing_plain_binary_immediate(uint32_t raw) +{ + GArchInstruction *result; /* Instruction à renvoyer */ + uint32_t op; /* Champ 'op' à retrouver */ + uint32_t rn; /* Champ 'rn' à retrouver */ + + /** + * Suit les directives de : + * § A6.3.3 Data-processing (plain binary immediate) + */ + + if ((raw & 0xfa008000) != 0xf2000000) return NULL; + + result = NULL; + + op = (raw >> 20) & b11111; + rn = (raw >> 16) & b1111; + + switch (op) + { + case b00000: + + if (rn == b1111) + result = armv7_read_thumb_32_instr_adr(raw); + + else + result = armv7_read_thumb_32_instr_add_immediate_thumb(raw); + + break; + + case b00100: + result = armv7_read_thumb_32_instr_mov_immediate(raw); + break; + + case b01010: + + if (rn == b11111) + result = armv7_read_thumb_32_instr_adr(raw); + + else + result = armv7_read_thumb_32_instr_sub_immediate_thumb(raw); + + break; + + case b01100: + result = armv7_read_thumb_32_instr_movt(raw); + break; + + case b10000: + result = armv7_read_thumb_32_instr_ssat(raw); + break; + + case b10010: + + if ((raw & 0x000070c0) != 0) + result = armv7_read_thumb_32_instr_ssat(raw); + + else + result = armv7_read_thumb_32_instr_ssat16(raw); + + break; + + case b10100: + result = armv7_read_thumb_32_instr_sbfx(raw); + break; + + case b10110: + + if (rn == b11111) + result = armv7_read_thumb_32_instr_bfc(raw); + + else + result = armv7_read_thumb_32_instr_bfi(raw); + + break; + + case b11000: + result = armv7_read_thumb_32_instr_usat(raw); + break; + + case b11010: + + if ((raw & 0x000070c0) != 0) + result = armv7_read_thumb_32_instr_usat(raw); + + else + result = armv7_read_thumb_32_instr_usat16(raw); + + break; + + case b11100: + result = armv7_read_thumb_32_instr_ubfx(raw); + break; + + } + + return result; + +} + + +/****************************************************************************** +* * +* Paramètres : raw = donnée brute de 32 bits à désassembler. * +* * +* Description : Désassemble une instruction ARMv7 liées au chapitre A6.3.4. * +* * +* Retour : Instruction mise en place ou NULL en cas d'échec. * +* * +* Remarques : - * +* * +******************************************************************************/ + +static GArchInstruction *process_armv7_thumb_32_branches_and_miscellaneous_control(uint32_t raw) +{ + GArchInstruction *result; /* Instruction à renvoyer */ + uint32_t op; /* Champ 'op' à retrouver */ + uint32_t op1; /* Champ 'op1' à retrouver */ + uint32_t op2; /* Champ 'op2' à retrouver */ + uint32_t imm8; /* Champ 'imm8' à retrouver */ + + /** + * Suit les directives de : + * § A6.3.4 Branches and miscellaneous control + */ + + if ((raw & 0xf8000000) != 0xf0000000) return NULL; + + result = NULL; + + op = (raw >> 20) & b1111111; + op1 = (raw >> 12) & b111; + op2 = (raw >> 8) & b1111; + imm8 = (raw >> 0) & b11111111; + + if (op1 == b000 && op == b1111110) + result = armv7_read_thumb_32_instr_hvc(raw); + + else if (op1 == b000 && op == b1111111) + result = armv7_read_thumb_32_instr_smc_previously_smi(raw); + + else if ((op1 & b101) == b000) + { + if ((op & b0111000) != b0111000) + result = armv7_read_thumb_32_instr_b(raw); + + else if ((imm8 & b00100000) == b00100000 && (op & b1111110) == b0111000) + result = armv7_read_thumb_32_instr_msr_banked_register(raw); + + else if ((imm8 & b00100000) == b00000000 && op == b0111000 && (op2 & b0011) == b0000) + result = armv7_read_thumb_32_instr_msr_register(raw); + + else if ((imm8 & b00100000) == b00000000 && op == b0111000 && (op2 & b0011) == b0001) + result = armv7_read_thumb_32_instr_b_msr_register(raw); + + else if ((imm8 & b00100000) == b00000000 && op == b0111000 && (op2 & b0010) == b0010) + result = armv7_read_thumb_32_instr_b_msr_register(raw); + + else if ((imm8 & b00100000) == b00000000 && op == b0111001) + result = armv7_read_thumb_32_instr_b_msr_register(raw); + + else if (op == b0111010) + result = process_armv7_thumb_32_change_processor_state_and_hints(raw); + + else if (op == b0111011) + result = process_armv7_thumb_32_miscellaneous_control_instructions(raw); + + else if (op == b0111100) + result = armv7_read_thumb_32_instr_bxj(raw); + + else if (imm8 == b00000000 && op == b0111101) + result = armv7_read_thumb_32_instr_eret(raw); + + else if (imm8 != b00000000 && op == b0111101) + result = armv7_read_thumb_32_instr_subs_pc_lr_thumb(raw); + + else if ((imm8 & b00100000) == b00100000 && (op & b1111110) == b0111110) + result = armv7_read_thumb_32_instr_mrs_banked_register(raw); + + else if ((imm8 & b00100000) == b00000000 && op == b0111110) + result = armv7_read_thumb_32_instr_mrs(raw); + + else if ((imm8 & b00100000) == b00000000 && op == b0111111) + result = armv7_read_thumb_32_instr_b_mrs(raw); + + } + + else if ((op1 & b101) == b001) + result = armv7_read_thumb_32_instr_b(raw); + + else if (op1 == b010 && op == b1111111) + result = armv7_read_thumb_32_instr_udf(raw); + + else if ((op1 & b101) == b100) + result = armv7_read_thumb_32_instr_bl_blx_immediate(raw); + + else if ((op1 & b101) == b101) + result = armv7_read_thumb_32_instr_bl_blx_immediate(raw); + + return result; + +} + + +/****************************************************************************** +* * +* Paramètres : raw = donnée brute de 32 bits à désassembler. * +* * +* Description : Désassemble une instruction ARMv7 classique. * +* * +* Retour : Désassemble une instruction ARMv7 liées au chapitre A6.3.4b. * +* * +* Remarques : - * +* * +******************************************************************************/ + +static GArchInstruction *process_armv7_thumb_32_change_processor_state_and_hints(uint32_t raw) +{ + GArchInstruction *result; /* Instruction à renvoyer */ + uint32_t op1; /* Champ 'op1' à retrouver */ + uint32_t op2; /* Champ 'op2' à retrouver */ + + /** + * Suit les directives de : + * § A6.3.4 Branches and miscellaneous control + * |-> Change Processor State, and hints + */ + + if ((raw & 0xfff0d000) != 0xf3a08000) return NULL; + + result = NULL; + + op1 = (raw >> 8) & b111; + op2 = (raw >> 0) & b11111111; + + if (op1 != b000) + result = armv7_read_thumb_32_instr_cps_thumb(raw); + + else + { + if (op2 == b00000000) + result = armv7_read_thumb_32_instr_nop(raw); + + else if (op2 == b00000001) + result = armv7_read_thumb_32_instr_yield(raw); + + else if (op2 == b00000010) + result = armv7_read_thumb_32_instr_wfe(raw); + + else if (op2 == b00000011) + result = armv7_read_thumb_32_instr_wfi(raw); + + else if (op2 == b00000100) + result = armv7_read_thumb_32_instr_sev(raw); + + else if ((op2 & b11110000) == b11110000) + result = armv7_read_thumb_32_instr_dbg(raw); + + } + + return result; + +} + + +/****************************************************************************** +* * +* Paramètres : raw = donnée brute de 32 bits à désassembler. * +* * +* Description : Désassemble une instruction ARMv7 liées au chapitre A6.3.4t. * +* * +* Retour : Instruction mise en place ou NULL en cas d'échec. * +* * +* Remarques : - * +* * +******************************************************************************/ + +static GArchInstruction *process_armv7_thumb_32_miscellaneous_control_instructions(uint32_t raw) +{ + GArchInstruction *result; /* Instruction à renvoyer */ + uint32_t op; /* Champ 'op' à retrouver */ + + /** + * Suit les directives de : + * § A6.3.4 Branches and miscellaneous control + * |-> Miscellaneous control instructions + */ + + if ((raw & 0xfff0d000) != 0xf3b08000) return NULL; + + result = NULL; + + op = (raw >> 4) & b1111; + + switch (op) + { + case b0000: + result = armv7_read_thumb_32_instr_enterx_leavex(raw); + break; + + case b0001: + result = armv7_read_thumb_32_instr_enterx_leavex(raw); + break; + + case b0010: + result = armv7_read_thumb_32_instr_clrex(raw); + break; + + case b0100: + result = armv7_read_thumb_32_instr_dsb(raw); + break; + + case b0101: + result = armv7_read_thumb_32_instr_dmb(raw); + break; + + case b0110: + result = armv7_read_thumb_32_instr_isb(raw); + break; + + } + + return result; + +} + + +/****************************************************************************** +* * +* Paramètres : raw = donnée brute de 32 bits à désassembler. * +* * +* Description : Désassemble une instruction ARMv7 liées au chapitre A6.3.5. * +* * +* Retour : Instruction mise en place ou NULL en cas d'échec. * +* * +* Remarques : - * +* * +******************************************************************************/ + +static GArchInstruction *process_armv7_thumb_32_load_store_multiple(uint32_t raw) +{ + GArchInstruction *result; /* Instruction à renvoyer */ + uint32_t op; /* Champ 'op' à retrouver */ + uint32_t l; /* Champ 'l' à retrouver */ + uint32_t wrn; /* Champ 'wrn' à retrouver */ + + /** + * Suit les directives de : + * § A6.3.5 Load/store multiple + */ + + if ((raw & 0xfe400000) != 0xe8000000) return NULL; + + result = NULL; + + op = (raw >> 23) & b11; + l = (raw >> 20) & b1; + wrn = (((raw >> 21) & b1) << 4) | ((raw >> 16) & b1111); + + switch (op) + { + case b00: + + if (l == b0) + result = armv7_read_thumb_32_instr_srs_thumb(raw); + + else + result = armv7_read_thumb_32_instr_rfe(raw); + + break; + + case b01: + + if (l == b0) + result = armv7_read_thumb_32_instr_stm_stmia_stmea(raw); + + else + { + if (wrn == b11101) + result = armv7_read_thumb_32_instr_pop_thumb(raw); + + else + result = armv7_read_thumb_32_instr_ldm_ldmia_ldmfd_thumb(raw); + + } + + break; + + case b10: + + if (l == b0) + { + if (wrn == b11101) + result = armv7_read_thumb_32_instr_push(raw); + + else + result = armv7_read_thumb_32_instr_stmdb_stmfd(raw); + + } + + else + result = armv7_read_thumb_32_instr_ldmdb_ldmea(raw); + + break; + + case b11: + + if (l == b0) + result = armv7_read_thumb_32_instr_srs_thumb(raw); + + else + result = armv7_read_thumb_32_instr_rfe(raw); + + break; + + } + + return result; + +} + + +/****************************************************************************** +* * +* Paramètres : raw = donnée brute de 32 bits à désassembler. * +* * +* Description : Désassemble une instruction ARMv7 liées au chapitre A6.3.6. * +* * +* Retour : Instruction mise en place ou NULL en cas d'échec. * +* * +* Remarques : - * +* * +******************************************************************************/ + +static GArchInstruction *process_armv7_thumb_32_load_store_dual_load_store_exclusive_table_branch(uint32_t raw) +{ + GArchInstruction *result; /* Instruction à renvoyer */ + uint32_t op1; /* Champ 'op1' à retrouver */ + uint32_t op2; /* Champ 'op2' à retrouver */ + uint32_t rn; /* Champ 'rn' à retrouver */ + uint32_t op3; /* Champ 'op3' à retrouver */ + + /** + * Suit les directives de : + * § A6.3.6 Load/store dual, load/store exclusive, table branch + */ + + if ((raw & 0xfe400000) != 0xe8400000) return NULL; + + result = NULL; + + op1 = (raw >> 23) & 0x3; + op2 = (raw >> 20) & 0x3; + rn = (raw >> 16) & 0xf; + op3 = (raw >> 4) & 0xf; + + if (op1 == b00 && op2 == b00) + result = armv7_read_thumb_32_instr_strex(raw); + + else if (op1 == b00 && op2 == b01) + result = armv7_read_thumb_32_instr_ldrex(raw); + + else if ((op1 & b10) == b00 && op2 == b10) + result = armv7_read_thumb_32_instr_strd_immediate(raw); + + else if ((op1 & b10) == b10 && (op2 & b01) == b00) + result = armv7_read_thumb_32_instr_strd_immediate(raw); + + else if ((op1 & b10) == b00 && op2 == b11) + { + if (rn != b1111) + result = armv7_read_thumb_32_instr_ldrd_immediate(raw); + + else/* if (rn == b1111)*/ + result = armv7_read_thumb_32_instr_ldrd_literal(raw); + + } + + else if ((op1 & b10) == b10 && (op2 & b01) == b01) + { + if (rn != b1111) + result = armv7_read_thumb_32_instr_ldrd_immediate(raw); + + else/* if (rn == b1111)*/ + result = armv7_read_thumb_32_instr_ldrd_literal(raw); + + } + + else if (op1 == b01 && op2 == b00) + switch (op3) + { + case b0100: + result = armv7_read_thumb_32_instr_strexb(raw); + break; + + case b0101: + result = armv7_read_thumb_32_instr_strexh(raw); + break; + + case b0111: + result = armv7_read_thumb_32_instr_strexd(raw); + break; + + } + + else if (op1 == b01 && op2 == b01) + switch (op3) + { + case b0000: + result = armv7_read_thumb_32_instr_tbb_tbh(raw); + break; + + case b0001: + result = armv7_read_thumb_32_instr_tbb_tbh(raw); + break; + + case b0100: + result = armv7_read_thumb_32_instr_ldrexb(raw); + break; + + case b0101: + result = armv7_read_thumb_32_instr_ldrexh(raw); + break; + + case b0111: + result = armv7_read_thumb_32_instr_ldrexd(raw); + break; + + } + + return result; + +} + + +/****************************************************************************** +* * +* Paramètres : raw = donnée brute de 32 bits à désassembler. * +* * +* Description : Désassemble une instruction ARMv7 liées au chapitre A6.3.7. * +* * +* Retour : Instruction mise en place ou NULL en cas d'échec. * +* * +* Remarques : - * +* * +******************************************************************************/ + +static GArchInstruction *process_armv7_thumb_32_load_word(uint32_t raw) +{ + GArchInstruction *result; /* Instruction à renvoyer */ + uint32_t op1; /* Champ 'op1' à retrouver */ + uint32_t rn; /* Champ 'rn' à retrouver */ + uint32_t op2; /* Champ 'op2' à retrouver */ + + /** + * Suit les directives de : + * § A6.3.7 Load word + */ + + if ((raw & 0xfe700000) != 0xf8500000) return NULL; + + result = NULL; + + op1 = (raw >> 23) & b11; + rn = (raw >> 16) & b1111; + op2 = (raw >> 6) & b111111; + + switch (op1) + { + case b00: + + if (op2 == b000000 && rn != b1111) + result = armv7_read_thumb_32_instr_ldr_register_thumb(raw); + + else if ((op2 & b100100) == b100100 && rn != b1111) + result = armv7_read_thumb_32_instr_ldr_immediate_thumb(raw); + + else if ((op2 & b111100) == b110000 && rn != b1111) + result = armv7_read_thumb_32_instr_ldr_immediate_thumb(raw); + + else if ((op2 & b111100) == b111000 && rn != b1111) + result = armv7_read_thumb_32_instr_ldrt(raw); + + break; + + case b01: + if (rn != b1111) + result = armv7_read_thumb_32_instr_ldr_immediate_thumb(raw); + break; + + } + + if (result == NULL && (op1 & b10) == b00 && rn == b1111) + result = armv7_read_thumb_32_instr_ldr_literal(raw); + + return result; + +} + + +/****************************************************************************** +* * +* Paramètres : raw = donnée brute de 32 bits à désassembler. * +* * +* Description : Désassemble une instruction ARMv7 liées au chapitre A6.3.8. * +* * +* Retour : Instruction mise en place ou NULL en cas d'échec. * +* * +* Remarques : - * +* * +******************************************************************************/ + +static GArchInstruction *process_armv7_thumb_32_load_halfword_memory_hints(uint32_t raw) +{ + GArchInstruction *result; /* Instruction à renvoyer */ + uint32_t op1; /* Champ 'op1' à retrouver */ + uint32_t rn; /* Champ 'rn' à retrouver */ + uint32_t rt; /* Champ 'rt' à retrouver */ + uint32_t op2; /* Champ 'op2' à retrouver */ + + /** + * Suit les directives de : + * § A6.3.8 Load halfword, memory hints + */ + + if ((raw & 0xfe700000) != 0xf8300000) return NULL; + + result = NULL; + + op1 = (raw >> 23) & 0x3; + rn = (raw >> 16) & 0xf; + rt = (raw >> 12) & 0xf; + op2 = (raw >> 6) & 0x3f; + + if (rn == b1111) + { + if ((op1 & b10) == b00) + { + if (rt != b1111) + result = armv7_read_thumb_32_instr_ldrh_literal(raw); + + else/* if (rt == b1111)*/ + result = armv7_read_thumb_32_instr_pld_literal(raw); + + } + + else/* if ((op1 & b10) == b10)*/ + { + if (rt != b1111) + result = armv7_read_thumb_32_instr_ldrsh_literal(raw); + + else/* if (rt == b1111)*/ + result = g_undef_instruction_new(IBS_NOP); + + } + + } + + else/* if (rn != b1111)*/ + { + if (op1 == b00) + { + if ((op2 & b100100) == b100100) + result = armv7_read_thumb_32_instr_ldrh_immediate_thumb(raw); + + else if ((op2 & b111100) == b110000 && rt != b1111) + result = armv7_read_thumb_32_instr_ldrh_immediate_thumb(raw); + + else if (op2 == b000000 && rt != b1111) + result = armv7_read_thumb_32_instr_ldrh_register(raw); + + else if ((op2 & b111100) == b111000) + result = armv7_read_thumb_32_instr_ldrht(raw); + + else if (op2 == b000000 && rt == b1111) + result = armv7_read_thumb_32_instr_pld_pldw_register(raw); + + else if ((op2 & b111100) == b110000 && rt == b1111) + result = armv7_read_thumb_32_instr_pld_pldw_immediate(raw); + + } + + else if (op1 == b01) + { + if (rt != b1111) + result = armv7_read_thumb_32_instr_ldrh_immediate_thumb(raw); + + else/* if (rt == b1111)*/ + result = armv7_read_thumb_32_instr_pld_pldw_immediate(raw); + + } + + else if (op1 == b10) + { + if ((op2 & b100100) == b100100) + result = armv7_read_thumb_32_instr_ldrsh_immediate(raw); + + else if ((op2 & b111100) == b110000 && rt != b1111) + result = armv7_read_thumb_32_instr_ldrsh_immediate(raw); + + else if (op2 == b000000 && rt != b1111) + result = armv7_read_thumb_32_instr_ldrsh_register(raw); + + else if ((op2 & b111100) == b111000) + result = armv7_read_thumb_32_instr_ldrsht(raw); + + else if (op2 == b000000 && rt == b1111) + result = g_undef_instruction_new(IBS_NOP); + + else if ((op2 & b111100) == b110000 && rt == b1111) + result = g_undef_instruction_new(IBS_NOP); + + } + + else if (op1 == b11) + { + if (rt != b1111) + result = armv7_read_thumb_32_instr_ldrsh_immediate(raw); + + else/* if (rt == b1111)*/ + result = g_undef_instruction_new(IBS_NOP); + + } + + } + + return result; + +} + + +/****************************************************************************** +* * +* Paramètres : raw = donnée brute de 32 bits à désassembler. * +* * +* Description : Désassemble une instruction ARMv7 liées au chapitre A6.3.9. * +* * +* Retour : Instruction mise en place ou NULL en cas d'échec. * +* * +* Remarques : - * +* * +******************************************************************************/ + +static GArchInstruction *process_armv7_thumb_32_load_byte_memory_hints(uint32_t raw) +{ + GArchInstruction *result; /* Instruction à renvoyer */ + uint32_t op1; /* Champ 'op1' à retrouver */ + uint32_t rn; /* Champ 'rn' à retrouver */ + uint32_t rt; /* Champ 'rt' à retrouver */ + uint32_t op2; /* Champ 'op2' à retrouver */ + + /** + * Suit les directives de : + * § A6.3.9 Load byte, memory hints + */ + + if ((raw & 0xfe700000) != 0xf8100000) return NULL; + + result = NULL; + + op1 = (raw >> 23) & b11; + rn = (raw >> 16) & b1111; + rt = (raw >> 12) & b1111; + op2 = (raw >> 6) & b111111; + + if (op1 == b00 && op2 == b000000 && rn != b1111) + { + if (rt != b1111) + result = armv7_read_thumb_32_instr_ldrb_register(raw); + + else /*if (rt == b1111) */ + result = armv7_read_thumb_32_instr_pld_register(raw); + + } + + else if ((op1 & b10) == b00 && rn == b1111) + { + if (rt != b1111) + result = armv7_read_thumb_32_instr_ldrb_literal(raw); + + else /*if (rt == b1111) */ + result = armv7_read_thumb_32_instr_pld_literal(raw); + + } + + else if (op1 == b00 && (op2 & b100100) == b100100 && rn != b1111) + result = armv7_read_thumb_32_instr_ldrb_immediate_thumb(raw); + + else if (op1 == b00 && (op2 & b111100) == b110000 && rn != b1111) + { + if (rt != b1111) + result = armv7_read_thumb_32_instr_ldrb_immediate_thumb(raw); + + else /*if (rt == b1111) */ + result = armv7_read_thumb_32_instr_pld_immediate(raw); + + } + + else if (op1 == b00 && (op2 & b111100) == b111000 && rn != b1111) + result = armv7_read_thumb_32_instr_ldrbt(raw); + + else if (op1 == b01 && rn != b1111) + { + if (rt != b1111) + result = armv7_read_thumb_32_instr_ldrb_immediate_thumb(raw); + + else /*if (rt == b1111) */ + result = armv7_read_thumb_32_instr_pld_immediate(raw); + + } + + if (op1 == b10 && op2 == b000000 && rn != b1111) + { + if (rt != b1111) + result = armv7_read_thumb_32_instr_ldrsb_register(raw); + else /*if (rt == b1111) */ + result = armv7_read_thumb_32_instr_pli_register(raw); + } + + else if ((op1 & b10) == b10 && rn == b1111) + { + if (rt != b1111) + result = armv7_read_thumb_32_instr_ldrsb_literal(raw); + + else /*if (rt == b1111) */ + result = armv7_read_thumb_32_instr_pli_immediate_literal(raw); + + } + + else if (op1 == b10 && (op2 & b100100) == b100100 && rn != b1111) + result = armv7_read_thumb_32_instr_ldrsb_immediate(raw); + + else if (op1 == b10 && (op2 & b111100) == b110000 && rn != b1111) + { + if (rt != b1111) + result = armv7_read_thumb_32_instr_ldrsb_immediate(raw); + + else /*if (rt == b1111) */ + result = armv7_read_thumb_32_instr_pli_immediate_literal(raw); + + } + + else if (op1 == b10 && (op2 & b111100) == b111000 && rn != b1111) + result = armv7_read_thumb_32_instr_ldrsbt(raw); + + else if (op1 == b11 && rn != b1111) + { + if (rt != b1111) + result = armv7_read_thumb_32_instr_ldrsb_immediate(raw); + + else /*if (rt == b1111) */ + result = armv7_read_thumb_32_instr_pli_immediate_literal(raw); + + } + + return result; + +} + + +/****************************************************************************** +* * +* Paramètres : raw = donnée brute de 32 bits à désassembler. * +* * +* Description : Désassemble une instruction ARMv7 liées au chapitre A6.3.10. * +* * +* Retour : Instruction mise en place ou NULL en cas d'échec. * +* * +* Remarques : - * +* * +******************************************************************************/ + +static GArchInstruction *process_armv7_thumb_32_store_single_data_item(uint32_t raw) +{ + GArchInstruction *result; /* Instruction à renvoyer */ + uint32_t op1; /* Champ 'op1' à retrouver */ + uint32_t op2; /* Champ 'op2' à retrouver */ + + /** + * Suit les directives de : + * § A6.3.10 Store single data item + */ + + if ((raw & 0xff100000) != 0xf8000000) return NULL; + + result = NULL; + + op1 = (raw >> 21) & b111; + op2 = (raw >> 6) & b111111; + + switch (op1) + { + case b000: + + if (op2 == b000000) + result = armv7_read_thumb_32_instr_strb_register(raw); + + else if ((op2 & b100100) == b100100) + result = armv7_read_thumb_32_instr_strb_immediate_thumb(raw); + + else if ((op2 & b111100) == b110000) + result = armv7_read_thumb_32_instr_strb_immediate_thumb(raw); + + else if ((op2 & b111100) == b111000) + result = armv7_read_thumb_32_instr_strbt(raw); + + break; + + case b001: + + if (op2 == b000000) + result = armv7_read_thumb_32_instr_strh_register(raw); + + else if ((op2 & b100100) == b100100) + result = armv7_read_thumb_32_instr_strh_immediate_thumb(raw); + + else if ((op2 & b111100) == b110000) + result = armv7_read_thumb_32_instr_strh_immediate_thumb(raw); + + else if ((op2 & b111100) == b111000) + result = armv7_read_thumb_32_instr_strht(raw); + + break; + + case b010: + + if (op2 == b000000) + result = armv7_read_thumb_32_instr_str_register(raw); + + else if ((op2 & b100100) == b100100) + result = armv7_read_thumb_32_instr_str_immediate_thumb(raw); + + else if ((op2 & b111100) == b110000) + result = armv7_read_thumb_32_instr_str_immediate_thumb(raw); + + else if ((op2 & b111100) == b111000) + result = armv7_read_thumb_32_instr_strt(raw); + + break; + + case b100: + result = armv7_read_thumb_32_instr_strb_immediate_thumb(raw); + break; + + case b101: + result = armv7_read_thumb_32_instr_strh_immediate_thumb(raw); + break; + + case b110: + result = armv7_read_thumb_32_instr_str_immediate_thumb(raw); + break; + + } + + return result; + +} + + +/****************************************************************************** +* * +* Paramètres : raw = donnée brute de 32 bits à désassembler. * +* * +* Description : Désassemble une instruction ARMv7 liées au chapitre A6.3.11. * +* * +* Retour : Instruction mise en place ou NULL en cas d'échec. * +* * +* Remarques : - * +* * +******************************************************************************/ + +static GArchInstruction *process_armv7_thumb_32_data_processing_shifted_register(uint32_t raw) +{ + GArchInstruction *result; /* Instruction à renvoyer */ + uint32_t op; /* Champ 'op' à retrouver */ + uint32_t rn; /* Champ 'rn' à retrouver */ + uint32_t rds; /* Champ 'rds' à retrouver */ + + /** + * Suit les directives de : + * § A6.3.11 Data-processing (shifted register) + */ + + if ((raw & 0xfe000000) != 0xea000000) return NULL; + + result = NULL; + + op = (raw >> 21) & b1111; + rn = (raw >> 16) & b1111; + rds = (((raw >> 8) & b1111) << 1) | ((raw >> 20) & b1); + + switch (op) + { + case b0000: + + if (rds == b11111) + result = armv7_read_thumb_32_instr_tst_register(raw); + + else + result = armv7_read_thumb_32_instr_and_register(raw); + + break; + + case b0001: + result = armv7_read_thumb_32_instr_bic_register(raw); + break; + + case b0010: + + if (rn == b11111) + result = process_armv7_thumb_32_move_register_and_immediate_shifts(raw); + + else + result = armv7_read_thumb_32_instr_orr_register(raw); + + break; + + case b0011: + + if (rn == b11111) + result = armv7_read_thumb_32_instr_mvn_register(raw); + + else + result = armv7_read_thumb_32_instr_orn_register(raw); + + break; + + case b0100: + + if (rds == b11111) + result = armv7_read_thumb_32_instr_teq_register(raw); + + else + result = armv7_read_thumb_32_instr_eor_register(raw); + + break; + + case b0110: + result = armv7_read_thumb_32_instr_pkh(raw); + break; + + case b1000: + + if (rds == b11111) + result = armv7_read_thumb_32_instr_cmn_register(raw); + + else + result = armv7_read_thumb_32_instr_add_register_thumb(raw); + + break; + + case b1010: + result = armv7_read_thumb_32_instr_adc_register(raw); + break; + + case b1011: + result = armv7_read_thumb_32_instr_sbc_register(raw); + break; + + case b1101: + + if (rds == b11111) + result = armv7_read_thumb_32_instr_cmp_register(raw); + + else + result = armv7_read_thumb_32_instr_sub_register_thumb(raw); + + break; + + case b1110: + result = armv7_read_thumb_32_instr_rsb_register(raw); + break; + + } + + return result; + +} + + +/****************************************************************************** +* * +* Paramètres : raw = donnée brute de 32 bits à désassembler. * +* * +* Description : Désassemble une instruction ARMv7 liées au chapitre A6.3.11b.* +* * +* Retour : Instruction mise en place ou NULL en cas d'échec. * +* * +* Remarques : - * +* * +******************************************************************************/ + +static GArchInstruction *process_armv7_thumb_32_move_register_and_immediate_shifts(uint32_t raw) +{ + GArchInstruction *result; /* Instruction à renvoyer */ + uint32_t imm5; /* Champs 'imm[32]' à retrouver*/ + uint32_t type; /* Champ 'type' à retrouver */ + + /** + * Suit les directives de : + * § A6.3.11 Data-processing (shifted register) + * |-> Move register and immediate shifts + */ + + if ((raw & 0xffef0000) != 0xea4f0000) return NULL; + + result = NULL; + + imm5 = (((raw >> 12) & 0x7) << 2) | ((raw >> 6) & 0x3); + type = (raw >> 4) & 0x3; + + switch (type) + { + case b00: + + if (imm5 == b00000) + result = armv7_read_thumb_32_instr_mov_register_thumb(raw); + + else/* if (imm5 != b00000)*/ + result = armv7_read_thumb_32_instr_lsl_immediate(raw); + + break; + + case b01: + result = armv7_read_thumb_32_instr_lsr_immediate(raw); + break; + + case b10: + result = armv7_read_thumb_32_instr_asr_immediate(raw); + break; + + case b11: + + if (imm5 == b00000) + result = armv7_read_thumb_32_instr_rrx(raw); + + else/* if (imm5 != b00000)*/ + result = armv7_read_thumb_32_instr_ror_immediate(raw); + + break; + + } + + return result; + +} + + +/****************************************************************************** +* * +* Paramètres : raw = donnée brute de 32 bits à désassembler. * +* * +* Description : Désassemble une instruction ARMv7 liées au chapitre A6.3.12. * +* * +* Retour : Instruction mise en place ou NULL en cas d'échec. * +* * +* Remarques : - * +* * +******************************************************************************/ + +static GArchInstruction *process_armv7_thumb_32_data_processing_register(uint32_t raw) +{ + GArchInstruction *result; /* Instruction à renvoyer */ + uint32_t op1; /* Champ 'op1' à retrouver */ + uint32_t rn; /* Champ 'rn' à retrouver */ + uint32_t op2; /* Champ 'op2' à retrouver */ + + /** + * Suit les directives de : + * § A6.3.12 Data-processing (register) + */ + + if ((raw & 0xff00f000) != 0xfa00f000) return NULL; + + result = NULL; + + op1 = (raw >> 20) & b1111; + rn = (raw >> 16) & b1111; + op2 = (raw >> 4) & b1111; + + if ((op1 & b1110) == b0000 && op2 == b0000) + result = armv7_read_thumb_32_instr_lsl_register(raw); + + else if ((op1 & b1110) == b0010 && op2 == b0000) + result = armv7_read_thumb_32_instr_lsr_register(raw); + + else if ((op1 & b1110) == b0100 && op2 == b0000) + result = armv7_read_thumb_32_instr_asr_register(raw); + + else if ((op1 & b1110) == b0110 && op2 == b0000) + result = armv7_read_thumb_32_instr_ror_register(raw); + + else if (op1 == b0000 && (op2 & b1000) == b1000) + { + if (rn == b1111) + result = armv7_read_thumb_32_instr_sxth(raw); + + else + result = armv7_read_thumb_32_instr_sxtah(raw); + + } + + else if (op1 == b0001 && (op2 & b1000) == b1000) + { + if (rn == b1111) + result = armv7_read_thumb_32_instr_uxth(raw); + + else + result = armv7_read_thumb_32_instr_uxtah(raw); + + } + + else if (op1 == b0010 && (op2 & b1000) == b1000) + { + if (rn == b1111) + result = armv7_read_thumb_32_instr_sxtb16(raw); + + else + result = armv7_read_thumb_32_instr_sxtab16(raw); + + } + + else if (op1 == b0011 && (op2 & b1000) == b1000) + { + if (rn == b1111) + result = armv7_read_thumb_32_instr_uxtb16(raw); + + else + result = armv7_read_thumb_32_instr_uxtab16(raw); + + } + + else if (op1 == b0100 && (op2 & b1000) == b1000) + { + if (rn == b1111) + result = armv7_read_thumb_32_instr_sxtb(raw); + + else + result = armv7_read_thumb_32_instr_sxtab(raw); + + } + + else if (op1 == b0101 && (op2 & b1000) == b1000) + { + if (rn == b1111) + result = armv7_read_thumb_32_instr_uxtb(raw); + + else + result = armv7_read_thumb_32_instr_uxtab(raw); + + } + + else if ((op1 & b1000) == b1000 && (op2 & b1100) == b0000) + result = process_armv7_thumb_32_parallel_addition_and_subtraction_signed(raw); + + else if ((op1 & b1000) == b1000 && (op2 & b1100) == b0100) + result = process_armv7_thumb_32_parallel_addition_and_subtraction_unsigned(raw); + + else if ((op1 & b1100) == b1000 && (op2 & b1100) == b1000) + result = process_armv7_thumb_32_miscellaneous_operations(raw); + + return result; + +} + + +/****************************************************************************** +* * +* Paramètres : raw = donnée brute de 32 bits à désassembler. * +* * +* Description : Désassemble une instruction ARMv7 liées au chapitre A6.3.13. * +* * +* Retour : Instruction mise en place ou NULL en cas d'échec. * +* * +* Remarques : - * +* * +******************************************************************************/ + +static GArchInstruction *process_armv7_thumb_32_parallel_addition_and_subtraction_signed(uint32_t raw) +{ + GArchInstruction *result; /* Instruction à renvoyer */ + uint32_t op1; /* Champ 'op1' à retrouver */ + uint32_t op2; /* Champ 'op2' à retrouver */ + + /** + * Suit les directives de : + * § A6.3.13 Parallel addition and subtraction, signed + */ + + if ((raw & 0xff80f000) != 0xfa80f000) return NULL; + + result = NULL; + + op1 = (raw >> 20) & b111; + op2 = (raw >> 4) & b11; + + switch (op2) + { + case b00: + switch (op1) + { + case b001: + result = armv7_read_thumb_32_instr_sadd16(raw); + break; + + case b010: + result = armv7_read_thumb_32_instr_sasx(raw); + break; + + case b110: + result = armv7_read_thumb_32_instr_ssax(raw); + break; + + case b101: + result = armv7_read_thumb_32_instr_ssub16(raw); + break; + + case b000: + result = armv7_read_thumb_32_instr_sadd8(raw); + break; + + case b100: + result = armv7_read_thumb_32_instr_ssub8(raw); + break; + + } + break; + + case b01: + switch (op1) + { + case b001: + result = armv7_read_thumb_32_instr_sqadd16(raw); + break; + + case b010: + result = armv7_read_thumb_32_instr_sqasx(raw); + break; + + case b110: + result = armv7_read_thumb_32_instr_sqsax(raw); + break; + + case b101: + result = armv7_read_thumb_32_instr_sqsub16(raw); + break; + + case b000: + result = armv7_read_thumb_32_instr_sqadd8(raw); + break; + + case b100: + result = armv7_read_thumb_32_instr_sqsub8(raw); + break; + + } + break; + + case b10: + switch (op1) + { + case b001: + result = armv7_read_thumb_32_instr_shadd16(raw); + break; + + case b010: + result = armv7_read_thumb_32_instr_shasx(raw); + break; + + case b110: + result = armv7_read_thumb_32_instr_shsax(raw); + break; + + case b101: + result = armv7_read_thumb_32_instr_shsub16(raw); + break; + + case b000: + result = armv7_read_thumb_32_instr_shadd8(raw); + break; + + case b100: + result = armv7_read_thumb_32_instr_shsub8(raw); + break; + + } + break; + + } + + return result; + +} + + +/****************************************************************************** +* * +* Paramètres : raw = donnée brute de 32 bits à désassembler. * +* * +* Description : Désassemble une instruction ARMv7 liées au chapitre A6.3.14. * +* * +* Retour : Instruction mise en place ou NULL en cas d'échec. * +* * +* Remarques : - * +* * +******************************************************************************/ + +static GArchInstruction *process_armv7_thumb_32_parallel_addition_and_subtraction_unsigned(uint32_t raw) +{ + GArchInstruction *result; /* Instruction à renvoyer */ + uint32_t op1; /* Champ 'op1' à retrouver */ + uint32_t op2; /* Champ 'op2' à retrouver */ + + /** + * Suit les directives de : + * § A6.3.14 Parallel addition and subtraction, unsigned + */ + + if ((raw & 0xff80f0c0) != 0xfa80f040) return NULL; + + result = NULL; + + op1 = (raw >> 20) & b111; + op2 = (raw >> 4) & b11; + + switch (op2) + { + case b00: + switch (op1) + { + case b001: + result = armv7_read_thumb_32_instr_uadd16(raw); + break; + + case b010: + result = armv7_read_thumb_32_instr_uasx(raw); + break; + + case b110: + result = armv7_read_thumb_32_instr_usax(raw); + break; + + case b101: + result = armv7_read_thumb_32_instr_usub16(raw); + break; + + case b000: + result = armv7_read_thumb_32_instr_uadd8(raw); + break; + + case b100: + result = armv7_read_thumb_32_instr_usub8(raw); + break; + + } + break; + + case b01: + switch (op1) + { + case b001: + result = armv7_read_thumb_32_instr_uqadd16(raw); + break; + + case b010: + result = armv7_read_thumb_32_instr_uqasx(raw); + break; + + case b110: + result = armv7_read_thumb_32_instr_uqsax(raw); + break; + + case b101: + result = armv7_read_thumb_32_instr_uqsub16(raw); + break; + + case b000: + result = armv7_read_thumb_32_instr_uqadd8(raw); + break; + + case b100: + result = armv7_read_thumb_32_instr_uqsub8(raw); + break; + + } + break; + + case b10: + switch (op1) + { + case b001: + result = armv7_read_thumb_32_instr_uhadd16(raw); + break; + + case b010: + result = armv7_read_thumb_32_instr_uhasx(raw); + break; + + case b110: + result = armv7_read_thumb_32_instr_uhsax(raw); + break; + + case b101: + result = armv7_read_thumb_32_instr_uhsub16(raw); + break; + + case b000: + result = armv7_read_thumb_32_instr_uhadd8(raw); + break; + + case b100: + result = armv7_read_thumb_32_instr_uhsub8(raw); + break; + + } + break; + + } + + return result; + +} + + +/****************************************************************************** +* * +* Paramètres : raw = donnée brute de 32 bits à désassembler. * +* * +* Description : Désassemble une instruction ARMv7 liées au chapitre A6.3.15. * +* * +* Retour : Instruction mise en place ou NULL en cas d'échec. * +* * +* Remarques : - * +* * +******************************************************************************/ + +static GArchInstruction *process_armv7_thumb_32_miscellaneous_operations(uint32_t raw) +{ + GArchInstruction *result; /* Instruction à renvoyer */ + uint32_t op1; /* Champ 'op1' à retrouver */ + uint32_t op2; /* Champ 'op2' à retrouver */ + + /** + * Suit les directives de : + * § A6.3.15 Miscellaneous operations + */ + + if ((raw & 0xffc0f0c0) != 0xfa80f080) return NULL; + + result = NULL; + + op1 = (raw >> 20) & b11; + op2 = (raw >> 4) & b11; + + switch (op1) + { + case b00: + switch (op2) + { + case b00: + result = armv7_read_thumb_32_instr_qadd(raw); + break; + + case b01: + result = armv7_read_thumb_32_instr_qdadd(raw); + break; + + case b10: + result = armv7_read_thumb_32_instr_qsub(raw); + break; + + case b11: + result = armv7_read_thumb_32_instr_qdsub(raw); + break; + + } + break; + + case b01: + switch (op2) + { + case b00: + result = armv7_read_thumb_32_instr_rev(raw); + break; + + case b01: + result = armv7_read_thumb_32_instr_rev16(raw); + break; + + case b10: + result = armv7_read_thumb_32_instr_rbit(raw); + break; + + case b11: + result = armv7_read_thumb_32_instr_revsh(raw); + break; + + } + break; + + case b10: + if (op2 == b00) + result = armv7_read_thumb_32_instr_sel(raw); + break; + + case b11: + if (op2 == b00) + result = armv7_read_thumb_32_instr_clz(raw); + break; + + } + + return result; + +} + + +/****************************************************************************** +* * +* Paramètres : raw = donnée brute de 32 bits à désassembler. * +* * +* Description : Désassemble une instruction ARMv7 liées au chapitre A6.3.16. * +* * +* Retour : Instruction mise en place ou NULL en cas d'échec. * +* * +* Remarques : - * +* * +******************************************************************************/ + +static GArchInstruction *process_armv7_thumb_32_multiply_multiply_accumulate_and_absolute_difference(uint32_t raw) +{ + GArchInstruction *result; /* Instruction à renvoyer */ + uint32_t op1; /* Champ 'op1' à retrouver */ + uint32_t ra; /* Champ 'ra' à retrouver */ + uint32_t op2; /* Champ 'op2' à retrouver */ + + /** + * Suit les directives de : + * § A6.3.16 Multiply, multiply accumulate, and absolute difference + */ + + if ((raw & 0xff8000c0) != 0xfb000000) return NULL; + + result = NULL; + + op1 = (raw >> 20) & b111; + ra = (raw >> 12) & b1111; + op2 = (raw >> 4) & b11; + + switch (op1) + { + case b000: + + if (op2 == b00) + { + if (ra == b1111) + result = armv7_read_thumb_32_instr_mul(raw); + + else + result = armv7_read_thumb_32_instr_mla(raw); + + } + + else if (op2 == b01) + result = armv7_read_thumb_32_instr_mls(raw); + + break; + + case b001: + + if (ra == b1111) + result = armv7_read_thumb_32_instr_smulbb_smulbt_smultb_smultt(raw); + + else + result = armv7_read_thumb_32_instr_smlabb_smlabt_smlatb_smlatt(raw); + + break; + + case b010: + if ((op2 & b10) == b00) + { + if (ra == b1111) + result = armv7_read_thumb_32_instr_smuad(raw); + + else + result = armv7_read_thumb_32_instr_smlad(raw); + + } + break; + + case b011: + if ((op2 & b10) == b00) + { + if (ra == b1111) + result = armv7_read_thumb_32_instr_smulwb_smulwt(raw); + + else + result = armv7_read_thumb_32_instr_smlawb_smlawt(raw); + + } + break; + + case b100: + if ((op2 & b10) == b00) + { + if (ra == b1111) + result = armv7_read_thumb_32_instr_smusd(raw); + + else + result = armv7_read_thumb_32_instr_smlsd(raw); + + } + break; + + case b101: + if ((op2 & b10) == b00) + { + if (ra == b1111) + result = armv7_read_thumb_32_instr_smmul(raw); + + else + result = armv7_read_thumb_32_instr_smmla(raw); + + } + break; + + case b110: + if ((op2 & b10) == b00) + result = armv7_read_thumb_32_instr_smmls(raw); + break; + + case b111: + if (op2 == b00) + { + if (ra == b1111) + result = armv7_read_thumb_32_instr_usad8(raw); + + else + result = armv7_read_thumb_32_instr_usada8(raw); + + } + break; + + } + + return result; + +} + + +/****************************************************************************** +* * +* Paramètres : raw = donnée brute de 32 bits à désassembler. * +* * +* Description : Désassemble une instruction ARMv7 liées au chapitre A6.3.17. * +* * +* Retour : Instruction mise en place ou NULL en cas d'échec. * +* * +* Remarques : - * +* * +******************************************************************************/ + +static GArchInstruction *process_armv7_thumb_32_long_multiply_long_multiply_accumulate_and_divide(uint32_t raw) +{ + GArchInstruction *result; /* Instruction à renvoyer */ + uint32_t op1; /* Champ 'op1' à retrouver */ + uint32_t op2; /* Champ 'op2' à retrouver */ + + /** + * Suit les directives de : + * § A6.3.17 Long multiply, long multiply accumulate, and divide + */ + + if ((raw & 0xff800000) != 0xfb800000) return NULL; + + result = NULL; + + op1 = (raw >> 20) & b111; + op2 = (raw >> 4) & b1111; + + switch (op1) + { + case b000: + if (op2 == b0000) + result = armv7_read_thumb_32_instr_smull(raw); + break; + + case b001: + if (op2 == b1111) + result = armv7_read_thumb_32_instr_sdiv(raw); + break; + + case b010: + if (op2 == b0000) + result = armv7_read_thumb_32_instr_umull(raw); + break; + + case b011: + if (op2 == b1111) + result = armv7_read_thumb_32_instr_udiv(raw); + break; + + case b100: + + if (op2 == b0000) + result = armv7_read_thumb_32_instr_smlal(raw); + + else if ((op2 & b1100) == b1000) + result = armv7_read_thumb_32_instr_smlalbb_smlalbt_smlaltb_smlaltt(raw); + + else if ((op2 & b1110) == b1100) + result = armv7_read_thumb_32_instr_smlald(raw); + + break; + + case b101: + if ((op2 & b1110) == b1100) + result = armv7_read_thumb_32_instr_smlsld(raw); + break; + + case b110: + + if (op2 == b0000) + result = armv7_read_thumb_32_instr_umlal(raw); + + else if (op2 == b0110) + result = armv7_read_thumb_32_instr_umaal(raw); + + break; + + } + + return result; + +} + + +/****************************************************************************** +* * +* Paramètres : raw = donnée brute de 32 bits à désassembler. * +* * +* Description : Désassemble une instruction ARMv7 liées au chapitre A6.3.18. * +* * +* Retour : Instruction mise en place ou NULL en cas d'échec. * +* * +* Remarques : - * +* * +******************************************************************************/ + +static GArchInstruction *process_armv7_thumb_32_coprocessor_advanced_simd_and_floating_point_instructions(uint32_t raw) +{ + GArchInstruction *result; /* Instruction à renvoyer */ + uint32_t op1; /* Champ 'op1' à retrouver */ + uint32_t rn; /* Champ 'rn' à retrouver */ + uint32_t coproc; /* Champ 'coproc' à retrouver */ + uint32_t op; /* Champ 'op' à retrouver */ + + /** + * Suit les directives de : + * § A6.3.18 Coprocessor, Advanced SIMD, and Floating-point instructions + */ + + if ((raw & 0xec000000) != 0xec000000) return NULL; + + result = NULL; + + op1 = (raw >> 20) & 0x3f; + rn = (raw >> 16) & 0xf; + coproc = (raw >> 8) & 0xf; + op = (raw >> 4) & 0x1; + + if ((op1 & b111110) == b000000) + result = g_undef_instruction_new(IBS_UNDEFINED); + + else if ((op1 & b110000) == b110000) + result = process_armv7_simd_advanced_simd_data_processing_instructions(raw, false); + + else if ((coproc & b1110) != b1010) + { + if ((op1 & b100001) == b000000 && (op1 & b111010) != b000000) + result = armv7_read_thumb_32_instr_stc_stc2(raw); + + else if ((op1 & b100001) == b000001 && (op1 & b111010) != b000000) + { + if (rn != b1111) + result = armv7_read_thumb_32_instr_ldc_ldc2_immediate(raw); + + else/* if (rn == b1111)*/ + result = armv7_read_thumb_32_instr_ldc_ldc2_literal(raw); + + } + + else if (op1 == b000100) + result = armv7_read_thumb_32_instr_mcrr_mcrr2(raw); + + else if (op1 == b000101) + result = armv7_read_thumb_32_instr_mrrc_mrrc2(raw); + + else if ((op1 & b110000) == b100000 && op == b0) + result = armv7_read_thumb_32_instr_cdp_cdp2(raw); + + else if ((op1 & b110001) == b100000 && op == b1) + result = armv7_read_thumb_32_instr_mcr_mcr2(raw); + + else if ((op1 & b110001) == b100001 && op == b1) + result = armv7_read_thumb_32_instr_mrc_mrc2(raw); + + } + + else if ((coproc & b1110) == b1010) + { + if ((op1 & b100000) == b000000 && (op1 & b111010) != b000000) + result = process_armv7_simd_extension_register_load_store_instructions(raw, false); + + else if ((op1 & b111110) == b000100) + result = process_armv7_simd_64_bit_transfers_between_arm_core_and_extension_registers(raw, false); + + else if ((op1 & b110000) == b100000) + { + if (op == b0) + result = process_armv7_simd_floating_point_data_processing_instructions(raw, false); + + else/* if (op == b1)*/ + result = process_armv7_simd_8_16_and_32_bit_transfer_between_arm_core_and_extension_registers(raw, false); + + } + + } + + return result; + +} diff --git a/plugins/arm/v7/thumb_32.h b/plugins/arm/v7/thumb_32.h new file mode 100644 index 0000000..15ae7df --- /dev/null +++ b/plugins/arm/v7/thumb_32.h @@ -0,0 +1,37 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * thumb_32.h - prototypes pour le désassemblage des instructions ARMv7 Thumb 32 bits + * + * Copyright (C) 2014-2017 Cyrille Bagard + * + * This file is part of Chrysalide. + * + * Chrysalide is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Chrysalide is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Foobar. If not, see . + */ + + +#ifndef _PLUGINS_ARM_V7_THUMB_32_H +#define _PLUGINS_ARM_V7_THUMB_32_H + + +#include + + + +/* Désassemble une instruction ARMv7 liées au chapitre A6.3. */ +GArchInstruction *process_armv7_thumb_32_instruction_set_encoding(uint32_t); + + + +#endif /* _PLUGINS_ARM_V7_THUMB_32_H */ diff --git a/plugins/pychrysa/arch/Makefile.am b/plugins/pychrysa/arch/Makefile.am index 9421e04..694c9e0 100644 --- a/plugins/pychrysa/arch/Makefile.am +++ b/plugins/pychrysa/arch/Makefile.am @@ -11,8 +11,7 @@ libpychrysaarch_la_SOURCES = \ raw.h raw.c \ vmpa.h vmpa.c -libpychrysaarch_la_LIBADD = \ - arm/libpychrysaarcharm.la +libpychrysaarch_la_LIBADD = libpychrysaarch_la_LDFLAGS = @@ -23,4 +22,4 @@ AM_CPPFLAGS = $(LIBGTK_CFLAGS) $(LIBXML_CFLAGS) $(LIBPYTHON_CFLAGS) $(LIBPYGOBJE AM_CFLAGS = $(DEBUG_CFLAGS) $(WARNING_FLAGS) $(COMPLIANCE_FLAGS) -SUBDIRS = arm +SUBDIRS = diff --git a/plugins/pychrysa/arch/arm/Makefile.am b/plugins/pychrysa/arch/arm/Makefile.am deleted file mode 100644 index b081061..0000000 --- a/plugins/pychrysa/arch/arm/Makefile.am +++ /dev/null @@ -1,20 +0,0 @@ - -noinst_LTLIBRARIES = libpychrysaarcharm.la - -libpychrysaarcharm_la_SOURCES = \ - instruction.h instruction.c \ - module.h module.c \ - processor.h processor.c - -libpychrysaarcharm_la_LIBADD = \ - v7/libpychrysaarcharmv7.la - -libpychrysaarcharm_la_LDFLAGS = - - -AM_CPPFLAGS = $(LIBGTK_CFLAGS) $(LIBXML_CFLAGS) $(LIBPYTHON_CFLAGS) $(LIBPYGOBJECT_CFLAGS) \ - -I../../../../src - -AM_CFLAGS = $(DEBUG_CFLAGS) $(WARNING_FLAGS) $(COMPLIANCE_FLAGS) - -SUBDIRS = v7 diff --git a/plugins/pychrysa/arch/arm/instruction.c b/plugins/pychrysa/arch/arm/instruction.c deleted file mode 100644 index 7c5f41d..0000000 --- a/plugins/pychrysa/arch/arm/instruction.c +++ /dev/null @@ -1,111 +0,0 @@ - -/* Chrysalide - Outil d'analyse de fichiers binaires - * instruction.c - équivalent Python du fichier "arch/arm/instruction.c" - * - * Copyright (C) 2015-2017 Cyrille Bagard - * - * This file is part of Chrysalide. - * - * Chrysalide is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Chrysalide is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - - -#include "instruction.h" - - -#include - - -#include - - -#include "../instruction.h" -#include "../../helpers.h" - - - -/****************************************************************************** -* * -* Paramètres : - * -* * -* Description : Fournit un accès à une définition de type à diffuser. * -* * -* Retour : Définition d'objet pour Python. * -* * -* Remarques : - * -* * -******************************************************************************/ - -PyTypeObject *get_python_arm_instruction_type(void) -{ - static PyMethodDef py_arm_instruction_methods[] = { - { NULL } - }; - - static PyGetSetDef py_arm_instruction_getseters[] = { - { NULL } - }; - - static PyTypeObject py_arm_instruction_type = { - - PyVarObject_HEAD_INIT(NULL, 0) - - .tp_name = "pychrysalide.arch.arm.ArmInstruction", - .tp_basicsize = sizeof(PyGObject), - - .tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, - - .tp_doc = "PyChrysalide instruction for an ARM architecture.", - - .tp_methods = py_arm_instruction_methods, - .tp_getset = py_arm_instruction_getseters, - - }; - - return &py_arm_instruction_type; - -} - - -/****************************************************************************** -* * -* Paramètres : module = module dont la définition est à compléter. * -* * -* Description : Prend en charge l'objet 'pychrysalide....arm.ArmInstruction'.* -* * -* Retour : Bilan de l'opération. * -* * -* Remarques : - * -* * -******************************************************************************/ - -bool register_python_arm_instruction(PyObject *module) -{ - PyTypeObject *py_arm_instruction_type; /* Type Python 'BinContent' */ - PyObject *dict; /* Dictionnaire du module */ - - py_arm_instruction_type = get_python_arm_instruction_type(); - - APPLY_ABSTRACT_FLAG(py_arm_instruction_type); - - dict = PyModule_GetDict(module); - - if (!register_class_for_pygobject(dict, G_TYPE_ARM_INSTRUCTION, - py_arm_instruction_type, get_python_arch_instruction_type())) - return false; - - return true; - -} diff --git a/plugins/pychrysa/arch/arm/instruction.h b/plugins/pychrysa/arch/arm/instruction.h deleted file mode 100644 index c10c41c..0000000 --- a/plugins/pychrysa/arch/arm/instruction.h +++ /dev/null @@ -1,42 +0,0 @@ - -/* Chrysalide - Outil d'analyse de fichiers binaires - * instruction.h - prototypes pour l'équivalent Python du fichier "arch/arm/instruction.h" - * - * Copyright (C) 2015-2017 Cyrille Bagard - * - * This file is part of Chrysalide. - * - * Chrysalide is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Chrysalide is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - - -#ifndef _PLUGINS_PYCHRYSALIDE_ARCH_ARM_INSTRUCTION_H -#define _PLUGINS_PYCHRYSALIDE_ARCH_ARM_INSTRUCTION_H - - -#include -#include - - - -/* Fournit un accès à une définition de type à diffuser. */ -PyTypeObject *get_python_arm_instruction_type(void); - -/* Prend en charge l'objet 'pychrysalide.arch.arm.ArmInstruction'. */ -bool register_python_arm_instruction(PyObject *); - - - -#endif /* _PLUGINS_PYCHRYSALIDE_ARCH_ARM_INSTRUCTION_H */ diff --git a/plugins/pychrysa/arch/arm/module.c b/plugins/pychrysa/arch/arm/module.c deleted file mode 100644 index 7036449..0000000 --- a/plugins/pychrysa/arch/arm/module.c +++ /dev/null @@ -1,96 +0,0 @@ - -/* Chrysalide - Outil d'analyse de fichiers binaires - * module.c - intégration du répertoire arm en tant que module - * - * Copyright (C) 2015-2017 Cyrille Bagard - * - * This file is part of Chrysalide. - * - * Chrysalide is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Chrysalide is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - - -#include "module.h" - - -#include "instruction.h" -#include "processor.h" -#include "v7/module.h" - - - -/****************************************************************************** -* * -* Paramètres : module = module dont la définition est à compléter. * -* * -* Description : Ajoute le module 'arm' au module Python. * -* * -* Retour : - * -* * -* Remarques : - * -* * -******************************************************************************/ - -bool add_arch_arm_module_to_python_module(PyObject *super) -{ - bool result; /* Bilan à retourner */ - PyObject *module; /* Sous-module mis en place */ - int ret; /* Bilan d'un appel */ - - static PyModuleDef py_chrysalide_arm_module = { - - .m_base = PyModuleDef_HEAD_INIT, - - .m_name = "pychrysalide.arch.arm", - .m_doc = "Python module for Chrysalide.arch.arm", - - .m_size = -1, - - }; - - result = false; - - module = PyModule_Create(&py_chrysalide_arm_module); - if (module == NULL) return false; - - ret = PyState_AddModule(super, &py_chrysalide_arm_module); - if (ret != 0) goto aaamtpm_exit; - - ret = _PyImport_FixupBuiltin(module, "pychrysalide.arch.arm"); - if (ret != 0) goto aaamtpm_exit; - - Py_INCREF(module); - ret = PyModule_AddObject(super, "arm", module); - if (ret != 0) goto aaamtpm_exit; - - result = true; - - result &= register_python_arm_instruction(module); - result &= register_python_arm_processor(module); - - result &= add_arch_arm_v7_module_to_python_module(module); - - aaamtpm_exit: - - if (!result) - { - printf("something went wrong in %s...\n", __FUNCTION__); - /* ... */ - - } - - return result; - -} diff --git a/plugins/pychrysa/arch/arm/module.h b/plugins/pychrysa/arch/arm/module.h deleted file mode 100644 index 9a945e7..0000000 --- a/plugins/pychrysa/arch/arm/module.h +++ /dev/null @@ -1,39 +0,0 @@ - -/* Chrysalide - Outil d'analyse de fichiers binaires - * module.h - prototypes pour l'intégration du répertoire arm en tant que module - * - * Copyright (C) 2015-2017 Cyrille Bagard - * - * This file is part of Chrysalide. - * - * Chrysalide is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Chrysalide is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - - -#ifndef _PLUGINS_PYCHRYSALIDE_ARCH_ARM_MODULE_H -#define _PLUGINS_PYCHRYSALIDE_ARCH_ARM_MODULE_H - - -#include -#include - - - -/* Ajoute le module 'arm' au module Python. */ -bool add_arch_arm_module_to_python_module(PyObject *); - - - -#endif /* _PLUGINS_PYCHRYSALIDE_ARCH_ARM_MODULE_H */ diff --git a/plugins/pychrysa/arch/arm/processor.c b/plugins/pychrysa/arch/arm/processor.c deleted file mode 100644 index 32cdf0c..0000000 --- a/plugins/pychrysa/arch/arm/processor.c +++ /dev/null @@ -1,108 +0,0 @@ - -/* Chrysalide - Outil d'analyse de fichiers binaires - * processor.c - équivalent Python du fichier "arch/arm/processor.c" - * - * Copyright (C) 2015-2017 Cyrille Bagard - * - * This file is part of Chrysalide. - * - * Chrysalide is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Chrysalide is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - - -#include "processor.h" - - -#include - - -#include - - -#include "../processor.h" -#include "../../helpers.h" - - - -/****************************************************************************** -* * -* Paramètres : - * -* * -* Description : Fournit un accès à une définition de type à diffuser. * -* * -* Retour : Définition d'objet pour Python. * -* * -* Remarques : - * -* * -******************************************************************************/ - -PyTypeObject *get_python_arm_processor_type(void) -{ - static PyMethodDef py_arm_processor_methods[] = { - { NULL } - }; - - static PyGetSetDef py_arm_processor_getseters[] = { - { NULL } - }; - - static PyTypeObject py_arm_processor_type = { - - PyVarObject_HEAD_INIT(NULL, 0) - - .tp_name = "pychrysalide.arch.arm.ArmProcessor", - .tp_basicsize = sizeof(PyGObject), - - .tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, - - .tp_doc = "PyChrysalide processor for an ARM architecture.", - - .tp_methods = py_arm_processor_methods, - .tp_getset = py_arm_processor_getseters, - - }; - - return &py_arm_processor_type; - -} - - -/****************************************************************************** -* * -* Paramètres : module = module dont la définition est à compléter. * -* * -* Description : Prend en charge l'objet 'pychrysalide.arch.arm.ArmProcessor'.* -* * -* Retour : Bilan de l'opération. * -* * -* Remarques : - * -* * -******************************************************************************/ - -bool register_python_arm_processor(PyObject *module) -{ - PyTypeObject *py_arm_processor_type; /* Type Python 'BinContent' */ - PyObject *dict; /* Dictionnaire du module */ - - py_arm_processor_type = get_python_arm_processor_type(); - - dict = PyModule_GetDict(module); - - if (!register_class_for_pygobject(dict, G_TYPE_ARM_PROCESSOR, py_arm_processor_type, get_python_arch_processor_type())) - return false; - - return true; - -} diff --git a/plugins/pychrysa/arch/arm/processor.h b/plugins/pychrysa/arch/arm/processor.h deleted file mode 100644 index 5039e7b..0000000 --- a/plugins/pychrysa/arch/arm/processor.h +++ /dev/null @@ -1,42 +0,0 @@ - -/* Chrysalide - Outil d'analyse de fichiers binaires - * processor.h - prototypes pour l'équivalent Python du fichier "arch/arm/processor.h" - * - * Copyright (C) 2015-2017 Cyrille Bagard - * - * This file is part of Chrysalide. - * - * Chrysalide is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Chrysalide is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - - -#ifndef _PLUGINS_PYCHRYSALIDE_ARCH_ARM_PROCESSOR_H -#define _PLUGINS_PYCHRYSALIDE_ARCH_ARM_PROCESSOR_H - - -#include -#include - - - -/* Fournit un accès à une définition de type à diffuser. */ -PyTypeObject *get_python_arm_processor_type(void); - -/* Prend en charge l'objet 'pychrysalide.arch.arm.ArmProcessor'. */ -bool register_python_arm_processor(PyObject *); - - - -#endif /* _PLUGINS_PYCHRYSALIDE_ARCH_ARM_PROCESSOR_H */ diff --git a/plugins/pychrysa/arch/arm/v7/Makefile.am b/plugins/pychrysa/arch/arm/v7/Makefile.am deleted file mode 100644 index d95aff3..0000000 --- a/plugins/pychrysa/arch/arm/v7/Makefile.am +++ /dev/null @@ -1,16 +0,0 @@ - -noinst_LTLIBRARIES = libpychrysaarcharmv7.la - -libpychrysaarcharmv7_la_SOURCES = \ - instruction.h instruction.c \ - module.h module.c \ - processor.h processor.c - - -libpychrysaarcharmv7_la_LDFLAGS = - - -AM_CPPFLAGS = $(LIBGTK_CFLAGS) $(LIBXML_CFLAGS) $(LIBPYTHON_CFLAGS) $(LIBPYGOBJECT_CFLAGS) \ - -I../../../../../src - -AM_CFLAGS = $(DEBUG_CFLAGS) $(WARNING_FLAGS) $(COMPLIANCE_FLAGS) diff --git a/plugins/pychrysa/arch/arm/v7/instruction.c b/plugins/pychrysa/arch/arm/v7/instruction.c deleted file mode 100644 index 2964f16..0000000 --- a/plugins/pychrysa/arch/arm/v7/instruction.c +++ /dev/null @@ -1,109 +0,0 @@ - -/* Chrysalide - Outil d'analyse de fichiers binaires - * instruction.c - équivalent Python du fichier "arch/arm/v7/instruction.c" - * - * Copyright (C) 2015-2017 Cyrille Bagard - * - * This file is part of Chrysalide. - * - * Chrysalide is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Chrysalide is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - - -#include "instruction.h" - - -#include - - -#include - - -#include "../instruction.h" -#include "../../../helpers.h" - - - -/****************************************************************************** -* * -* Paramètres : - * -* * -* Description : Fournit un accès à une définition de type à diffuser. * -* * -* Retour : Définition d'objet pour Python. * -* * -* Remarques : - * -* * -******************************************************************************/ - -PyTypeObject *get_python_armv7_instruction_type(void) -{ - static PyMethodDef py_armv7_instruction_methods[] = { - { NULL } - }; - - static PyGetSetDef py_armv7_instruction_getseters[] = { - { NULL } - }; - - static PyTypeObject py_armv7_instruction_type = { - - PyVarObject_HEAD_INIT(NULL, 0) - - .tp_name = "pychrysalide.arch.arm.v7.ArmV7Instruction", - .tp_basicsize = sizeof(PyGObject), - - .tp_flags = Py_TPFLAGS_DEFAULT, - - .tp_doc = "PyChrysalide instruction for an ARMv7 architecture.", - - .tp_methods = py_armv7_instruction_methods, - .tp_getset = py_armv7_instruction_getseters, - - }; - - return &py_armv7_instruction_type; - -} - - -/****************************************************************************** -* * -* Paramètres : module = module dont la définition est à compléter. * -* * -* Description : Prend en charge l'objet 'pychrysalide....arm.ArmInstruction'.* -* * -* Retour : Bilan de l'opération. * -* * -* Remarques : - * -* * -******************************************************************************/ - -bool register_python_armv7_instruction(PyObject *module) -{ - PyTypeObject *py_armv7_instruction_type;/* Type Python 'BinContent' */ - PyObject *dict; /* Dictionnaire du module */ - - py_armv7_instruction_type = get_python_armv7_instruction_type(); - - dict = PyModule_GetDict(module); - - if (!register_class_for_pygobject(dict, G_TYPE_ARMV7_INSTRUCTION, - py_armv7_instruction_type, get_python_arm_instruction_type())) - return false; - - return true; - -} diff --git a/plugins/pychrysa/arch/arm/v7/instruction.h b/plugins/pychrysa/arch/arm/v7/instruction.h deleted file mode 100644 index cf10039..0000000 --- a/plugins/pychrysa/arch/arm/v7/instruction.h +++ /dev/null @@ -1,42 +0,0 @@ - -/* Chrysalide - Outil d'analyse de fichiers binaires - * instruction.h - prototypes pour l'équivalent Python du fichier "arch/arm/v7/instruction.h" - * - * Copyright (C) 2015-2017 Cyrille Bagard - * - * This file is part of Chrysalide. - * - * Chrysalide is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Chrysalide is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - - -#ifndef _PLUGINS_PYCHRYSALIDE_ARCH_ARM_V7_INSTRUCTION_H -#define _PLUGINS_PYCHRYSALIDE_ARCH_ARM_V7_INSTRUCTION_H - - -#include -#include - - - -/* Fournit un accès à une définition de type à diffuser. */ -PyTypeObject *get_python_armv7_instruction_type(void); - -/* Prend en charge l'objet 'pychrysalide.arch.arm.v7.ArmV7Instruction'. */ -bool register_python_armv7_instruction(PyObject *); - - - -#endif /* _PLUGINS_PYCHRYSALIDE_ARCH_ARM_V7_INSTRUCTION_H */ diff --git a/plugins/pychrysa/arch/arm/v7/module.c b/plugins/pychrysa/arch/arm/v7/module.c deleted file mode 100644 index 9188ae4..0000000 --- a/plugins/pychrysa/arch/arm/v7/module.c +++ /dev/null @@ -1,93 +0,0 @@ - -/* Chrysalide - Outil d'analyse de fichiers binaires - * module.c - intégration du répertoire v7 en tant que module - * - * Copyright (C) 2015-2017 Cyrille Bagard - * - * This file is part of Chrysalide. - * - * Chrysalide is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Chrysalide is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - - -#include "module.h" - - -#include "instruction.h" -#include "processor.h" - - - -/****************************************************************************** -* * -* Paramètres : module = module dont la définition est à compléter. * -* * -* Description : Ajoute le module 'arm' au module Python. * -* * -* Retour : - * -* * -* Remarques : - * -* * -******************************************************************************/ - -bool add_arch_arm_v7_module_to_python_module(PyObject *super) -{ - bool result; /* Bilan à retourner */ - PyObject *module; /* Sous-module mis en place */ - int ret; /* Bilan d'un appel */ - - static PyModuleDef py_chrysalide_v7_module = { - - .m_base = PyModuleDef_HEAD_INIT, - - .m_name = "pychrysalide.arch.arm.v7", - .m_doc = "Python module for Chrysalide.arch.arm.v7", - - .m_size = -1, - - }; - - result = false; - - module = PyModule_Create(&py_chrysalide_v7_module); - if (module == NULL) return false; - - ret = PyState_AddModule(super, &py_chrysalide_v7_module); - if (ret != 0) goto aaamtpm_exit; - - ret = _PyImport_FixupBuiltin(module, "pychrysalide.arch.arm.v7"); - if (ret != 0) goto aaamtpm_exit; - - Py_INCREF(module); - ret = PyModule_AddObject(super, "v7", module); - if (ret != 0) goto aaamtpm_exit; - - result = true; - - result &= register_python_armv7_instruction(module); - result &= register_python_armv7_processor(module); - - aaamtpm_exit: - - if (!result) - { - printf("something went wrong in %s...\n", __FUNCTION__); - /* ... */ - - } - - return result; - -} diff --git a/plugins/pychrysa/arch/arm/v7/module.h b/plugins/pychrysa/arch/arm/v7/module.h deleted file mode 100644 index 18e7d47..0000000 --- a/plugins/pychrysa/arch/arm/v7/module.h +++ /dev/null @@ -1,39 +0,0 @@ - -/* Chrysalide - Outil d'analyse de fichiers binaires - * module.h - prototypes pour l'intégration du répertoire v7 en tant que module - * - * Copyright (C) 2015-2017 Cyrille Bagard - * - * This file is part of Chrysalide. - * - * Chrysalide is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Chrysalide is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - - -#ifndef _PLUGINS_PYCHRYSALIDE_ARCH_ARM_V7_MODULE_H -#define _PLUGINS_PYCHRYSALIDE_ARCH_ARM_V7_MODULE_H - - -#include -#include - - - -/* Ajoute le module 'arm' au module Python. */ -bool add_arch_arm_v7_module_to_python_module(PyObject *); - - - -#endif /* _PLUGINS_PYCHRYSALIDE_ARCH_ARM_V7_MODULE_H */ diff --git a/plugins/pychrysa/arch/arm/v7/processor.c b/plugins/pychrysa/arch/arm/v7/processor.c deleted file mode 100644 index cd0e9eb..0000000 --- a/plugins/pychrysa/arch/arm/v7/processor.c +++ /dev/null @@ -1,108 +0,0 @@ - -/* Chrysalide - Outil d'analyse de fichiers binaires - * processor.c - équivalent Python du fichier "arch/arm/v7/processor.c" - * - * Copyright (C) 2015-2017 Cyrille Bagard - * - * This file is part of Chrysalide. - * - * Chrysalide is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Chrysalide is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - - -#include "processor.h" - - -#include - - -#include - - -#include "../processor.h" -#include "../../../helpers.h" - - - -/****************************************************************************** -* * -* Paramètres : - * -* * -* Description : Fournit un accès à une définition de type à diffuser. * -* * -* Retour : Définition d'objet pour Python. * -* * -* Remarques : - * -* * -******************************************************************************/ - -PyTypeObject *get_python_armv7_processor_type(void) -{ - static PyMethodDef py_armv7_processor_methods[] = { - { NULL } - }; - - static PyGetSetDef py_armv7_processor_getseters[] = { - { NULL } - }; - - static PyTypeObject py_armv7_processor_type = { - - PyVarObject_HEAD_INIT(NULL, 0) - - .tp_name = "pychrysalide.arch.arm.v7.ArmV7Processor", - .tp_basicsize = sizeof(PyGObject), - - .tp_flags = Py_TPFLAGS_DEFAULT, - - .tp_doc = "PyChrysalide processor for an ARMv7 architecture.", - - .tp_methods = py_armv7_processor_methods, - .tp_getset = py_armv7_processor_getseters, - - }; - - return &py_armv7_processor_type; - -} - - -/****************************************************************************** -* * -* Paramètres : module = module dont la définition est à compléter. * -* * -* Description : Prend en charge l'objet 'pychrysalide.arch.arm.ArmProcessor'.* -* * -* Retour : Bilan de l'opération. * -* * -* Remarques : - * -* * -******************************************************************************/ - -bool register_python_armv7_processor(PyObject *module) -{ - PyTypeObject *py_armv7_processor_type; /* Type Python 'BinContent' */ - PyObject *dict; /* Dictionnaire du module */ - - py_armv7_processor_type = get_python_armv7_processor_type(); - - dict = PyModule_GetDict(module); - - if (!register_class_for_pygobject(dict, G_TYPE_ARMV7_PROCESSOR, py_armv7_processor_type, get_python_arm_processor_type())) - return false; - - return true; - -} diff --git a/plugins/pychrysa/arch/arm/v7/processor.h b/plugins/pychrysa/arch/arm/v7/processor.h deleted file mode 100644 index 6d7cb4a..0000000 --- a/plugins/pychrysa/arch/arm/v7/processor.h +++ /dev/null @@ -1,42 +0,0 @@ - -/* Chrysalide - Outil d'analyse de fichiers binaires - * processor.h - prototypes pour l'équivalent Python du fichier "arch/arm/v7/processor.h" - * - * Copyright (C) 2015-2017 Cyrille Bagard - * - * This file is part of Chrysalide. - * - * Chrysalide is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Chrysalide is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - - -#ifndef _PLUGINS_PYCHRYSALIDE_ARCH_ARM_V7_PROCESSOR_H -#define _PLUGINS_PYCHRYSALIDE_ARCH_ARM_V7_PROCESSOR_H - - -#include -#include - - - -/* Fournit un accès à une définition de type à diffuser. */ -PyTypeObject *get_python_armv7_processor_type(void); - -/* Prend en charge l'objet 'pychrysalide.arch.arm.v7.ArmV7Processor'. */ -bool register_python_armv7_processor(PyObject *); - - - -#endif /* _PLUGINS_PYCHRYSALIDE_ARCH_ARM_V7_PROCESSOR_H */ diff --git a/plugins/pychrysa/arch/module.c b/plugins/pychrysa/arch/module.c index ae90b5d..54b470c 100644 --- a/plugins/pychrysa/arch/module.c +++ b/plugins/pychrysa/arch/module.c @@ -38,7 +38,6 @@ #include "processor.h" #include "raw.h" #include "vmpa.h" -#include "arm/module.h" #include "../access.h" #include "../helpers.h" @@ -154,8 +153,6 @@ bool add_arch_module_to_python_module(PyObject *super) result &= register_python_imm_operand(module); - result &= add_arch_arm_module_to_python_module(module); - if (result) register_access_to_python_module("pychrysalide.arch", module); diff --git a/plugins/ropgadgets/helper_arm.c b/plugins/ropgadgets/helper_arm.c index d68a4e6..bb2e2b2 100644 --- a/plugins/ropgadgets/helper_arm.c +++ b/plugins/ropgadgets/helper_arm.c @@ -27,7 +27,7 @@ #include -#include +#include diff --git a/plugins/ropgadgets/plugin.c b/plugins/ropgadgets/plugin.c index 85ae6dd..299c090 100644 --- a/plugins/ropgadgets/plugin.c +++ b/plugins/ropgadgets/plugin.c @@ -36,8 +36,8 @@ -DEFINE_CHRYSALIDE_ACTIVE_PLUGIN("ROP gadgets", "Find available gadgets for a ROP chain", "0.1.0", - PGA_PLUGIN_INIT); +DEFINE_CHRYSALIDE_PLUGIN("ROP gadgets", "Find available gadgets for a ROP chain", "0.1.0", + RL("PyChrysalide"), AL(PGA_PLUGIN_INIT)); diff --git a/src/arch/Makefile.am b/src/arch/Makefile.am index 005f640..bffd15e 100644 --- a/src/arch/Makefile.am +++ b/src/arch/Makefile.am @@ -29,8 +29,7 @@ libarch_la_SOURCES = \ # mips/libarchmips.la \ # x86/libarchx86.la -libarch_la_LIBADD = \ - arm/libarcharm.la +libarch_la_LIBADD = libarch_la_LDFLAGS = @@ -41,4 +40,4 @@ AM_CFLAGS = $(DEBUG_CFLAGS) $(WARNING_FLAGS) $(COMPLIANCE_FLAGS) #SUBDIRS = arm dalvik jvm mips x86 -SUBDIRS = arm +SUBDIRS = diff --git a/src/arch/arm/Makefile.am b/src/arch/arm/Makefile.am deleted file mode 100644 index 496872a..0000000 --- a/src/arch/arm/Makefile.am +++ /dev/null @@ -1,27 +0,0 @@ - -noinst_LTLIBRARIES = libarcharm.la - -libarcharm_la_SOURCES = \ - cond.h \ - context-int.h \ - context.h context.c \ - instruction-int.h \ - instruction.h instruction.c \ - link.h link.c \ - processor-int.h \ - processor.h processor.c \ - register-int.h \ - register.h register.c - -libarcharm_la_LIBADD = \ - v7/libarcharmv7.la - -libarcharm_la_CFLAGS = $(AM_CFLAGS) - - -AM_CPPFLAGS = $(LIBGTK_CFLAGS) $(LIBXML_CFLAGS) - -AM_CFLAGS = $(DEBUG_CFLAGS) $(WARNING_FLAGS) $(COMPLIANCE_FLAGS) - - -SUBDIRS = v7 diff --git a/src/arch/arm/cond.h b/src/arch/arm/cond.h deleted file mode 100644 index 549d368..0000000 --- a/src/arch/arm/cond.h +++ /dev/null @@ -1,64 +0,0 @@ - -/* Chrysalide - Outil d'analyse de fichiers binaires - * encoding.h - prototypes pour le décodage des conditions d'exécution ARM - * - * Copyright (C) 2014-2017 Cyrille Bagard - * - * This file is part of Chrysalide. - * - * Chrysalide is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Chrysalide is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Foobar. If not, see . - */ - - -#ifndef _ARCH_ARM_ENCODING_H -#define _ARCH_ARM_ENCODING_H - - - -/** - * Les conditions d'exécutions sont partagées par les architectures ARM : - * - * ARMv7 Instruction Details - * § A8.3 Conditional execution - * - * ARMv8 Instruction Set Overview. - * § 4.3 Condition Codes. - * - */ - -/* Liste des conditions possibles */ -typedef enum _ArmCondCode -{ - ACC_EQ = 0x0, /* Equal */ - ACC_NE = 0x1, /* Not equal */ - ACC_HS = 0x2, /* Unsigned higher or same */ - ACC_LO = 0x3, /* Unsigned lower */ - ACC_MI = 0x4, /* Minus */ - ACC_PL = 0x5, /* Plus or zero */ - ACC_VS = 0x6, /* Overflow set */ - ACC_VC = 0x7, /* Overflow clear */ - ACC_HI = 0x8, /* Unsigned higher */ - ACC_LS = 0x9, /* Unsigned lower or same */ - ACC_GE = 0xa, /* Signed greater than or equal*/ - ACC_LT = 0xb, /* Signed less than */ - ACC_GT = 0xc, /* Signed greater than */ - ACC_LE = 0xd, /* Signed less than or equal */ - ACC_AL = 0xe, /* Always */ - ACC_NV = 0xf, /* (Never) */ - -} ArmCondCode; - - - -#endif /* _ARCH_ARM_ENCODING_H */ diff --git a/src/arch/arm/context-int.h b/src/arch/arm/context-int.h deleted file mode 100644 index 4e7d9a3..0000000 --- a/src/arch/arm/context-int.h +++ /dev/null @@ -1,75 +0,0 @@ - -/* Chrysalide - Outil d'analyse de fichiers binaires - * context-int.h - prototypes internes pour le contexte lié à l'exécution d'un processeur - * - * Copyright (C) 2015-2017 Cyrille Bagard - * - * This file is part of Chrysalide. - * - * Chrysalide is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Chrysalide is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Foobar. If not, see . - */ - - -#ifndef _ARCH_ARM_CONTEXT_INT_H -#define _ARCH_ARM_CONTEXT_INT_H - - -#include "context.h" - - -#include "../context-int.h" - - - -/* Découpage de la zone de désassemblage */ -typedef struct _disass_arm_area -{ - virt_t start; /* Début de la zone */ - virt_t end; /* Fin de la zone */ - - unsigned int marker; /* Type de décodage associé */ - -} disass_arm_area; - - -/* Définition d'un contexte pour processeur ARM (instance) */ -struct _GArmContext -{ - GProcContext parent; /* A laisser en premier */ - - disass_arm_area *areas; /* Désassemblage découpé */ - size_t acount; /* Nombre de zones définies */ - GMutex areas_access; /* Accès aux découpes de zones */ - -}; - - -/* Définition d'un contexte pour processeur ARM (classe) */ -struct _GArmContextClass -{ - GProcContextClass parent; /* A laisser en premier */ - -}; - - - -/* Enregistre l'encodage (générique) utilisé à une adresse. */ -void _g_arm_context_define_encoding(GArmContext *, virt_t, unsigned int); - -/* Indique l'encodage (générique) utilisé à une adresse donnée. */ -unsigned int _g_arm_context_find_encoding(GArmContext *, virt_t); - - - -#endif /* _ARCH_ARM_CONTEXT_INT_H */ diff --git a/src/arch/arm/context.c b/src/arch/arm/context.c deleted file mode 100644 index 15c7bf5..0000000 --- a/src/arch/arm/context.c +++ /dev/null @@ -1,447 +0,0 @@ - -/* Chrysalide - Outil d'analyse de fichiers binaires - * context.c - contexte lié à l'exécution d'un processeur - * - * Copyright (C) 2014-2017 Cyrille Bagard - * - * This file is part of Chrysalide. - * - * Chrysalide is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Chrysalide is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Foobar. If not, see . - */ - - -#include "context.h" - - -#include -#include -#include - - -#include "context-int.h" - - - -/* ------------------------ MANIPULATION GLOBALE DU CONTEXTE ------------------------ */ - - -/* Initialise la classe des contextes de processeur ARM. */ -static void g_arm_context_class_init(GArmContextClass *); - -/* Initialise une instance de contexte de processeur ARM. */ -static void g_arm_context_init(GArmContext *); - -/* Supprime toutes les références externes. */ -static void g_arm_context_dispose(GArmContext *); - -/* Procède à la libération totale de la mémoire. */ -static void g_arm_context_finalize(GArmContext *); - -/* Indique l'encodage (générique) utilisé à une adresse donnée. */ -static size_t find_disass_arm_area(disass_arm_area *, virt_t, size_t, size_t); - - - -/* ------------------------- CONTEXTE POUR LA DECOMPILATION ------------------------- */ - -#if 0 -/* Définition d'un contexte pour décompilation ARM (instance) */ -struct _GArmDContext -{ - GDecContext parent; /* A laisser en premier */ - - GDecInstruction *this; /* Représentation de la classe */ - GHashTable *args; /* Correspondance arg./pseudo */ - GHashTable *locals; /* Correspondance var./pseudo */ - size_t locals_count; /* Quantité de var. locales */ - -}; - - -/* Définition d'un contexte pour décompilation ARM (classe) */ -struct _GArmDContextClass -{ - GDecContextClass parent; /* A laisser en premier */ - -}; - - -/* Initialise la classe des contextes de décompilation ARM. */ -static void g_arm_dcontext_class_init(GArmDContextClass *); - -/* Initialise une instance de contexte de décompilation ARM. */ -static void g_arm_dcontext_init(GArmDContext *); - -/* Supprime toutes les références externes. */ -static void g_arm_dcontext_dispose(GArmDContext *); - -/* Procède à la libération totale de la mémoire. */ -static void g_arm_dcontext_finalize(GArmDContext *); -#endif - - - -/* ---------------------------------------------------------------------------------- */ -/* MANIPULATION GLOBALE DU CONTEXTE */ -/* ---------------------------------------------------------------------------------- */ - - -/* Indique le type définit par la GLib pour le contexte de processeur ARM. */ -G_DEFINE_TYPE(GArmContext, g_arm_context, G_TYPE_PROC_CONTEXT); - - -/****************************************************************************** -* * -* Paramètres : klass = classe à initialiser. * -* * -* Description : Initialise la classe des contextes de processeur ARM. * -* * -* Retour : - * -* * -* Remarques : - * -* * -******************************************************************************/ - -static void g_arm_context_class_init(GArmContextClass *klass) -{ - GObjectClass *object; /* Autre version de la classe */ - - object = G_OBJECT_CLASS(klass); - - object->dispose = (GObjectFinalizeFunc/* ! */)g_arm_context_dispose; - object->finalize = (GObjectFinalizeFunc)g_arm_context_finalize; - -} - - -/****************************************************************************** -* * -* Paramètres : ctx = instance à initialiser. * -* * -* Description : Initialise une instance de contexte de processeur ARM. * -* * -* Retour : - * -* * -* Remarques : - * -* * -******************************************************************************/ - -static void g_arm_context_init(GArmContext *ctx) -{ - g_mutex_init(&ctx->areas_access); - -} - - -/****************************************************************************** -* * -* Paramètres : ctx = instance d'objet GLib à traiter. * -* * -* Description : Supprime toutes les références externes. * -* * -* Retour : - * -* * -* Remarques : - * -* * -******************************************************************************/ - -static void g_arm_context_dispose(GArmContext *ctx) -{ - g_mutex_clear(&ctx->areas_access); - - G_OBJECT_CLASS(g_arm_context_parent_class)->dispose(G_OBJECT(ctx)); - -} - - -/****************************************************************************** -* * -* Paramètres : ctx = instance d'objet GLib à traiter. * -* * -* Description : Procède à la libération totale de la mémoire. * -* * -* Retour : - * -* * -* Remarques : - * -* * -******************************************************************************/ - -static void g_arm_context_finalize(GArmContext *ctx) -{ - G_OBJECT_CLASS(g_arm_context_parent_class)->finalize(G_OBJECT(ctx)); - -} - - -/****************************************************************************** -* * -* Paramètres : - * -* * -* Description : Crée un contexte pour l'exécution du processeur ARM. * -* * -* Retour : Contexte mis en place. * -* * -* Remarques : - * -* * -******************************************************************************/ - -GArmContext *g_arm_context_new(void) -{ - GArmContext *result; /* Structure à retourner */ - - result = g_object_new(G_TYPE_ARM_CONTEXT, NULL); - - return result; - -} - - -/****************************************************************************** -* * -* Paramètres : areas = ensemble des découpages du désassemblage. * -* addr = adresse d'un nouveau point de départ à retrouver. * -* first = indice de la première zone à considérer. * -* last = indice de la dernière zone à considérer. * -* * -* Description : Indique l'encodage (générique) utilisé à une adresse donnée. * -* * -* Retour : Marqueur à priori toujours valide. * -* * -* Remarques : - * -* * -******************************************************************************/ - -static size_t find_disass_arm_area(disass_arm_area *areas, virt_t addr, size_t first, size_t last) -{ - size_t index; /* Indice de cellule idéale */ - size_t mid; /* Division de l'espace */ - - if (first == last) - index = first; - - else - { - mid = first + (last - first + 1) / 2; - - if (areas[mid].start <= addr) - index = find_disass_arm_area(areas, addr, mid, last); - else - index = find_disass_arm_area(areas, addr, first, mid - 1); - - } - - assert(areas[index].start <= addr && addr <= areas[index].end); - - return index; - -} - - -/****************************************************************************** -* * -* Paramètres : ctx = contexte de désassemblage à compléter. * -* addr = adresse d'un nouveau point de départ à créer. * -* marker = forme générique d'un encodage à mémoriser. * -* * -* Description : Enregistre l'encodage (générique) utilisé à une adresse. * -* * -* Retour : - * -* * -* Remarques : - * -* * -******************************************************************************/ - -void _g_arm_context_define_encoding(GArmContext *ctx, virt_t addr, unsigned int marker) -{ - size_t selected; /* Zone associée à une adresse */ - - g_mutex_lock(&ctx->areas_access); - - selected = find_disass_arm_area(ctx->areas, addr, 0, ctx->acount - 1); - - //assert(ctx->areas[selected].start != addr || ctx->areas[selected].marker == marker); - - /* S'agit-il d'une redéfinition ? */ - if (ctx->areas[selected].start == addr) - ctx->areas[selected].marker = marker; - - /* Sinon on redivise... */ - else - { - ctx->areas = (disass_arm_area *)realloc(ctx->areas, ++ctx->acount * sizeof(disass_arm_area)); - - memmove(&ctx->areas[selected + 1], &ctx->areas[selected], - (ctx->acount - selected - 1) * sizeof(disass_arm_area)); - - ctx->areas[selected].start = ctx->areas[selected + 1].start; - ctx->areas[selected].end = addr - 1; - ctx->areas[selected].marker = ctx->areas[selected + 1].marker; - - ctx->areas[selected + 1].start = addr; - ctx->areas[selected + 1].marker = marker; - - } - - g_mutex_unlock(&ctx->areas_access); - -} - - -/****************************************************************************** -* * -* Paramètres : ctx = contexte de désassemblage à consulter. * -* addr = adresse d'un nouveau point de départ à retrouver. * -* * -* Description : Indique l'encodage (générique) utilisé à une adresse donnée. * -* * -* Retour : Marqueur à priori toujours valide. * -* * -* Remarques : - * -* * -******************************************************************************/ - -unsigned int _g_arm_context_find_encoding(GArmContext *ctx, virt_t addr) -{ - unsigned int result; /* Identifiant à retourner */ - size_t selected; /* Zone associée à une adresse */ - - g_mutex_lock(&ctx->areas_access); - - selected = find_disass_arm_area(ctx->areas, addr, 0, ctx->acount - 1); - - result = ctx->areas[selected].marker; - - g_mutex_unlock(&ctx->areas_access); - - return result; - -} - - - - - - - -/* ---------------------------------------------------------------------------------- */ -/* CONTEXTE POUR LA DECOMPILATION */ -/* ---------------------------------------------------------------------------------- */ - -#if 0 -/* Indique le type définit par la GLib pour le contexte de décompilation ARM. */ -G_DEFINE_TYPE(GArmDContext, g_arm_dcontext, G_TYPE_DEC_CONTEXT); - - -/****************************************************************************** -* * -* Paramètres : class = classe à initialiser. * -* * -* Description : Initialise la classe des contextes de décompilation ARM. * -* * -* Retour : - * -* * -* Remarques : - * -* * -******************************************************************************/ - -static void g_arm_dcontext_class_init(GArmDContextClass *class) -{ - GObjectClass *object; /* Autre version de la classe */ - - object = G_OBJECT_CLASS(class); - - object->dispose = (GObjectFinalizeFunc/* ! */)g_arm_dcontext_dispose; - object->finalize = (GObjectFinalizeFunc)g_arm_dcontext_finalize; - -} - - -/****************************************************************************** -* * -* Paramètres : ctx = instance à initialiser. * -* * -* Description : Initialise une instance de contexte de décompilation ARM. * -* * -* Retour : - * -* * -* Remarques : - * -* * -******************************************************************************/ - -static void g_arm_dcontext_init(GArmDContext *ctx) -{ - -} - - -/****************************************************************************** -* * -* Paramètres : ctx = instance d'objet GLib à traiter. * -* * -* Description : Supprime toutes les références externes. * -* * -* Retour : - * -* * -* Remarques : - * -* * -******************************************************************************/ - -static void g_arm_dcontext_dispose(GArmDContext *ctx) -{ - G_OBJECT_CLASS(g_arm_dcontext_parent_class)->dispose(G_OBJECT(ctx)); - -} - - -/****************************************************************************** -* * -* Paramètres : ctx = instance d'objet GLib à traiter. * -* * -* Description : Procède à la libération totale de la mémoire. * -* * -* Retour : - * -* * -* Remarques : - * -* * -******************************************************************************/ - -static void g_arm_dcontext_finalize(GArmDContext *ctx) -{ - G_OBJECT_CLASS(g_arm_dcontext_parent_class)->finalize(G_OBJECT(ctx)); - -} - - -/****************************************************************************** -* * -* Paramètres : - * -* * -* Description : Crée un contexte pour la décompilation ARM. * -* * -* Retour : Contexte mis en place. * -* * -* Remarques : - * -* * -******************************************************************************/ - -GArmDContext *g_arm_dcontext_new(void) -{ - GArmDContext *result; /* Structure à retourner */ - - result = g_object_new(G_TYPE_ARM_DCONTEXT, NULL); - - return result; - -} -#endif diff --git a/src/arch/arm/context.h b/src/arch/arm/context.h deleted file mode 100644 index 2b5402d..0000000 --- a/src/arch/arm/context.h +++ /dev/null @@ -1,85 +0,0 @@ - -/* Chrysalide - Outil d'analyse de fichiers binaires - * context.h - prototypes pour le contexte lié à l'exécution d'un processeur - * - * Copyright (C) 2014-2017 Cyrille Bagard - * - * This file is part of Chrysalide. - * - * Chrysalide is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Chrysalide is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Foobar. If not, see . - */ - - -#ifndef _ARCH_ARM_CONTEXT_H -#define _ARCH_ARM_CONTEXT_H - - -#include - - - -/* ------------------------ MANIPULATION GLOBALE DU CONTEXTE ------------------------ */ - - -#define G_TYPE_ARM_CONTEXT g_arm_context_get_type() -#define G_ARM_CONTEXT(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), g_arm_context_get_type(), GArmContext)) -#define G_IS_ARM_CONTEXT(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), g_arm_context_get_type())) -#define G_ARM_CONTEXT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), G_TYPE_ARM_CONTEXT, GGArmContextClass)) -#define G_IS_ARM_CONTEXT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), G_TYPE_ARM_CONTEXT)) -#define G_ARM_CONTEXT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), G_TYPE_ARM_CONTEXT, GGArmContextClass)) - - -/* Définition d'un contexte pour processeur ARM (instance) */ -typedef struct _GArmContext GArmContext; - -/* Définition d'un contexte pour processeur ARM (classe) */ -typedef struct _GArmContextClass GArmContextClass; - - -/* Indique le type définit par la GLib pour le contexte de processeur ARM. */ -GType g_arm_context_get_type(void); - -/* Crée un contexte pour l'exécution du processeur ARM. */ -GArmContext *g_arm_context_new(void); - - - -/* ------------------------- CONTEXTE POUR LA DECOMPILATION ------------------------- */ - -#if 0 -#define G_TYPE_ARM_DCONTEXT g_arm_dcontext_get_type() -#define G_ARM_DCONTEXT(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), g_arm_dcontext_get_type(), GArmDContext)) -#define G_IS_ARM_DCONTEXT(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), g_arm_dcontext_get_type())) -#define G_ARM_DCONTEXT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), G_TYPE_ARM_DCONTEXT, GGArmDContextClass)) -#define G_IS_ARM_DCONTEXT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), G_TYPE_ARM_DCONTEXT)) -#define G_ARM_DCONTEXT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), G_TYPE_ARM_DCONTEXT, GGArmDContextClass)) - - -/* Définition d'un contexte pour décompilation ARM (instance) */ -typedef struct _GArmDContext GArmDContext; - -/* Définition d'un contexte pour décompilation ARM (classe) */ -typedef struct _GArmDContextClass GArmDContextClass; - - -/* Indique le type définit par la GLib pour le contexte de décompilation ARM. */ -GType g_arm_dcontext_get_type(void); - -/* Crée un contexte pour la décompilation ARM. */ -GArmDContext *g_arm_dcontext_new(void); -#endif - - - -#endif /* _ARCH_ARM_CONTEXT_H */ diff --git a/src/arch/arm/instruction-int.h b/src/arch/arm/instruction-int.h deleted file mode 100644 index 408b44c..0000000 --- a/src/arch/arm/instruction-int.h +++ /dev/null @@ -1,55 +0,0 @@ - -/* Chrysalide - Outil d'analyse de fichiers binaires - * instruction-int.h - prototypes pour la définition générique interne des instructions ARM - * - * Copyright (C) 2013-2017 Cyrille Bagard - * - * This file is part of Chrysalide. - * - * Chrysalide is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Chrysalide is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Foobar. If not, see . - */ - - -#ifndef _ARCH_ARM_INSTRUCTION_INT_H -#define _ARCH_ARM_INSTRUCTION_INT_H - - -#include "instruction.h" -#include "../instruction-int.h" - - - -/* Définition générique d'une instruction d'architecture ARM (instance) */ -struct _GArmInstruction -{ - GArchInstruction parent; /* A laisser en premier */ - - const char *keyword; /* Nom clef de l'instruction */ - char *suffix; /* Complément au nom affiché */ - char *cached_keyword; /* Désignation complète */ - - ArmCondCode cond; /* Condition d'exécution */ - -}; - -/* Définition générique d'une instruction d'architecture ARM (classe) */ -struct _GArmInstructionClass -{ - GArchInstructionClass parent; /* A laisser en premier */ - -}; - - - -#endif /* _ARCH_ARM_INSTRUCTION_INT_H */ diff --git a/src/arch/arm/instruction.c b/src/arch/arm/instruction.c deleted file mode 100644 index bcd0f74..0000000 --- a/src/arch/arm/instruction.c +++ /dev/null @@ -1,272 +0,0 @@ - -/* Chrysalide - Outil d'analyse de fichiers binaires - * instruction.c - gestion des instructions de la ARM - * - * Copyright (C) 2013-2017 Cyrille Bagard - * - * This file is part of Chrysalide. - * - * Chrysalide is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Chrysalide is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Foobar. If not, see . - */ - - -#include "instruction.h" - - -#include -#include - - -#include "instruction-int.h" -#include "../../common/extstr.h" - - - -/* Initialise la classe des instructions ARM. */ -static void g_arm_instruction_class_init(GArmInstructionClass *); - -/* Initialise une instance de instruction ARM. */ -static void g_arm_instruction_init(GArmInstruction *); - -/* Supprime toutes les références externes. */ -static void g_arm_instruction_dispose(GArmInstruction *); - -/* Procède à la libération totale de la mémoire. */ -static void g_arm_instruction_finalize(GArmInstruction *); - -/* Fournit le nom humain de l'instruction manipulée. */ -static const char *g_arm_instruction_get_keyword(GArmInstruction *, AsmSyntax); - - - -/* Indique le type défini pour une représentation d'une instruction ARM. */ -G_DEFINE_TYPE(GArmInstruction, g_arm_instruction, G_TYPE_ARCH_INSTRUCTION); - - -/****************************************************************************** -* * -* Paramètres : klass = classe à initialiser. * -* * -* Description : Initialise la classe des instructions ARM. * -* * -* Retour : - * -* * -* Remarques : - * -* * -******************************************************************************/ - -static void g_arm_instruction_class_init(GArmInstructionClass *klass) -{ - GObjectClass *object_class; /* Autre version de la classe */ - GArchInstructionClass *instr; /* Encore une autre vision... */ - - object_class = G_OBJECT_CLASS(klass); - instr = G_ARCH_INSTRUCTION_CLASS(klass); - - object_class->dispose = (GObjectFinalizeFunc/* ! */)g_arm_instruction_dispose; - object_class->finalize = (GObjectFinalizeFunc)g_arm_instruction_finalize; - - instr->get_keyword = (get_instruction_keyword_fc)g_arm_instruction_get_keyword; - -} - - -/****************************************************************************** -* * -* Paramètres : instr = instance à initialiser. * -* * -* Description : Initialise une instance d'instruction ARM. * -* * -* Retour : - * -* * -* Remarques : - * -* * -******************************************************************************/ - -static void g_arm_instruction_init(GArmInstruction *instr) -{ - instr->cond = ACC_AL; - -} - - -/****************************************************************************** -* * -* Paramètres : instr = instance d'objet GLib à traiter. * -* * -* Description : Supprime toutes les références externes. * -* * -* Retour : - * -* * -* Remarques : - * -* * -******************************************************************************/ - -static void g_arm_instruction_dispose(GArmInstruction *instr) -{ - G_OBJECT_CLASS(g_arm_instruction_parent_class)->dispose(G_OBJECT(instr)); - -} - - -/****************************************************************************** -* * -* Paramètres : instr = instance d'objet GLib à traiter. * -* * -* Description : Procède à la libération totale de la mémoire. * -* * -* Retour : - * -* * -* Remarques : - * -* * -******************************************************************************/ - -static void g_arm_instruction_finalize(GArmInstruction *instr) -{ - if (instr->suffix != NULL) - free(instr->suffix); - - if (instr->cached_keyword != NULL) - free(instr->cached_keyword); - - G_OBJECT_CLASS(g_arm_instruction_parent_class)->finalize(G_OBJECT(instr)); - -} - - -/****************************************************************************** -* * -* Paramètres : instr = instruction quelconque à modifier. * -* suffix = chaîne de caractères fournie en complément. * -* * -* Description : Etend la désignation d'un nom d'instruction. * -* * -* Retour : true. * -* * -* Remarques : - * -* * -******************************************************************************/ - -bool g_arm_instruction_extend_keyword(GArmInstruction *instr, const char *suffix) -{ - instr->suffix = stradd(instr->suffix, suffix); - - if (instr->cached_keyword != NULL) - { - free(instr->cached_keyword); - instr->cached_keyword = NULL; - } - - return true; - -} - - -/****************************************************************************** -* * -* Paramètres : instr = instruction d'assemblage à consulter. * -* syntax = type de représentation demandée. * -* * -* Description : Fournit le nom humain de l'instruction manipulée. * -* * -* Retour : Mot clef de bas niveau. * -* * -* Remarques : - * -* * -******************************************************************************/ - -static const char *g_arm_instruction_get_keyword(GArmInstruction *instr, AsmSyntax syntax) -{ - if (instr->cached_keyword == NULL) - { - instr->cached_keyword = strdup(instr->keyword); - - if (instr->suffix != NULL) - instr->cached_keyword = stradd(instr->cached_keyword, instr->suffix); - - } - - return instr->cached_keyword; - -} - - -/****************************************************************************** -* * -* Paramètres : instr = instruction ARM à mettre à jour. * -* cond = condition d'exécution de l'instruction. * -* * -* Description : Définit les conditions d'exécution d'une instruction ARM. * -* * -* Retour : Bilan de l'opération. * -* * -* Remarques : - * -* * -******************************************************************************/ - -bool g_arm_instruction_set_cond(GArmInstruction *instr, ArmCondCode cond) -{ - bool result; /* Bilan à retourner */ - const char *suffix; /* Eventuelle marque à ajouter */ - - instr->cond = cond; - - switch (cond) - { - case ACC_EQ: suffix = "eq"; break; - case ACC_NE: suffix = "ne"; break; - case ACC_HS: suffix = "hs"; break; - case ACC_LO: suffix = "lo"; break; - case ACC_MI: suffix = "mi"; break; - case ACC_PL: suffix = "pl"; break; - case ACC_VS: suffix = "vs"; break; - case ACC_VC: suffix = "vc"; break; - case ACC_HI: suffix = "hi"; break; - case ACC_LS: suffix = "ls"; break; - case ACC_GE: suffix = "ge"; break; - case ACC_LT: suffix = "lt"; break; - case ACC_GT: suffix = "gt"; break; - case ACC_LE: suffix = "le"; break; - case ACC_AL: suffix = NULL; break; - case ACC_NV: suffix = "nv"; break; - } - - if (suffix != NULL) - result = g_arm_instruction_extend_keyword(instr, suffix); - - else - result = true; - - return result; - -} - - -/****************************************************************************** -* * -* Paramètres : instr = instruction ARM à consulter. * -* * -* Description : Indique les conditions d'exécution d'une instruction ARM. * -* * -* Retour : Condition d'exécution de l'instruction. * -* * -* Remarques : - * -* * -******************************************************************************/ - -ArmCondCode g_arm_instruction_get_cond(const GArmInstruction *instr) -{ - return instr->cond; - -} diff --git a/src/arch/arm/instruction.h b/src/arch/arm/instruction.h deleted file mode 100644 index 8b0110d..0000000 --- a/src/arch/arm/instruction.h +++ /dev/null @@ -1,67 +0,0 @@ - -/* Chrysalide - Outil d'analyse de fichiers binaires - * instruction.h - prototypes pour la gestion des instructions ARM - * - * Copyright (C) 2013-2017 Cyrille Bagard - * - * This file is part of Chrysalide. - * - * Chrysalide is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Chrysalide is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Foobar. If not, see . - */ - - -#ifndef _ARCH_ARM_INSTRUCTION_H -#define _ARCH_ARM_INSTRUCTION_H - - -#include -#include -#include - - -#include "cond.h" -#include "../instruction.h" - - - -#define G_TYPE_ARM_INSTRUCTION g_arm_instruction_get_type() -#define G_ARM_INSTRUCTION(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), g_arm_instruction_get_type(), GArmInstruction)) -#define G_IS_ARM_INSTRUCTION(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), g_arm_instruction_get_type())) -#define G_ARM_INSTRUCTION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), G_TYPE_ARM_INSTRUCTION, GArmInstructionClass)) -#define G_IS_ARM_INSTRUCTION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), G_TYPE_ARM_INSTRUCTION)) -#define G_ARM_INSTRUCTION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), G_TYPE_ARM_INSTRUCTION, GArmInstructionClass)) - - -/* Définition d'une instruction d'architecture ARM (instance) */ -typedef struct _GArmInstruction GArmInstruction; - -/* Définition d'une instruction d'architecture ARM (classe) */ -typedef struct _GArmInstructionClass GArmInstructionClass; - - -/* Indique le type défini pour une représentation d'une instruction ARM. */ -GType g_arm_instruction_get_type(void); - -/* Etend la désignation d'un nom d'instruction. */ -bool g_arm_instruction_extend_keyword(GArmInstruction *, const char *); - -/* Définit les conditions d'exécution d'une instruction ARM. */ -bool g_arm_instruction_set_cond(GArmInstruction *, ArmCondCode); - -/* Indique les conditions d'exécution d'une instruction ARM. */ -ArmCondCode g_arm_instruction_get_cond(const GArmInstruction *); - - - -#endif /* _ARCH_ARM_INSTRUCTION_H */ diff --git a/src/arch/arm/link.c b/src/arch/arm/link.c deleted file mode 100644 index 57f0f98..0000000 --- a/src/arch/arm/link.c +++ /dev/null @@ -1,65 +0,0 @@ - -/* Chrysalide - Outil d'analyse de fichiers binaires - * link.c - édition des liens après la phase de désassemblage ARM - * - * Copyright (C) 2015-2017 Cyrille Bagard - * - * This file is part of Chrysalide. - * - * Chrysalide is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Chrysalide is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Foobar. If not, see . - */ - - -#include "link.h" - - -#include "cond.h" -#include "instruction.h" -#include "../link.h" - - - -/****************************************************************************** -* * -* Paramètres : instr = instruction ARM à traiter. * -* proc = représentation de l'architecture utilisée. * -* context = contexte associé à la phase de désassemblage. * -* format = acès aux données du binaire d'origine. * -* * -* Description : Etablit un lien conditionnel selon une instruction donnée. * -* * -* Retour : - * -* * -* Remarques : - * -* * -******************************************************************************/ - -void handle_arm_conditional_branch_as_link(GArchInstruction *instr, GArchProcessor *proc, GProcContext *context, GExeFormat *format) -{ - switch (g_arm_instruction_get_cond(G_ARM_INSTRUCTION(instr))) - { - case ACC_AL: - handle_jump_as_link(instr, proc, context, format); - break; - - case ACC_NV: - break; - - default: - handle_branch_if_true_as_link(instr, proc, context, format); - break; - - } - -} diff --git a/src/arch/arm/link.h b/src/arch/arm/link.h deleted file mode 100644 index 216277d..0000000 --- a/src/arch/arm/link.h +++ /dev/null @@ -1,38 +0,0 @@ - -/* Chrysalide - Outil d'analyse de fichiers binaires - * link.h - prototypes pour l'édition des liens après la phase de désassemblage ARM - * - * Copyright (C) 2015-2017 Cyrille Bagard - * - * This file is part of Chrysalide. - * - * Chrysalide is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Chrysalide is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Foobar. If not, see . - */ - - -#ifndef _ARCH_ARM_LINK_H -#define _ARCH_ARM_LINK_H - - -#include "../instruction.h" -#include "../processor.h" - - - -/* Etablit un lien conditionnel selon une instruction donnée. */ -void handle_arm_conditional_branch_as_link(GArchInstruction *, GArchProcessor *, GProcContext *, GExeFormat *); - - - -#endif /* _ARCH_ARM_LINK_H */ diff --git a/src/arch/arm/processor-int.h b/src/arch/arm/processor-int.h deleted file mode 100644 index 45d4380..0000000 --- a/src/arch/arm/processor-int.h +++ /dev/null @@ -1,50 +0,0 @@ - -/* Chrysalide - Outil d'analyse de fichiers binaires - * instruction-int.h - prototypes pour la définition générique interne des processeurs ARM - * - * Copyright (C) 2014-2017 Cyrille Bagard - * - * This file is part of Chrysalide. - * - * Chrysalide is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Chrysalide is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Foobar. If not, see . - */ - - -#ifndef _ARCH_ARM_PROCESSOR_INT_H -#define _ARCH_ARM_PROCESSOR_INT_H - - -#include "processor.h" -#include "../processor-int.h" - - - -/* Définition du processeur ARM (instance) */ -struct _GArmProcessor -{ - GArchProcessor parent; /* Instance parente */ - -}; - - -/* Définition du processeur ARM (classe) */ -struct _GArmProcessorClass -{ - GArchProcessorClass parent; /* Classe parente */ - -}; - - - -#endif /* _ARCH_ARM_PROCESSOR_INT_H */ diff --git a/src/arch/arm/processor.c b/src/arch/arm/processor.c deleted file mode 100644 index 4906799..0000000 --- a/src/arch/arm/processor.c +++ /dev/null @@ -1,126 +0,0 @@ - -/* Chrysalide - Outil d'analyse de fichiers binaires - * processor.c - manipulation du processeur ARM - * - * Copyright (C) 2010-2017 Cyrille Bagard - * - * This file is part of Chrysalide. - * - * Chrysalide is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Chrysalide is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Foobar. If not, see . - */ - - -#include "processor.h" - - -#include "processor-int.h" - - - -/* Initialise la classe des registres ARM. */ -static void g_arm_processor_class_init(GArmProcessorClass *); - -/* Initialise une instance de registre ARM. */ -static void g_arm_processor_init(GArmProcessor *); - -/* Supprime toutes les références externes. */ -static void g_arm_processor_dispose(GArmProcessor *); - -/* Procède à la libération totale de la mémoire. */ -static void g_arm_processor_finalize(GArmProcessor *); - - - -/* Indique le type défini par la GLib pour le processeur ARM. */ -G_DEFINE_TYPE(GArmProcessor, g_arm_processor, G_TYPE_ARCH_PROCESSOR); - - -/****************************************************************************** -* * -* Paramètres : klass = classe à initialiser. * -* * -* Description : Initialise la classe des processeurs ARM. * -* * -* Retour : - * -* * -* Remarques : - * -* * -******************************************************************************/ - -static void g_arm_processor_class_init(GArmProcessorClass *klass) -{ - GObjectClass *object_class; /* Autre version de la classe */ - - object_class = G_OBJECT_CLASS(klass); - - object_class->dispose = (GObjectFinalizeFunc/* ! */)g_arm_processor_dispose; - object_class->finalize = (GObjectFinalizeFunc)g_arm_processor_finalize; - -} - - -/****************************************************************************** -* * -* Paramètres : proc = instance à initialiser. * -* * -* Description : Initialise une instance de processeur ARM. * -* * -* Retour : - * -* * -* Remarques : - * -* * -******************************************************************************/ - -static void g_arm_processor_init(GArmProcessor *proc) -{ - -} - - -/****************************************************************************** -* * -* Paramètres : proc = instance d'objet GLib à traiter. * -* * -* Description : Supprime toutes les références externes. * -* * -* Retour : - * -* * -* Remarques : - * -* * -******************************************************************************/ - -static void g_arm_processor_dispose(GArmProcessor *proc) -{ - G_OBJECT_CLASS(g_arm_processor_parent_class)->dispose(G_OBJECT(proc)); - -} - - -/****************************************************************************** -* * -* Paramètres : proc = instance d'objet GLib à traiter. * -* * -* Description : Procède à la libération totale de la mémoire. * -* * -* Retour : - * -* * -* Remarques : - * -* * -******************************************************************************/ - -static void g_arm_processor_finalize(GArmProcessor *proc) -{ - G_OBJECT_CLASS(g_arm_processor_parent_class)->finalize(G_OBJECT(proc)); - -} diff --git a/src/arch/arm/processor.h b/src/arch/arm/processor.h deleted file mode 100644 index 7f65def..0000000 --- a/src/arch/arm/processor.h +++ /dev/null @@ -1,53 +0,0 @@ - -/* Chrysalide - Outil d'analyse de fichiers binaires - * processor.h - prototypes pour la manipulation du processeur ARM - * - * Copyright (C) 2010-2017 Cyrille Bagard - * - * This file is part of Chrysalide. - * - * Chrysalide is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Chrysalide is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Foobar. If not, see . - */ - - -#ifndef _ARCH_ARM_PROCESSOR_H -#define _ARCH_ARM_PROCESSOR_H - - -#include -#include - - - -#define G_TYPE_ARM_PROCESSOR g_arm_processor_get_type() -#define G_ARM_PROCESSOR(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), g_arm_processor_get_type(), GArmProcessor)) -#define G_IS_ARM_PROCESSOR(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), g_arm_processor_get_type())) -#define G_ARM_PROCESSOR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), G_TYPE_ARM_PROCESSOR, GArmProcessorClass)) -#define G_IS_ARM_PROCESSOR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), G_TYPE_ARM_PROCESSOR)) -#define G_ARM_PROCESSOR_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), G_TYPE_ARM_PROCESSOR, GArmProcessorClass)) - - -/* Définition du processeur ARM (instance) */ -typedef struct _GArmProcessor GArmProcessor; - -/* Définition du processeur ARM (classe) */ -typedef struct _GArmProcessorClass GArmProcessorClass; - - -/* Indique le type défini par la GLib pour le processeur ARM. */ -GType g_arm_processor_get_type(void); - - - -#endif /* _ARCH_ARM_PROCESSOR_H */ diff --git a/src/arch/arm/register-int.h b/src/arch/arm/register-int.h deleted file mode 100644 index ec80bdd..0000000 --- a/src/arch/arm/register-int.h +++ /dev/null @@ -1,56 +0,0 @@ - -/* Chrysalide - Outil d'analyse de fichiers binaires - * register-int.h - définitions internes pour la représentation d'un registre ARM - * - * Copyright (C) 2014-2017 Cyrille Bagard - * - * This file is part of Chrysalide. - * - * Chrysalide is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Chrysalide is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Foobar. If not, see . - */ - - -#ifndef _ARCH_ARM_REGISTER_INT_H -#define _ARCH_ARM_REGISTER_INT_H - - - -#include "register.h" -#include "../register-int.h" - - - -#define MAX_REGNAME_LEN 8 - - -/* Représentation d'un registre ARM (instance) */ -struct _GArmRegister -{ - GArchRegister parent; /* A laisser en premier */ - - uint8_t index; /* Indice du registre */ - -}; - - -/* Représentation d'un registre ARM (classe) */ -struct _GArmRegisterClass -{ - GArchRegisterClass parent; /* A laisser en premier */ - -}; - - - -#endif /* _ARCH_ARM_REGISTER_INT_H */ diff --git a/src/arch/arm/register.c b/src/arch/arm/register.c deleted file mode 100644 index c351f12..0000000 --- a/src/arch/arm/register.c +++ /dev/null @@ -1,200 +0,0 @@ - -/* Chrysalide - Outil d'analyse de fichiers binaires - * registers.c - aides auxiliaires relatives aux registres ARM - * - * Copyright (C) 2014-2017 Cyrille Bagard - * - * This file is part of Chrysalide. - * - * Chrysalide is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Chrysalide is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Foobar. If not, see . - */ - - -#include "register.h" - - -#include "register-int.h" -#include "../../common/sort.h" - - - -/* Initialise la classe des registres ARM. */ -static void g_arm_register_class_init(GArmRegisterClass *); - -/* Initialise une instance de registre ARM. */ -static void g_arm_register_init(GArmRegister *); - -/* Supprime toutes les références externes. */ -static void g_arm_register_dispose(GArmRegister *); - -/* Procède à la libération totale de la mémoire. */ -static void g_arm_register_finalize(GArmRegister *); - -/* Produit une empreinte à partir d'un registre. */ -static guint g_arm_register_hash(const GArmRegister *); - -/* Compare un registre avec un autre. */ -static int g_arm_register_compare(const GArmRegister *, const GArmRegister *); - - - -/* Indique le type défini pour une représentation d'un registre ARM. */ -G_DEFINE_TYPE(GArmRegister, g_arm_register, G_TYPE_ARCH_REGISTER); - - -/****************************************************************************** -* * -* Paramètres : klass = classe à initialiser. * -* * -* Description : Initialise la classe des registres Arm. * -* * -* Retour : - * -* * -* Remarques : - * -* * -******************************************************************************/ - -static void g_arm_register_class_init(GArmRegisterClass *klass) -{ - GObjectClass *object_class; /* Autre version de la classe */ - GArchRegisterClass *register_class; /* Classe de haut niveau */ - - object_class = G_OBJECT_CLASS(klass); - register_class = G_ARCH_REGISTER_CLASS(klass); - - object_class->dispose = (GObjectFinalizeFunc/* ! */)g_arm_register_dispose; - object_class->finalize = (GObjectFinalizeFunc)g_arm_register_finalize; - - register_class->hash = (reg_hash_fc)g_arm_register_hash; - register_class->compare = (reg_compare_fc)g_arm_register_compare; - -} - - -/****************************************************************************** -* * -* Paramètres : reg = instance à initialiser. * -* * -* Description : Initialise une instance de registre ARM. * -* * -* Retour : - * -* * -* Remarques : - * -* * -******************************************************************************/ - -static void g_arm_register_init(GArmRegister *reg) -{ - -} - - -/****************************************************************************** -* * -* Paramètres : reg = instance d'objet GLib à traiter. * -* * -* Description : Supprime toutes les références externes. * -* * -* Retour : - * -* * -* Remarques : - * -* * -******************************************************************************/ - -static void g_arm_register_dispose(GArmRegister *reg) -{ - G_OBJECT_CLASS(g_arm_register_parent_class)->dispose(G_OBJECT(reg)); - -} - - -/****************************************************************************** -* * -* Paramètres : reg = instance d'objet GLib à traiter. * -* * -* Description : Procède à la libération totale de la mémoire. * -* * -* Retour : - * -* * -* Remarques : - * -* * -******************************************************************************/ - -static void g_arm_register_finalize(GArmRegister *reg) -{ - G_OBJECT_CLASS(g_arm_register_parent_class)->finalize(G_OBJECT(reg)); - -} - - -/****************************************************************************** -* * -* Paramètres : reg = registre à consulter. * -* * -* Description : Fournit l'indice d'un registre ARM. * -* * -* Retour : Inditifiant représentant le registre. * -* * -* Remarques : - * -* * -******************************************************************************/ - -uint8_t g_arm_register_get_index(const GArmRegister *reg) -{ - return reg->index; - -} - - -/****************************************************************************** -* * -* Paramètres : reg = opérande à consulter pour le calcul. * -* * -* Description : Produit une empreinte à partir d'un registre. * -* * -* Retour : Bilan de l'opération. * -* * -* Remarques : - * -* * -******************************************************************************/ - -static guint g_arm_register_hash(const GArmRegister *reg) -{ - return reg->index; - -} - - -/****************************************************************************** -* * -* Paramètres : a = premier opérande à consulter. * -* b = second opérande à consulter. * -* * -* Description : Compare un registre avec un autre. * -* * -* Retour : Bilan de la comparaison. * -* * -* Remarques : - * -* * -******************************************************************************/ - -static int g_arm_register_compare(const GArmRegister *a, const GArmRegister *b) -{ - int result; /* Bilan à retourner */ - - result = sort_unsigned_long(b->index, b->index); - - return result; - -} diff --git a/src/arch/arm/register.h b/src/arch/arm/register.h deleted file mode 100644 index cb4e492..0000000 --- a/src/arch/arm/register.h +++ /dev/null @@ -1,56 +0,0 @@ - -/* Chrysalide - Outil d'analyse de fichiers binaires - * registers.h - prototypes pour les aides auxiliaires relatives aux registres ARM - * - * Copyright (C) 2014-2017 Cyrille Bagard - * - * This file is part of Chrysalide. - * - * Chrysalide is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Chrysalide is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Foobar. If not, see . - */ - - -#ifndef _ARCH_ARM_REGISTER_H -#define _ARCH_ARM_REGISTER_H - - -#include -#include - - - -#define G_TYPE_ARM_REGISTER g_arm_register_get_type() -#define G_ARM_REGISTER(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), g_arm_register_get_type(), GArmRegister)) -#define G_IS_ARM_REGISTER(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), g_arm_register_get_type())) -#define G_ARM_REGISTER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), G_TYPE_ARM_REGISTER, GArmRegisterClass)) -#define G_IS_ARM_REGISTER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), G_TYPE_ARM_REGISTER)) -#define G_ARM_REGISTER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), G_TYPE_ARM_REGISTER, GArmRegisterClass)) - - -/* Représentation d'un registre ARM (instance) */ -typedef struct _GArmRegister GArmRegister; - -/* Représentation d'un registre ARM (classe) */ -typedef struct _GArmRegisterClass GArmRegisterClass; - - -/* Indique le type défini pour une représentation d'un registre ARM. */ -GType g_arm_register_get_type(void); - -/* Fournit l'indice d'un registre ARM. */ -uint8_t g_arm_register_get_index(const GArmRegister *); - - - -#endif /* _ARCH_ARM_REGISTER_H */ diff --git a/src/arch/arm/v7/Makefile.am b/src/arch/arm/v7/Makefile.am deleted file mode 100644 index 339bc29..0000000 --- a/src/arch/arm/v7/Makefile.am +++ /dev/null @@ -1,33 +0,0 @@ - -noinst_LTLIBRARIES = libarcharmv7.la - -libarcharmv7_la_SOURCES = \ - arm.h arm.c \ - context.h context.c \ - core.h core.c \ - cregister.h cregister.c \ - fetch.h fetch.c \ - helpers.h helpers.c \ - instruction.h instruction.c \ - link.h link.c \ - post.h post.c \ - processor.h processor.c \ - pseudo.h pseudo.c \ - register.h register.c \ - simd.h simd.c \ - thumb_16.h thumb_16.c \ - thumb_32.h thumb_32.c - -libarcharmv7_la_LIBADD = \ - opcodes/libarcharmv7opcodes.la \ - operands/libarcharmv7operands.la - -libarcharmv7_la_CFLAGS = $(AM_CFLAGS) - - -AM_CPPFLAGS = $(LIBGTK_CFLAGS) $(LIBXML_CFLAGS) - -AM_CFLAGS = $(DEBUG_CFLAGS) $(WARNING_FLAGS) $(COMPLIANCE_FLAGS) - - -SUBDIRS = opdefs opcodes operands diff --git a/src/arch/arm/v7/arm.c b/src/arch/arm/v7/arm.c deleted file mode 100644 index 55593af..0000000 --- a/src/arch/arm/v7/arm.c +++ /dev/null @@ -1,2269 +0,0 @@ - -/* Chrysalide - Outil d'analyse de fichiers binaires - * arm.c - désassemblage des instructions ARMv7 - * - * Copyright (C) 2014-2017 Cyrille Bagard - * - * This file is part of Chrysalide. - * - * Chrysalide is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Chrysalide is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Foobar. If not, see . - */ - - -#include "arm.h" - - -#include - - -#include "simd.h" -#include "opcodes/arm_opcodes.h" -#include "opcodes/opcodes_tmp_arm.h" -#include "../../undefined.h" -#include "../../../common/bconst.h" - - - -/* Désassemble une instruction ARMv7 de données ou autre. */ -static GArchInstruction *process_armv7_arm_data_processing_and_miscellaneous_instructions(uint32_t); - -/* Désassemble une instruction ARMv7 liées au chapitre A5.2.1. */ -static GArchInstruction *process_armv7_arm_data_processing_register(uint32_t); - -/* Désassemble une instruction ARMv7 liées au chapitre A5.2.2. */ -static GArchInstruction *process_armv7_arm_data_processing_register_shifted_register(uint32_t); - -/* Désassemble une instruction ARMv7 liées au chapitre A5.2.3. */ -static GArchInstruction *process_armv7_arm_data_processing_immediate(uint32_t); - -/* Désassemble une instruction ARMv7 liées au chapitre A5.2.5. */ -static GArchInstruction *process_armv7_arm_multiply_and_multiply_accumulate(uint32_t); - -/* Désassemble une instruction ARMv7 liées au chapitre A5.2.6. */ -static GArchInstruction *process_armv7_arm_saturating_addition_and_subtraction(uint32_t); - -/* Désassemble une instruction ARMv7 liées au chapitre A5.2.7. */ -static GArchInstruction *process_armv7_arm_halfword_multiply_and_multiply_accumulate(uint32_t); - -/* Désassemble une instruction ARMv7 liées au chapitre A5.2.8. */ -static GArchInstruction *process_armv7_arm_extra_load_store_instructions(uint32_t); - -/* Désassemble une instruction ARMv7 liées au chapitre A5.2.9. */ -static GArchInstruction *process_armv7_arm_extra_load_store_instructions_unprivileged(uint32_t); - -/* Désassemble une instruction ARMv7 liées au chapitre A5.2.10. */ -static GArchInstruction *process_armv7_arm_synchronization_primitives(uint32_t); - -/* Désassemble une instruction ARMv7 liées au chapitre A5.2.11. */ -static GArchInstruction *process_armv7_arm_msr_immediate_and_hints(uint32_t); - -/* Désassemble une instruction ARMv7 liées au chapitre A5.2.12. */ -static GArchInstruction *process_armv7_arm_miscellaneous_instructions(uint32_t); - -/* Désassemble une instruction ARMv7 liées au chapitre A5.3. */ -static GArchInstruction *process_armv7_arm_load_store_word_and_unsigned_byte(uint32_t); - -/* Désassemble une instruction ARMv7 liées au chapitre A5.4. */ -static GArchInstruction *process_armv7_arm_media_instructions(uint32_t); - -/* Désassemble une instruction ARMv7 liées au chapitre A5.4.1. */ -static GArchInstruction *process_armv7_arm_parallel_addition_and_subtraction_signed(uint32_t); - -/* Désassemble une instruction ARMv7 liées au chapitre A5.4.2. */ -static GArchInstruction *process_armv7_arm_parallel_addition_and_subtraction_unsigned(uint32_t); - -/* Désassemble une instruction ARMv7 liées au chapitre A5.4.3. */ -static GArchInstruction *process_armv7_arm_packing_unpacking_saturation_and_reversal(uint32_t); - -/* Désassemble une instruction ARMv7 liées au chapitre A5.4.4. */ -static GArchInstruction *process_armv7_arm_signed_multiply_signed_and_unsigned_divide(uint32_t); - -/* Désassemble une instruction ARMv7 liées au chapitre A5.5. */ -static GArchInstruction *process_armv7_arm_branch_branch_with_link_and_block_data_transfer(uint32_t); - -/* Désassemble une instruction ARMv7 liées au chapitre A5.6. */ -static GArchInstruction *process_armv7_arm_coprocessor_instructions_and_supervisor_call(uint32_t); - -/* Désassemble une instruction ARMv7 liées au chapitre A5.7. */ -static GArchInstruction *process_armv7_arm_unconditional_instructions(uint32_t); - -/* Désassemble une instruction ARMv7 liées au chapitre A5.7.1. */ -static GArchInstruction *process_armv7_arm_memory_hints_advanced_simd_instructions_and_miscellaneous_instructions(uint32_t); - - - -/****************************************************************************** -* * -* Paramètres : raw = donnée brute de 32 bits à désassembler. * -* * -* Description : Désassemble une instruction ARMv7 liées au chapitre A5.1. * -* * -* Retour : Instruction mise en place ou NULL en cas d'échec. * -* * -* Remarques : - * -* * -******************************************************************************/ - -GArchInstruction *process_armv7_arm_instruction_set_encoding(uint32_t raw) -{ - GArchInstruction *result; /* Instruction à renvoyer */ - uint32_t cond; /* Champ 'cond' à retrouver */ - uint32_t op1; /* Champ 'op1' à retrouver */ - uint32_t op; /* Champ 'op' à retrouver */ - - /** - * Suit les directives de : - * § A5.1 ARM instruction set encoding - */ - - result = NULL; - - cond = (raw >> 28) & 0xf; - op1 = (raw >> 25) & 0x7; - op = (raw >> 4) & 0x1; - - if (cond != b1111) - { - if ((op1 & b110) == b000) - result = process_armv7_arm_data_processing_and_miscellaneous_instructions(raw); - - else if (op1 == b010) - result = process_armv7_arm_load_store_word_and_unsigned_byte(raw); - - else if (op1 == b011) - { - if (op == b0) - result = process_armv7_arm_load_store_word_and_unsigned_byte(raw); - - else/* if (op == b1)*/ - result = process_armv7_arm_media_instructions(raw); - - } - - else if ((op1 & b110) == b100) - result = process_armv7_arm_branch_branch_with_link_and_block_data_transfer(raw); - - else if ((op1 & b110) == b110) - result = process_armv7_arm_coprocessor_instructions_and_supervisor_call(raw); - - } - - else /* if (cond == b1111) */ - result = process_armv7_arm_unconditional_instructions(raw); - - return result; - -} - - -/****************************************************************************** -* * -* Paramètres : raw = donnée brute de 32 bits à désassembler. * -* * -* Description : Désassemble une instruction ARMv7 de données ou autre. * -* * -* Retour : Instruction mise en place ou NULL en cas d'échec. * -* * -* Remarques : - * -* * -******************************************************************************/ - -static GArchInstruction *process_armv7_arm_data_processing_and_miscellaneous_instructions(uint32_t raw) -{ - GArchInstruction *result; /* Instruction à retourner */ - uint32_t op; /* Champ 'op' à retrouver */ - uint32_t op1; /* Champ 'op1' à retrouver */ - uint32_t op2; /* Champ 'op2' à retrouver */ - - /** - * Suit les directives de : - * § A5.2 Data-processing and miscellaneous instructions - */ - - result = NULL; - - op = (raw >> 25) & 0x1; - op1 = (raw >> 20) & 0x1f; - op2 = (raw >> 4) & 0xf; - - if (op == b0) - { - if ((op1 & b11001) != b10000) - { - if ((op2 & b0001) == b0000) - result = process_armv7_arm_data_processing_register(raw); - - else if ((op2 & b1001) == b0001) - result = process_armv7_arm_data_processing_register_shifted_register(raw); - - if (result != NULL) goto padpami_found; - - } - - else /* if ((op1 & b11001) == b10000) */ - { - if ((op2 & b1000) == b0000) - result = process_armv7_arm_miscellaneous_instructions(raw); - - else if ((op2 & b1001) == b1000) - result = process_armv7_arm_halfword_multiply_and_multiply_accumulate(raw); - - if (result != NULL) goto padpami_found; - - } - - if ((op1 & b10000) == b00000) - { - if (op2 == b1001) - result = process_armv7_arm_multiply_and_multiply_accumulate(raw); - - if (result != NULL) goto padpami_found; - - } - - if ((op1 & b10000) == b10000) - { - if (op2 == b1001) - result = process_armv7_arm_synchronization_primitives(raw); - - if (result != NULL) goto padpami_found; - - } - - if ((op1 & b10010) != b00010) - { - if (op2 == b1011) - result = process_armv7_arm_extra_load_store_instructions(raw); - - else if ((op2 & b1101) == b1101) - result = process_armv7_arm_extra_load_store_instructions(raw); - - if (result != NULL) goto padpami_found; - - } - - else /* if ((op1 & b10010) != b00010) */ - { - if (op2 == b1011) - result = process_armv7_arm_extra_load_store_instructions_unprivileged(raw); - - else if ((op2 & b1101) == b1101) - result = process_armv7_arm_extra_load_store_instructions(raw); - - if (result != NULL) goto padpami_found; - - } - - } - - else - { - if ((op1 & b11001) != b10000) - result = process_armv7_arm_data_processing_immediate(raw); - - else if (op1 == b10000) - result = armv7_read_arm_instr_mov_immediate(raw); - - else if (op1 == b10100) - result = armv7_read_arm_instr_movt(raw); - - else if ((op1 & b11011) == b10010) - result = process_armv7_arm_msr_immediate_and_hints(raw); - - } - - padpami_found: - - return result; - -} - - -/****************************************************************************** -* * -* Paramètres : raw = donnée brute de 32 bits à désassembler. * -* * -* Description : Désassemble une instruction ARMv7 liées au chapitre A5.2.1. * -* * -* Retour : Instruction mise en place ou NULL en cas d'échec. * -* * -* Remarques : - * -* * -******************************************************************************/ - -static GArchInstruction *process_armv7_arm_data_processing_register(uint32_t raw) -{ - GArchInstruction *result; /* Instruction à retourner */ - uint32_t op; /* Champ 'op' à retrouver */ - uint32_t imm5; /* Champ 'imm5' à retrouver */ - uint32_t op2; /* Champ 'op2' à retrouver */ - - /** - * Suit les directives de : - * § A5.2.1 Data-processing (register) - */ - - if ((raw & 0x0e000010) != 0x00000000) return NULL; - - result = NULL; - - op = (raw >> 20) & 0x1f; - imm5 = (raw >> 7) & 0x1f; - op2 = (raw >> 5) & 0x3; - - if ((op & b11110) == b00000) - result = armv7_read_arm_instr_and_register(raw); - - else if ((op & b11110) == b00010) - result = armv7_read_arm_instr_eor_register(raw); - - else if ((op & b11110) == b00100) - result = armv7_read_arm_instr_sub_register(raw); - - else if ((op & b11110) == b00110) - result = armv7_read_arm_instr_rsb_register(raw); - - else if ((op & b11110) == b01000) - result = armv7_read_arm_instr_add_register_arm(raw); - - else if ((op & b11110) == b01010) - result = armv7_read_arm_instr_adc_register(raw); - - else if ((op & b11110) == b01100) - result = armv7_read_arm_instr_sbc_register(raw); - - else if ((op & b11110) == b01110) - result = armv7_read_arm_instr_rsc_register(raw); - - /* - else if ((op & b11001) == b10000) - result = process_armv7_arm_data_processing_and_miscellaneous_instructions(raw); - */ - - else if (op == b10001) - result = armv7_read_arm_instr_tst_register(raw); - - else if (op == b10011) - result = armv7_read_arm_instr_teq_register(raw); - - else if (op == b10101) - result = armv7_read_arm_instr_cmp_register(raw); - - else if (op == b10111) - result = armv7_read_arm_instr_cmn_register(raw); - - else if ((op & b11110) == b11000) - result = armv7_read_arm_instr_orr_register(raw); - - else if ((op & b11110) == b11010) - { - if (op2 == b00) - { - if (imm5 == b00000) - result = armv7_read_arm_instr_mov_register_arm(raw); - - else - result = armv7_read_arm_instr_lsl_immediate(raw); - - } - - else if (op2 == b01) - result = armv7_read_arm_instr_lsr_immediate(raw); - - else if (op2 == b10) - result = armv7_read_arm_instr_asr_immediate(raw); - - else if (op2 == b11) - { - if (imm5 == b00000) - result = armv7_read_arm_instr_rrx(raw); - - else - result = armv7_read_arm_instr_ror_immediate(raw); - - } - - } - - else if ((op & b11110) == b11100) - result = armv7_read_arm_instr_bic_register(raw); - - else if ((op & b11110) == b11110) - result = armv7_read_arm_instr_mvn_register(raw); - - return result; - -} - - -/****************************************************************************** -* * -* Paramètres : raw = donnée brute de 32 bits à désassembler. * -* * -* Description : Désassemble une instruction ARMv7 liées au chapitre A5.2.2. * -* * -* Retour : Instruction mise en place ou NULL en cas d'échec. * -* * -* Remarques : - * -* * -******************************************************************************/ - -static GArchInstruction *process_armv7_arm_data_processing_register_shifted_register(uint32_t raw) -{ - GArchInstruction *result; /* Instruction à retourner */ - uint32_t op1; /* Champ 'op1' à retrouver */ - uint32_t op2; /* Champ 'op2' à retrouver */ - - /** - * Suit les directives de : - * § A5.2.2 Data-processing (register-shifted register) - */ - - if ((raw & 0x0e000090) != 0x00000010) return NULL; - - result = NULL; - - op1 = (raw >> 20) & 0x1f; - op2 = (raw >> 5) & 0x3; - - if ((op1 & b11110) == b00000) - result = armv7_read_arm_instr_and_register_shifted_register(raw); - - else if ((op1 & b11110) == b00010) - result = armv7_read_arm_instr_eor_register_shifted_register(raw); - - else if ((op1 & b11110) == b00100) - result = armv7_read_arm_instr_sub_register_shifted_register(raw); - - else if ((op1 & b11110) == b00110) - result = armv7_read_arm_instr_rsb_register_shifted_register(raw); - - else if ((op1 & b11110) == b01000) - result = armv7_read_arm_instr_add_register_shifted_register(raw); - - else if ((op1 & b11110) == b01010) - result = armv7_read_arm_instr_adc_register_shifted_register(raw); - - else if ((op1 & b11110) == b01100) - result = armv7_read_arm_instr_sbc_register_shifted_register(raw); - - else if ((op1 & b11110) == b01110) - result = armv7_read_arm_instr_rsc_register_shifted_register(raw); - -#if 0 - else if ((op1 & b11001) == b10000) - /* See Data-processing and miscellaneous instructions on page A5-196 */ -#endif - - else if (op1 == b10001) - result = armv7_read_arm_instr_tst_register_shifted_register(raw); - - else if (op1 == b10011) - result = armv7_read_arm_instr_teq_register_shifted_register(raw); - - else if (op1 == b10101) - result = armv7_read_arm_instr_cmp_register_shifted_register(raw); - - else if (op1 == b10111) - result = armv7_read_arm_instr_cmn_register_shifted_register(raw); - - else if ((op1 & b11110) == b11000) - result = armv7_read_arm_instr_orr_register_shifted_register(raw); - - else if ((op1 & b11110) == b11010) - { - if (op2 == b00) - result = armv7_read_arm_instr_lsl_register(raw); - - else if (op2 == b01) - result = armv7_read_arm_instr_lsr_register(raw); - - else if (op2 == b10) - result = armv7_read_arm_instr_asr_register(raw); - - else if (op2 == b11) - result = armv7_read_arm_instr_ror_register(raw); - - } - - else if ((op1 & b11110) == b11100) - result = armv7_read_arm_instr_bic_register_shifted_register(raw); - - else if ((op1 & b11110) == b11110) - result = armv7_read_arm_instr_mvn_register_shifted_register(raw); - - return result; - -} - - -/****************************************************************************** -* * -* Paramètres : raw = donnée brute de 32 bits à désassembler. * -* * -* Description : Désassemble une instruction ARMv7 liées au chapitre A5.2.3. * -* * -* Retour : Instruction mise en place ou NULL en cas d'échec. * -* * -* Remarques : - * -* * -******************************************************************************/ - -static GArchInstruction *process_armv7_arm_data_processing_immediate(uint32_t raw) -{ - GArchInstruction *result; /* Instruction à retourner */ - uint32_t op; /* Champ 'op' à retrouver */ - uint32_t rn; /* Champ 'rn' à retrouver */ - - /** - * Suit les directives de : - * § A5.2.3 Data-processing (immediate) - */ - - if ((raw & 0x0e000000) != 0x02000000) return NULL; - - result = NULL; - - op = (raw >> 20) & 0x1f; - rn = (raw >> 16) & 0xf; - - if ((op & b11110) == b00000) - result = armv7_read_arm_instr_and_immediate(raw); - - else if ((op & b11110) == b00010) - result = armv7_read_arm_instr_eor_immediate(raw); - - else if ((op & b11110) == b00100) - { - if (rn == b1111) - result = armv7_read_arm_instr_adr(raw); - - else - result = armv7_read_arm_instr_sub_immediate_arm(raw); - - } - - else if ((op & b11110) == b00110) - result = armv7_read_arm_instr_rsb_immediate(raw); - - else if ((op & b11110) == b01000) - { - if (rn == b1111) - result = armv7_read_arm_instr_adr(raw); - - else - result = armv7_read_arm_instr_add_immediate_arm(raw); - - } - - else if ((op & b11110) == b01010) - result = armv7_read_arm_instr_adc_immediate(raw); - - else if ((op & b11110) == b01100) - result = armv7_read_arm_instr_sbc_immediate(raw); - - else if ((op & b11110) == b01110) - result = armv7_read_arm_instr_rsc_immediate(raw); - - /* - else if ((op & b11110) == b10000) - result = process_armv7_arm_data_processing_and_miscellaneous_instructions(raw); - */ - - else if (op == b10001) - result = armv7_read_arm_instr_tst_immediate(raw); - - else if (op == b10011) - result = armv7_read_arm_instr_teq_immediate(raw); - - else if (op == b10101) - result = armv7_read_arm_instr_cmp_immediate(raw); - - else if (op == b10111) - result = armv7_read_arm_instr_cmn_immediate(raw); - - else if ((op & b11110) == b11000) - result = armv7_read_arm_instr_orr_immediate(raw); - - else if ((op & b11110) == b11010) - result = armv7_read_arm_instr_mov_immediate(raw); - - else if ((op & b11110) == b11100) - result = armv7_read_arm_instr_bic_immediate(raw); - - else if ((op & b11110) == b11110) - result = armv7_read_arm_instr_mvn_immediate(raw); - - return result; - -} - - -/****************************************************************************** -* * -* Paramètres : raw = donnée brute de 32 bits à désassembler. * -* * -* Description : Désassemble une instruction ARMv7 liées au chapitre A5.2.5. * -* * -* Retour : Instruction mise en place ou NULL en cas d'échec. * -* * -* Remarques : - * -* * -******************************************************************************/ - -static GArchInstruction *process_armv7_arm_multiply_and_multiply_accumulate(uint32_t raw) -{ - GArchInstruction *result; /* Instruction à retourner */ - uint32_t op; /* Champ 'op' à retrouver */ - - /** - * Suit les directives de : - * § A5.2.5 Multiply and multiply accumulate - */ - - if ((raw & 0x0f0000f0) != 0x00000090) return NULL; - - result = NULL; - - op = (raw >> 20) & 0xf; - - if ((op & b1110) == b0000) - result = armv7_read_arm_instr_mul(raw); - - else if ((op & b1110) == b0010) - result = armv7_read_arm_instr_mla(raw); - - else if (op == b0100) - result = armv7_read_arm_instr_umaal(raw); - - else if (op == b0101) - result = NULL; /* Non défini */ - - else if (op == b0110) - result = armv7_read_arm_instr_mls(raw); - - else if (op == b0111) - result = NULL; /* Non défini */ - - else if ((op & b1110) == b1000) - result = armv7_read_arm_instr_umull(raw); - - else if ((op & b1110) == b1010) - result = armv7_read_arm_instr_umlal(raw); - - else if ((op & b1110) == b1100) - result = armv7_read_arm_instr_smull(raw); - - else if ((op & b1110) == b1110) - result = armv7_read_arm_instr_smlal(raw); - - return result; - -} - - -/****************************************************************************** -* * -* Paramètres : raw = donnée brute de 32 bits à désassembler. * -* * -* Description : Désassemble une instruction ARMv7 liées au chapitre A5.2.6. * -* * -* Retour : Instruction mise en place ou NULL en cas d'échec. * -* * -* Remarques : - * -* * -******************************************************************************/ - -static GArchInstruction *process_armv7_arm_saturating_addition_and_subtraction(uint32_t raw) -{ - GArchInstruction *result; /* Instruction à retourner */ - uint32_t op; /* Champ 'op' à retrouver */ - - /** - * Suit les directives de : - * § A5.2.6 Saturating addition and subtraction - */ - - if ((raw & 0x0f9000f0) != 0x01000050) return NULL; - - result = NULL; - - op = (raw >> 21) & 0x3; - - if (op == b00) - result = armv7_read_arm_instr_qadd(raw); - - else if (op == b01) - result = armv7_read_arm_instr_qsub(raw); - - else if (op == b10) - result = armv7_read_arm_instr_qdadd(raw); - - else if (op == b11) - result = armv7_read_arm_instr_qdsub(raw); - - return result; - -} - - -/****************************************************************************** -* * -* Paramètres : raw = donnée brute de 32 bits à désassembler. * -* * -* Description : Désassemble une instruction ARMv7 liées au chapitre A5.2.7. * -* * -* Retour : Instruction mise en place ou NULL en cas d'échec. * -* * -* Remarques : - * -* * -******************************************************************************/ - -static GArchInstruction *process_armv7_arm_halfword_multiply_and_multiply_accumulate(uint32_t raw) -{ - GArchInstruction *result; /* Instruction à retourner */ - uint32_t op1; /* Champ 'op1' à retrouver */ - uint32_t op; /* Champ 'op' à retrouver */ - - /** - * Suit les directives de : - * § A5.2.7 Halfword multiply and multiply accumulate - */ - - if ((raw & 0x0f900090) != 0x01000080) return NULL; - - result = NULL; - - op1 = (raw >> 21) & 0x3; - op = (raw >> 5) & 0x1; - - if (op1 == b00) - result = armv7_read_arm_instr_smlabb_smlabt_smlatb_smlatt(raw); - - else if (op1 == b01) - { - if (op == b0) - result = armv7_read_arm_instr_smlawb_smlawt(raw); - - else/* if (op == b1)*/ - result = armv7_read_arm_instr_smulwb_smulwt(raw); - - } - - else if (op1 == b10) - result = armv7_read_arm_instr_smlalbb_smlalbt_smlaltb_smlaltt(raw); - - else if (op1 == b11) - result = armv7_read_arm_instr_smulbb_smulbt_smultb_smultt(raw); - - return result; - -} - - -/****************************************************************************** -* * -* Paramètres : raw = donnée brute de 32 bits à désassembler. * -* * -* Description : Désassemble une instruction ARMv7 liées au chapitre A5.2.8. * -* * -* Retour : Instruction mise en place ou NULL en cas d'échec. * -* * -* Remarques : - * -* * -******************************************************************************/ - -static GArchInstruction *process_armv7_arm_extra_load_store_instructions(uint32_t raw) -{ - GArchInstruction *result; /* Instruction à retourner */ - uint32_t op1; /* Champ 'op1' à retrouver */ - uint32_t rn; /* Champ 'rn' à retrouver */ - uint32_t op2; /* Champ 'op2' à retrouver */ - - /** - * Suit les directives de : - * § A5.2.8 Extra load/store instructions - */ - - if ((raw & 0x0e000090) != 0x00000090) return NULL; - - result = NULL; - - op1 = (raw >> 20) & 0x1f; - rn = (raw >> 16) & 0xf; - op2 = (raw >> 5) & 0x3; - - if (op2 == b01) - { - if ((op1 & b00101) == b00000) - result = armv7_read_arm_instr_strh_register(raw); - - else if ((op1 & b00101) == b00001) - result = armv7_read_arm_instr_ldrh_register(raw); - - else if ((op1 & b00101) == b00100) - result = armv7_read_arm_instr_strh_immediate_arm(raw); - - else/* if ((op1 & b00101) == b00101)*/ - { - if (rn == b1111) - result = armv7_read_arm_instr_ldrh_literal(raw); - - else - result = armv7_read_arm_instr_ldrh_immediate_arm(raw); - - } - - } - - else if (op2 == b10) - { - if ((op1 & b00101) == b00000) - result = armv7_read_arm_instr_ldrd_register(raw); - - else if ((op1 & b00101) == b00001) - result = armv7_read_arm_instr_ldrsb_register(raw); - - else if ((op1 & b00101) == b00100) - { - if (rn == b1111) - result = armv7_read_arm_instr_ldrd_literal(raw); - - else - result = armv7_read_arm_instr_ldrd_immediate(raw); - - } - - else/* if ((op1 & b00101) == b00101)*/ - { - if (rn == b1111) - result = armv7_read_arm_instr_ldrsb_literal(raw); - - else - result = armv7_read_arm_instr_ldrsb_immediate(raw); - - } - - } - - else if (op2 == b11) - { - if ((op1 & b00101) == b00000) - result = armv7_read_arm_instr_strd_register(raw); - - else if ((op1 & b00101) == b00001) - result = armv7_read_arm_instr_ldrsh_register(raw); - - else if ((op1 & b00101) == b00100) - result = armv7_read_arm_instr_strd_immediate(raw); - - else/* if ((op1 & b00101) == b00101)*/ - { - if (rn == b1111) - result = armv7_read_arm_instr_ldrsh_literal(raw); - - else - result = armv7_read_arm_instr_ldrsh_immediate(raw); - - } - - } - - return result; - -} - - -/****************************************************************************** -* * -* Paramètres : raw = donnée brute de 32 bits à désassembler. * -* * -* Description : Désassemble une instruction ARMv7 liées au chapitre A5.2.9. * -* * -* Retour : Instruction mise en place ou NULL en cas d'échec. * -* * -* Remarques : - * -* * -******************************************************************************/ - -static GArchInstruction *process_armv7_arm_extra_load_store_instructions_unprivileged(uint32_t raw) -{ - GArchInstruction *result; /* Instruction à retourner */ - uint32_t op; /* Champ 'op' à retrouver */ - uint32_t op2; /* Champ 'op2' à retrouver */ - - /** - * Suit les directives de : - * § A5.2.9 Extra load/store instructions, unprivileged - */ - - if ((raw & 0x0f200090) != 0x00200090) return NULL; - - result = NULL; - - op = (raw >> 20) & 0x1; - op2 = (raw >> 5) & 0x3; - - if (op2 == b01) - { - if (op == b0) - result = armv7_read_arm_instr_strht(raw); - - else/* if (op == b1)*/ - result = armv7_read_arm_instr_ldrht(raw); - - } - - else if (op2 == b10) - { - if (op == b1) - result = armv7_read_arm_instr_ldrsbt(raw); - - } - - else if (op2 == b11) - { - if (op == b1) - result = armv7_read_arm_instr_ldrsht(raw); - - } - - return result; - -} - - -/****************************************************************************** -* * -* Paramètres : raw = donnée brute de 32 bits à désassembler. * -* * -* Description : Désassemble une instruction ARMv7 liées au chapitre A5.2.10. * -* * -* Retour : Instruction mise en place ou NULL en cas d'échec. * -* * -* Remarques : - * -* * -******************************************************************************/ - -static GArchInstruction *process_armv7_arm_synchronization_primitives(uint32_t raw) -{ - GArchInstruction *result; /* Instruction à retourner */ - uint32_t op; /* Champ 'op' à retrouver */ - - /** - * Suit les directives de : - * § A5.2.10 Synchronization primitives - */ - - if ((raw & 0x0f0000f0) != 0x01000090) return NULL; - - result = NULL; - - op = (raw >> 20) & 0xf; - - if ((op & b1011) == b0000) - result = armv7_read_arm_instr_swp_swpb(raw); - - else if (op == b1000) - result = armv7_read_arm_instr_strex(raw); - - else if (op == b1001) - result = armv7_read_arm_instr_ldrex(raw); - - else if (op == b1010) - result = armv7_read_arm_instr_strexd(raw); - - else if (op == b1011) - result = armv7_read_arm_instr_ldrexd(raw); - - else if (op == b1100) - result = armv7_read_arm_instr_strexb(raw); - - else if (op == b1101) - result = armv7_read_arm_instr_ldrexb(raw); - - else if (op == b1110) - result = armv7_read_arm_instr_strexh(raw); - - else if (op == b1111) - result = armv7_read_arm_instr_ldrexh(raw); - - return result; - -} - - -/****************************************************************************** -* * -* Paramètres : raw = donnée brute de 32 bits à désassembler. * -* * -* Description : Désassemble une instruction ARMv7 liées au chapitre A5.2.11. * -* * -* Retour : Instruction mise en place ou NULL en cas d'échec. * -* * -* Remarques : - * -* * -******************************************************************************/ - -static GArchInstruction *process_armv7_arm_msr_immediate_and_hints(uint32_t raw) -{ - GArchInstruction *result; /* Instruction à retourner */ - uint32_t op; /* Champ 'op' à retrouver */ - uint32_t op1; /* Champ 'op1' à retrouver */ - uint32_t op2; /* Champ 'op2' à retrouver */ - - /** - * Suit les directives de : - * § A5.2.11 MSR (immediate), and hints - */ - - if ((raw & 0x0fb00000) != 0x03200000) return NULL; - - result = NULL; - - op = (raw >> 22) & 0x1; - op1 = (raw >> 16) & 0xf; - op2 = (raw >> 0) & 0x1; - - if (op == b0) - { - if (op1 == b0000) - { - if (op2 == b00000000) - result = armv7_read_arm_instr_nop(raw); - - else if (op2 == b00000001) - result = armv7_read_arm_instr_yield(raw); - - else if (op2 == b00000010) - result = armv7_read_arm_instr_wfe(raw); - - else if (op2 == b00000011) - result = armv7_read_arm_instr_wfi(raw); - - else if (op2 == b00000100) - result = armv7_read_arm_instr_sev(raw); - - else if ((op2 & b11110000) == b11110000) - result = armv7_read_arm_instr_dbg(raw); - - } - - else if (op1 == b0100 || (op1 & b1011) == b1000) - result = armv7_read_arm_instr_msr_immediate_a8(raw); - - else if ((op1 & b0011) == b0001 || (op1 & b0010) == b0010) - result = armv7_read_arm_instr_msr_immediate_b9(raw); - - } - - else/* if (op == b1)*/ - result = armv7_read_arm_instr_msr_immediate_b9(raw); - - return result; - -} - - -/****************************************************************************** -* * -* Paramètres : raw = donnée brute de 32 bits à désassembler. * -* * -* Description : Désassemble une instruction ARMv7 liées au chapitre A5.2.12. * -* * -* Retour : Instruction mise en place ou NULL en cas d'échec. * -* * -* Remarques : - * -* * -******************************************************************************/ - -static GArchInstruction *process_armv7_arm_miscellaneous_instructions(uint32_t raw) -{ - GArchInstruction *result; /* Instruction à retourner */ - uint32_t op; /* Champ 'op' à retrouver */ - uint32_t op1; /* Champ 'op1' à retrouver */ - uint32_t b; /* Champ 'b' à retrouver */ - uint32_t op2; /* Champ 'op2' à retrouver */ - - /** - * Suit les directives de : - * § A5.2.12 Miscellaneous instructions - */ - - if ((raw & 0x0f900080) != 0x01000000) return NULL; - - result = NULL; - - op = (raw >> 21) & 0x3; - op1 = (raw >> 16) & 0xf; - b = (raw >> 9) & 0x1; - op2 = (raw >> 4) & 0x7; - - if (op2 == b000) - { - if (b == b1) - { - if ((op & b01) == b00) - result = armv7_read_arm_instr_mrs_banked_register(raw); - - else/* if ((op & b01) == b01)*/ - result = armv7_read_arm_instr_msr_banked_register(raw); - - } - else/* if (b == b0)*/ - { - if ((op & b01) == b00) - result = armv7_read_arm_instr_mrs(raw); - - else if (op == b01) - { - if ((op1 & b0011) == b0000) - result = armv7_read_arm_instr_msr_register_a8(raw); - - else if ((op1 & b0011) == b0001 || (op1 & b0010) == b0010) - result = armv7_read_arm_instr_msr_register_b9(raw); - - } - - else if (op == b11) - result = armv7_read_arm_instr_msr_register_b9(raw); - - } - - } - - else if (op2 == b001) - { - if (op == b01) - result = armv7_read_arm_instr_bx(raw); - - else if (op == b11) - result = armv7_read_arm_instr_clz(raw); - - } - - else if (op2 == b010) - { - if (op == b01) - result = armv7_read_arm_instr_bxj(raw); - - } - - else if (op2 == b011) - { - if (op == b01) - result = armv7_read_arm_instr_blx_register(raw); - - } - - else if (op2 == b101) - result = process_armv7_arm_saturating_addition_and_subtraction(raw); - - else if (op2 == b110) - { - if (op == b11) - result = armv7_read_arm_instr_eret(raw); - - } - - else if (op2 == b111) - { - if (op == b) - result = armv7_read_arm_instr_bkpt(raw); - - else if (op == b) - result = armv7_read_arm_instr_hvc(raw); - - else if (op == b) - result = armv7_read_arm_instr_smc_previously_smi(raw); - - } - - return result; - -} - - -/****************************************************************************** -* * -* Paramètres : raw = donnée brute de 32 bits à désassembler. * -* * -* Description : Désassemble une instruction ARMv7 liées au chapitre A5.3. * -* * -* Retour : Instruction mise en place ou NULL en cas d'échec. * -* * -* Remarques : - * -* * -******************************************************************************/ - -static GArchInstruction *process_armv7_arm_load_store_word_and_unsigned_byte(uint32_t raw) -{ - GArchInstruction *result; /* Instruction à retourner */ - uint32_t a; /* Champ 'a' à retrouver */ - uint32_t op1; /* Champ 'op1' à retrouver */ - uint32_t rn; /* Champ 'rn' à retrouver */ - uint32_t b; /* Champ 'b' à retrouver */ - - /** - * Suit les directives de : - * § A5.3 Load/store word and unsigned byte - */ - - if ((raw & 0x0c000000) != 0x04000000) return NULL; - - result = NULL; - - a = (raw >> 25) & 0x1; - op1 = (raw >> 20) & 0x1f; - rn = (raw >> 16) & 0xf; - b = (raw >> 4) & 0x1; - - if (a == b0) - { - if ((op1 & b00101) == b00000 && (op1 & b10111) != b00010) - result = armv7_read_arm_instr_str_immediate_arm(raw); - - else if ((op1 & b10111) == b00010) - result = armv7_read_arm_instr_strt(raw); - - else if ((op1 & b00101) == b00001 && (op1 & b10111) != b00011) - { - if (rn != b1111) - result = armv7_read_arm_instr_ldr_immediate_arm(raw); - else - result = armv7_read_arm_instr_ldr_literal(raw); - } - - else if ((op1 & b10111) == b00011) - result = armv7_read_arm_instr_ldrt(raw); - - else if ((op1 & b00101) == b00100 && (op1 & b10110) != b00110) - result = armv7_read_arm_instr_strb_immediate_arm(raw); - - else if ((op1 & b10110) == b00110) - result = armv7_read_arm_instr_strbt(raw); - - else if ((op1 & b00101) == b00101 && (op1 & b10111) != b00111) - { - if (rn != b1111) - result = armv7_read_arm_instr_ldrb_immediate_arm(raw); - else - result = armv7_read_arm_instr_ldrb_literal(raw); - } - - else if ((op1 & b10111) == b00111) - result = armv7_read_arm_instr_ldrbt(raw); - - } - else /*if (a == b1)*/ - { - if ((op1 & b00101) == b00000 && (op1 & b10111) != b00010 && b == b0) - result = armv7_read_arm_instr_str_register(raw); - - else if ((op1 & b10111) == b00010 && b == b0) - result = armv7_read_arm_instr_strt(raw); - - else if ((op1 & b00101) == b00001 && (op1 & b10111) != b00011 && b == b0) - result = armv7_read_arm_instr_ldr_register_arm(raw); - - else if ((op1 & b10111) == b00011 && b == b0) - result = armv7_read_arm_instr_ldrt(raw); - - else if ((op1 & b00101) == b00100 && (op1 & b10110) != b00110 && b == b0) - result = armv7_read_arm_instr_strb_register(raw); - - else if ((op1 & b10110) == b00110 && b == b0) - result = armv7_read_arm_instr_strbt(raw); - - else if ((op1 & b00101) == b00101 && (op1 & b10111) != b00111 && b == b0) - result = armv7_read_arm_instr_ldrb_register(raw); - - else if ((op1 & b10111) == b00111 && b == b0) - result = armv7_read_arm_instr_ldrbt(raw); - - } - - return result; - -} - - -/****************************************************************************** -* * -* Paramètres : raw = donnée brute de 32 bits à désassembler. * -* * -* Description : Désassemble une instruction ARMv7 liées au chapitre A5.4. * -* * -* Retour : Instruction mise en place ou NULL en cas d'échec. * -* * -* Remarques : - * -* * -******************************************************************************/ - -static GArchInstruction *process_armv7_arm_media_instructions(uint32_t raw) -{ - GArchInstruction *result; /* Instruction à retourner */ - uint32_t cond; /* Champ 'cond' à retrouver */ - uint32_t op1; /* Champ 'op1' à retrouver */ - uint32_t rd; /* Champ 'rd' à retrouver */ - uint32_t op2; /* Champ 'op2' à retrouver */ - uint32_t rn; /* Champ 'rn' à retrouver */ - - /** - * Suit les directives de : - * § A5.4 Media instructions - */ - - if ((raw & 0x0e000010) != 0x06000010) return NULL; - - result = NULL; - - cond = (raw >> 28) & 0xf; - op1 = (raw >> 20) & 0x1f; - rd = (raw >> 12) & 0xf; - op2 = (raw >> 5) & 0x7; - rn = (raw >> 0) & 0xf; - - if ((op1 & b11100) == b00000) - result = process_armv7_arm_parallel_addition_and_subtraction_signed(raw); - - else if ((op1 & b11100) == b00100) - result = process_armv7_arm_parallel_addition_and_subtraction_unsigned(raw); - - else if ((op1 & b11000) == b01000) - result = process_armv7_arm_packing_unpacking_saturation_and_reversal(raw); - - else if ((op1 & b11000) == b10000) - result = process_armv7_arm_signed_multiply_signed_and_unsigned_divide(raw); - - else if (op1 == b11000) - { - if (op2 == b000) - { - if (rd == b1111) - result = armv7_read_arm_instr_usad8(raw); - else - result = armv7_read_arm_instr_usada8(raw); - } - - goto a54_done; - - } - - else if ((op1 & b11110) == b11010) - { - if ((op2 & b011) == b010) - result = armv7_read_arm_instr_sbfx(raw); - - goto a54_done; - - } - - else if ((op1 & b11110) == b11100) - { - if ((op2 & b011) == b000) - { - if (rn == b1111) - result = armv7_read_arm_instr_bfc(raw); - else - result = armv7_read_arm_instr_bfi(raw); - } - - goto a54_done; - - } - - else if ((op1 & b11110) == b11110) - { - if ((op2 & b011) == b010) - result = armv7_read_arm_instr_ubfx(raw); - - goto a54_done; - - } - - else if (op1 == b11111 && op2 == b111 && cond == b1110) - result = armv7_read_arm_instr_ubfx(raw); - - a54_done: - - return result; - -} - - -/****************************************************************************** -* * -* Paramètres : raw = donnée brute de 32 bits à désassembler. * -* * -* Description : Désassemble une instruction ARMv7 liées au chapitre A5.4.1. * -* * -* Retour : Instruction mise en place ou NULL en cas d'échec. * -* * -* Remarques : - * -* * -******************************************************************************/ - -static GArchInstruction *process_armv7_arm_parallel_addition_and_subtraction_signed(uint32_t raw) -{ - GArchInstruction *result; /* Instruction à retourner */ - uint32_t op1; /* Champ 'op1' à retrouver */ - uint32_t op2; /* Champ 'op2' à retrouver */ - - /** - * Suit les directives de : - * § A5.4.1 Parallel addition and subtraction, signed - */ - - if ((raw & 0x0fc00010) != 0x06000010) return NULL; - - result = NULL; - - op1 = (raw >> 20) & 0x3; - op2 = (raw >> 5) & 0x7; - - if (op1 == b01) - { - if (op2 == b000) - result = armv7_read_arm_instr_sadd16(raw); - - else if (op2 == b001) - result = armv7_read_arm_instr_sasx(raw); - - else if (op2 == b010) - result = armv7_read_arm_instr_ssax(raw); - - else if (op2 == b011) - result = armv7_read_arm_instr_ssub16(raw); - - else if (op2 == b100) - result = armv7_read_arm_instr_sadd8(raw); - - else if (op2 == b111) - result = armv7_read_arm_instr_ssub8(raw); - - } - - else if (op1 == b10) - { - if (op2 == b000) - result = armv7_read_arm_instr_qadd16(raw); - - else if (op2 == b001) - result = armv7_read_arm_instr_qasx(raw); - - else if (op2 == b010) - result = armv7_read_arm_instr_qsax(raw); - - else if (op2 == b011) - result = armv7_read_arm_instr_qsub16(raw); - - else if (op2 == b100) - result = armv7_read_arm_instr_qadd8(raw); - - else if (op2 == b111) - result = armv7_read_arm_instr_qsub8(raw); - - } - - else if (op1 == b11) - { - if (op2 == b000) - result = armv7_read_arm_instr_shadd16(raw); - - else if (op2 == b001) - result = armv7_read_arm_instr_shasx(raw); - - else if (op2 == b010) - result = armv7_read_arm_instr_shsax(raw); - - else if (op2 == b011) - result = armv7_read_arm_instr_shsub16(raw); - - else if (op2 == b100) - result = armv7_read_arm_instr_shadd8(raw); - - else if (op2 == b111) - result = armv7_read_arm_instr_shsub8(raw); - - } - - return result; - -} - - -/****************************************************************************** -* * -* Paramètres : raw = donnée brute de 32 bits à désassembler. * -* * -* Description : Désassemble une instruction ARMv7 liées au chapitre A5.4.2. * -* * -* Retour : Instruction mise en place ou NULL en cas d'échec. * -* * -* Remarques : - * -* * -******************************************************************************/ - -static GArchInstruction *process_armv7_arm_parallel_addition_and_subtraction_unsigned(uint32_t raw) -{ - GArchInstruction *result; /* Instruction à retourner */ - uint32_t op1; /* Champ 'op1' à retrouver */ - uint32_t op2; /* Champ 'op2' à retrouver */ - - /** - * Suit les directives de : - * § A5.4.2 Parallel addition and subtraction, unsigned - */ - - if ((raw & 0x0fc00010) != 0x06400010) return NULL; - - result = NULL; - - op1 = (raw >> 20) & 0x3; - op2 = (raw >> 5) & 0x7; - - if (op1 == b01) - { - if (op2 == b000) - result = armv7_read_arm_instr_uadd16(raw); - - else if (op2 == b001) - result = armv7_read_arm_instr_uasx(raw); - - else if (op2 == b010) - result = armv7_read_arm_instr_usax(raw); - - else if (op2 == b011) - result = armv7_read_arm_instr_usub16(raw); - - else if (op2 == b100) - result = armv7_read_arm_instr_uadd8(raw); - - else if (op2 == b111) - result = armv7_read_arm_instr_usub8(raw); - - } - - else if (op1 == b10) - { - if (op2 == b000) - result = armv7_read_arm_instr_uqadd16(raw); - - else if (op2 == b001) - result = armv7_read_arm_instr_uqasx(raw); - - else if (op2 == b010) - result = armv7_read_arm_instr_uqsax(raw); - - else if (op2 == b011) - result = armv7_read_arm_instr_uqsub16(raw); - - else if (op2 == b100) - result = armv7_read_arm_instr_uqadd8(raw); - - else if (op2 == b111) - result = armv7_read_arm_instr_uqsub8(raw); - - } - - else if (op1 == b11) - { - if (op2 == b000) - result = armv7_read_arm_instr_uhadd16(raw); - - else if (op2 == b001) - result = armv7_read_arm_instr_uhasx(raw); - - else if (op2 == b010) - result = armv7_read_arm_instr_uhsax(raw); - - else if (op2 == b011) - result = armv7_read_arm_instr_uhsub16(raw); - - else if (op2 == b100) - result = armv7_read_arm_instr_uhadd8(raw); - - else if (op2 == b111) - result = armv7_read_arm_instr_uhsub8(raw); - - } - - return result; - -} - - -/****************************************************************************** -* * -* Paramètres : raw = donnée brute de 32 bits à désassembler. * -* * -* Description : Désassemble une instruction ARMv7 liées au chapitre A5.4.3. * -* * -* Retour : Instruction mise en place ou NULL en cas d'échec. * -* * -* Remarques : - * -* * -******************************************************************************/ - -static GArchInstruction *process_armv7_arm_packing_unpacking_saturation_and_reversal(uint32_t raw) -{ - GArchInstruction *result; /* Instruction à retourner */ - uint32_t op1; /* Champ 'op1' à retrouver */ - uint32_t a; /* Champ 'a' à retrouver */ - uint32_t op2; /* Champ 'op2' à retrouver */ - - /** - * Suit les directives de : - * § A5.4.3 Packing, unpacking, saturation, and reversal - */ - - if ((raw & 0x0f800010) != 0x06800010) return NULL; - - result = NULL; - - op1 = (raw >> 20) & 0x7; - a = (raw >> 16) & 0xf; - op2 = (raw >> 5) & 0x7; - - if ((op1 & b111) == b000) - { - if ((op2 & b001) == b000) - { - result = armv7_read_arm_instr_pkh(raw); - goto a543_done; - } - else if (op2 == b011) - { - if (a == b1111) - { - result = armv7_read_arm_instr_sxtb16(raw); - goto a543_done; - } - else - { - result = armv7_read_arm_instr_sxtab16(raw); - goto a543_done; - } - } - else if (op2 == b101) - { - result = armv7_read_arm_instr_sel(raw); - goto a543_done; - } - } - - else if ((op1 & b110) == b010 && (op2 & b001) == b000) - { - result = armv7_read_arm_instr_ssat(raw); - goto a543_done; - } - - else if (op1 == b010) - { - if (op2 == b001) - { - result = armv7_read_arm_instr_ssat16(raw); - goto a543_done; - } - else if (op2 == b011) - { - if (a == b1111) - { - result = armv7_read_arm_instr_sxtb(raw); - goto a543_done; - } - else - { - result = armv7_read_arm_instr_sxtab(raw); - goto a543_done; - } - } - } - - else if (op1 == b011) - { - if (op2 == b001) - { - result = armv7_read_arm_instr_rev(raw); - goto a543_done; - } - else if (op2 == b011) - { - if (a == b1111) - { - result = armv7_read_arm_instr_sxth(raw); - goto a543_done; - } - else - { - result = armv7_read_arm_instr_sxtah(raw); - goto a543_done; - } - } - else if (op2 == b101) - { - result = armv7_read_arm_instr_rev16(raw); - goto a543_done; - } - } - - else if (op1 == b100 && op2 == b011) - { - if (a == b1111) - { - result = armv7_read_arm_instr_uxtb16(raw); - goto a543_done; - } - else - { - result = armv7_read_arm_instr_uxtab16(raw); - goto a543_done; - } - } - - else if ((op1 & b110) == b110 && (op2 & b001) == b000) - { - result = armv7_read_arm_instr_usat(raw); - goto a543_done; - } - - else if (op1 == b110) - { - if (op2 == b001) - { - result = armv7_read_arm_instr_usat16(raw); - goto a543_done; - } - else if (op2 == b011) - { - if (a == b1111) - { - result = armv7_read_arm_instr_uxtb(raw); - goto a543_done; - } - else - { - result = armv7_read_arm_instr_uxtab(raw); - goto a543_done; - } - } - } - - else if (op1 == b111) - { - if (op2 == b001) - { - result = armv7_read_arm_instr_rbit(raw); - goto a543_done; - } - else if (op2 == b011) - { - if (a == b1111) - { - result = armv7_read_arm_instr_uxth(raw); - goto a543_done; - } - else - { - result = armv7_read_arm_instr_uxtah(raw); - goto a543_done; - } - } - else if (op2 == b101) - { - result = armv7_read_arm_instr_revsh(raw); - goto a543_done; - } - } - - a543_done: - - return result; - -} - - -/****************************************************************************** -* * -* Paramètres : raw = donnée brute de 32 bits à désassembler. * -* * -* Description : Désassemble une instruction ARMv7 liées au chapitre A5.4.4. * -* * -* Retour : Instruction mise en place ou NULL en cas d'échec. * -* * -* Remarques : - * -* * -******************************************************************************/ - -static GArchInstruction *process_armv7_arm_signed_multiply_signed_and_unsigned_divide(uint32_t raw) -{ - GArchInstruction *result; /* Instruction à retourner */ - uint32_t op1; /* Champ 'op1' à retrouver */ - uint32_t a; /* Champ 'a' à retrouver */ - uint32_t op2; /* Champ 'op2' à retrouver */ - - /** - * Suit les directives de : - * § A5.4.4 Signed multiply, signed and unsigned divide - */ - - if ((raw & 0x0f800010) != 0x07000010) return NULL; - - result = NULL; - - op1 = (raw >> 20) & 0x7; - a = (raw >> 12) & 0xf; - op2 = (raw >> 5) & 0x7; - - if (op1 == b000) - { - if ((op2 & b110) == b000) - { - if (a != b1111) - result = armv7_read_arm_instr_smlad(raw); - else/* if (a == b1111)*/ - result = armv7_read_arm_instr_smuad(raw); - - } - - else if ((op2 & b110) == b010) - { - if (a != b1111) - result = armv7_read_arm_instr_smlsd(raw); - else/* if (a == b1111)*/ - result = armv7_read_arm_instr_smusd(raw); - - } - - } - - else if (op1 == b001) - { - if (op2 == b000) - result = armv7_read_arm_instr_sdiv(raw); - - } - - else if (op1 == b011) - { - if (op2 == b000) - result = armv7_read_arm_instr_udiv(raw); - - } - - else if (op1 == b100) - { - if ((op2 & b110) == b000) - result = armv7_read_arm_instr_smlald(raw); - - else if ((op2 & b110) == b010) - result = armv7_read_arm_instr_smlsld(raw); - - } - - else if (op1 == b101) - { - if ((op2 & b110) == b000) - { - if (a != b1111) - result = armv7_read_arm_instr_smmla(raw); - else/* if (a == b1111)*/ - result = armv7_read_arm_instr_smmul(raw); - - } - - else if ((op2 & b110) == b110) - result = armv7_read_arm_instr_smmls(raw); - - } - - return result; - -} - - -/****************************************************************************** -* * -* Paramètres : raw = donnée brute de 32 bits à désassembler. * -* * -* Description : Désassemble une instruction ARMv7 liées au chapitre A5.5. * -* * -* Retour : Instruction mise en place ou NULL en cas d'échec. * -* * -* Remarques : - * -* * -******************************************************************************/ - -static GArchInstruction *process_armv7_arm_branch_branch_with_link_and_block_data_transfer(uint32_t raw) -{ - GArchInstruction *result; /* Instruction à retourner */ - uint32_t op; /* Champ 'op' à retrouver */ - uint32_t rn; /* Champ 'rn' à retrouver */ - uint32_t r; /* Champ 'r' à retrouver */ - - /** - * Suit les directives de : - * § A5.5 Branch, branch with link, and block data transferr - */ - - if ((raw & 0x0c000000) != 0x08000000) return NULL; - - result = NULL; - - op = (raw >> 20) & 0x3f; - rn = (raw >> 16) & 0xf; - r = (raw >> 15) & 0x1; - - if ((op & b111101) == b000000) - result = armv7_read_arm_instr_stmda_stmed(raw); - - else if ((op & b111101) == b000001) - result = armv7_read_arm_instr_ldmda_ldmfa(raw); - - else if ((op & b111101) == b001000) - result = armv7_read_arm_instr_stm_stmia_stmea(raw); - - else if (op == b001001) - result = armv7_read_arm_instr_ldm_ldmia_ldmfd_arm(raw); - - else if (op == b001011) - { - if (rn != b1101) - result = armv7_read_arm_instr_ldm_ldmia_ldmfd_arm(raw); - else /* if (rn == b1101) */ - result = armv7_read_arm_instr_pop_arm(raw); - } - - else if (op == b010000) - result = armv7_read_arm_instr_stmdb_stmfd(raw); - - else if (op == b010010) - { - if (rn != b1101) - result = armv7_read_arm_instr_stmdb_stmfd(raw); - else /* if (rn == b1101) */ - result = armv7_read_arm_instr_push(raw); - } - - else if ((op & b111101) == b010001) - result = armv7_read_arm_instr_ldmdb_ldmea(raw); - - else if ((op & b111101) == b011000) - result = armv7_read_arm_instr_stmib_stmfa(raw); - - else if ((op & b111101) == b011001) - result = armv7_read_arm_instr_ldmib_ldmed(raw); - - else if ((op & b100101) == b000100) - result = armv7_read_arm_instr_stm_user_registers(raw); - - else if ((op & b100101) == b000101) - { - if (r == b0) - result = armv7_read_arm_instr_ldm_user_registers(raw); - else /* if (r == b1) */ - result = armv7_read_arm_instr_ldm_exception_return(raw); - } - - else if ((op & b110000) == b100000) - result = armv7_read_arm_instr_b(raw); - - else if ((op & b110000) == b110000) - result = armv7_read_arm_instr_bl_blx_immediate(raw); - - return result; - -} - - -/****************************************************************************** -* * -* Paramètres : raw = donnée brute de 32 bits à désassembler. * -* * -* Description : Désassemble une instruction ARMv7 liées au chapitre A5.6. * -* * -* Retour : Instruction mise en place ou NULL en cas d'échec. * -* * -* Remarques : - * -* * -******************************************************************************/ - -static GArchInstruction *process_armv7_arm_coprocessor_instructions_and_supervisor_call(uint32_t raw) -{ - GArchInstruction *result; /* Instruction à retourner */ - uint32_t op1; /* Champ 'op1' à retrouver */ - uint32_t rn; /* Champ 'rn' à retrouver */ - uint32_t coproc; /* Champ 'coproc' à retrouver */ - uint32_t op; /* Champ 'op' à retrouver */ - - /** - * Suit les directives de : - * § A5.6 Coprocessor instructions, and Supervisor Call - */ - - if ((raw & 0x0c000000) != 0x0c000000) return NULL; - - result = NULL; - - op1 = (raw >> 20) & 0x3f; - rn = (raw >> 16) & 0xf; - coproc = (raw >> 8) & 0xf; - op = (raw >> 4) & 0x1; - - if ((op1 & b111110) == b000000) - result = g_undef_instruction_new(IBS_UNDEFINED); - - else if ((op1 & b110000) == b110000) - result = armv7_read_arm_instr_svc_previously_swi(raw); - - else if ((coproc & b1110) != b1010) - { - if ((op1 & b100001) == b000000 && (op1 & b111011) != b000000) - result = armv7_read_arm_instr_stc_stc2(raw); - - else if ((op1 & b100001) == b000001 && (op1 & b111011) != b000001) - { - if (rn != b1111) - result = armv7_read_arm_instr_ldc_ldc2_immediate(raw); - else - result = armv7_read_arm_instr_ldc_ldc2_literal(raw); - - } - - else if (op1 == b000100) - result = armv7_read_arm_instr_mcrr_mcrr2(raw); - - else if (op1 == b000101) - result = armv7_read_arm_instr_mrrc_mrrc2(raw); - - - else if ((op1 & b110000) == b100000 && op == b0) - result = armv7_read_arm_instr_cdp_cdp2(raw); - - else if ((op1 & b110001) == b100000 && op == b1) - result = armv7_read_arm_instr_mcr_mcr2(raw); - - else if ((op1 & b110001) == b100001 && op == b1) - result = armv7_read_arm_instr_mrc_mrc2(raw); - - } - - else if ((coproc & b1110) == b1010) - { - /* TODO */ - - } - - return result; - -} - - -/****************************************************************************** -* * -* Paramètres : raw = donnée brute de 32 bits à désassembler. * -* * -* Description : Désassemble une instruction ARMv7 liées au chapitre A5.7. * -* * -* Retour : Instruction mise en place ou NULL en cas d'échec. * -* * -* Remarques : - * -* * -******************************************************************************/ - -static GArchInstruction *process_armv7_arm_unconditional_instructions(uint32_t raw) -{ - GArchInstruction *result; /* Instruction à retourner */ - uint32_t op1; /* Champ 'op1' à retrouver */ - uint32_t rn; /* Champ 'rn' à retrouver */ - uint32_t op; /* Champ 'op' à retrouver */ - - /** - * Suit les directives de : - * § A5.7 Unconditional instructions - */ - - if ((raw & 0xf0000000) != 0xf0000000) return NULL; - - result = NULL; - - op1 = (raw >> 20) & 0xff; - rn = (raw >> 16) & 0xf; - op = (raw >> 4) & 0x1; - - if ((op1 & b10000000) == b00000000) - result = process_armv7_arm_memory_hints_advanced_simd_instructions_and_miscellaneous_instructions(raw); - - else if ((op1 & b11100101) == b10000100) - result = armv7_read_arm_instr_srs_arm(raw); - - else if ((op1 & b11100101) == b10000001) - result = armv7_read_arm_instr_rfe(raw); - - else if ((op1 & b11100000) == b10100000) - result = armv7_read_arm_instr_bl_blx_immediate(raw); - - else if ((op1 & b11100001) == b11000000 && (op1 & b11111011) != b11000000) - result = armv7_read_arm_instr_stc_stc2(raw); - - else if ((op1 & b11100001) == b11000001 && (op1 & b11111011) != b11000001) - { - if (rn != b1111) - result = armv7_read_arm_instr_ldc_ldc2_immediate(raw); - else/* if (rn == b1111)*/ - result = armv7_read_arm_instr_ldc_ldc2_literal(raw); - } - - else if (op1 == b11000100) - result = armv7_read_arm_instr_mcrr_mcrr2(raw); - - else if (op1 == b11000101) - result = armv7_read_arm_instr_mrrc_mrrc2(raw); - - else if ((op1 & b11110000) == b11100000 && op == b0) - result = armv7_read_arm_instr_cdp_cdp2(raw); - - else if ((op1 & b11110001) == b11100000 && op == b1) - result = armv7_read_arm_instr_mcr_mcr2(raw); - - else if ((op1 & b11110001) == b11100001 && op == b1) - result = armv7_read_arm_instr_mrc_mrc2(raw); - - return result; - -} - - -/****************************************************************************** -* * -* Paramètres : raw = donnée brute de 32 bits à désassembler. * -* * -* Description : Désassemble une instruction ARMv7 liées au chapitre A5.7.1. * -* * -* Retour : Instruction mise en place ou NULL en cas d'échec. * -* * -* Remarques : - * -* * -******************************************************************************/ - -static GArchInstruction *process_armv7_arm_memory_hints_advanced_simd_instructions_and_miscellaneous_instructions(uint32_t raw) -{ - GArchInstruction *result; /* Instruction à retourner */ - uint32_t op1; /* Champ 'op1' à retrouver */ - uint32_t rn; /* Champ 'rn' à retrouver */ - uint32_t op2; /* Champ 'op2' à retrouver */ - - /** - * Suit les directives de : - * § A5.7.1 Memory hints, Advanced SIMD instructions, and miscellaneous instructions - */ - - if ((raw & 0xf8000000) != 0xf0000000) return NULL; - - result = NULL; - - op1 = (raw >> 20) & 0x7f; - rn = (raw >> 16) & 0xf; - op2 = (raw >> 4) & 0xf; - - if (op1 == b0010000) - { - if ((op2 & b0010) == b0000 && (rn & b0001) == b0000) - result = armv7_read_arm_instr_cps_arm(raw); - - else if (op2 == b0000 && (rn & b0001) == b0001) - result = armv7_read_arm_instr_cps_arm(raw); - - } - - else if ((op1 & b1100000) == b0100000) - result = process_armv7_simd_advanced_simd_data_processing_instructions(raw, true); - - else if ((op1 & b1110001) == b1000000) - result = process_armv7_simd_advanced_simd_element_or_structure_load_store_instructions(raw, true); - - else if ((op1 & b1110111) == b1000001) - result = g_undef_instruction_new(IBS_NOP); - - else if ((op1 & b1110111) == b1000101) - result = armv7_read_arm_instr_pli_immediate_literal(raw); - - else if ((op1 & b1110011) == b1000011) - result = g_undef_instruction_new(IBS_UNPREDICTABLE); - - else if ((op1 & b1110111) == b1010101) - { - if (rn != b1111) - result = armv7_read_arm_instr_pld_pldw_immediate(raw); - else - result = g_undef_instruction_new(IBS_UNPREDICTABLE); - - } - - else if ((op1 & b1110111) == b1010101) - { - if (rn != b1111) - result = armv7_read_arm_instr_pld_pldw_immediate(raw); - else - result = armv7_read_arm_instr_pld_literal(raw); - - } - - else if (op1 == b1010011) - result = g_undef_instruction_new(IBS_UNPREDICTABLE); - - else if (op1 == b1010111) - { - if (op2 == b0000) - result = g_undef_instruction_new(IBS_UNPREDICTABLE); - - else if (op2 == b0001) - result = armv7_read_arm_instr_clrex(raw); - - else if ((op2 & b1110) == b0010) - result = g_undef_instruction_new(IBS_UNPREDICTABLE); - - else if (op2 == b0100) - result = armv7_read_arm_instr_dsb(raw); - - else if (op2 == b0101) - result = armv7_read_arm_instr_dmb(raw); - - else if (op2 == b0110) - result = armv7_read_arm_instr_isb(raw); - - else if (op2 == b0111) - result = g_undef_instruction_new(IBS_UNPREDICTABLE); - - else if ((op2 & b1000) == b1000) - result = g_undef_instruction_new(IBS_UNPREDICTABLE); - - } - - else if ((op1 & b1111011) == b1011011) - result = g_undef_instruction_new(IBS_UNPREDICTABLE); - - else if ((op1 & b1110111) == b1100001 && (op2 & b0001) == b0000) - result = g_undef_instruction_new(IBS_NOP); - - else if ((op1 & b1110111) == b1100101 && (op2 & b0001) == b0000) - result = armv7_read_arm_instr_pli_register(raw); - - else if ((op1 & b1110111) == b1110001 && (op2 & b0001) == b0000) - result = armv7_read_arm_instr_pld_pldw_register(raw); - - return result; - -} diff --git a/src/arch/arm/v7/arm.h b/src/arch/arm/v7/arm.h deleted file mode 100644 index 997bf64..0000000 --- a/src/arch/arm/v7/arm.h +++ /dev/null @@ -1,37 +0,0 @@ - -/* Chrysalide - Outil d'analyse de fichiers binaires - * arm.h - prototypes pour le désassemblage des instructions ARMv7 - * - * Copyright (C) 2014-2017 Cyrille Bagard - * - * This file is part of Chrysalide. - * - * Chrysalide is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Chrysalide is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Foobar. If not, see . - */ - - -#ifndef _ARCH_ARM_V7_ARM_H -#define _ARCH_ARM_V7_ARM_H - - -#include "../../instruction.h" - - - -/* Désassemble une instruction ARMv7 liées au chapitre A5.1. */ -GArchInstruction *process_armv7_arm_instruction_set_encoding(uint32_t raw); - - - -#endif /* _ARCH_ARM_V7_ARM_H */ diff --git a/src/arch/arm/v7/build_tmp_decl.sh b/src/arch/arm/v7/build_tmp_decl.sh deleted file mode 100755 index 0d0feee..0000000 --- a/src/arch/arm/v7/build_tmp_decl.sh +++ /dev/null @@ -1,39 +0,0 @@ -#!/bin/sh - - -arch=$1 -header="opcodes/${arch}_opcodes.h" -headertmp="opcodes/opcodes_tmp_$arch.h" - -echo "#ifndef ${arch}_def_tmp_h" > $headertmp -echo "#define ${arch}_def_tmp_h" >> $headertmp - -target=armv7_read_${arch}_instr - -needed=`grep $target $arch.c | sed "s/.*\(${target}_[^(]*\).*/\1/" | sort | uniq` - -for n in $needed; do - - echo " $n..." - - test -f $header && grep -q "$n(" $header - if [ $? -ne 0 ]; then - - if [ $arch = "simd" ]; then - echo "#define $n(r, a) NULL" >> $headertmp - else - echo "#define $n(r) NULL" >> $headertmp - fi - - else - - echo "$n found in $header" - - fi - -done - -echo "#endif" >> $headertmp - - - diff --git a/src/arch/arm/v7/context.c b/src/arch/arm/v7/context.c deleted file mode 100644 index 8fc7fc1..0000000 --- a/src/arch/arm/v7/context.c +++ /dev/null @@ -1,305 +0,0 @@ - -/* Chrysalide - Outil d'analyse de fichiers binaires - * context.c - contexte lié à l'exécution d'un processeur - * - * Copyright (C) 2015-2017 Cyrille Bagard - * - * This file is part of Chrysalide. - * - * Chrysalide is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Chrysalide is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Foobar. If not, see . - */ - - -#include "context.h" - - -#include - - -#include "../context-int.h" - - - -/* ------------------------ MANIPULATION GLOBALE DU CONTEXTE ------------------------ */ - - -/* Définition d'un contexte pour processeur ARM (instance) */ -struct _GArmV7Context -{ - GArmContext parent; /* A laisser en premier */ - -}; - - -/* Définition d'un contexte pour processeur ARM (classe) */ -struct _GArmV7ContextClass -{ - GArmContextClass parent; /* A laisser en premier */ - -}; - - -/* Initialise la classe des contextes de processeur ARM. */ -static void g_armv7_context_class_init(GArmV7ContextClass *); - -/* Initialise une instance de contexte de processeur ARM. */ -static void g_armv7_context_init(GArmV7Context *); - -/* Supprime toutes les références externes. */ -static void g_armv7_context_dispose(GArmV7Context *); - -/* Procède à la libération totale de la mémoire. */ -static void g_armv7_context_finalize(GArmV7Context *); - -/* Ajoute une adresse virtuelle comme point de départ de code. */ -static void g_armv7_context_push_drop_point(GArmV7Context *, DisassPriorityLevel, virt_t, va_list); - - - -/* ---------------------------------------------------------------------------------- */ -/* MANIPULATION GLOBALE DU CONTEXTE */ -/* ---------------------------------------------------------------------------------- */ - - -/* Indique le type définit par la GLib pour le contexte de processeur ARM. */ -G_DEFINE_TYPE(GArmV7Context, g_armv7_context, G_TYPE_ARM_CONTEXT); - - -/****************************************************************************** -* * -* Paramètres : klass = classe à initialiser. * -* * -* Description : Initialise la classe des contextes de processeur ARM. * -* * -* Retour : - * -* * -* Remarques : - * -* * -******************************************************************************/ - -static void g_armv7_context_class_init(GArmV7ContextClass *klass) -{ - GObjectClass *object; /* Autre version de la classe */ - GProcContextClass *proc; /* Version parente de la classe*/ - - object = G_OBJECT_CLASS(klass); - - object->dispose = (GObjectFinalizeFunc/* ! */)g_armv7_context_dispose; - object->finalize = (GObjectFinalizeFunc)g_armv7_context_finalize; - - proc = G_PROC_CONTEXT_CLASS(klass); - - proc->push_point = (push_drop_point_fc)g_armv7_context_push_drop_point; - -} - - -/****************************************************************************** -* * -* Paramètres : ctx = instance à initialiser. * -* * -* Description : Initialise une instance de contexte de processeur ARM. * -* * -* Retour : - * -* * -* Remarques : - * -* * -******************************************************************************/ - -static void g_armv7_context_init(GArmV7Context *ctx) -{ - GArmContext *base; /* Autre version du contexte */ - - base = G_ARM_CONTEXT(ctx); - - base->areas = (disass_arm_area *)calloc(1, sizeof(disass_arm_area)); - base->acount = 1; - - base->areas[0].start = 0; - base->areas[0].end = (virt_t)-1; - base->areas[0].marker = AV7IS_ARM; - -} - - -/****************************************************************************** -* * -* Paramètres : ctx = instance d'objet GLib à traiter. * -* * -* Description : Supprime toutes les références externes. * -* * -* Retour : - * -* * -* Remarques : - * -* * -******************************************************************************/ - -static void g_armv7_context_dispose(GArmV7Context *ctx) -{ - G_OBJECT_CLASS(g_armv7_context_parent_class)->dispose(G_OBJECT(ctx)); - -} - - -/****************************************************************************** -* * -* Paramètres : ctx = instance d'objet GLib à traiter. * -* * -* Description : Procède à la libération totale de la mémoire. * -* * -* Retour : - * -* * -* Remarques : - * -* * -******************************************************************************/ - -static void g_armv7_context_finalize(GArmV7Context *ctx) -{ - G_OBJECT_CLASS(g_armv7_context_parent_class)->finalize(G_OBJECT(ctx)); - -} - - -/****************************************************************************** -* * -* Paramètres : - * -* * -* Description : Crée un contexte pour l'exécution du processeur ARM. * -* * -* Retour : Contexte mis en place. * -* * -* Remarques : - * -* * -******************************************************************************/ - -GArmV7Context *g_armv7_context_new(void) -{ - GArmV7Context *result; /* Structure à retourner */ - - result = g_object_new(G_TYPE_ARMV7_CONTEXT, NULL); - - return result; - -} - - -/****************************************************************************** -* * -* Paramètres : ctx = contexte de désassemblage à compléter. * -* level = indication de priorité et d'origine de l'adresse. * -* addr = adresse d'un nouveau point de départ à traiter. * -* ap = forme générique d'un encodage à mémoriser. * -* * -* Description : Ajoute une adresse virtuelle comme point de départ de code. * -* * -* Retour : - * -* * -* Remarques : - * -* * -******************************************************************************/ - -static void g_armv7_context_push_drop_point(GArmV7Context *ctx, DisassPriorityLevel level, virt_t addr, va_list ap) -{ - ArmV7InstrSet marker; /* Type de jeu d'instructions */ - - switch (level) - { - case DPL_ENTRY_POINT: - case DPL_SYMBOL: - - if (addr & 0x1) - { - addr -= 0x1; - marker = AV7IS_THUMB; - } - else - marker = AV7IS_ARM; - - break; - - default: - - /** - * Les messages de GCC annoncent parfois les choses très clairement : - * - * context.c:233:33: warning: 'ArmV7InstrSet' is promoted to 'int' when passed through '...' - * marker = va_arg(ap, ArmV7InstrSet); - * ^ - * context.c:233:33: note: (so you should pass 'int' not 'ArmV7InstrSet' to 'va_arg') - * context.c:233:33: note: if this code is reached, the program will abort - * - */ - - marker = (ArmV7InstrSet)va_arg(ap, unsigned int); - - /** - * Attention : toute adresse impaire est destinée à du mode Thumb. - * - * Mais la réciproque n'est pas vraie : le mode Thumb peut aussi - * manipuler des adresses paires. - */ - assert(((addr & 0x1) && marker == AV7IS_THUMB) || (addr & 0x1) == 0); - - addr &= ~0x1; - - break; - - } - - g_armv7_context_define_encoding(ctx, addr, marker); - - G_PROC_CONTEXT_CLASS(g_armv7_context_parent_class)->push_point(G_PROC_CONTEXT(ctx), level, addr, ap); - -} - - -/****************************************************************************** -* * -* Paramètres : ctx = contexte de désassemblage à compléter. * -* addr = adresse d'un nouveau point de départ à créer. * -* marker = forme générique d'un encodage à mémoriser. * -* * -* Description : Enregistre l'encodage (générique) utilisé à une adresse. * -* * -* Retour : - * -* * -* Remarques : - * -* * -******************************************************************************/ - -void g_armv7_context_define_encoding(GArmV7Context *ctx, virt_t addr, ArmV7InstrSet marker) -{ - _g_arm_context_define_encoding(G_ARM_CONTEXT(ctx), addr, marker); - -} - - -/****************************************************************************** -* * -* Paramètres : ctx = contexte de désassemblage à consulter. * -* addr = adresse d'un nouveau point de départ à retrouver. * -* * -* Description : Indique l'encodage (générique) utilisé à une adresse donnée. * -* * -* Retour : Marqueur à priori toujours valide. * -* * -* Remarques : - * -* * -******************************************************************************/ - -ArmV7InstrSet g_armv7_context_find_encoding(GArmV7Context *ctx, virt_t addr) -{ - return (ArmV7InstrSet)_g_arm_context_find_encoding(G_ARM_CONTEXT(ctx), addr); - -} diff --git a/src/arch/arm/v7/context.h b/src/arch/arm/v7/context.h deleted file mode 100644 index 2c3ff03..0000000 --- a/src/arch/arm/v7/context.h +++ /dev/null @@ -1,81 +0,0 @@ - -/* Chrysalide - Outil d'analyse de fichiers binaires - * context.h - prototypes pour le contexte lié à l'exécution d'un processeur - * - * Copyright (C) 2015-2017 Cyrille Bagard - * - * This file is part of Chrysalide. - * - * Chrysalide is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Chrysalide is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Foobar. If not, see . - */ - - -#ifndef _ARCH_ARM_V7_CONTEXT_H -#define _ARCH_ARM_V7_CONTEXT_H - - -#include - - -#include "../../vmpa.h" - - - -/* ------------------------ MANIPULATION GLOBALE DU CONTEXTE ------------------------ */ - - -#define G_TYPE_ARMV7_CONTEXT g_armv7_context_get_type() -#define G_ARMV7_CONTEXT(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), g_armv7_context_get_type(), GArmV7Context)) -#define G_IS_ARMV7_CONTEXT(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), g_armv7_context_get_type())) -#define G_ARMV7_CONTEXT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), G_TYPE_ARMV7_CONTEXT, GGArmV7ContextClass)) -#define G_IS_ARMV7_CONTEXT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), G_TYPE_ARMV7_CONTEXT)) -#define G_ARMV7_CONTEXT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), G_TYPE_ARMV7_CONTEXT, GGArmV7ContextClass)) - - -/* Définition d'un contexte pour processeur ARM (instance) */ -typedef struct _GArmV7Context GArmV7Context; - -/* Définition d'un contexte pour processeur ARM (classe) */ -typedef struct _GArmV7ContextClass GArmV7ContextClass; - - -/* Indique le type définit par la GLib pour le contexte de processeur ARM. */ -GType g_armv7_context_get_type(void); - -/* Crée un contexte pour l'exécution du processeur ARM. */ -GArmV7Context *g_armv7_context_new(void); - - -/* Jeux d'instructions possibles avec ARM v7 */ -typedef enum _ArmV7InstrSet -{ - AV7IS_ARM, /* Encodage classique */ - AV7IS_THUMB, /* Encodage compressé */ - AV7IS_JAZELLE, /* Encodage JVM */ - AV7IS_THUMBEE, /* Encodage dense + JIT/AOT */ - - AV7IS_COUNT - -} ArmV7InstrSet; - - -/* Enregistre l'encodage (générique) utilisé à une adresse. */ -void g_armv7_context_define_encoding(GArmV7Context *, virt_t, ArmV7InstrSet); - -/* Indique l'encodage (générique) utilisé à une adresse donnée. */ -ArmV7InstrSet g_armv7_context_find_encoding(GArmV7Context *, virt_t); - - - -#endif /* _ARCH_ARM_V7_CONTEXT_H */ diff --git a/src/arch/arm/v7/core.c b/src/arch/arm/v7/core.c deleted file mode 100644 index a2d0e45..0000000 --- a/src/arch/arm/v7/core.c +++ /dev/null @@ -1,66 +0,0 @@ - -/* Chrysalide - Outil d'analyse de fichiers binaires - * core.c - chargement et déchargement des mécanismes internes de l'architecture ARMv7 - * - * Copyright (C) 2016-2017 Cyrille Bagard - * - * This file is part of Chrysalide. - * - * Chrysalide is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Chrysalide is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Foobar. If not, see . - */ - - -#include "core.h" - - - -/****************************************************************************** -* * -* Paramètres : - * -* * -* Description : Met en place les mécanismes internes de l'architecture ARMv7.* -* * -* Retour : Bilan de l'opération. * -* * -* Remarques : - * -* * -******************************************************************************/ - -bool init_armv7_core(void) -{ - bool result; /* Bilan à renvoyer */ - - result = true; - - return result; - -} - - -/****************************************************************************** -* * -* Paramètres : - * -* * -* Description : Supprime les mécanismes internes de l'architecture ARMv7. * -* * -* Retour : - * -* * -* Remarques : - * -* * -******************************************************************************/ - -void exit_armv7_core(void) -{ - -} diff --git a/src/arch/arm/v7/core.h b/src/arch/arm/v7/core.h deleted file mode 100644 index b4c254f..0000000 --- a/src/arch/arm/v7/core.h +++ /dev/null @@ -1,40 +0,0 @@ - -/* Chrysalide - Outil d'analyse de fichiers binaires - * core.h - prototypes pour le chargement et le déchargement des mécanismes internes de l'architecture ARMv7 - * - * Copyright (C) 2016-2017 Cyrille Bagard - * - * This file is part of Chrysalide. - * - * Chrysalide is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Chrysalide is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Foobar. If not, see . - */ - - -#ifndef _ARCH_ARM_V7_CORE_H -#define _ARCH_ARM_V7_CORE_H - - -#include - - - -/* Met en place les mécanismes internes de l'architecture ARMv7. */ -bool init_armv7_core(void); - -/* Supprime les mécanismes internes de l'architecture ARMv7. */ -void exit_armv7_core(void); - - - -#endif /* _ARCH_ARM_V7_CORE_H */ diff --git a/src/arch/arm/v7/cregister.c b/src/arch/arm/v7/cregister.c deleted file mode 100644 index 33564f0..0000000 --- a/src/arch/arm/v7/cregister.c +++ /dev/null @@ -1,212 +0,0 @@ - -/* Chrysalide - Outil d'analyse de fichiers binaires - * cregisters.c - aides auxiliaires relatives aux registres de co-processeur ARMv7 - * - * Copyright (C) 2016-2017 Cyrille Bagard - * - * This file is part of Chrysalide. - * - * Chrysalide is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Chrysalide is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Foobar. If not, see . - */ - - -#include "cregister.h" - - -#include - - -#include "../register-int.h" - - - -/* Représentation d'un registre de co-processeur ARMv7 (instance) */ -struct _GArmV7CRegister -{ - GArmRegister parent; /* Instance parente */ - -}; - - -/* Représentation d'un registre de co-processeur ARMv7 (classe) */ -struct _GArmV7CRegisterClass -{ - GArmRegisterClass parent; /* Classe parente */ - -}; - - - -/* Initialise la classe des registres de co-processeur ARMv7. */ -static void g_armv7_cregister_class_init(GArmV7CRegisterClass *); - -/* Initialise une instance de registre de co-processeur ARMv7. */ -static void g_armv7_cregister_init(GArmV7CRegister *); - -/* Supprime toutes les références externes. */ -static void g_armv7_cregister_dispose(GArmV7CRegister *); - -/* Procède à la libération totale de la mémoire. */ -static void g_armv7_cregister_finalize(GArmV7CRegister *); - -/* Traduit un registre en version humainement lisible. */ -static void g_armv7_cregister_print(const GArmV7CRegister *, GBufferLine *, AsmSyntax); - - - -/* Indique le type défini pour une représentation d'un registre de co-processeur ARMv7. */ -G_DEFINE_TYPE(GArmV7CRegister, g_armv7_cregister, G_TYPE_ARM_REGISTER); - - -/****************************************************************************** -* * -* Paramètres : klass = classe à initialiser. * -* * -* Description : Initialise la classe des registres de co-processeur ARMv7. * -* * -* Retour : - * -* * -* Remarques : - * -* * -******************************************************************************/ - -static void g_armv7_cregister_class_init(GArmV7CRegisterClass *klass) -{ - GObjectClass *object_class; /* Autre version de la classe */ - GArchRegisterClass *reg_class; /* Classe de haut niveau */ - - object_class = G_OBJECT_CLASS(klass); - reg_class = G_ARCH_REGISTER_CLASS(klass); - - object_class->dispose = (GObjectFinalizeFunc/* ! */)g_armv7_cregister_dispose; - object_class->finalize = (GObjectFinalizeFunc)g_armv7_cregister_finalize; - - reg_class->print = (reg_print_fc)g_armv7_cregister_print; - -} - - -/****************************************************************************** -* * -* Paramètres : reg = instance à initialiser. * -* * -* Description : Initialise une instance de registre de co-processeur ARMv7. * -* * -* Retour : - * -* * -* Remarques : - * -* * -******************************************************************************/ - -static void g_armv7_cregister_init(GArmV7CRegister *reg) -{ - -} - - -/****************************************************************************** -* * -* Paramètres : reg = instance d'objet GLib à traiter. * -* * -* Description : Supprime toutes les références externes. * -* * -* Retour : - * -* * -* Remarques : - * -* * -******************************************************************************/ - -static void g_armv7_cregister_dispose(GArmV7CRegister *reg) -{ - G_OBJECT_CLASS(g_armv7_cregister_parent_class)->dispose(G_OBJECT(reg)); - -} - - -/****************************************************************************** -* * -* Paramètres : reg = instance d'objet GLib à traiter. * -* * -* Description : Procède à la libération totale de la mémoire. * -* * -* Retour : - * -* * -* Remarques : - * -* * -******************************************************************************/ - -static void g_armv7_cregister_finalize(GArmV7CRegister *reg) -{ - G_OBJECT_CLASS(g_armv7_cregister_parent_class)->finalize(G_OBJECT(reg)); - -} - - -/****************************************************************************** -* * -* Paramètres : index = indice du registre correspondant. * -* * -* Description : Crée une réprésentation de registre de co-processeur ARMv7. * -* * -* Retour : Adresse de la structure mise en place. * -* * -* Remarques : - * -* * -******************************************************************************/ - -GArmV7CRegister *g_armv7_cregister_new(uint8_t index) -{ - GArmV7CRegister *result; /* Structure à retourner */ - - result = g_object_new(G_TYPE_ARMV7_CREGISTER, NULL); - - G_ARM_REGISTER(result)->index = index; - - return result; - -} - - -/****************************************************************************** -* * -* Paramètres : reg = registre à transcrire. * -* line = ligne tampon où imprimer l'opérande donné. * -* syntax = type de représentation demandée. * -* * -* Description : Traduit un registre en version humainement lisible. * -* * -* Retour : - * -* * -* Remarques : - * -* * -******************************************************************************/ - -static void g_armv7_cregister_print(const GArmV7CRegister *reg, GBufferLine *line, AsmSyntax syntax) -{ - char key[MAX_REGNAME_LEN]; /* Mot clef principal */ - size_t klen; /* Taille de ce mot clef */ - - switch (G_ARM_REGISTER(reg)->index) - { - case 0 ... 15: - klen = snprintf(key, MAX_REGNAME_LEN, "c%hhu", G_ARM_REGISTER(reg)->index); - break; - default: - klen = snprintf(key, MAX_REGNAME_LEN, "c??"); - break; - } - - g_buffer_line_append_text(line, BLC_ASSEMBLY, key, klen, RTT_REGISTER, NULL); - -} diff --git a/src/arch/arm/v7/cregister.h b/src/arch/arm/v7/cregister.h deleted file mode 100644 index 5d3a6cf..0000000 --- a/src/arch/arm/v7/cregister.h +++ /dev/null @@ -1,56 +0,0 @@ - -/* Chrysalide - Outil d'analyse de fichiers binaires - * cregisters.h - prototypes pour les aides auxiliaires relatives aux registres de co-processeur ARMv7 - * - * Copyright (C) 2016-2017 Cyrille Bagard - * - * This file is part of Chrysalide. - * - * Chrysalide is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Chrysalide is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Foobar. If not, see . - */ - - -#ifndef _ARCH_ARM_V7_CREGISTER_H -#define _ARCH_ARM_V7_CREGISTER_H - - -#include -#include - - - -#define G_TYPE_ARMV7_CREGISTER g_armv7_cregister_get_type() -#define G_ARMV7_CREGISTER(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), g_armv7_cregister_get_type(), GArmV7CRegister)) -#define G_IS_ARMV7_CREGISTER(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), g_armv7_cregister_get_type())) -#define G_ARMV7_CREGISTER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), G_TYPE_ARMV7_CREGISTER, GArmV7CRegisterClass)) -#define G_IS_ARMV7_CREGISTER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), G_TYPE_ARMV7_CREGISTER)) -#define G_ARMV7_CREGISTER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), G_TYPE_ARMV7_CREGISTER, GArmV7CRegisterClass)) - - -/* Représentation d'un registre de co-processeur ARMv7 (instance) */ -typedef struct _GArmV7CRegister GArmV7CRegister; - -/* Représentation d'un registre de co-processeur ARMv7 (classe) */ -typedef struct _GArmV7CRegisterClass GArmV7CRegisterClass; - - -/* Indique le type défini pour une représentation d'un registre de co-processeur ARMv7. */ -GType g_armv7_cregister_get_type(void); - -/* Crée une réprésentation de registre de co-processeur ARMv7. */ -GArmV7CRegister *g_armv7_cregister_new(uint8_t); - - - -#endif /* _ARCH_ARM_V7_CREGISTER_H */ diff --git a/src/arch/arm/v7/fetch.c b/src/arch/arm/v7/fetch.c deleted file mode 100644 index dee9aa2..0000000 --- a/src/arch/arm/v7/fetch.c +++ /dev/null @@ -1,521 +0,0 @@ - -/* Chrysalide - Outil d'analyse de fichiers binaires - * fetch.c - ajouts de sauts à traiter durant la phase de désassemblage - * - * Copyright (C) 2015-2017 Cyrille Bagard - * - * This file is part of Chrysalide. - * - * Chrysalide is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Chrysalide is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Foobar. If not, see . - */ - - -#include "fetch.h" - - -#include -#include - - -#include - - -#include "operands/offset.h" -#include "../register.h" -#include "../../raw.h" -#include "../../../format/format.h" -#include "../../../format/preload.h" - - - -/****************************************************************************** -* * -* Paramètres : instr = instruction ARMv7 à traiter. * -* proc = représentation de l'architecture utilisée. * -* context = contexte associé à la phase de désassemblage. * -* format = acès aux données du binaire d'origine. * -* iset = type de jeu d'instructions courant à faire suivre. * -* * -* Description : Complète un désassemblage accompli pour une instruction. * -* * -* Retour : - * -* * -* Remarques : - * -* * -******************************************************************************/ - -void help_fetching_with_instruction_b_with_orig(GArchInstruction *instr, GArchProcessor *proc, GArmV7Context *context, GExeFormat *format, ArmV7InstrSet iset) -{ - const mrange_t *range; /* Emplacementt d'instruction */ - virt_t pc; /* Position dans l'exécution */ - GImmOperand *op; /* Opérande numérique en place */ - int32_t offset; /* Décallage encodé en dur */ - virt_t target; /* Adresse virtuelle visée */ - - range = g_arch_instruction_get_range(instr); - - pc = get_virt_addr(get_mrange_addr(range)); - - - - - switch (iset) - { - case AV7IS_ARM: - pc += 8; - break; - case AV7IS_THUMB: - pc += 4; - break; - default: - assert(0); - break; - } - - - - //pc += get_mrange_length(range); - - op = G_IMM_OPERAND(g_arch_instruction_get_operand(instr, 0)); - - if (g_imm_operand_get_value(op, MDS_32_BITS_SIGNED, &offset)) - g_imm_operand_set_value(op, MDS_32_BITS_UNSIGNED, pc + offset); - - else assert(0); - - g_object_unref(G_OBJECT(op)); - - target = pc + offset; - - //g_armv7_context_define_encoding(context, target, iset); - g_proc_context_push_drop_point(G_PROC_CONTEXT(context), DPL_OTHER, target, iset); - -} - - -/****************************************************************************** -* * -* Paramètres : instr = instruction ARMv7 à traiter. * -* proc = représentation de l'architecture utilisée. * -* context = contexte associé à la phase de désassemblage. * -* format = acès aux données du binaire d'origine. * -* iset = type de jeu d'instructions courant à faire suivre. * -* * -* Description : Complète un désassemblage accompli pour une instruction. * -* * -* Retour : - * -* * -* Remarques : - * -* * -******************************************************************************/ - -void help_fetching_with_instruction_bl_with_orig(GArchInstruction *instr, GArchProcessor *proc, GArmV7Context *context, GExeFormat *format, ArmV7InstrSet iset) -{ - const mrange_t *range; /* Emplacementt d'instruction */ - virt_t pc; /* Position dans l'exécution */ - GImmOperand *op; /* Opérande numérique en place */ - int32_t offset; /* Décallage encodé en dur */ - virt_t target; /* Adresse virtuelle visée */ - - range = g_arch_instruction_get_range(instr); - - pc = get_virt_addr(get_mrange_addr(range)); - - /** - * Qu'on se trouve en mode Thumb ou ARM, l'instruction - * ne peut qu'être encodée sur 4 octets. - */ - - assert(get_mrange_length(range) == 4); - - switch (iset) - { - case AV7IS_ARM: - pc += 8; - break; - case AV7IS_THUMB: - pc += 4; - break; - default: - assert(0); - break; - } - - op = G_IMM_OPERAND(g_arch_instruction_get_operand(instr, 0)); - - if (g_imm_operand_get_value(op, MDS_32_BITS_SIGNED, &offset)) - g_imm_operand_set_value(op, MDS_32_BITS_UNSIGNED, pc + offset); - - else assert(0); - - g_object_unref(G_OBJECT(op)); - - target = pc + offset; - - //g_armv7_context_define_encoding(context, target, iset); - g_proc_context_push_drop_point(G_PROC_CONTEXT(context), DPL_OTHER, target, iset); - -} - - -/****************************************************************************** -* * -* Paramètres : instr = instruction ARMv7 à traiter. * -* proc = représentation de l'architecture utilisée. * -* context = contexte associé à la phase de désassemblage. * -* format = acès aux données du binaire d'origine. * -* iset = type de jeu d'instructions courant à inverser. * -* * -* Description : Complète un désassemblage accompli pour une instruction. * -* * -* Retour : - * -* * -* Remarques : - * -* * -******************************************************************************/ - -void help_fetching_with_instruction_blx_with_dest(GArchInstruction *instr, GArchProcessor *proc, GArmV7Context *context, GExeFormat *format, ArmV7InstrSet iset) -{ - const mrange_t *range; /* Emplacementt d'instruction */ - virt_t pc; /* Position dans l'exécution */ - GImmOperand *op; /* Opérande numérique en place */ - int32_t offset; /* Décallage encodé en dur */ - virt_t target; /* Adresse virtuelle visée */ - - range = g_arch_instruction_get_range(instr); - - pc = get_virt_addr(get_mrange_addr(range)); - - /** - * Qu'on se trouve en mode Thumb ou ARM, l'instruction - * ne peut qu'être encodée sur 4 octets. - */ - - assert(get_mrange_length(range) == 4); - - pc += 4; - pc -= pc % 4; - - op = G_IMM_OPERAND(g_arch_instruction_get_operand(instr, 0)); - - if (g_imm_operand_get_value(op, MDS_32_BITS_SIGNED, &offset)) - g_imm_operand_set_value(op, MDS_32_BITS_UNSIGNED, pc + offset); - - else assert(0); - - g_object_unref(G_OBJECT(op)); - - target = pc + offset; - - //g_armv7_context_define_encoding(context, target, iset); - g_proc_context_push_drop_point(G_PROC_CONTEXT(context), DPL_OTHER, target, iset); - -} - - -/****************************************************************************** -* * -* Paramètres : instr = instruction ARMv7 à traiter. * -* proc = représentation de l'architecture utilisée. * -* context = contexte associé à la phase de désassemblage. * -* format = acès aux données du binaire d'origine. * -* iset = type de jeu d'instructions courant à faire suivre. * -* * -* Description : Complète un désassemblage accompli pour une instruction. * -* * -* Retour : - * -* * -* Remarques : - * -* * -******************************************************************************/ - -void help_fetching_with_instruction_bx_with_orig(GArchInstruction *instr, GArchProcessor *proc, GArmV7Context *context, GExeFormat *format, ArmV7InstrSet iset) -{ - GArchOperand *op; /* Opérande numérique en place */ - GArmRegister *reg; /* Registre matériel manipulé */ - bool is_pc; /* Nature de ce même registre */ - const mrange_t *range; /* Emplacementt d'instruction */ - virt_t pc; /* Position dans l'exécution */ - - op = g_arch_instruction_get_operand(instr, 0); - assert(G_IS_REGISTER_OPERAND(op)); - - /** - * On ne sait agir qu'avec le seul contenu facilement prédictible : pc ! - */ - - reg = G_ARM_REGISTER(g_register_operand_get_register(G_REGISTER_OPERAND(op))); - - is_pc = (g_arm_register_get_index(reg) == 15 /* pc */); - - g_object_unref(G_OBJECT(reg)); - - if (!is_pc) goto hfwibwo_no_pc; - - /** - * On bascule alors le mode de décodage à cette adresse... - */ - - range = g_arch_instruction_get_range(instr); - - pc = get_virt_addr(get_mrange_addr(range)); - - switch (iset) - { - case AV7IS_ARM: - pc += 8; - //g_armv7_context_define_encoding(context, - g_proc_context_push_drop_point(G_PROC_CONTEXT(context), DPL_OTHER, pc, AV7IS_THUMB); - break; - case AV7IS_THUMB: - pc += 4; - //g_armv7_context_define_encoding(context, - g_proc_context_push_drop_point(G_PROC_CONTEXT(context), DPL_OTHER, pc, AV7IS_ARM); - break; - default: - assert(0); - break; - } - - hfwibwo_no_pc: - - g_object_unref(G_OBJECT(op)); - -} - - -/****************************************************************************** -* * -* Paramètres : instr = instruction ARMv7 à traiter. * -* proc = représentation de l'architecture utilisée. * -* context = contexte associé à la phase de désassemblage. * -* format = acès aux données du binaire d'origine. * -* * -* Description : Complète un désassemblage accompli pour une instruction. * -* * -* Retour : - * -* * -* Remarques : - * -* * -******************************************************************************/ - -void help_fetching_with_instruction_cb_n_z(GArchInstruction *instr, GArchProcessor *proc, GArmV7Context *context, GExeFormat *format) -{ - const mrange_t *range; /* Emplacementt d'instruction */ - virt_t pc; /* Position dans l'exécution */ - GImmOperand *op; /* Opérande numérique en place */ - uint32_t offset; /* Décallage encodé en dur */ - virt_t target; /* Adresse virtuelle visée */ - - range = g_arch_instruction_get_range(instr); - - pc = get_virt_addr(get_mrange_addr(range)); - - /** - * En mode Thumb, pc a pour valeur l'adresse courante plus 4. - */ - - pc += 4; - - op = G_IMM_OPERAND(g_arch_instruction_get_operand(instr, 1)); - - if (g_imm_operand_get_value(op, MDS_32_BITS_UNSIGNED, &offset)) - g_imm_operand_set_value(op, MDS_32_BITS_UNSIGNED, pc + offset); - - else assert(0); - - g_object_unref(G_OBJECT(op)); - - target = pc + offset; - - //g_armv7_context_define_encoding(context, target, AV7IS_THUMB); - g_proc_context_push_drop_point(G_PROC_CONTEXT(context), DPL_OTHER, target, AV7IS_THUMB); - -} - - -/****************************************************************************** -* * -* Paramètres : instr = instruction ARMv7 à traiter. * -* proc = représentation de l'architecture utilisée. * -* context = contexte associé à la phase de désassemblage. * -* format = acès aux données du binaire d'origine. * -* iset = type de jeu d'instructions courant. * -* * -* Description : Complète un désassemblage accompli pour une instruction. * -* * -* Retour : - * -* * -* Remarques : - * -* * -******************************************************************************/ - -void help_fetching_with_instruction_ldr_literal_with_orig(GArchInstruction *instr, GArchProcessor *proc, GArmV7Context *context, GExeFormat *format, ArmV7InstrSet iset) -{ - const mrange_t *range; /* Emplacementt d'instruction */ - phys_t phys_pc; /* Position dans l'exécution */ - GArchOperand *op; /* Opérande de surcouche */ - uint32_t offset; /* Décallage encodé en dur */ - bool ret; /* Bilan d'une récupération */ - off_t val_offset; /* Position de valeur à lire */ - vmpa2t loaded_addr; /* Adresse de valeur chargée */ - mrange_t loaded_range; /* Espace de chargement */ - GBinContent *content; /* Contenu binaire à relire */ - uint32_t target; /* Adresse virtuelle visée */ - vmpa2t pos; /* Tête de lecture de valeur */ - VMPA_BUFFER(loc); /* Adresse au format texte */ - GPreloadInfo *info; /* Informations préchargées */ - GArchInstruction *loaded; /* Instruction de valeur */ - bool inserted; /* Bilan d'une insertion */ - char *desc; /* Description d'accompagnement*/ - GDbComment *comment; /* Définition de commentaire */ - GArchOperand *new; /* Instruction de ciblage */ - - /* Récupération de l'adresse visée par le chargement */ - - range = g_arch_instruction_get_range(instr); - - phys_pc = get_phy_addr(get_mrange_addr(range)); - - phys_pc &= ~3; - //phys_pc = (phys_pc + 3) & ~3; - - switch (iset) - { - case AV7IS_ARM: - phys_pc += 8; - break; - case AV7IS_THUMB: - phys_pc += 4; - break; - default: - assert(0); - break; - } - - g_arch_instruction_lock_operands(instr); - - op = _g_arch_instruction_get_operand(instr, 1); - assert(G_IS_IMM_OPERAND(op)); - - ret = g_imm_operand_get_value(G_IMM_OPERAND(op), MDS_32_BITS_UNSIGNED, &offset); - if (!ret) - { - assert(0); - g_object_unref(G_OBJECT(op)); - g_arch_instruction_unlock_operands(instr); - return; - } - - /* Transformations et conservation d'une position de chargement */ - - val_offset = phys_pc + offset; - - if (!g_exe_format_translate_offset_into_vmpa(format, val_offset, &loaded_addr)) - { - assert(0); - g_object_unref(G_OBJECT(op)); - g_arch_instruction_unlock_operands(instr); - return; - } - - init_mrange(&loaded_range, &loaded_addr, 4); - - /* Lecture de la valeur vers laquelle renvoyer */ - - content = g_binary_format_get_content(G_BIN_FORMAT(format)); - - copy_vmpa(&pos, &loaded_addr); - - ret = g_binary_content_read_u32(content, &pos, SRE_LITTLE /* FIXME */, &target); - g_object_unref(G_OBJECT(content)); - - if (!ret) - { - g_object_unref(G_OBJECT(op)); - g_arch_instruction_unlock_operands(instr); - return; - } - - /* Réalise l'intégration de la valeur chargée */ - - copy_vmpa(&pos, &loaded_addr); - - info = G_PRELOAD_INFO(context); - - loaded = g_raw_instruction_new_from_value(&pos, MDS_32_BITS_UNSIGNED, target); - - inserted = g_preload_info_add_instruction(info, loaded); - - if (inserted) - { - /* Commentaire associé */ - - vmpa2_virt_to_string(get_mrange_addr(range), MDS_32_BITS, loc, NULL); - asprintf(&desc, _("Value used @ %s"), loc); - - g_preload_info_lock_comments(info); - - comment = _g_preload_info_find_comment_at(info, &loaded_addr); - - if (comment != NULL) - { - g_db_comment_add_static_text(comment, "\n"); - g_db_comment_add_dynamic_text(comment, desc); - } - - else - { - comment = g_db_comment_new_inlined(&loaded_addr, BLF_HAS_CODE, false); - g_db_item_set_volatile(G_DB_ITEM(comment), true); - - g_db_comment_add_dynamic_text(comment, desc); - - _g_preload_info_add_comment(info, comment); - - } - - g_preload_info_unlock_comments(info); - - } - - /* Mise à jour de l'affichage et conclusion */ - - new = g_imm_operand_new_from_value(MDS_32_BITS_UNSIGNED, target); - _g_arch_instruction_replace_operand(instr, op, new); - - g_object_unref(G_OBJECT(op)); - g_arch_instruction_unlock_operands(instr); - - - - //exit(0); - - - - //target = pc + offset; - - - if (target & 0x1) - iset = AV7IS_THUMB; - //else - // iset = AV7IS_ARM; - - //g_armv7_context_define_encoding(context, target, AV7IS_THUMB); - g_proc_context_push_drop_point(G_PROC_CONTEXT(context), DPL_OTHER, target, iset); - - - //exit(0); - -} diff --git a/src/arch/arm/v7/fetch.h b/src/arch/arm/v7/fetch.h deleted file mode 100644 index ece4b42..0000000 --- a/src/arch/arm/v7/fetch.h +++ /dev/null @@ -1,112 +0,0 @@ - -/* Chrysalide - Outil d'analyse de fichiers binaires - * fetch.h - prototypes pour les ajouts de sauts à traiter durant la phase de désassemblage - * - * Copyright (C) 2015-2017 Cyrille Bagard - * - * This file is part of Chrysalide. - * - * Chrysalide is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Chrysalide is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Foobar. If not, see . - */ - - -#ifndef _ARCH_ARM_V7_FETCH_H -#define _ARCH_ARM_V7_FETCH_H - - -#include "context.h" -#include "../../instruction.h" - - - -/* Complète un désassemblage accompli pour une instruction. */ -void help_fetching_with_instruction_b_with_orig(GArchInstruction *, GArchProcessor *, GArmV7Context *, GExeFormat *, ArmV7InstrSet); - - -static inline void help_fetching_with_instruction_b_from_arm(GArchInstruction *ins, GArchProcessor *proc, GArmV7Context *ctx, GExeFormat *fmt) -{ - help_fetching_with_instruction_b_with_orig(ins, proc, ctx, fmt, AV7IS_ARM); -} - -static inline void help_fetching_with_instruction_b_from_thumb(GArchInstruction *ins, GArchProcessor *proc, GArmV7Context *ctx, GExeFormat *fmt) -{ - help_fetching_with_instruction_b_with_orig(ins, proc, ctx, fmt, AV7IS_THUMB); -} - - -/* Complète un désassemblage accompli pour une instruction. */ -void help_fetching_with_instruction_bl_with_orig(GArchInstruction *, GArchProcessor *, GArmV7Context *, GExeFormat *, ArmV7InstrSet); - - -static inline void help_fetching_with_instruction_bl_from_arm(GArchInstruction *ins, GArchProcessor *proc, GArmV7Context *ctx, GExeFormat *fmt) -{ - help_fetching_with_instruction_bl_with_orig(ins, proc, ctx, fmt, AV7IS_ARM); -} - -static inline void help_fetching_with_instruction_bl_from_thumb(GArchInstruction *ins, GArchProcessor *proc, GArmV7Context *ctx, GExeFormat *fmt) -{ - help_fetching_with_instruction_bl_with_orig(ins, proc, ctx, fmt, AV7IS_THUMB); -} - - -/* Complète un désassemblage accompli pour une instruction. */ -void help_fetching_with_instruction_blx_with_dest(GArchInstruction *, GArchProcessor *, GArmV7Context *, GExeFormat *, ArmV7InstrSet); - - -static inline void help_fetching_with_instruction_blx_from_arm(GArchInstruction *ins, GArchProcessor *proc, GArmV7Context *ctx, GExeFormat *fmt) -{ - help_fetching_with_instruction_blx_with_dest(ins, proc, ctx, fmt, AV7IS_THUMB); -} - -static inline void help_fetching_with_instruction_blx_from_thumb(GArchInstruction *ins, GArchProcessor *proc, GArmV7Context *ctx, GExeFormat *fmt) -{ - help_fetching_with_instruction_blx_with_dest(ins, proc, ctx, fmt, AV7IS_ARM); -} - - -/* Complète un désassemblage accompli pour une instruction. */ -void help_fetching_with_instruction_bx_with_orig(GArchInstruction *, GArchProcessor *, GArmV7Context *, GExeFormat *, ArmV7InstrSet); - - -static inline void help_fetching_with_instruction_bx_from_arm(GArchInstruction *ins, GArchProcessor *proc, GArmV7Context *ctx, GExeFormat *fmt) -{ - help_fetching_with_instruction_bx_with_orig(ins, proc, ctx, fmt, AV7IS_ARM); -} - -static inline void help_fetching_with_instruction_bx_from_thumb(GArchInstruction *ins, GArchProcessor *proc, GArmV7Context *ctx, GExeFormat *fmt) -{ - help_fetching_with_instruction_bx_with_orig(ins, proc, ctx, fmt, AV7IS_THUMB); -} - - -/* Complète un désassemblage accompli pour une instruction. */ -void help_fetching_with_instruction_cb_n_z(GArchInstruction *, GArchProcessor *, GArmV7Context *, GExeFormat *); - -/* Complète un désassemblage accompli pour une instruction. */ -void help_fetching_with_instruction_ldr_literal_with_orig(GArchInstruction *, GArchProcessor *, GArmV7Context *, GExeFormat *, ArmV7InstrSet); - - -static inline void help_fetching_with_instruction_ldr_literal_from_arm(GArchInstruction *ins, GArchProcessor *proc, GArmV7Context *ctx, GExeFormat *fmt) -{ - help_fetching_with_instruction_ldr_literal_with_orig(ins, proc, ctx, fmt, AV7IS_ARM); -} - -static inline void help_fetching_with_instruction_ldr_literal_from_thumb(GArchInstruction *ins, GArchProcessor *proc, GArmV7Context *ctx, GExeFormat *fmt) -{ - help_fetching_with_instruction_ldr_literal_with_orig(ins, proc, ctx, fmt, AV7IS_THUMB); -} - - - -#endif /* _ARCH_ARM_V7_FETCH_H */ diff --git a/src/arch/arm/v7/helpers.c b/src/arch/arm/v7/helpers.c deleted file mode 100644 index 4fa3667..0000000 --- a/src/arch/arm/v7/helpers.c +++ /dev/null @@ -1,275 +0,0 @@ - -/* Chrysalide - Outil d'analyse de fichiers binaires - * helpers.c - aide à la mise en place des opérandes ARMv7 - * - * Copyright (C) 2014-2017 Cyrille Bagard - * - * This file is part of Chrysalide. - * - * Chrysalide is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Chrysalide is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Foobar. If not, see . - */ - - -#include "helpers.h" - - -#include "register.h" -#include "../../register.h" -#include "../../immediate.h" -#include "../../../common/asm.h" -#include "../../../common/bconst.h" - - - -/****************************************************************************** -* * -* Paramètres : x = valeur sur 32 bits maximum à traiter. * -* shift = nombre de décallages visés. * -* * -* Description : Effectue une rotation vers la droit d'une valeur. * -* * -* Retour : Adresse de la structure mise en place. * -* * -* Remarques : Correspond à la pseudo fonction 'ROR_C'. * -* * -******************************************************************************/ - -GArchOperand *ror_armv7_imm(uint32_t x, unsigned int shift) -{ - GArchOperand *result; /* Opérande à faire remonter */ - uint32_t val32; /* Valeur sur 32 bits */ - - shift %= 32; - - val32 = (x >> shift) | (x << (32 - shift)); - - result = g_imm_operand_new_from_value(MDS_32_BITS_UNSIGNED, val32); - - return result; - -} - - - - - - - - - - - - -#if 0 - -// Shift_C() -// ========= -(bits(N), bit) Shift_C(bits(N) value, SRType type, integer amount, bit carry_in) -assert !(type == SRType_RRX && amount != 1); -if amount == 0 then -(result, carry_out) = (value, carry_in); -else -case type of - -when SRType_LSL -(result, carry_out) = LSL_C(value, amount); - -when SRType_LSR -(result, carry_out) - -when SRType_ASR -(result, carry_out) - -when SRType_ROR -(result, carry_out) - -when SRType_RRX -(result, carry_out) -= LSR_C(value, amount); -= ASR_C(value, amount); -= ROR_C(value, amount); -= RRX_C(value, carry_in); - -#endif - - - - - - -/****************************************************************************** -* * -* Paramètres : value = valeur sur 32 bits maximum à traiter. * -* topbit = valeur du bit de poids fort manipulé. * -* size = taille de la valeur finale à constituer. * -* * -* Description : Crée un opérande de valeur immédiate avec extension de signe.* -* * -* Retour : Adresse de la structure mise en place. * -* * -* Remarques : - * -* * -******************************************************************************/ - -GArchOperand *sign_extend_armv7_imm(uint32_t value, bool topbit, unsigned int size) -{ - GArchOperand *result; /* Opérande à faire remonter */ - unsigned int msb; /* Position du premier bit à 1 */ - MemoryDataSize mds; /* Conversion de la taille */ - uint32_t val4; /* Valeur sur 4 bits */ - uint32_t val8; /* Valeur sur 8 bits */ - uint32_t val16; /* Valeur sur 16 bits */ - uint32_t val32; /* Valeur sur 32 bits */ - unsigned int i; /* Boucle de parcours */ - - result = NULL; - - topbit &= msb_32(value, &msb); - - switch (size) - { - -#define SIGN_EXTEND_CASE(sz) \ - case sz: \ - mds = MDS_ ## sz ## _BITS_SIGNED; \ - val ## sz = value; \ - if (topbit) \ - for (i = msb; i < sz; i++) \ - val ## sz |= (1 << i); \ - result = g_imm_operand_new_from_value(mds, val ## sz); \ - break; - - SIGN_EXTEND_CASE(4); - SIGN_EXTEND_CASE(8); - SIGN_EXTEND_CASE(16); - SIGN_EXTEND_CASE(32); - - } - - return result; - -} - - -/****************************************************************************** -* * -* Paramètres : value = valeur sur 32 bits maximum à traiter. * -* * -* Description : Etend une valeur immédiate en mode 'Thumb' ARMv7. * -* * -* Retour : Adresse de la structure mise en place. * -* * -* Remarques : - * -* * -******************************************************************************/ - -GArchOperand *thumb_expand_armv7_imm(uint32_t value) -{ - GArchOperand *result; /* Opérande à faire remonter */ - uint8_t byte; /* Octet à reproduire */ - uint32_t val32; /* Valeur sur 32 bits */ - uint32_t unrotated; /* Transformation à décaller */ - - result = NULL; - - if (((value >> 10) & b11) == b00) - { - byte = value & 0xff; - - switch ((value >> 8) & b11) - { - case b00: - result = zero_extend_armv7_imm(byte, 32); - break; - - case b01: - if (byte == 0) return NULL; - val32 = byte << 16 | byte; - result = g_imm_operand_new_from_value(MDS_32_BITS_UNSIGNED, val32); - break; - - case b10: - if (byte == 0) return NULL; - val32 = byte << 24 | byte << 8; - result = g_imm_operand_new_from_value(MDS_32_BITS_UNSIGNED, val32); - break; - - case b11: - if (byte == 0) return NULL; - val32 = byte << 24 | byte << 16 | byte << 8 | byte; - result = g_imm_operand_new_from_value(MDS_32_BITS_UNSIGNED, val32); - break; - - } - - } - else - { - unrotated = 1 << 7 | (value & 0x3f); - result = ror_armv7_imm(unrotated, (value >> 7) & 0x1f); - } - - return result; - -} - - - - - - -/****************************************************************************** -* * -* Paramètres : value = valeur sur 32 bits maximum à traiter. * -* size = taille de la valeur finale à constituer. * -* * -* Description : Réalise un simple transtypage de valeur entière. * -* * -* Retour : Adresse de la structure mise en place. * -* * -* Remarques : Correspond à la pseudo fonction 'ZeroExtend'. * -* * -******************************************************************************/ - -GArchOperand *zero_extend_armv7_imm(uint32_t value, unsigned int size) -{ - GArchOperand *result; /* Opérande à faire remonter */ - MemoryDataSize mds; /* Conversion de la taille */ - uint32_t val4; /* Valeur sur 4 bits */ - uint32_t val8; /* Valeur sur 8 bits */ - uint32_t val16; /* Valeur sur 16 bits */ - uint32_t val32; /* Valeur sur 32 bits */ - - result = NULL; - - switch (size) - { - -#define ZERO_EXTEND_CASE(sz) \ - case sz: \ - mds = MDS_ ## sz ## _BITS_UNSIGNED; \ - val ## sz = value; \ - result = g_imm_operand_new_from_value(mds, val ## sz); \ - break; - - ZERO_EXTEND_CASE(4); - ZERO_EXTEND_CASE(8); - ZERO_EXTEND_CASE(16); - ZERO_EXTEND_CASE(32); - - } - - return result; - -} diff --git a/src/arch/arm/v7/helpers.h b/src/arch/arm/v7/helpers.h deleted file mode 100644 index aed7f3f..0000000 --- a/src/arch/arm/v7/helpers.h +++ /dev/null @@ -1,439 +0,0 @@ - -/* Chrysalide - Outil d'analyse de fichiers binaires - * helpers.h - prototypes pour l'aide à la mise en place des opérandes ARMv7 - * - * Copyright (C) 2014-2017 Cyrille Bagard - * - * This file is part of Chrysalide. - * - * Chrysalide is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Chrysalide is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Foobar. If not, see . - */ - - -#ifndef _ARCH_ARM_V7_HELPERS_H -#define _ARCH_ARM_V7_HELPERS_H - - -#include "cregister.h" -#include "pseudo.h" -#include "operands/coproc.h" -#include "operands/estate.h" -#include "operands/limitation.h" -#include "operands/maccess.h" -#include "operands/offset.h" -#include "operands/reglist.h" -#include "operands/rotation.h" -#include "operands/shift.h" -#include "../register.h" -#include "../../operand.h" - - - - - -#define BarrierLimitation(opt) \ - ({ \ - GArchOperand *__result; \ - __result = g_armv7_limitation_operand_new(opt); \ - __result; \ - }) - - -#define BitDiff(msb, lsb) \ - ({ \ - GArchOperand *__result; \ - uint32_t __width; \ - __width = g_imm_operand_get_raw_value(G_IMM_OPERAND(msb)); \ - __width -= g_imm_operand_get_raw_value(G_IMM_OPERAND(lsb)); \ - __width += 1; \ - __result = g_imm_operand_new_from_value(MDS_32_BITS_UNSIGNED, __width); \ - __result; \ - }) - - -#define BuildImm8(val) \ - ({ \ - GArchOperand *__result; \ - __result = g_imm_operand_new_from_value(MDS_8_BITS_UNSIGNED, (uint8_t)val); \ - __result; \ - }) - - -#define BuildImm16(val) \ - ({ \ - GArchOperand *__result; \ - __result = g_imm_operand_new_from_value(MDS_16_BITS_UNSIGNED, (uint16_t)val); \ - __result; \ - }) - - -#define CoProcessor(idx) \ - ({ \ - GArchOperand *__result; \ - __result = g_armv7_coproc_operand_new(idx); \ - __result; \ - }) - - -#define CRegister(idx) \ - ({ \ - GArchOperand *__result; \ - GArmV7CRegister *__reg; \ - __reg = g_armv7_cregister_new(idx); \ - if (__reg == NULL) \ - __result = NULL; \ - else \ - __result = g_register_operand_new(G_ARCH_REGISTER(__reg)); \ - __result; \ - }) - - -#define IncWidth(widthm1) \ - ({ \ - GArchOperand *__result; \ - uint32_t __width; \ - __width = widthm1 + 1; \ - __result = g_imm_operand_new_from_value(MDS_32_BITS_UNSIGNED, __width); \ - __result; \ - }) - - -#define DecodeImmShift(type, imm5) \ - ({ \ - GArchOperand *__result; \ - SRType __shift_t; \ - uint32_t __shift_n; \ - GArchOperand *__op_n; \ - if (!armv7_decode_imm_shift(type, imm5, &__shift_t, &__shift_n)) \ - __result = NULL; \ - else \ - { \ - __op_n = g_imm_operand_new_from_value(MDS_32_BITS_UNSIGNED, __shift_n); \ - __result = g_armv7_shift_operand_new(__shift_t, __op_n); \ - } \ - __result; \ - }) - - -#define EndianState(big) \ - ({ \ - GArchOperand *__result; \ - __result = g_armv7_endian_operand_new(big); \ - __result; \ - }) - - -#define MakeMemoryAccess(base, off, shift, index, add, wback) \ - ({ \ - GArchOperand *__result; \ - GArchOperand *__offset; \ - if (off != NULL) \ - __offset = g_armv7_offset_operand_new(add, off); \ - else \ - __offset = NULL; \ - __result = g_armv7_maccess_operand_new(base, __offset, shift, index, wback); \ - __result; \ - }) - - -#define NextRegister(prev) \ - ({ \ - GRegisterOperand *__prev_op; \ - GArchRegister *__reg; \ - uint8_t __id; \ - __prev_op = G_REGISTER_OPERAND(prev); \ - __reg = g_register_operand_get_register(__prev_op); \ - __id = g_arm_register_get_index(G_ARM_REGISTER(__reg)); \ - Register(__id + 1); \ - }) - - -#define RawValue(val) \ - ({ \ - GArchOperand *__result; \ - __result = g_imm_operand_new_from_value(MDS_32_BITS_UNSIGNED, (uint32_t)val); \ - __result; \ - }) - - -#define Register(idx) \ - ({ \ - GArchOperand *__result; \ - GArmV7Register *__reg; \ - __reg = g_armv7_register_new(idx); \ - if (__reg == NULL) \ - __result = NULL; \ - else \ - __result = g_register_operand_new(G_ARCH_REGISTER(__reg)); \ - __result; \ - }) - - -#define RegisterShift(shift_t, rs) \ - ({ \ - GArchOperand *__result; \ - GArchOperand *__reg; \ - __reg = Register(rs); \ - if (__reg == NULL) \ - __result = NULL; \ - else \ - __result = g_armv7_shift_operand_new(shift_t, __reg); \ - __result; \ - }) - - -#define Rotation(val5) \ - ({ \ - GArchOperand *__result; \ - uint8_t __rot; \ - GArchOperand *__rot_op; \ - __rot = val5; \ - __rot_op = g_imm_operand_new_from_value(MDS_8_BITS_UNSIGNED, __rot); \ - __result = g_armv7_rotation_operand_new(__rot_op); \ - if (__result == NULL) \ - g_object_unref(G_OBJECT(__rot_op)); \ - __result; \ - }) - - -#define UInt(val) \ - ({ \ - GArchOperand *__result; \ - __result = g_imm_operand_new_from_value(MDS_8_BITS_UNSIGNED, (uint8_t)val); \ - __result; \ - }) - - - - -//#define DecodeImmShift(raw_type, raw_imm5); -//g_armv7_shift_operand_new(SRType type, GArchOperand *value) - - - -//#define MakeMemoryAccess(base, off, shift, index, add, wback) NULL - -//g_armv7_maccess_operand_new(GArchOperand *base, GArchOperand *offset, GArchOperand *shift, bool indexed, bool writeb) - -//g_armv7_offset_operand_new(add, off) - - - - -//////////////////// - -#define Imm16(imm16) \ - ({ \ - GArchOperand *__result; \ - __result = g_imm_operand_new_from_value(MDS_16_BITS_UNSIGNED, (uint16_t)imm16); \ - __result; \ - }) - -#define ARMExpandImm_C(imm12, c) \ - ({ \ - GArchOperand *__result; \ - uint32_t __val; \ - if (armv7_arm_expand_imm_c(imm12, (bool []) { c }, &__val)) \ - __result = g_imm_operand_new_from_value(MDS_32_BITS_UNSIGNED, __val); \ - else \ - __result = NULL; \ - __result; \ - }) - -#define ARMExpandImm(imm12) \ - ({ \ - GArchOperand *__result; \ - uint32_t __val; \ - if (armv7_arm_expand_imm(imm12, &__val)) \ - __result = g_imm_operand_new_from_value(MDS_32_BITS_UNSIGNED, __val); \ - else \ - __result = NULL; \ - __result; \ - }) - -#define ThumbExpandImm_C(imm12, c) \ - ({ \ - GArchOperand *__result; \ - uint32_t __val; \ - if (armv7_thumb_expand_imm_c(imm12, (bool []) { c }, &__val)) \ - __result = g_imm_operand_new_from_value(MDS_32_BITS_UNSIGNED, __val); \ - else \ - __result = NULL; \ - __result; \ - }) - -#define ThumbExpandImm(imm12) \ - ({ \ - GArchOperand *__result; \ - uint32_t __val; \ - if (armv7_thumb_expand_imm(imm12, &__val)) \ - __result = g_imm_operand_new_from_value(MDS_32_BITS_UNSIGNED, __val); \ - else \ - __result = NULL; \ - __result; \ - }) - - - - - - - -#define DecodeImmShiftValue(imm5) \ - ({ \ - GArchOperand *__result; \ - uint32_t __shift_n; \ - if (!armv7_decode_imm_shift(0, imm5, (SRType []) { 0 }, &__shift_n)) \ - __result = NULL; \ - else \ - __result = g_imm_operand_new_from_value(MDS_32_BITS_UNSIGNED, __shift_n); \ - __result; \ - }) - - -#if 0 -// DecodeRegShift() -// ================ -SRType DecodeRegShift(bits(2) type) -case type of -when '00' shift_t = SRType_LSL; -when '01' shift_t = SRType_LSR; -when '10' shift_t = SRType_ASR; -when '11' shift_t = SRType_ROR; -return shift_t; -#endif - - - -#define ZeroExtend(x, i) \ - ({ \ - MemoryDataSize __mds; \ - uint ## i ## _t __val; \ - __mds = MDS_ ## i ## _BITS_UNSIGNED; \ - __val = armv7_zero_extend(x, 0/**/, i); \ - g_imm_operand_new_from_value(__mds, __val); \ - }) - - - -#define Zeros(i) \ - ({ \ - MemoryDataSize __mds; \ - uint ## i ## _t __val; \ - __mds = MDS_ ## i ## _BITS_UNSIGNED; \ - __val = 0; \ - g_imm_operand_new_from_value(__mds, __val); \ - }) - - - - - - - - -/** - * Glue purement interne. - */ - - -#define MakeAccessOffset(add, off) \ - g_armv7_offset_operand_new(add, off) - - -#define MakeShiftedMemoryAccess(base, off, shift, wr) \ - g_armv7_maccess_operand_new(base, off, shift, wr) - - -#define _MakeMemoryAccess(base, off, wr) \ - MakeShiftedMemoryAccess(base, off, NULL, wr) - -/* -#define MakeMemoryAccess(base, off, add, wr) \ - ({ \ - GArchOperand *__off; \ - __off = MakeAccessOffset(add, off); \ - _MakeMemoryAccess(base, __off, wr); \ - }) -*/ - -#define MakeMemoryNotIndexed(base, wr) \ - _MakeMemoryAccess(base, NULL, wr) - - - - - - - - -// type == '10', pas 2 ! (FIXME) -#define FixedShift(type, imm5) \ - ({ \ - GArchOperand *__result; \ - uint32_t __shift_n; \ - __shift_n = imm5; \ - __result = g_imm_operand_new_from_value(MDS_32_BITS_UNSIGNED, __shift_n); \ - __result; \ - }) - - - - - -/** - * Glue purement interne pour les listes de registres. - */ - -#define RegistersList(mask) \ - ({ \ - GArchOperand *__result; \ - __result = g_armv7_reglist_operand_new(); \ - if (!g_armv7_reglist_load_registers(G_ARMV7_REGLIST_OPERAND(__result), mask)) \ - { \ - g_object_unref(G_OBJECT(__result)); \ - __result = NULL; \ - } \ - __result; \ - }) - - -#define ListFromRegister(regop) \ - ({ \ - GArchOperand *__result; \ - GArmV7Register *__reg; \ - __result = g_armv7_reglist_operand_new(); \ - __reg = G_ARMV7_REGISTER(regop); \ - g_armv7_reglist_add_register(G_ARMV7_REGLIST_OPERAND(__result), __reg); \ - __result; \ - }) - - - - -/* Effectue une rotation vers la droit d'une valeur. */ -GArchOperand *ror_armv7_imm(uint32_t, unsigned int); - -/* Crée un opérande de valeur immédiate avec extension de signe. */ -GArchOperand *sign_extend_armv7_imm(uint32_t, bool, unsigned int); - -/* Etend une valeur immédiate en mode 'Thumb' ARMv7. */ -GArchOperand *thumb_expand_armv7_imm(uint32_t); - -/* Réalise un simple transtypage de valeur entière. */ -GArchOperand *zero_extend_armv7_imm(uint32_t, unsigned int); - - - -#endif /* _ARCH_ARM_V7_HELPERS_H */ diff --git a/src/arch/arm/v7/instruction.c b/src/arch/arm/v7/instruction.c deleted file mode 100644 index d9e4275..0000000 --- a/src/arch/arm/v7/instruction.c +++ /dev/null @@ -1,284 +0,0 @@ - -/* Chrysalide - Outil d'analyse de fichiers binaires - * instruction.c - gestion des instructions ARMv7 - * - * Copyright (C) 2014-2017 Cyrille Bagard - * - * This file is part of Chrysalide. - * - * Chrysalide is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Chrysalide is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Foobar. If not, see . - */ - - -#include "instruction.h" - - -#include -#ifndef NDEBUG -# include -#endif - - -#include "../instruction-int.h" - - - -/* Définition d'une instruction d'architecture ARMv7 (instance) */ -struct _GArmV7Instruction -{ - GArmInstruction parent; /* Instance parente */ - - char encoding; /* Encodage de l'instruction */ - - bool setflags; /* Mise à jour des drapeaux */ - -}; - - -/* Définition d'une instruction d'architecture ARMv7 (classe) */ -struct _GArmV7InstructionClass -{ - GArmInstructionClass parent; /* Classe parente */ - -}; - - -/* Initialise la classe des instructions ARMv7. */ -static void g_armv7_instruction_class_init(GArmV7InstructionClass *); - -/* Initialise une instance d'instruction ARMv7. */ -static void g_armv7_instruction_init(GArmV7Instruction *); - -/* Supprime toutes les références externes. */ -static void g_armv7_instruction_dispose(GArmV7Instruction *); - -/* Procède à la libération totale de la mémoire. */ -static void g_armv7_instruction_finalize(GArmV7Instruction *); - -/* Indique l'encodage d'une instruction de façon détaillée. */ -static const char *g_armv7_instruction_get_encoding(const GArmV7Instruction *); - - -/* Indique le type défini pour une représentation d'une instruction ARMv7. */ -G_DEFINE_TYPE(GArmV7Instruction, g_armv7_instruction, G_TYPE_ARM_INSTRUCTION); - - -/****************************************************************************** -* * -* Paramètres : klass = classe à initialiser. * -* * -* Description : Initialise la classe des instructions ARMv7. * -* * -* Retour : - * -* * -* Remarques : - * -* * -******************************************************************************/ - -static void g_armv7_instruction_class_init(GArmV7InstructionClass *klass) -{ - GObjectClass *object_class; /* Autre version de la classe */ - GArchInstructionClass *instr; /* Encore une autre vision... */ - - object_class = G_OBJECT_CLASS(klass); - instr = G_ARCH_INSTRUCTION_CLASS(klass); - - object_class->dispose = (GObjectFinalizeFunc/* ! */)g_armv7_instruction_dispose; - object_class->finalize = (GObjectFinalizeFunc)g_armv7_instruction_finalize; - - instr->get_encoding = (get_instruction_encoding_fc)g_armv7_instruction_get_encoding; - -} - - -/****************************************************************************** -* * -* Paramètres : instr = instance à initialiser. * -* * -* Description : Initialise une instance d'instruction ARMv7. * -* * -* Retour : - * -* * -* Remarques : - * -* * -******************************************************************************/ - -static void g_armv7_instruction_init(GArmV7Instruction *instr) -{ - -} - - -/****************************************************************************** -* * -* Paramètres : instr = instance d'objet GLib à traiter. * -* * -* Description : Supprime toutes les références externes. * -* * -* Retour : - * -* * -* Remarques : - * -* * -******************************************************************************/ - -static void g_armv7_instruction_dispose(GArmV7Instruction *instr) -{ - G_OBJECT_CLASS(g_armv7_instruction_parent_class)->dispose(G_OBJECT(instr)); - -} - - -/****************************************************************************** -* * -* Paramètres : instr = instance d'objet GLib à traiter. * -* * -* Description : Procède à la libération totale de la mémoire. * -* * -* Retour : - * -* * -* Remarques : - * -* * -******************************************************************************/ - -static void g_armv7_instruction_finalize(GArmV7Instruction *instr) -{ - G_OBJECT_CLASS(g_armv7_instruction_parent_class)->finalize(G_OBJECT(instr)); - -} - - -/****************************************************************************** -* * -* Paramètres : keyword = définition du nom humaine de l'instruction. * -* * -* Description : Crée une instruction pour l'architecture ARMv7. * -* * -* Retour : Adresse de la structure mise en place. * -* * -* Remarques : - * -* * -******************************************************************************/ - -GArchInstruction *g_armv7_instruction_new(const char *keyword) -{ - GArchInstruction *result; /* Structure à retourner */ - - result = g_object_new(G_TYPE_ARMV7_INSTRUCTION, NULL); - - G_ARM_INSTRUCTION(result)->keyword = keyword; - - return result; - -} - - -/****************************************************************************** -* * -* Paramètres : instr = instruction quelconque à consulter. * -* * -* Description : Indique l'encodage d'une instruction de façon détaillée. * -* * -* Retour : Description humaine de l'encodage utilisé. * -* * -* Remarques : - * -* * -******************************************************************************/ - -static const char *g_armv7_instruction_get_encoding(const GArmV7Instruction *instr) -{ - const char *result; /* Description à retourner */ - - switch (instr->encoding) - { - case 't': - result = "Thumb/16"; - break; - - case 'T': - result = "Thumb/32"; - break; - - default: - result = "ARM"; - break; - - } - - return result; - -} - - -/****************************************************************************** -* * -* Paramètres : instr = instruction quelconque à modifier. * -* encoding = encodage de l'instruction. * -* * -* Description : Précise l'encodage d'une instruction ARMv7 dans le détail. * -* * -* Retour : - * -* * -* Remarques : - * -* * -******************************************************************************/ - -void g_armv7_instruction_set_encoding(GArmV7Instruction *instr, const char *encoding) -{ - assert(strlen(encoding) == 1); - assert(encoding[0] == 'A' || encoding[0] == 'T' || encoding[0] == 't'); - - instr->encoding = encoding[0]; - -} - - -/****************************************************************************** -* * -* Paramètres : instr = instruction ARMv7 à mettre à jour. * -* set = statut à enregistrer. * -* * -* Description : Définit si une instruction ARMv7 met à jour les drapeaux. * -* * -* Retour : Bilan de l'opération. * -* * -* Remarques : - * -* * -******************************************************************************/ - -bool g_armv7_instruction_define_setflags(GArmV7Instruction *instr, bool set) -{ - instr->setflags = set; - - return true; - -} - - -/****************************************************************************** -* * -* Paramètres : instr = instruction ARMv7 à consulter. * -* * -* Description : Indique si une instruction ARMv7 met à jour les drapeaux. * -* * -* Retour : Statut des incidences de l'instruction. * -* * -* Remarques : - * -* * -******************************************************************************/ - -bool g_armv7_instruction_get_setflags(const GArmV7Instruction *instr) -{ - return instr->setflags; - -} diff --git a/src/arch/arm/v7/instruction.h b/src/arch/arm/v7/instruction.h deleted file mode 100644 index 4b3c006..0000000 --- a/src/arch/arm/v7/instruction.h +++ /dev/null @@ -1,69 +0,0 @@ - -/* Chrysalide - Outil d'analyse de fichiers binaires - * instruction.h - prototypes pour la gestion des instructions ARMv7 - * - * Copyright (C) 2014-2017 Cyrille Bagard - * - * This file is part of Chrysalide. - * - * Chrysalide is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Chrysalide is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Foobar. If not, see . - */ - - -#ifndef _ARCH_ARM_V7_INSTRUCTION_H -#define _ARCH_ARM_V7_INSTRUCTION_H - - -#include -#include -#include - - -#include "../../instruction.h" - - - -#define G_TYPE_ARMV7_INSTRUCTION g_armv7_instruction_get_type() -#define G_ARMV7_INSTRUCTION(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), g_armv7_instruction_get_type(), GArmV7Instruction)) -#define G_IS_ARMV7_INSTRUCTION(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), g_armv7_instruction_get_type())) -#define G_ARMV7_INSTRUCTION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), G_TYPE_ARMV7_INSTRUCTION, GArmV7InstructionClass)) -#define G_IS_ARMV7_INSTRUCTION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), G_TYPE_ARMV7_INSTRUCTION)) -#define G_ARMV7_INSTRUCTION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), G_TYPE_ARMV7_INSTRUCTION, GArmV7InstructionClass)) - - -/* Définition d'une instruction d'architecture ARMv7 (instance) */ -typedef struct _GArmV7Instruction GArmV7Instruction; - -/* Définition d'une instruction d'architecture ARMv7 (classe) */ -typedef struct _GArmV7InstructionClass GArmV7InstructionClass; - - -/* Indique le type défini pour une représentation d'une instruction ARMv7. */ -GType g_armv7_instruction_get_type(void); - -/* Crée une instruction pour l'architecture ARMv7. */ -GArchInstruction *g_armv7_instruction_new(const char *); - -/* Précise l'encodage d'une instruction ARMv7 dans le détail. */ -void g_armv7_instruction_set_encoding(GArmV7Instruction *, const char *); - -/* Définit si une instruction ARMv7 met à jour les drapeaux. */ -bool g_armv7_instruction_define_setflags(GArmV7Instruction *, bool); - -/* Indique si une instruction ARMv7 met à jour les drapeaux. */ -bool g_armv7_instruction_get_setflags(const GArmV7Instruction *); - - - -#endif /* _ARCH_ARM_V7_INSTRUCTION_H */ diff --git a/src/arch/arm/v7/link.c b/src/arch/arm/v7/link.c deleted file mode 100644 index 68cde7b..0000000 --- a/src/arch/arm/v7/link.c +++ /dev/null @@ -1,114 +0,0 @@ - -/* Chrysalide - Outil d'analyse de fichiers binaires - * link.c - édition des liens après la phase de désassemblage ARM v7 - * - * Copyright (C) 2014-2017 Cyrille Bagard - * - * This file is part of Chrysalide. - * - * Chrysalide is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Chrysalide is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Foobar. If not, see . - */ - - -#include "link.h" - - -#include - - -#include "operands/reglist.h" -#include "../register.h" - - - -/****************************************************************************** -* * -* Paramètres : instr = instruction ARM à traiter. * -* proc = représentation de l'architecture utilisée. * -* context = contexte associé à la phase de désassemblage. * -* format = acès aux données du binaire d'origine. * -* * -* Description : Encadre les sauts à partir de registres ARMv7. * -* * -* Retour : - * -* * -* Remarques : - * -* * -******************************************************************************/ - -void handle_armv7_conditional_branch_from_register(GArchInstruction *instr, GArchProcessor *proc, GProcContext *context, GExeFormat *format) -{ - GArchOperand *op; /* Opérande numérique en place */ - GArmRegister *reg; /* Registre matériel manipulé */ - - op = g_arch_instruction_get_operand(instr, 0); - assert(G_IS_REGISTER_OPERAND(op)); - - reg = G_ARM_REGISTER(g_register_operand_get_register(G_REGISTER_OPERAND(op))); - - if (g_arm_register_get_index(reg) == 14 /* lr */) - g_arch_instruction_set_flag(instr, AIF_RETURN_POINT); - - else - g_arch_instruction_set_flag(instr, AIF_RETURN_POINT); /* FIXME : jump inconnu ! */ - - g_object_unref(G_OBJECT(reg)); - - g_object_unref(G_OBJECT(op)); - -} - - -/****************************************************************************** -* * -* Paramètres : instr = instruction ARM à traiter. * -* proc = représentation de l'architecture utilisée. * -* context = contexte associé à la phase de désassemblage. * -* format = acès aux données du binaire d'origine. * -* * -* Description : Détecte les fins de procédures à base d'instructions 'pop'. * -* * -* Retour : - * -* * -* Remarques : - * -* * -******************************************************************************/ - -void handle_armv7_return_from_pop(GArchInstruction *instr, GArchProcessor *proc, GProcContext *context, GExeFormat *format) -{ - GArchOperand *op; /* Opérande numérique en place */ - GArmV7RegListOperand *reglist; /* Autre version de l'instance */ - size_t count; /* Nombre de registres présents*/ - size_t i; /* Boucle de parcours */ - GArmRegister *reg; /* Registre matériel manipulé */ - - op = g_arch_instruction_get_operand(instr, 0); - assert(G_IS_ARMV7_REGLIST_OPERAND(op)); - - reglist = G_ARMV7_REGLIST_OPERAND(op); - - count = g_armv7_reglist_count_registers(reglist); - - for (i = 0; i < count; i++) - { - reg = G_ARM_REGISTER(g_armv7_reglist_operand_get_register(reglist, i)); - - if (g_arm_register_get_index(reg) == 15 /* pc */) - g_arch_instruction_set_flag(instr, AIF_RETURN_POINT); - - } - - g_object_unref(G_OBJECT(op)); - -} diff --git a/src/arch/arm/v7/link.h b/src/arch/arm/v7/link.h deleted file mode 100644 index d4e2a60..0000000 --- a/src/arch/arm/v7/link.h +++ /dev/null @@ -1,41 +0,0 @@ - -/* Chrysalide - Outil d'analyse de fichiers binaires - * link.h - prototypes pour l'édition des liens après la phase de désassemblage ARM v7 - * - * Copyright (C) 2014-2017 Cyrille Bagard - * - * This file is part of Chrysalide. - * - * Chrysalide is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Chrysalide is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Foobar. If not, see . - */ - - -#ifndef _ARCH_ARM_V7_LINK_H -#define _ARCH_ARM_V7_LINK_H - - -#include "context.h" -#include "../../instruction.h" - - - -/* Encadre les sauts à partir de registres ARMv7. */ -void handle_armv7_conditional_branch_from_register(GArchInstruction *, GArchProcessor *, GProcContext *, GExeFormat *); - -/* Détecte les fins de procédures à base d'instructions 'pop'. */ -void handle_armv7_return_from_pop(GArchInstruction *, GArchProcessor *, GProcContext *, GExeFormat *); - - - -#endif /* _ARCH_ARM_V7_LINK_H */ diff --git a/src/arch/arm/v7/opcodes/Makefile.am b/src/arch/arm/v7/opcodes/Makefile.am deleted file mode 100644 index fb00143..0000000 --- a/src/arch/arm/v7/opcodes/Makefile.am +++ /dev/null @@ -1,26 +0,0 @@ - -# Initialement, ce Makefile est conçu sans définition de am__depfiles_maybe. -# Est-ce parce que GENERATED_FILES est vide et qu'il n'y a donc pas de code -# source ? En tout cas, au premier écrasement de gencode.mk, tous les fichiers -# sont regénérés, et am__depfiles_maybe apparaît enfin. Mais trop tard : -# des fichiers .Plo sont attendus mais non créés par l'ancien Makefile. -# On force les choses ici. -am__depfiles_maybe = depfiles - -include gencode.mk - -noinst_LTLIBRARIES = libarcharmv7opcodes.la - -libarcharmv7opcodes_la_SOURCES = $(GENERATED_FILES) - -libarcharmv7opcodes_la_LIBADD = - -libarcharmv7opcodes_la_CFLAGS = $(AM_CFLAGS) - - -AM_CPPFLAGS = $(LIBGTK_CFLAGS) $(LIBXML_CFLAGS) - -AM_CFLAGS = $(DEBUG_CFLAGS) $(WARNING_FLAGS) $(COMPLIANCE_FLAGS) - - -EXTRA_DIST = opcodes_tmp_arm.h opcodes_tmp_simd.h opcodes_tmp_thumb_16.h opcodes_tmp_thumb_32.h diff --git a/src/arch/arm/v7/opcodes/opcodes_tmp_arm.h b/src/arch/arm/v7/opcodes/opcodes_tmp_arm.h deleted file mode 100644 index 4106cbd..0000000 --- a/src/arch/arm/v7/opcodes/opcodes_tmp_arm.h +++ /dev/null @@ -1,56 +0,0 @@ -#ifndef arm_def_tmp_h -#define arm_def_tmp_h -#define armv7_read_arm_instr_cps_arm(r) NULL -#define armv7_read_arm_instr_eret(r) NULL -#define armv7_read_arm_instr_hvc(r) NULL -#define armv7_read_arm_instr_isb(r) NULL -#define armv7_read_arm_instr_ldc_ldc2_immediate(r) NULL -#define armv7_read_arm_instr_ldc_ldc2_literal(r) NULL -#define armv7_read_arm_instr_ldmda_ldmfa(r) NULL -#define armv7_read_arm_instr_ldmdb_ldmea(r) NULL -#define armv7_read_arm_instr_ldm_exception_return(r) NULL -#define armv7_read_arm_instr_ldmib_ldmed(r) NULL -#define armv7_read_arm_instr_ldm_ldmia_ldmfd_arm(r) NULL -#define armv7_read_arm_instr_ldm_user_registers(r) NULL -#define armv7_read_arm_instr_mrs(r) NULL -#define armv7_read_arm_instr_mrs_banked_register(r) NULL -#define armv7_read_arm_instr_msr_banked_register(r) NULL -#define armv7_read_arm_instr_msr_immediate_a8(r) NULL -#define armv7_read_arm_instr_msr_immediate_b9(r) NULL -#define armv7_read_arm_instr_msr_register_a8(r) NULL -#define armv7_read_arm_instr_msr_register_b9(r) NULL -#define armv7_read_arm_instr_pkh(r) NULL -#define armv7_read_arm_instr_pld_literal(r) NULL -#define armv7_read_arm_instr_pld_pldw_immediate(r) NULL -#define armv7_read_arm_instr_pld_pldw_register(r) NULL -#define armv7_read_arm_instr_pli_immediate_literal(r) NULL -#define armv7_read_arm_instr_pli_register(r) NULL -#define armv7_read_arm_instr_rfe(r) NULL -#define armv7_read_arm_instr_smc_previously_smi(r) NULL -#define armv7_read_arm_instr_smlabb_smlabt_smlatb_smlatt(r) NULL -#define armv7_read_arm_instr_smlalbb_smlalbt_smlaltb_smlaltt(r) NULL -#define armv7_read_arm_instr_smlawb_smlawt(r) NULL -#define armv7_read_arm_instr_smulbb_smulbt_smultb_smultt(r) NULL -#define armv7_read_arm_instr_smulwb_smulwt(r) NULL -#define armv7_read_arm_instr_smusd(r) NULL -#define armv7_read_arm_instr_srs_arm(r) NULL -#define armv7_read_arm_instr_ssat(r) NULL -#define armv7_read_arm_instr_ssat16(r) NULL -#define armv7_read_arm_instr_ssax(r) NULL -#define armv7_read_arm_instr_ssub16(r) NULL -#define armv7_read_arm_instr_ssub8(r) NULL -#define armv7_read_arm_instr_stc_stc2(r) NULL -#define armv7_read_arm_instr_stmda_stmed(r) NULL -#define armv7_read_arm_instr_stmdb_stmfd(r) NULL -#define armv7_read_arm_instr_stmib_stmfa(r) NULL -#define armv7_read_arm_instr_stm_stmia_stmea(r) NULL -#define armv7_read_arm_instr_stm_user_registers(r) NULL -#define armv7_read_arm_instr_sub_register_shifted_register(r) NULL -#define armv7_read_arm_instr_sxtab(r) NULL -#define armv7_read_arm_instr_sxtab16(r) NULL -#define armv7_read_arm_instr_sxtah(r) NULL -#define armv7_read_arm_instr_sxtb(r) NULL -#define armv7_read_arm_instr_sxtb16(r) NULL -#define armv7_read_arm_instr_sxth(r) NULL -#define armv7_read_arm_instr_wfe(r) NULL -#endif diff --git a/src/arch/arm/v7/opcodes/opcodes_tmp_simd.h b/src/arch/arm/v7/opcodes/opcodes_tmp_simd.h deleted file mode 100644 index 1d7023e..0000000 --- a/src/arch/arm/v7/opcodes/opcodes_tmp_simd.h +++ /dev/null @@ -1,138 +0,0 @@ -#ifndef simd_def_tmp_h -#define simd_def_tmp_h -#define armv7_read_simd_instr_vaba_vabal(r, a) NULL -#define armv7_read_simd_instr_vabd_floating_point(r, a) NULL -#define armv7_read_simd_instr_vabd_vabdl_integer(r, a) NULL -#define armv7_read_simd_instr_vabs(r, a) NULL -#define armv7_read_simd_instr_vacge_vacgt_vacle_vaclt(r, a) NULL -#define armv7_read_simd_instr_vadd_floating_point(r, a) NULL -#define armv7_read_simd_instr_vaddhn(r, a) NULL -#define armv7_read_simd_instr_vadd_integer(r, a) NULL -#define armv7_read_simd_instr_vaddl_vaddw(r, a) NULL -#define armv7_read_simd_instr_vand_register(r, a) NULL -#define armv7_read_simd_instr_vbic_immediate(r, a) NULL -#define armv7_read_simd_instr_vbic_register(r, a) NULL -#define armv7_read_simd_instr_vbif_vbit_vbsl(r, a) NULL -#define armv7_read_simd_instr_vceq_immediate_0(r, a) NULL -#define armv7_read_simd_instr_vceq_register(r, a) NULL -#define armv7_read_simd_instr_vcge_immediate_0(r, a) NULL -#define armv7_read_simd_instr_vcge_register(r, a) NULL -#define armv7_read_simd_instr_vcgt_immediate_0(r, a) NULL -#define armv7_read_simd_instr_vcgt_register(r, a) NULL -#define armv7_read_simd_instr_vcle_immediate_0(r, a) NULL -#define armv7_read_simd_instr_vcls(r, a) NULL -#define armv7_read_simd_instr_vclt_immediate_0(r, a) NULL -#define armv7_read_simd_instr_vclz(r, a) NULL -#define armv7_read_simd_instr_vcmp_vcmpe(r, a) NULL -#define armv7_read_simd_instr_vcnt(r, a) NULL -#define armv7_read_simd_instr_vcvt_between_double_precision_and_single_precision(r, a) NULL -#define armv7_read_simd_instr_vcvt_between_floating_point_and_fixed_point_advanced_simd(r, a) NULL -#define armv7_read_simd_instr_vcvt_between_floating_point_and_fixed_point_floating_point(r, a) NULL -#define armv7_read_simd_instr_vcvtb_vcvtt(r, a) NULL -#define armv7_read_simd_instr_vcvt_vcvtr_between_floating_point_and_integer_floating_point(r, a) NULL -#define armv7_read_simd_instr_vdiv(r, a) NULL -#define armv7_read_simd_instr_vdup_arm_core_register(r, a) NULL -#define armv7_read_simd_instr_vdup_scalar(r, a) NULL -#define armv7_read_simd_instr_veor(r, a) NULL -#define armv7_read_simd_instr_vext(r, a) NULL -#define armv7_read_simd_instr_vfma_vfms(r, a) NULL -#define armv7_read_simd_instr_vfnma_vfnms(r, a) NULL -#define armv7_read_simd_instr_vhadd_vhsub(r, a) NULL -#define armv7_read_simd_instr_vld1_multiple_single_elements(r, a) NULL -#define armv7_read_simd_instr_vld1_single_element_to_all_lanes(r, a) NULL -#define armv7_read_simd_instr_vld1_single_element_to_one_lane(r, a) NULL -#define armv7_read_simd_instr_vld2_multiple_2_element_structures(r, a) NULL -#define armv7_read_simd_instr_vld2_single_2_element_structure_to_all_lanes(r, a) NULL -#define armv7_read_simd_instr_vld2_single_2_element_structure_to_one_lane(r, a) NULL -#define armv7_read_simd_instr_vld3_multiple_3_element_structures(r, a) NULL -#define armv7_read_simd_instr_vld3_single_3_element_structure_to_all_lanes(r, a) NULL -#define armv7_read_simd_instr_vld3_single_3_element_structure_to_one_lane(r, a) NULL -#define armv7_read_simd_instr_vld4_multiple_4_element_structures(r, a) NULL -#define armv7_read_simd_instr_vld4_single_4_element_structure_to_all_lanes(r, a) NULL -#define armv7_read_simd_instr_vld4_single_4_element_structure_to_one_lane(r, a) NULL -#define armv7_read_simd_instr_vldm(r, a) NULL -#define armv7_read_simd_instr_vldr(r, a) NULL -#define armv7_read_simd_instr_vmax_vmin_floating_point(r, a) NULL -#define armv7_read_simd_instr_vmax_vmin_integer(r, a) NULL -#define armv7_read_simd_instr_vmla_vmlal_vmls_vmlsl_by_scalar(r, a) NULL -#define armv7_read_simd_instr_vmla_vmlal_vmls_vmlsl_integer(r, a) NULL -#define armv7_read_simd_instr_vmla_vmls_floating_point(r, a) NULL -#define armv7_read_simd_instr_vmov_arm_core_register_to_scalar(r, a) NULL -#define armv7_read_simd_instr_vmov_between_arm_core_register_and_single_precision_register(r, a) NULL -#define armv7_read_simd_instr_vmov_between_two_arm_core_registers_and_a_doubleword_extension_register(r, a) NULL -#define armv7_read_simd_instr_vmov_between_two_arm_core_registers_and_two_single_precision_registers(r, a) NULL -#define armv7_read_simd_instr_vmov_immediate(r, a) NULL -#define armv7_read_simd_instr_vmovl(r, a) NULL -#define armv7_read_simd_instr_vmov_register(r, a) NULL -#define armv7_read_simd_instr_vmov_scalar_to_arm_core_register(r, a) NULL -#define armv7_read_simd_instr_vmrs(r, a) NULL -#define armv7_read_simd_instr_vmrs_b9(r, a) NULL -#define armv7_read_simd_instr_vmsr(r, a) NULL -#define armv7_read_simd_instr_vmsr_b9(r, a) NULL -#define armv7_read_simd_instr_vmul_floating_point(r, a) NULL -#define armv7_read_simd_instr_vmul_vmull_by_scalar(r, a) NULL -#define armv7_read_simd_instr_vmul_vmull_integer_and_polynomial(r, a) NULL -#define armv7_read_simd_instr_vmvn_immediate(r, a) NULL -#define armv7_read_simd_instr_vmvn_register(r, a) NULL -#define armv7_read_simd_instr_vneg(r, a) NULL -#define armv7_read_simd_instr_vnmla_vnmls_vnmul(r, a) NULL -#define armv7_read_simd_instr_vorn_register(r, a) NULL -#define armv7_read_simd_instr_vorr_immediate(r, a) NULL -#define armv7_read_simd_instr_vorr_register(r, a) NULL -#define armv7_read_simd_instr_vpadal(r, a) NULL -#define armv7_read_simd_instr_vpadd_floating_point(r, a) NULL -#define armv7_read_simd_instr_vpadd_integer(r, a) NULL -#define armv7_read_simd_instr_vpaddl(r, a) NULL -#define armv7_read_simd_instr_vpmax_vpmin_floating_point(r, a) NULL -#define armv7_read_simd_instr_vpmax_vpmin_integer(r, a) NULL -#define armv7_read_simd_instr_vpop(r, a) NULL -#define armv7_read_simd_instr_vpush(r, a) NULL -#define armv7_read_simd_instr_vqabs(r, a) NULL -#define armv7_read_simd_instr_vqadd(r, a) NULL -#define armv7_read_simd_instr_vqdmlal_vqdmlsl(r, a) NULL -#define armv7_read_simd_instr_vqdmulh(r, a) NULL -#define armv7_read_simd_instr_vqdmull(r, a) NULL -#define armv7_read_simd_instr_vqneg(r, a) NULL -#define armv7_read_simd_instr_vqrdmulh(r, a) NULL -#define armv7_read_simd_instr_vqrshl(r, a) NULL -#define armv7_read_simd_instr_vqrshrn_vqrshrun(r, a) NULL -#define armv7_read_simd_instr_vqshl_register(r, a) NULL -#define armv7_read_simd_instr_vqshl_vqshlu_immediate(r, a) NULL -#define armv7_read_simd_instr_vqshrn_vqshrun(r, a) NULL -#define armv7_read_simd_instr_vqsub(r, a) NULL -#define armv7_read_simd_instr_vraddhn(r, a) NULL -#define armv7_read_simd_instr_vrecps(r, a) NULL -#define armv7_read_simd_instr_vrev16_vrev32_vrev64(r, a) NULL -#define armv7_read_simd_instr_vrhadd(r, a) NULL -#define armv7_read_simd_instr_vrshl(r, a) NULL -#define armv7_read_simd_instr_vrshr(r, a) NULL -#define armv7_read_simd_instr_vrshrn(r, a) NULL -#define armv7_read_simd_instr_vrsqrts(r, a) NULL -#define armv7_read_simd_instr_vrsra(r, a) NULL -#define armv7_read_simd_instr_vrsubhn(r, a) NULL -#define armv7_read_simd_instr_vshl_immediate(r, a) NULL -#define armv7_read_simd_instr_vshll(r, a) NULL -#define armv7_read_simd_instr_vshl_register(r, a) NULL -#define armv7_read_simd_instr_vshr(r, a) NULL -#define armv7_read_simd_instr_vshrn(r, a) NULL -#define armv7_read_simd_instr_vsli(r, a) NULL -#define armv7_read_simd_instr_vsqrt(r, a) NULL -#define armv7_read_simd_instr_vsra(r, a) NULL -#define armv7_read_simd_instr_vsri(r, a) NULL -#define armv7_read_simd_instr_vst1_multiple_single_elements(r, a) NULL -#define armv7_read_simd_instr_vst1_single_element_from_one_lane(r, a) NULL -#define armv7_read_simd_instr_vst2_multiple_2_element_structures(r, a) NULL -#define armv7_read_simd_instr_vst2_single_2_element_structure_from_one_lane(r, a) NULL -#define armv7_read_simd_instr_vst3_multiple_3_element_structures(r, a) NULL -#define armv7_read_simd_instr_vst3_single_3_element_structure_from_one_lane(r, a) NULL -#define armv7_read_simd_instr_vst4_multiple_4_element_structures(r, a) NULL -#define armv7_read_simd_instr_vst4_single_4_element_structure_from_one_lane(r, a) NULL -#define armv7_read_simd_instr_vstm(r, a) NULL -#define armv7_read_simd_instr_vstr(r, a) NULL -#define armv7_read_simd_instr_vsub_floating_point(r, a) NULL -#define armv7_read_simd_instr_vsubhn(r, a) NULL -#define armv7_read_simd_instr_vsub_integer(r, a) NULL -#define armv7_read_simd_instr_vsubl_vsubw(r, a) NULL -#define armv7_read_simd_instr_vtbl_vtbx(r, a) NULL -#define armv7_read_simd_instr_vtst(r, a) NULL -#endif diff --git a/src/arch/arm/v7/opcodes/opcodes_tmp_thumb_16.h b/src/arch/arm/v7/opcodes/opcodes_tmp_thumb_16.h deleted file mode 100644 index 1968037..0000000 --- a/src/arch/arm/v7/opcodes/opcodes_tmp_thumb_16.h +++ /dev/null @@ -1,10 +0,0 @@ -#ifndef thumb_16_def_tmp_h -#define thumb_16_def_tmp_h -#define armv7_read_thumb_16_instr_cps_thumb(r) NULL -#define armv7_read_thumb_16_instr_it(r) NULL -#define armv7_read_thumb_16_instr_ldm_ldmia_ldmfd_thumb(r) NULL -#define armv7_read_thumb_16_instr_stm_stmia_stmea(r) NULL -#define armv7_read_thumb_16_instr_sxtb(r) NULL -#define armv7_read_thumb_16_instr_sxth(r) NULL -#define armv7_read_thumb_16_instr_wfe(r) NULL -#endif diff --git a/src/arch/arm/v7/opcodes/opcodes_tmp_thumb_32.h b/src/arch/arm/v7/opcodes/opcodes_tmp_thumb_32.h deleted file mode 100644 index 1ed547c..0000000 --- a/src/arch/arm/v7/opcodes/opcodes_tmp_thumb_32.h +++ /dev/null @@ -1,59 +0,0 @@ -#ifndef thumb_32_def_tmp_h -#define thumb_32_def_tmp_h -#define armv7_read_thumb_32_instr_b_mrs(r) NULL -#define armv7_read_thumb_32_instr_b_msr_register(r) NULL -#define armv7_read_thumb_32_instr_cps_thumb(r) NULL -#define armv7_read_thumb_32_instr_enterx_leavex(r) NULL -#define armv7_read_thumb_32_instr_eret(r) NULL -#define armv7_read_thumb_32_instr_hvc(r) NULL -#define armv7_read_thumb_32_instr_isb(r) NULL -#define armv7_read_thumb_32_instr_ldc_ldc2_immediate(r) NULL -#define armv7_read_thumb_32_instr_ldc_ldc2_literal(r) NULL -#define armv7_read_thumb_32_instr_ldmdb_ldmea(r) NULL -#define armv7_read_thumb_32_instr_ldm_ldmia_ldmfd_thumb(r) NULL -#define armv7_read_thumb_32_instr_mrs(r) NULL -#define armv7_read_thumb_32_instr_mrs_banked_register(r) NULL -#define armv7_read_thumb_32_instr_msr_banked_register(r) NULL -#define armv7_read_thumb_32_instr_msr_register(r) NULL -#define armv7_read_thumb_32_instr_pkh(r) NULL -#define armv7_read_thumb_32_instr_pld_immediate(r) NULL -#define armv7_read_thumb_32_instr_pld_literal(r) NULL -#define armv7_read_thumb_32_instr_pld_pldw_immediate(r) NULL -#define armv7_read_thumb_32_instr_pld_pldw_register(r) NULL -#define armv7_read_thumb_32_instr_pld_register(r) NULL -#define armv7_read_thumb_32_instr_pli_immediate_literal(r) NULL -#define armv7_read_thumb_32_instr_pli_register(r) NULL -#define armv7_read_thumb_32_instr_rfe(r) NULL -#define armv7_read_thumb_32_instr_smc_previously_smi(r) NULL -#define armv7_read_thumb_32_instr_smlabb_smlabt_smlatb_smlatt(r) NULL -#define armv7_read_thumb_32_instr_smlalbb_smlalbt_smlaltb_smlaltt(r) NULL -#define armv7_read_thumb_32_instr_smlawb_smlawt(r) NULL -#define armv7_read_thumb_32_instr_smulbb_smulbt_smultb_smultt(r) NULL -#define armv7_read_thumb_32_instr_smulwb_smulwt(r) NULL -#define armv7_read_thumb_32_instr_smusd(r) NULL -#define armv7_read_thumb_32_instr_sqadd16(r) NULL -#define armv7_read_thumb_32_instr_sqadd8(r) NULL -#define armv7_read_thumb_32_instr_sqasx(r) NULL -#define armv7_read_thumb_32_instr_sqsax(r) NULL -#define armv7_read_thumb_32_instr_sqsub16(r) NULL -#define armv7_read_thumb_32_instr_sqsub8(r) NULL -#define armv7_read_thumb_32_instr_srs_thumb(r) NULL -#define armv7_read_thumb_32_instr_ssat(r) NULL -#define armv7_read_thumb_32_instr_ssat16(r) NULL -#define armv7_read_thumb_32_instr_ssax(r) NULL -#define armv7_read_thumb_32_instr_ssub16(r) NULL -#define armv7_read_thumb_32_instr_ssub8(r) NULL -#define armv7_read_thumb_32_instr_stc_stc2(r) NULL -#define armv7_read_thumb_32_instr_stmdb_stmfd(r) NULL -#define armv7_read_thumb_32_instr_stm_stmia_stmea(r) NULL -#define armv7_read_thumb_32_instr_sub_register_thumb(r) NULL -#define armv7_read_thumb_32_instr_subs_pc_lr_thumb(r) NULL -#define armv7_read_thumb_32_instr_sxtab(r) NULL -#define armv7_read_thumb_32_instr_sxtab16(r) NULL -#define armv7_read_thumb_32_instr_sxtah(r) NULL -#define armv7_read_thumb_32_instr_sxtb(r) NULL -#define armv7_read_thumb_32_instr_sxtb16(r) NULL -#define armv7_read_thumb_32_instr_sxth(r) NULL -#define armv7_read_thumb_32_instr_tbb_tbh(r) NULL -#define armv7_read_thumb_32_instr_wfe(r) NULL -#endif diff --git a/src/arch/arm/v7/opdefs/Makefile.am b/src/arch/arm/v7/opdefs/Makefile.am deleted file mode 100644 index a702d10..0000000 --- a/src/arch/arm/v7/opdefs/Makefile.am +++ /dev/null @@ -1,301 +0,0 @@ - -include ../../../../../tools/d2c/d2c.mk - - -D2C_BIN = ../../../../../tools/d2c/d2c -GEN_BIN = ../../../../../tools/d2c/d2c_genmakefile.sh - -D2C_TYPE = raw - -D2C_OUTDIR = $(PWD)/.. - -D2C_ARCH = armv7 -D2C_HEADER = _ARCH_ARM_V7 - -D2C_ENCODINGS = \ - -e A=arm_ \ - -e t=thumb_16_ \ - -e T=thumb_32_ - -D2C_MACROS = \ - -M SetFlags=g_armv7_instruction_define_setflags \ - -M Condition=g_arm_instruction_set_cond \ - -M "ExpandImmC32=g_imm_operand_new_from_value(MDS_32_BITS_UNSIGNED, " \ - -M SignExtend=sign_extend_armv7_imm \ - -M SetInsFlag=g_arch_instruction_set_flag \ - -M StoreCondition=g_arm_instruction_set_cond \ - -M ExtendKeyword=g_arm_instruction_extend_keyword - -D2C_OPERANDS = \ - -n BarrierLimitation \ - -n BitDiff \ - -n IncWidth \ - -n DecodeImmShift \ - -n MakeMemoryAccess \ - -n Register \ - -n RegisterShift \ - -n UInt \ - -n ZeroExtend - -FIXED_C_INCLUDES = \ - \n\#include \"..\/helpers.h\" \ - \n\#include \"..\/instruction.h\" \ - \n\#include \"..\/fetch.h\" \ - \n\#include \"..\/link.h\" \ - \n\#include \"..\/post.h\" \ - \n\#include \"..\/..\/instruction.h\" \ - \n\#include \"..\/..\/link.h\" \ - \n\#include \"..\/..\/..\/link.h\" \ - \n\#include \"..\/..\/..\/..\/common\/bconst.h\" \ - \n\n - -FIXED_H_INCLUDES = \ - \n\#include \ \ - \n \ - \n\#include \"..\/..\/..\/instruction.h\" \ - \n\n - - -# for i in $(seq 1 426); do test -f *A88$i.d && (ls *A88$i.d | sed 's/^/\t/' | sed 's/$/\t\t\t\t\t\t\\/') ; done -ARMV7_DEFS = \ - adc_A881.d \ - adc_A882.d \ - adc_A883.d \ - add_A884.d \ - add_A885.d \ - add_A886.d \ - add_A887.d \ - add_A888.d \ - add_A889.d \ - add_A8810.d \ - add_A8811.d \ - adr_A8812.d \ - and_A8813.d \ - and_A8814.d \ - and_A8815.d \ - asr_A8816.d \ - asr_A8817.d \ - b_A8818.d \ - bfc_A8819.d \ - bfi_A8820.d \ - bic_A8821.d \ - bic_A8822.d \ - bic_A8823.d \ - bkpt_A8824.d \ - bl_A8825.d \ - blx_A8826.d \ - bx_A8827.d \ - bxj_A8828.d \ - cb_A8829.d \ - cdp_A8830.d \ - clrex_A8832.d \ - clz_A8833.d \ - cmn_A8834.d \ - cmn_A8835.d \ - cmn_A8836.d \ - cmp_A8837.d \ - cmp_A8838.d \ - cmp_A8839.d \ - dbg_A8842.d \ - dmb_A8843.d \ - dsb_A8844.d \ - eor_A8846.d \ - eor_A8847.d \ - eor_A8848.d \ - ldr_A8862.d \ - ldr_A8863.d \ - ldr_A8864.d \ - ldr_A8865.d \ - ldr_A8866.d \ - ldrb_A8867.d \ - ldrb_A8868.d \ - ldrb_A8869.d \ - ldrb_A8870.d \ - ldrbt_A8871.d \ - ldrd_A8872.d \ - ldrd_A8873.d \ - ldrd_A8874.d \ - ldrex_A8875.d \ - ldrexb_A8876.d \ - ldrexd_A8877.d \ - ldrexh_A8878.d \ - ldrh_A8879.d \ - ldrh_A8880.d \ - ldrh_A8881.d \ - ldrh_A8882.d \ - ldrht_A8883.d \ - ldrsb_A8884.d \ - ldrsb_A8885.d \ - ldrsb_A8886.d \ - ldrsbt_A8887.d \ - ldrsh_A8888.d \ - ldrsh_A8889.d \ - ldrsh_A8890.d \ - ldrsht_A8891.d \ - ldrt_A8892.d \ - lsl_A8894.d \ - lsl_A8895.d \ - lsr_A8896.d \ - lsr_A8897.d \ - mcr_A8898.d \ - mcrr_A8899.d \ - mla_A88100.d \ - mls_A88101.d \ - mov_A88102.d \ - mov_A88103.d \ - mov_A88104.d \ - movt_A88106.d \ - mrc_A88107.d \ - mrrc_A88108.d \ - mul_A88114.d \ - mvn_A88115.d \ - mvn_A88116.d \ - mvn_A88117.d \ - nop_A88119.d \ - orn_A88120.d \ - orn_A88121.d \ - orr_A88122.d \ - orr_A88123.d \ - orr_A88124.d \ - pop_A88131.d \ - pop_A88132.d \ - push_A88133.d \ - qadd_A88134.d \ - qadd16_A88135.d \ - qadd8_A88136.d \ - qasx_A88137.d \ - qdadd_A88138.d \ - qdsub_A88139.d \ - qsax_A88140.d \ - qsub_A88141.d \ - qsub16_A88142.d \ - qsub8_A88143.d \ - rbit_A88144.d \ - rev_A88145.d \ - rev16_A88146.d \ - revsh_A88147.d \ - ror_A88149.d \ - ror_A88150.d \ - rrx_A88151.d \ - rsb_A88152.d \ - rsb_A88153.d \ - rsb_A88154.d \ - rsc_A88155.d \ - rsc_A88156.d \ - rsc_A88157.d \ - sadd16_A88158.d \ - sadd8_A88159.d \ - sasx_A88160.d \ - sbc_A88161.d \ - sbc_A88162.d \ - sbc_A88163.d \ - sbfx_A88164.d \ - sdiv_A88165.d \ - sel_A88166.d \ - setend_A88167.d \ - sev_A88168.d \ - shadd16_A88169.d \ - shadd8_A88170.d \ - shasx_A88171.d \ - shsax_A88172.d \ - shsub16_A88173.d \ - shsub8_A88174.d \ - smlad_A88177.d \ - smlal_A88178.d \ - smlald_A88180.d \ - smlsd_A88182.d \ - smlsld_A88183.d \ - smmla_A88184.d \ - smmls_A88185.d \ - smmul_A88186.d \ - smuad_A88187.d \ - smull_A88189.d \ - str_A88203.d \ - str_A88204.d \ - str_A88205.d \ - strb_A88206.d \ - strb_A88207.d \ - strb_A88208.d \ - strbt_A88209.d \ - strd_A88210.d \ - strd_A88211.d \ - strex_A88212.d \ - strexb_A88213.d \ - strexd_A88214.d \ - strexh_A88215.d \ - strh_A88216.d \ - strh_A88217.d \ - strh_A88218.d \ - strht_A88219.d \ - strt_A88220.d \ - sub_A88221.d \ - sub_A88222.d \ - sub_A88223.d \ - sub_A88225.d \ - svc_A88228.d \ - swp_A88229.d \ - teq_A88237.d \ - teq_A88238.d \ - teq_A88239.d \ - tst_A88240.d \ - tst_A88241.d \ - tst_A88242.d \ - uadd16_A88243.d \ - uadd8_A88244.d \ - uasx_A88245.d \ - ubfx_A88246.d \ - udf_A88247.d \ - udiv_A88248.d \ - uhadd16_A88249.d \ - uhadd8_A88250.d \ - uhasx_A88251.d \ - uhsax_A88252.d \ - uhsub16_A88253.d \ - uhsub8_A88254.d \ - umaal_A88255.d \ - umlal_A88256.d \ - umull_A88257.d \ - uqadd16_A88258.d \ - uqadd8_A88259.d \ - uqasx_A88260.d \ - uqsax_A88261.d \ - uqsub16_A88262.d \ - uqsub8_A88263.d \ - usad8_A88264.d \ - usada8_A88265.d \ - usat_A88266.d \ - usat16_A88267.d \ - usax_A88268.d \ - usub16_A88269.d \ - usub8_A88270.d \ - uxtab_A88271.d \ - uxtab16_A88272.d \ - uxtah_A88273.d \ - uxtb_A88274.d \ - uxtb16_A88275.d \ - uxth_A88276.d \ - wfi_A88425.d \ - yield_A88426.d - -# subs_B9320.d - -# make dist procède répertoire par répertoire. Or le répertoire opcodes utilise -# le contenu du répertoire opdefs. Il faut donc générer les fichiers nécessaires -# au répertoire opcodes. Et comme on ne peut pas compléter la règle dist, on -# ajoute à la distribution les cibles marquant la génération. (1/2) - -EXTRA_DIST = $(ARMV7_DEFS) $(ARMV7_DEFS:.d=.g) - -# Après coup, on supprime les fichiers inutiles de la distribution/ (2/2) - -dist-hook: - cd $(distdir) && rm $(ARMV7_DEFS:.d=.g) - -all: $(ARMV7_DEFS:.d=.g) fmk.done d2c_final_rules - -fmk.done: $(ARMV7_DEFS) - $(GEN_BIN) ../opcodes/ ../opdefs/.gen ../../../../../tools/d2c/globalgen.mk arm thumb_32 thumb_16 - touch $@ - -clean: - rm -rf $(ARMV7_DEFS:.d=.g) .gen fmk.done diff --git a/src/arch/arm/v7/opdefs/adc_A881.d b/src/arch/arm/v7/opdefs/adc_A881.d deleted file mode 100644 index 6bc66e2..0000000 --- a/src/arch/arm/v7/opdefs/adc_A881.d +++ /dev/null @@ -1,74 +0,0 @@ - -/* Chrysalide - Outil d'analyse de fichiers binaires - * ##FILE## - traduction d'instructions ARMv7 - * - * Copyright (C) 2015 Cyrille Bagard - * - * This file is part of Chrysalide. - * - * Chrysalide is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Chrysalide is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Foobar. If not, see . - */ - - -@title ADC (immediate) - -@desc Add with Carry (immediate) adds an immediate value and the Carry flag value to a register value, and writes the result to the destination register. It can optionally update the condition flags based on the result. - -@encoding (T1) { - - @word 1 1 1 1 0 i(1) 0 1 0 1 0 S(1) Rn(4) 0 imm3(3) Rd(4) imm8(8) - - @syntax - - @conv { - - reg_D = Register(Rd) - reg_N = Register(Rn) - setflags = (S == '1') - imm32 = ThumbExpandImm(i:imm3:imm8) - - } - - @rules { - - if (setflags); chk_call ExtendKeyword("s") - - } - -} - -@encoding (A1) { - - @word cond(4) 0 0 1 0 1 0 1 S(1) Rn(4) Rd(4) imm12(12) - - @syntax - - @conv { - - reg_D = Register(Rd) - reg_N = Register(Rn) - setflags = (S == '1') - imm32 = ARMExpandImm(imm12) - - } - - @rules { - - if (setflags); chk_call ExtendKeyword("s") - chk_call StoreCondition(cond) - - } - -} - diff --git a/src/arch/arm/v7/opdefs/adc_A882.d b/src/arch/arm/v7/opdefs/adc_A882.d deleted file mode 100644 index 27ce6ad..0000000 --- a/src/arch/arm/v7/opdefs/adc_A882.d +++ /dev/null @@ -1,92 +0,0 @@ - -/* Chrysalide - Outil d'analyse de fichiers binaires - * ##FILE## - traduction d'instructions ARMv7 - * - * Copyright (C) 2015 Cyrille Bagard - * - * This file is part of Chrysalide. - * - * Chrysalide is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Chrysalide is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Foobar. If not, see . - */ - - -@title ADC (register) - -@desc Add with Carry (register) adds a register value, the Carry flag value, and an optionally-shifted register value, and writes the result to the destination register. It can optionally update the condition flags based on the result. - -@encoding (t1) { - - @half 0 1 0 0 0 0 0 1 0 1 Rm(3) Rdn(3) - - @syntax "adcs" - - @conv { - - reg_DN = Register(Rdn) - reg_M = Register(Rm) - - } - -} - -@encoding (T2) { - - @word 1 1 1 0 1 0 1 1 0 1 0 S(1) Rn(4) 0 imm3(3) Rd(4) imm2(2) type(2) Rm(4) - - @syntax - - @conv { - - reg_D = Register(Rd) - reg_N = Register(Rn) - reg_M = Register(Rm) - setflags = (S == '1') - shift = DecodeImmShift(type, imm3:imm2) - - } - - @rules { - - if (setflags); chk_call ExtendKeyword("s") - chk_call ExtendKeyword(".w") - - } - -} - -@encoding (A1) { - - @word cond(4) 0 0 0 0 1 0 1 S(1) Rn(4) Rd(4) imm5(5) type(2) 0 Rm(4) - - @syntax - - @conv { - - reg_D = Register(Rd) - reg_N = Register(Rn) - reg_M = Register(Rm) - setflags = (S == '1') - shift = DecodeImmShift(type, imm5) - - } - - @rules { - - if (setflags); chk_call ExtendKeyword("s") - chk_call StoreCondition(cond) - - } - -} - diff --git a/src/arch/arm/v7/opdefs/adc_A883.d b/src/arch/arm/v7/opdefs/adc_A883.d deleted file mode 100644 index a9c56d8..0000000 --- a/src/arch/arm/v7/opdefs/adc_A883.d +++ /dev/null @@ -1,52 +0,0 @@ - -/* Chrysalide - Outil d'analyse de fichiers binaires - * ##FILE## - traduction d'instructions ARMv7 - * - * Copyright (C) 2015 Cyrille Bagard - * - * This file is part of Chrysalide. - * - * Chrysalide is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Chrysalide is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Foobar. If not, see . - */ - - -@title ADC (register-shifted register) - -@desc Add with Carry (register-shifted register) adds a register value, the Carry flag value, and a register-shifted register value. It writes the result to the destination register, and can optionally update the condition flags based on the result. - -@encoding (A1) { - - @word cond(4) 0 0 0 0 1 0 1 S(1) Rn(4) Rd(4) Rs(4) 0 type(2) 1 Rm(4) - - @syntax - - @conv { - - reg_shift = RegisterShift(type, Rs) - reg_D = Register(Rd) - reg_N = Register(Rn) - reg_M = Register(Rm) - setflags = (S == '1') - - } - - @rules { - - if (setflags); chk_call ExtendKeyword("s") - chk_call StoreCondition(cond) - - } - -} - diff --git a/src/arch/arm/v7/opdefs/add_A8810.d b/src/arch/arm/v7/opdefs/add_A8810.d deleted file mode 100644 index 2047276..0000000 --- a/src/arch/arm/v7/opdefs/add_A8810.d +++ /dev/null @@ -1,83 +0,0 @@ - -/* Chrysalide - Outil d'analyse de fichiers binaires - * ##FILE## - traduction d'instructions ARMv7 - * - * Copyright (C) 2015 Cyrille Bagard - * - * This file is part of Chrysalide. - * - * Chrysalide is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Chrysalide is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Foobar. If not, see . - */ - - -@title ADD (SP plus register, Thumb) - -@desc This instruction adds an optionally-shifted register value to the SP value, and writes the result to the destination register. - -@encoding (t1) { - - @half 0 1 0 0 0 1 0 0 DM(1) 1 1 0 1 Rdm(3) - - @syntax - - @conv { - - reg_DM_1 = Register(DM:Rdm) - reg_DM_2 = Register(DM:Rdm) - SP = Register(13) - - } - -} - -@encoding (t2) { - - @half 0 1 0 0 0 1 0 0 1 Rm(4) 1 0 1 - - @syntax - - @conv { - - reg_M = Register(Rm) - SP = Register(13) - - } - -} - -@encoding (T3) { - - @word 1 1 1 0 1 0 1 1 0 0 0 S(1) 1 1 0 1 0 imm3(3) Rd(4) imm2(2) type(2) Rm(4) - - @syntax - - @conv { - - reg_D = Register(Rd) - reg_M = Register(Rm) - setflags = (S == '1') - shift = DecodeImmShift(type, imm3:imm2) - SP = Register(13) - - } - - @rules { - - if (setflags); chk_call ExtendKeyword("s") - chk_call ExtendKeyword(".w") - - } - -} - diff --git a/src/arch/arm/v7/opdefs/add_A8811.d b/src/arch/arm/v7/opdefs/add_A8811.d deleted file mode 100644 index 5b6c0d1..0000000 --- a/src/arch/arm/v7/opdefs/add_A8811.d +++ /dev/null @@ -1,52 +0,0 @@ - -/* Chrysalide - Outil d'analyse de fichiers binaires - * ##FILE## - traduction d'instructions ARMv7 - * - * Copyright (C) 2015 Cyrille Bagard - * - * This file is part of Chrysalide. - * - * Chrysalide is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Chrysalide is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Foobar. If not, see . - */ - - -@title ADD (SP plus register, ARM) - -@desc This instruction adds an optionally-shifted register value to the SP value, and writes the result to the destination register. - -@encoding (A1) { - - @word cond(4) 0 0 0 0 1 0 0 S(1) 1 1 0 1 Rd(4) imm5(5) type(2) 0 Rm(4) - - @syntax - - @conv { - - reg_D = Register(Rd) - reg_M = Register(Rm) - setflags = (S == '1') - shift = DecodeImmShift(type, imm5) - SP = Register(13) - - } - - @rules { - - if (setflags); chk_call ExtendKeyword("s") - chk_call StoreCondition(cond) - - } - -} - diff --git a/src/arch/arm/v7/opdefs/add_A884.d b/src/arch/arm/v7/opdefs/add_A884.d deleted file mode 100644 index 8b624a7..0000000 --- a/src/arch/arm/v7/opdefs/add_A884.d +++ /dev/null @@ -1,98 +0,0 @@ - -/* Chrysalide - Outil d'analyse de fichiers binaires - * ##FILE## - traduction d'instructions ARMv7 - * - * Copyright (C) 2015 Cyrille Bagard - * - * This file is part of Chrysalide. - * - * Chrysalide is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Chrysalide is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Foobar. If not, see . - */ - - -@title ADD (immediate, Thumb) - -@desc This instruction adds an immediate value to a register value, and writes the result to the destination register. It can optionally update the condition flags based on the result. - -@encoding (t1) { - - @half 0 0 0 1 1 1 0 imm3(3) Rn(3) Rd(3) - - @syntax "adds" - - @conv { - - reg_D = Register(Rd) - reg_N = Register(Rn) - imm32 = ZeroExtend(imm3, 32) - - } - -} - -@encoding (t2) { - - @half 0 0 1 1 0 Rdn(3) imm8(8) - - @syntax "adds" - - @conv { - - reg_DN = Register(Rdn) - imm32 = ZeroExtend(imm8, 32) - - } - -} - -@encoding (T3) { - - @word 1 1 1 1 0 i(1) 0 1 0 0 0 S(1) Rn(4) 0 imm3(3) Rd(4) imm8(8) - - @syntax - - @conv { - - reg_D = Register(Rd) - reg_N = Register(Rn) - setflags = (S == '1') - imm32 = ThumbExpandImm(i:imm3:imm8) - - } - - @rules { - - if (setflags); chk_call ExtendKeyword("s") - chk_call ExtendKeyword(".w") - - } - -} - -@encoding (T4) { - - @word 1 1 1 1 0 i(1) 1 0 0 0 0 0 Rn(4) 0 imm3(3) Rd(4) imm8(8) - - @syntax "addw" - - @conv { - - reg_D = Register(Rd) - reg_N = Register(Rn) - imm32 = ZeroExtend(i:imm3:imm8, 32) - - } - -} - diff --git a/src/arch/arm/v7/opdefs/add_A885.d b/src/arch/arm/v7/opdefs/add_A885.d deleted file mode 100644 index 0f4a919..0000000 --- a/src/arch/arm/v7/opdefs/add_A885.d +++ /dev/null @@ -1,51 +0,0 @@ - -/* Chrysalide - Outil d'analyse de fichiers binaires - * ##FILE## - traduction d'instructions ARMv7 - * - * Copyright (C) 2015 Cyrille Bagard - * - * This file is part of Chrysalide. - * - * Chrysalide is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Chrysalide is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Foobar. If not, see . - */ - - -@title ADD (immediate, ARM) - -@desc This instruction adds an immediate value to a register value, and writes the result to the destination register. It can optionally update the condition flags based on the result. - -@encoding (A1) { - - @word cond(4) 0 0 1 0 1 0 0 S(1) Rn(4) Rd(4) imm12(12) - - @syntax - - @conv { - - reg_D = Register(Rd) - reg_N = Register(Rn) - setflags = (S == '1') - imm32 = ARMExpandImm(imm12) - - } - - @rules { - - if (setflags); chk_call ExtendKeyword("s") - chk_call StoreCondition(cond) - - } - -} - diff --git a/src/arch/arm/v7/opdefs/add_A886.d b/src/arch/arm/v7/opdefs/add_A886.d deleted file mode 100644 index e4f9e00..0000000 --- a/src/arch/arm/v7/opdefs/add_A886.d +++ /dev/null @@ -1,83 +0,0 @@ - -/* Chrysalide - Outil d'analyse de fichiers binaires - * ##FILE## - traduction d'instructions ARMv7 - * - * Copyright (C) 2015 Cyrille Bagard - * - * This file is part of Chrysalide. - * - * Chrysalide is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Chrysalide is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Foobar. If not, see . - */ - - -@title ADD (register, Thumb) - -@desc This instruction adds a register value and an optionally-shifted register value, and writes the result to the destination register. It can optionally update the condition flags based on the result. - -@encoding (t1) { - - @half 0 0 0 1 1 0 0 Rm(3) Rn(3) Rd(3) - - @syntax "adds" - - @conv { - - reg_D = Register(Rd) - reg_N = Register(Rn) - reg_M = Register(Rm) - - } - -} - -@encoding (t2) { - - @half 0 1 0 0 0 1 0 0 DN(1) Rm(4) Rdn(3) - - @syntax - - @conv { - - reg_DN = Register(DN:Rdn) - reg_M = Register(Rm) - - } - -} - -@encoding (T3) { - - @word 1 1 1 0 1 0 1 1 0 0 0 S(1) Rn(4) 0 imm3(3) Rd(4) imm2(2) type(2) Rm(4) - - @syntax - - @conv { - - reg_D = Register(Rd) - reg_N = Register(Rn) - reg_M = Register(Rm) - setflags = (S == '1') - shift = DecodeImmShift(type, imm3:imm2) - - } - - @rules { - - if (setflags); chk_call ExtendKeyword("s") - chk_call ExtendKeyword(".w") - - } - -} - diff --git a/src/arch/arm/v7/opdefs/add_A887.d b/src/arch/arm/v7/opdefs/add_A887.d deleted file mode 100644 index 18400a6..0000000 --- a/src/arch/arm/v7/opdefs/add_A887.d +++ /dev/null @@ -1,52 +0,0 @@ - -/* Chrysalide - Outil d'analyse de fichiers binaires - * ##FILE## - traduction d'instructions ARMv7 - * - * Copyright (C) 2015 Cyrille Bagard - * - * This file is part of Chrysalide. - * - * Chrysalide is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Chrysalide is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Foobar. If not, see . - */ - - -@title ADD (register, ARM) - -@desc This instruction adds a register value and an optionally-shifted register value, and writes the result to the destination register. It can optionally update the condition flags based on the result. - -@encoding (A1) { - - @word cond(4) 0 0 0 0 1 0 0 S(1) Rn(4) Rd(4) imm5(5) type(2) 0 Rm(4) - - @syntax - - @conv { - - reg_D = Register(Rd) - reg_N = Register(Rn) - reg_M = Register(Rm) - setflags = (S == '1') - shift = DecodeImmShift(type, imm5) - - } - - @rules { - - if (setflags); chk_call ExtendKeyword("s") - chk_call StoreCondition(cond) - - } - -} - diff --git a/src/arch/arm/v7/opdefs/add_A888.d b/src/arch/arm/v7/opdefs/add_A888.d deleted file mode 100644 index 5549145..0000000 --- a/src/arch/arm/v7/opdefs/add_A888.d +++ /dev/null @@ -1,52 +0,0 @@ - -/* Chrysalide - Outil d'analyse de fichiers binaires - * ##FILE## - traduction d'instructions ARMv7 - * - * Copyright (C) 2015 Cyrille Bagard - * - * This file is part of Chrysalide. - * - * Chrysalide is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Chrysalide is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Foobar. If not, see . - */ - - -@title ADD (register-shifted register) - -@desc Add (register-shifted register) adds a register value and a register-shifted register value. It writes the result to the destination register, and can optionally update the condition flags based on the result. - -@encoding (A1) { - - @word cond(4) 0 0 0 0 1 0 0 S(1) Rn(4) Rd(4) Rs(4) 0 type(2) 1 Rm(4) - - @syntax - - @conv { - - reg_shift = RegisterShift(type, Rs) - reg_D = Register(Rd) - reg_N = Register(Rn) - reg_M = Register(Rm) - setflags = (S == '1') - - } - - @rules { - - if (setflags); chk_call ExtendKeyword("s") - chk_call StoreCondition(cond) - - } - -} - diff --git a/src/arch/arm/v7/opdefs/add_A889.d b/src/arch/arm/v7/opdefs/add_A889.d deleted file mode 100644 index 5fab17c..0000000 --- a/src/arch/arm/v7/opdefs/add_A889.d +++ /dev/null @@ -1,123 +0,0 @@ - -/* Chrysalide - Outil d'analyse de fichiers binaires - * ##FILE## - traduction d'instructions ARMv7 - * - * Copyright (C) 2015 Cyrille Bagard - * - * This file is part of Chrysalide. - * - * Chrysalide is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Chrysalide is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Foobar. If not, see . - */ - - -@title ADD (SP plus immediate) - -@desc This instruction adds an immediate value to the SP value, and writes the result to the destination register. - -@encoding (t1) { - - @half 1 0 1 0 1 Rd(3) imm8(8) - - @syntax - - @conv { - - reg_D = Register(Rd) - imm32 = ZeroExtend(imm8:'00', 32) - SP = Register(13) - - } - -} - -@encoding (t2) { - - @half 1 0 1 1 0 0 0 0 0 imm7(7) - - @syntax - - @conv { - - imm32 = ZeroExtend(imm7:'00', 32) - SP_0 = Register(13) - SP_1 = Register(13) - - } - -} - -@encoding (T3) { - - @word 1 1 1 1 0 i(1) 0 1 0 0 0 S(1) 1 1 0 1 0 imm3(3) Rd(4) imm8(8) - - @syntax - - @conv { - - reg_D = Register(Rd) - setflags = (S == '1') - imm32 = ThumbExpandImm(i:imm3:imm8) - SP = Register(13) - - } - - @rules { - - if (setflags); chk_call ExtendKeyword("s") - chk_call ExtendKeyword(".w") - - } - -} - -@encoding (T4) { - - @word 1 1 1 1 0 i(1) 1 0 0 0 0 0 1 1 0 1 0 imm3(3) Rd(4) imm8(8) - - @syntax "addw" - - @conv { - - reg_D = Register(Rd) - imm32 = ZeroExtend(i:imm3:imm8, 32) - SP = Register(13) - - } - -} - -@encoding (A1) { - - @word cond(4) 0 0 1 0 1 0 0 S(1) 1 1 0 1 Rd(4) imm12(12) - - @syntax - - @conv { - - reg_D = Register(Rd) - setflags = (S == '1') - imm32 = ARMExpandImm(imm12) - SP = Register(13) - - } - - @rules { - - if (setflags); chk_call ExtendKeyword("s") - chk_call StoreCondition(cond) - - } - -} - diff --git a/src/arch/arm/v7/opdefs/adr_A8812.d b/src/arch/arm/v7/opdefs/adr_A8812.d deleted file mode 100644 index 16615cb..0000000 --- a/src/arch/arm/v7/opdefs/adr_A8812.d +++ /dev/null @@ -1,114 +0,0 @@ - -/* Chrysalide - Outil d'analyse de fichiers binaires - * ##FILE## - traduction d'instructions ARMv7 - * - * Copyright (C) 2015 Cyrille Bagard - * - * This file is part of Chrysalide. - * - * Chrysalide is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Chrysalide is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Foobar. If not, see . - */ - - -@title ADR - -@desc This instruction adds an immediate value to the PC value to form a PC-relative address, and writes the result to the destination register. - -@encoding (t1) { - - @half 1 0 1 0 0 Rd(3) imm8(8) - - @syntax - - @conv { - - reg_D = Register(Rd) - imm32 = ZeroExtend(imm8:'00', 32) - - } - -} - -@encoding (T2) { - - @word 1 1 1 1 0 i(1) 1 0 1 0 1 0 1 1 1 1 0 imm3(3) Rd(4) imm8(8) - - @syntax ".W" - - @conv { - - reg_D = Register(Rd) - imm32 = ZeroExtend(i:imm3:imm8, 32) - - } - -} - -@encoding (T3) { - - @word 1 1 1 1 0 i(1) 1 0 0 0 0 0 1 1 1 1 0 imm3(3) Rd(4) imm8(8) - - @syntax ".W" - - @conv { - - reg_D = Register(Rd) - imm32 = ZeroExtend(i:imm3:imm8, 32) - - } - -} - -@encoding (A1) { - - @word cond(4) 0 0 1 0 1 0 0 0 1 1 1 1 Rd(4) imm12(12) - - @syntax - - @conv { - - reg_D = Register(Rd) - imm32 = ARMExpandImm(imm12) - - } - - @rules { - - chk_call StoreCondition(cond) - - } - -} - -@encoding (A2) { - - @word cond(4) 0 0 1 0 0 1 0 0 1 1 1 1 Rd(4) imm12(12) - - @syntax - - @conv { - - reg_D = Register(Rd) - imm32 = ARMExpandImm(imm12) - - } - - @rules { - - chk_call StoreCondition(cond) - - } - -} - diff --git a/src/arch/arm/v7/opdefs/and_A8813.d b/src/arch/arm/v7/opdefs/and_A8813.d deleted file mode 100644 index 3e1d0ed..0000000 --- a/src/arch/arm/v7/opdefs/and_A8813.d +++ /dev/null @@ -1,74 +0,0 @@ - -/* Chrysalide - Outil d'analyse de fichiers binaires - * ##FILE## - traduction d'instructions ARMv7 - * - * Copyright (C) 2015 Cyrille Bagard - * - * This file is part of Chrysalide. - * - * Chrysalide is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Chrysalide is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Foobar. If not, see . - */ - - -@title AND (immediate) - -@desc This instruction performs a bitwise AND of a register value and an immediate value, and writes the result to the destination register. - -@encoding (T1) { - - @word 1 1 1 1 0 i(1) 0 0 0 0 0 S(1) Rn(4) 0 imm3(3) Rd(4) imm8(8) - - @syntax - - @conv { - - reg_D = Register(Rd) - reg_N = Register(Rn) - setflags = (S == '1') - imm32 = ThumbExpandImm_C(i:imm3:imm8, 0) - - } - - @rules { - - if (setflags); chk_call ExtendKeyword("s") - - } - -} - -@encoding (A1) { - - @word cond(4) 0 0 1 0 0 0 0 S(1) Rn(4) Rd(4) imm12(12) - - @syntax - - @conv { - - reg_D = Register(Rd) - reg_N = Register(Rn) - setflags = (S == '1') - imm32 = ARMExpandImm_C(imm12, 0) - - } - - @rules { - - if (setflags); chk_call ExtendKeyword("s") - chk_call StoreCondition(cond) - - } - -} - diff --git a/src/arch/arm/v7/opdefs/and_A8814.d b/src/arch/arm/v7/opdefs/and_A8814.d deleted file mode 100644 index 77f7e55..0000000 --- a/src/arch/arm/v7/opdefs/and_A8814.d +++ /dev/null @@ -1,92 +0,0 @@ - -/* Chrysalide - Outil d'analyse de fichiers binaires - * ##FILE## - traduction d'instructions ARMv7 - * - * Copyright (C) 2015 Cyrille Bagard - * - * This file is part of Chrysalide. - * - * Chrysalide is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Chrysalide is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Foobar. If not, see . - */ - - -@title AND (register) - -@desc This instruction performs a bitwise AND of a register value and an optionally-shifted register value, and writes the result to the destination register. It can optionally update the condition flags based on the result. - -@encoding (t1) { - - @half 0 1 0 0 0 0 0 0 0 0 Rm(3) Rdn(3) - - @syntax "ands" - - @conv { - - reg_DN = Register(Rdn) - reg_M = Register(Rm) - - } - -} - -@encoding (T2) { - - @word 1 1 1 0 1 0 1 0 0 0 0 S(1) Rn(4) 0 imm3(3) Rd(4) imm2(2) type(2) Rm(4) - - @syntax - - @conv { - - reg_D = Register(Rd) - reg_N = Register(Rn) - reg_M = Register(Rm) - setflags = (S == '1') - shift = DecodeImmShift(type, imm3:imm2) - - } - - @rules { - - if (setflags); chk_call ExtendKeyword("s") - chk_call ExtendKeyword(".w") - - } - -} - -@encoding (A1) { - - @word cond(4) 0 0 0 0 0 0 0 S(1) Rn(4) Rd(4) imm5(5) type(2) 0 Rm(4) - - @syntax - - @conv { - - reg_D = Register(Rd) - reg_N = Register(Rn) - reg_M = Register(Rm) - setflags = (S == '1') - shift = DecodeImmShift(type, imm5) - - } - - @rules { - - if (setflags); chk_call ExtendKeyword("s") - chk_call StoreCondition(cond) - - } - -} - diff --git a/src/arch/arm/v7/opdefs/and_A8815.d b/src/arch/arm/v7/opdefs/and_A8815.d deleted file mode 100644 index 5ace3fa..0000000 --- a/src/arch/arm/v7/opdefs/and_A8815.d +++ /dev/null @@ -1,52 +0,0 @@ - -/* Chrysalide - Outil d'analyse de fichiers binaires - * ##FILE## - traduction d'instructions ARMv7 - * - * Copyright (C) 2015 Cyrille Bagard - * - * This file is part of Chrysalide. - * - * Chrysalide is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Chrysalide is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Foobar. If not, see . - */ - - -@title AND (register-shifted register) - -@desc This instruction performs a bitwise AND of a register value and a register-shifted register value. It writes the result to the destination register, and can optionally update the condition flags based on the result. - -@encoding (A1) { - - @word cond(4) 0 0 0 0 0 0 0 S(1) Rn(4) Rd(4) Rs(4) 0 type(2) 1 Rm(4) - - @syntax - - @conv { - - reg_shift = RegisterShift(type, Rs) - reg_D = Register(Rd) - reg_N = Register(Rn) - reg_M = Register(Rm) - setflags = (S == '1') - - } - - @rules { - - if (setflags); chk_call ExtendKeyword("s") - chk_call StoreCondition(cond) - - } - -} - diff --git a/src/arch/arm/v7/opdefs/asr_A8816.d b/src/arch/arm/v7/opdefs/asr_A8816.d deleted file mode 100644 index 006a26c..0000000 --- a/src/arch/arm/v7/opdefs/asr_A8816.d +++ /dev/null @@ -1,91 +0,0 @@ - -/* Chrysalide - Outil d'analyse de fichiers binaires - * ##FILE## - traduction d'instructions ARMv7 - * - * Copyright (C) 2015 Cyrille Bagard - * - * This file is part of Chrysalide. - * - * Chrysalide is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Chrysalide is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Foobar. If not, see . - */ - - -@title ASR (immediate) - -@desc Arithmetic Shift Right (immediate) shifts a register value right by an immediate number of bits, shifting in copies of its sign bit, and writes the result to the destination register. It can optionally update the condition flags based on the result. - -@encoding (t1) { - - @half 0 0 0 1 0 imm5(5) Rm(3) Rd(3) - - @syntax "asrs" - - @conv { - - reg_D = Register(Rd) - reg_M = Register(Rm) - shift_imm = DecodeImmShift('10', imm5) - - } - -} - -@encoding (T2) { - - @word 1 1 1 0 1 0 1 0 0 1 0 S(1) 1 1 1 1 0 imm3(3) Rd(4) imm2(2) 1 0 Rm(4) - - @syntax - - @conv { - - reg_D = Register(Rd) - reg_M = Register(Rm) - setflags = (S == '1') - shift_imm = DecodeImmShift('10', imm3:imm2) - - } - - @rules { - - if (setflags); chk_call ExtendKeyword("s") - chk_call ExtendKeyword(".w") - - } - -} - -@encoding (A1) { - - @word cond(4) 0 0 0 1 1 0 1 S(1) 0 0 0 0 Rd(4) imm5(5) 1 0 0 Rm(4) - - @syntax - - @conv { - - reg_D = Register(Rd) - reg_M = Register(Rm) - setflags = (S == '1') - shift_imm = DecodeImmShift('10', imm5) - - } - - @rules { - - if (setflags); chk_call ExtendKeyword("s") - chk_call StoreCondition(cond) - - } - -} - diff --git a/src/arch/arm/v7/opdefs/asr_A8817.d b/src/arch/arm/v7/opdefs/asr_A8817.d deleted file mode 100644 index 1e1e9c1..0000000 --- a/src/arch/arm/v7/opdefs/asr_A8817.d +++ /dev/null @@ -1,90 +0,0 @@ - -/* Chrysalide - Outil d'analyse de fichiers binaires - * ##FILE## - traduction d'instructions ARMv7 - * - * Copyright (C) 2015 Cyrille Bagard - * - * This file is part of Chrysalide. - * - * Chrysalide is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Chrysalide is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Foobar. If not, see . - */ - - -@title ASR (register) - -@desc Arithmetic Shift Right (register) shifts a register value right by a variable number of bits, shifting in copies of its sign bit, and writes the result to the destination register. The variable number of bits is read from the bottom byte of a register. It can optionally update the condition flags based on the result. - -@encoding (t1) { - - @half 0 1 0 0 0 0 0 1 0 0 Rm(3) Rdn(3) - - @syntax "asrs" - - @conv { - - reg_DN = Register(Rdn) - reg_M = Register(Rm) - - } - -} - -@encoding (T2) { - - @word 1 1 1 1 1 0 1 0 0 1 0 S(1) Rn(4) 1 1 1 1 Rd(4) 0 0 0 0 Rm(4) - - @syntax - - @conv { - - reg_D = Register(Rd) - reg_N = Register(Rn) - reg_M = Register(Rm) - setflags = (S == '1') - - } - - @rules { - - if (setflags); chk_call ExtendKeyword("s") - chk_call ExtendKeyword(".w") - - } - -} - -@encoding (A1) { - - @word cond(4) 0 0 0 1 1 0 1 S(1) 0 0 0 0 Rd(4) Rm(4) 0 1 0 1 Rn(4) - - @syntax - - @conv { - - reg_D = Register(Rd) - reg_N = Register(Rn) - reg_M = Register(Rm) - setflags = (S == '1') - - } - - @rules { - - if (setflags); chk_call ExtendKeyword("s") - chk_call StoreCondition(cond) - - } - -} - diff --git a/src/arch/arm/v7/opdefs/b_A8818.d b/src/arch/arm/v7/opdefs/b_A8818.d deleted file mode 100644 index 9e27753..0000000 --- a/src/arch/arm/v7/opdefs/b_A8818.d +++ /dev/null @@ -1,157 +0,0 @@ - -/* Chrysalide - Outil d'analyse de fichiers binaires - * ##FILE## - traduction d'instructions ARMv7 - * - * Copyright (C) 2015 Cyrille Bagard - * - * This file is part of Chrysalide. - * - * Chrysalide is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Chrysalide is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Foobar. If not, see . - */ - - -@title B - -@desc Branch causes a branch to a target address. - -@encoding (t1) { - - @half 1 1 0 1 cond(4) imm8(8) - - @syntax - - @conv { - - imm32 = SignExtend(imm8:'0', imm8 & 0x80, 32) - - } - - @rules { - - chk_call StoreCondition(cond) - - } - - @hooks { - - fetch = help_fetching_with_instruction_b_from_thumb - link = handle_arm_conditional_branch_as_link - post = post_process_branch_instructions - - } - -} - -@encoding (t2) { - - @half 1 1 1 0 0 imm11(11) - - @syntax - - @conv { - - imm32 = SignExtend(imm11:'0', imm11 & 0x400, 32) - - } - - @hooks { - - fetch = help_fetching_with_instruction_b_from_thumb - link = handle_arm_conditional_branch_as_link - post = post_process_branch_instructions - - } - -} - -@encoding (T3) { - - @word 1 1 1 1 0 S(1) cond(4) imm6(6) 1 0 J1(1) 0 J2(1) imm11(11) - - @syntax ".W" - - @conv { - - imm32 = SignExtend(S:J2:J1:imm6:imm11:'0', S & 0x1, 32) - - } - - @rules { - - chk_call StoreCondition(cond) - - } - - @hooks { - - fetch = help_fetching_with_instruction_b_from_thumb - link = handle_arm_conditional_branch_as_link - post = post_process_branch_instructions - - } - -} - -@encoding (T4) { - - @word 1 1 1 1 0 S(1) imm10(10) 1 0 J1(1) 1 J2(1) imm11(11) - - @syntax ".W" - - @conv { - - I1 = NOT(J1 EOR S) - I2 = NOT(J2 EOR S) - imm32 = SignExtend(S:I1:I2:imm10:imm11:'0', S & 0x1, 32) - - } - - @hooks { - - fetch = help_fetching_with_instruction_b_from_thumb - link = handle_arm_conditional_branch_as_link - post = post_process_branch_instructions - - } - -} - -@encoding (A1) { - - @word cond(4) 1 0 1 0 imm24(24) - - @syntax - - @conv { - - imm32 = SignExtend(imm24:'00', imm24 & 0x800000, 32) - - } - - @rules { - - chk_call StoreCondition(cond) - - } - - @hooks { - - fetch = help_fetching_with_instruction_b_from_arm - link = handle_arm_conditional_branch_as_link - post = post_process_branch_instructions - - } - -} - diff --git a/src/arch/arm/v7/opdefs/bfc_A8819.d b/src/arch/arm/v7/opdefs/bfc_A8819.d deleted file mode 100644 index 0ee99c8..0000000 --- a/src/arch/arm/v7/opdefs/bfc_A8819.d +++ /dev/null @@ -1,67 +0,0 @@ - -/* Chrysalide - Outil d'analyse de fichiers binaires - * ##FILE## - traduction d'instructions ARMv7 - * - * Copyright (C) 2015 Cyrille Bagard - * - * This file is part of Chrysalide. - * - * Chrysalide is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Chrysalide is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Foobar. If not, see . - */ - - -@title BFC - -@desc Bit Field Clear clears any number of adjacent bits at any position in a register, without affecting the other bits in the register. - -@encoding (T1) { - - @word 1 1 1 1 0 0 1 1 0 1 1 0 1 1 1 1 0 imm3(3) Rd(4) imm2(2) 0 msb(5) - - @syntax - - @conv { - - reg_D = Register(Rd) - msbit = UInt(msb) - lsbit = UInt(imm3:imm2) - width = BitDiff(msbit, lsbit) - - } - -} - -@encoding (A1) { - - @word cond(4) 0 1 1 1 1 1 0 msb(5) Rd(4) lsb(5) 0 0 1 1 1 1 1 - - @syntax - - @conv { - - reg_D = Register(Rd) - msbit = UInt(msb) - lsbit = UInt(lsb) - width = BitDiff(msbit, lsbit) - - } - - @rules { - - chk_call StoreCondition(cond) - - } - -} - diff --git a/src/arch/arm/v7/opdefs/bfi_A8820.d b/src/arch/arm/v7/opdefs/bfi_A8820.d deleted file mode 100644 index 1d2bb2f..0000000 --- a/src/arch/arm/v7/opdefs/bfi_A8820.d +++ /dev/null @@ -1,69 +0,0 @@ - -/* Chrysalide - Outil d'analyse de fichiers binaires - * ##FILE## - traduction d'instructions ARMv7 - * - * Copyright (C) 2015 Cyrille Bagard - * - * This file is part of Chrysalide. - * - * Chrysalide is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Chrysalide is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Foobar. If not, see . - */ - - -@title BFI - -@desc Bit Field Insert copies any number of low order bits from a register into the same number of adjacent bits at any position in the destination register. - -@encoding (T1) { - - @word 1 1 1 1 0 0 1 1 0 1 1 0 Rn(4) 0 imm3(3) Rd(4) imm2(2) 0 msb(5) - - @syntax - - @conv { - - reg_D = Register(Rd) - reg_N = Register(Rn) - msbit = UInt(msb) - lsbit = UInt(imm3:imm2) - width = BitDiff(msbit, lsbit) - - } - -} - -@encoding (A1) { - - @word cond(4) 0 1 1 1 1 1 0 msb(5) Rd(4) lsb(5) 0 0 1 Rn(4) - - @syntax - - @conv { - - reg_D = Register(Rd) - reg_N = Register(Rn) - msbit = UInt(msb) - lsbit = UInt(lsb) - width = BitDiff(msbit, lsbit) - - } - - @rules { - - chk_call StoreCondition(cond) - - } - -} - diff --git a/src/arch/arm/v7/opdefs/bic_A8821.d b/src/arch/arm/v7/opdefs/bic_A8821.d deleted file mode 100644 index 9171b69..0000000 --- a/src/arch/arm/v7/opdefs/bic_A8821.d +++ /dev/null @@ -1,74 +0,0 @@ - -/* Chrysalide - Outil d'analyse de fichiers binaires - * ##FILE## - traduction d'instructions ARMv7 - * - * Copyright (C) 2015 Cyrille Bagard - * - * This file is part of Chrysalide. - * - * Chrysalide is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Chrysalide is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Foobar. If not, see . - */ - - -@title BIC (immediate) - -@desc Bitwise Bit Clear (immediate) performs a bitwise AND of a register value and the complement of an immediate value, and writes the result to the destination register. It can optionally update the condition flags based on the result. - -@encoding (T1) { - - @word 1 1 1 1 0 i(1) 0 0 0 0 1 S(1) Rn(4) 0 imm3(3) Rd(4) imm8(8) - - @syntax - - @conv { - - reg_D = Register(Rd) - reg_N = Register(Rn) - setflags = (S == '1') - imm32 = ThumbExpandImm_C(i:imm3:imm8, 0) - - } - - @rules { - - if (setflags); chk_call ExtendKeyword("s") - - } - -} - -@encoding (A1) { - - @word cond(4) 0 0 1 1 1 1 0 S(1) Rn(4) Rd(4) imm12(12) - - @syntax - - @conv { - - reg_D = Register(Rd) - reg_N = Register(Rn) - setflags = (S == '1') - imm32 = ARMExpandImm_C(imm12, 0) - - } - - @rules { - - if (setflags); chk_call ExtendKeyword("s") - chk_call StoreCondition(cond) - - } - -} - diff --git a/src/arch/arm/v7/opdefs/bic_A8822.d b/src/arch/arm/v7/opdefs/bic_A8822.d deleted file mode 100644 index 8503460..0000000 --- a/src/arch/arm/v7/opdefs/bic_A8822.d +++ /dev/null @@ -1,92 +0,0 @@ - -/* Chrysalide - Outil d'analyse de fichiers binaires - * ##FILE## - traduction d'instructions ARMv7 - * - * Copyright (C) 2015 Cyrille Bagard - * - * This file is part of Chrysalide. - * - * Chrysalide is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Chrysalide is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Foobar. If not, see . - */ - - -@title BIC (register) - -@desc Bitwise Bit Clear (register) performs a bitwise AND of a register value and the complement of an optionally-shifted register value, and writes the result to the destination register. It can optionally update the condition flags based on the result. - -@encoding (t1) { - - @half 0 1 0 0 0 0 1 1 1 0 Rm(3) Rdn(3) - - @syntax "bics" - - @conv { - - reg_DN = Register(Rdn) - reg_M = Register(Rm) - - } - -} - -@encoding (T2) { - - @word 1 1 1 0 1 0 1 0 0 0 1 S(1) Rn(4) 0 imm3(3) Rd(4) imm2(2) type(2) Rm(4) - - @syntax - - @conv { - - reg_D = Register(Rd) - reg_N = Register(Rn) - reg_M = Register(Rm) - setflags = (S == '1') - shift = DecodeImmShift(type, imm3:imm2) - - } - - @rules { - - if (setflags); chk_call ExtendKeyword("s") - chk_call ExtendKeyword(".w") - - } - -} - -@encoding (A1) { - - @word cond(4) 0 0 0 1 1 1 0 S(1) Rn(4) Rd(4) imm5(5) type(2) 0 Rm(4) - - @syntax - - @conv { - - reg_D = Register(Rd) - reg_N = Register(Rn) - reg_M = Register(Rm) - setflags = (S == '1') - shift = DecodeImmShift(type, imm5) - - } - - @rules { - - if (setflags); chk_call ExtendKeyword("s") - chk_call StoreCondition(cond) - - } - -} - diff --git a/src/arch/arm/v7/opdefs/bic_A8823.d b/src/arch/arm/v7/opdefs/bic_A8823.d deleted file mode 100644 index e6903db..0000000 --- a/src/arch/arm/v7/opdefs/bic_A8823.d +++ /dev/null @@ -1,52 +0,0 @@ - -/* Chrysalide - Outil d'analyse de fichiers binaires - * ##FILE## - traduction d'instructions ARMv7 - * - * Copyright (C) 2015 Cyrille Bagard - * - * This file is part of Chrysalide. - * - * Chrysalide is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Chrysalide is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Foobar. If not, see . - */ - - -@title BIC (register-shifted register) - -@desc Bitwise Bit Clear (register-shifted register) performs a bitwise AND of a register value and the complement of a register-shifted register value. It writes the result to the destination register, and can optionally update the condition flags based on the result. - -@encoding (A1) { - - @word cond(4) 0 0 0 1 1 1 0 S(1) Rn(4) Rd(4) Rs(4) 0 type(2) 1 Rm(4) - - @syntax - - @conv { - - reg_shift = RegisterShift(type, Rs) - reg_D = Register(Rd) - reg_N = Register(Rn) - reg_M = Register(Rm) - setflags = (S == '1') - - } - - @rules { - - if (setflags); chk_call ExtendKeyword("s") - chk_call StoreCondition(cond) - - } - -} - diff --git a/src/arch/arm/v7/opdefs/bkpt_A8824.d b/src/arch/arm/v7/opdefs/bkpt_A8824.d deleted file mode 100644 index f0aa13a..0000000 --- a/src/arch/arm/v7/opdefs/bkpt_A8824.d +++ /dev/null @@ -1,55 +0,0 @@ - -/* Chrysalide - Outil d'analyse de fichiers binaires - * ##FILE## - traduction d'instructions ARMv7 - * - * Copyright (C) 2015 Cyrille Bagard - * - * This file is part of Chrysalide. - * - * Chrysalide is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Chrysalide is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Foobar. If not, see . - */ - - -@title BKPT - -@desc Breakpoint causes a software breakpoint to occur. Breakpoint is always unconditional, even when inside an IT block. - -@encoding (t1) { - - @half 1 0 1 1 1 1 1 0 imm8(8) - - @syntax - - @conv { - - imm32 = ZeroExtend(imm8, 32) - - } - -} - -@encoding (A1) { - - @word cond(4) 0 0 0 1 0 0 1 0 imm12(12) 0 1 1 1 imm4(4) - - @syntax - - @conv { - - imm32 = ZeroExtend(imm12:imm4, 32) - - } - -} - diff --git a/src/arch/arm/v7/opdefs/bl_A8825.d b/src/arch/arm/v7/opdefs/bl_A8825.d deleted file mode 100644 index da0def4..0000000 --- a/src/arch/arm/v7/opdefs/bl_A8825.d +++ /dev/null @@ -1,125 +0,0 @@ - -/* Chrysalide - Outil d'analyse de fichiers binaires - * ##FILE## - traduction d'instructions ARMv7 - * - * Copyright (C) 2015 Cyrille Bagard - * - * This file is part of Chrysalide. - * - * Chrysalide is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Chrysalide is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Foobar. If not, see . - */ - - -@title BL, BLX (immediate) - -@desc Branch with Link calls a subroutine at a PC-relative address. Branch with Link and Exchange Instruction Sets (immediate) calls a subroutine at a PC-relative address, and changes instruction set from ARM to Thumb, or from Thumb to ARM. - -@encoding (T1) { - - @word 1 1 1 1 0 S(1) imm10(10) 1 1 J1(1) 1 J2(1) imm11(11) - - @syntax - - @conv { - - I1 = NOT(J1 EOR S) - I2 = NOT(J2 EOR S) - imm32 = SignExtend(S:I1:I2:imm10:imm11:'0', S & 0x1, 32) - - } - - @hooks { - - fetch = help_fetching_with_instruction_bl_from_thumb - link = handle_call_as_link - post = post_process_branch_and_link_instructions - - } - -} - -@encoding (T2) { - - @word 1 1 1 1 0 S(1) imm10H(10) 1 1 J1(1) 0 J2(1) imm10L(10) H(1) - - @syntax "blx" - - @conv { - - I1 = NOT(J1 EOR S) - I2 = NOT(J2 EOR S) - imm32 = SignExtend(S:I1:I2:imm10H:imm10L:'00', S & 0x1, 32) - - } - - @hooks { - - fetch = help_fetching_with_instruction_blx_from_thumb - link = handle_call_as_link - post = post_process_branch_and_link_instructions - - } - -} - -@encoding (A1) { - - @word cond(4) 1 0 1 1 imm24(24) - - @syntax - - @conv { - - imm32 = SignExtend(imm24:'00', imm24 & 0x800000, 32) - - } - - @rules { - - chk_call StoreCondition(cond) - - } - - @hooks { - - fetch = help_fetching_with_instruction_bl_from_arm - link = handle_call_as_link - post = post_process_branch_and_link_instructions - - } - -} - -@encoding (A2) { - - @word 1 1 1 1 1 0 1 H(1) imm24(24) - - @syntax "blx" - - @conv { - - imm32 = SignExtend(imm24:H:'0', imm24 & 0x800000, 32) - - } - - @hooks { - - fetch = help_fetching_with_instruction_blx_from_arm - link = handle_call_as_link - post = post_process_branch_and_link_instructions - - } - -} - diff --git a/src/arch/arm/v7/opdefs/blx_A8826.d b/src/arch/arm/v7/opdefs/blx_A8826.d deleted file mode 100644 index 29719fa..0000000 --- a/src/arch/arm/v7/opdefs/blx_A8826.d +++ /dev/null @@ -1,61 +0,0 @@ - -/* Chrysalide - Outil d'analyse de fichiers binaires - * ##FILE## - traduction d'instructions ARMv7 - * - * Copyright (C) 2015 Cyrille Bagard - * - * This file is part of Chrysalide. - * - * Chrysalide is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Chrysalide is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Foobar. If not, see . - */ - - -@title BLX (register) - -@desc Branch with Link and Exchange (register) calls a subroutine at an address and instruction set specified by a register. - -@encoding (t1) { - - @half 0 1 0 0 0 1 1 1 1 Rm(4) 0 0 0 - - @syntax - - @conv { - - reg_M = Register(Rm) - - } - -} - -@encoding (A1) { - - @word cond(4) 0 0 0 1 0 0 1 0 1 1 1 1 1 1 1 1 1 1 1 1 0 0 1 1 Rm(4) - - @syntax - - @conv { - - reg_M = Register(Rm) - - } - - @rules { - - chk_call StoreCondition(cond) - - } - -} - diff --git a/src/arch/arm/v7/opdefs/bx_A8827.d b/src/arch/arm/v7/opdefs/bx_A8827.d deleted file mode 100644 index f3681e7..0000000 --- a/src/arch/arm/v7/opdefs/bx_A8827.d +++ /dev/null @@ -1,75 +0,0 @@ - -/* Chrysalide - Outil d'analyse de fichiers binaires - * ##FILE## - traduction d'instructions ARMv7 - * - * Copyright (C) 2015 Cyrille Bagard - * - * This file is part of Chrysalide. - * - * Chrysalide is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Chrysalide is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Foobar. If not, see . - */ - - -@title BX - -@desc Branch and Exchange causes a branch to an address and instruction set specified by a register. - -@encoding (t1) { - - @half 0 1 0 0 0 1 1 1 0 Rm(4) 0 0 0 - - @syntax - - @conv { - - reg_M = Register(Rm) - - } - - @hooks { - - fetch = help_fetching_with_instruction_bx_from_thumb - link = handle_armv7_conditional_branch_from_register - - } - -} - -@encoding (A1) { - - @word cond(4) 0 0 0 1 0 0 1 0 1 1 1 1 1 1 1 1 1 1 1 1 0 0 0 1 Rm(4) - - @syntax - - @conv { - - reg_M = Register(Rm) - - } - - @rules { - - chk_call StoreCondition(cond) - - } - - @hooks { - - fetch = help_fetching_with_instruction_bx_from_arm - link = handle_armv7_conditional_branch_from_register - - } - -} - diff --git a/src/arch/arm/v7/opdefs/bxj_A8828.d b/src/arch/arm/v7/opdefs/bxj_A8828.d deleted file mode 100644 index efa2de2..0000000 --- a/src/arch/arm/v7/opdefs/bxj_A8828.d +++ /dev/null @@ -1,61 +0,0 @@ - -/* Chrysalide - Outil d'analyse de fichiers binaires - * ##FILE## - traduction d'instructions ARMv7 - * - * Copyright (C) 2015 Cyrille Bagard - * - * This file is part of Chrysalide. - * - * Chrysalide is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Chrysalide is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Foobar. If not, see . - */ - - -@title BXJ - -@desc Branch and Exchange Jazelle attempts to change to Jazelle state. If the attempt fails, it branches to an address and instruction set specified by a register as though it were a BX instruction. In an implementation that includes the Virtualization Extensions, if HSTR.TJDBX is set to 1, execution of a BXJ instruction in a Non-secure mode other than Hyp mode generates a Hyp Trap exception. For more information see Trapping accesses to Jazelle functionality on page B1-1255. - -@encoding (T1) { - - @word 1 1 1 1 0 0 1 1 1 1 0 0 Rm(4) 1 0 0 0 1 1 1 1 0 0 0 0 0 0 0 0 - - @syntax - - @conv { - - reg_M = Register(Rm) - - } - -} - -@encoding (A1) { - - @word cond(4) 0 0 0 1 0 0 1 0 1 1 1 1 1 1 1 1 1 1 1 1 0 0 1 0 Rm(4) - - @syntax - - @conv { - - reg_M = Register(Rm) - - } - - @rules { - - chk_call StoreCondition(cond) - - } - -} - diff --git a/src/arch/arm/v7/opdefs/cb_A8829.d b/src/arch/arm/v7/opdefs/cb_A8829.d deleted file mode 100644 index 134e0f4..0000000 --- a/src/arch/arm/v7/opdefs/cb_A8829.d +++ /dev/null @@ -1,58 +0,0 @@ - -/* Chrysalide - Outil d'analyse de fichiers binaires - * ##FILE## - traduction d'instructions ARMv7 - * - * Copyright (C) 2015 Cyrille Bagard - * - * This file is part of Chrysalide. - * - * Chrysalide is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Chrysalide is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Foobar. If not, see . - */ - - -@title CBNZ, CBZ - -@desc Compare and Branch on Nonzero and Compare and Branch on Zero compare the value in a register with zero, and conditionally branch forward a constant value. They do not affect the condition flags. - -@encoding (t1) { - - @half 1 0 1 1 op(1) 0 i(1) 1 imm5(5) Rn(3) - - @syntax - - @conv { - - reg_N = Register(Rn) - imm32 = ZeroExtend(i:imm5:'0', 32) - nonzero = (op == '1') - - } - - @rules { - - if (nonzero); chk_call ExtendKeyword("n") - chk_call ExtendKeyword("z") - - } - - @hooks { - - fetch = help_fetching_with_instruction_cb_n_z - link = handle_comp_and_branch_if_true_as_link - post = post_process_comp_and_branch_instructions - - } - -} - diff --git a/src/arch/arm/v7/opdefs/cdp_A8830.d b/src/arch/arm/v7/opdefs/cdp_A8830.d deleted file mode 100644 index 109b89b..0000000 --- a/src/arch/arm/v7/opdefs/cdp_A8830.d +++ /dev/null @@ -1,109 +0,0 @@ - -/* Chrysalide - Outil d'analyse de fichiers binaires - * ##FILE## - traduction d'instructions ARMv7 - * - * Copyright (C) 2015 Cyrille Bagard - * - * This file is part of Chrysalide. - * - * Chrysalide is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Chrysalide is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Foobar. If not, see . - */ - - -@title CDP, CDP2 - -@desc Coprocessor Data Processing tells a coprocessor to perform an operation that is independent of ARM core registers and memory. If no coprocessor can execute the instruction, an Undefined Instruction exception is generated. This is a generic coprocessor instruction. Some of the fields have no functionality defined by the architecture and are free for use by the coprocessor instruction set designer. These are the opc1, opc2, CRd, CRn, and CRm fields. However, coprocessors CP8-CP15 are reserved for use by ARM, and this manual defines the valid CDP and CDP2 instructions when coproc is in the range p8-p15. For more information see Coprocessor support on page A2-94. - -@encoding (T1) { - - @word 1 1 1 0 1 1 1 0 opc1(4) CRn(4) CRd(4) coproc(4) opc2(3) 0 CRm(4) - - @syntax - - @conv { - - cp = CoProcessor(coproc) - undef_opc1 = RawValue(opc1) - creg_D = CRegister(CRd) - creg_N = CRegister(CRn) - creg_M = CRegister(CRm) - undef_opc2 = RawValue(opc2) - - } - -} - -@encoding (A1) { - - @word cond(4) 1 1 1 0 opc1(4) CRn(4) CRd(4) coproc(4) opc2(3) 0 CRm(4) - - @syntax - - @conv { - - cp = CoProcessor(coproc) - undef_opc1 = RawValue(opc1) - creg_D = CRegister(CRd) - creg_N = CRegister(CRn) - creg_M = CRegister(CRm) - undef_opc2 = RawValue(opc2) - - } - - @rules { - - chk_call StoreCondition(cond) - - } - -} - -@encoding (T2) { - - @word 1 1 1 1 1 1 1 0 opc1(4) CRn(4) CRd(4) coproc(4) opc2(3) 0 CRm(4) - - @syntax "cdp2" - - @conv { - - cp = CoProcessor(coproc) - undef_opc1 = RawValue(opc1) - creg_D = CRegister(CRd) - creg_N = CRegister(CRn) - creg_M = CRegister(CRm) - undef_opc2 = RawValue(opc2) - - } - -} - -@encoding (A2) { - - @word 1 1 1 1 1 1 1 0 opc1(4) CRn(4) CRd(4) coproc(4) opc2(3) 0 CRm(4) - - @syntax "cdp2" - - @conv { - - cp = CoProcessor(coproc) - undef_opc1 = RawValue(opc1) - creg_D = CRegister(CRd) - creg_N = CRegister(CRn) - creg_M = CRegister(CRm) - undef_opc2 = RawValue(opc2) - - } - -} - diff --git a/src/arch/arm/v7/opdefs/clrex_A8832.d b/src/arch/arm/v7/opdefs/clrex_A8832.d deleted file mode 100644 index 4f313f2..0000000 --- a/src/arch/arm/v7/opdefs/clrex_A8832.d +++ /dev/null @@ -1,39 +0,0 @@ - -/* Chrysalide - Outil d'analyse de fichiers binaires - * ##FILE## - traduction d'instructions ARMv7 - * - * Copyright (C) 2015 Cyrille Bagard - * - * This file is part of Chrysalide. - * - * Chrysalide is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Chrysalide is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Foobar. If not, see . - */ - - -@title CLREX - -@desc Clear-Exclusive clears the local record of the executing processor that an address has had a request for an exclusive access. - -@encoding (T1) { - - @word 1 1 1 1 0 0 1 1 1 0 1 1 1 1 1 1 1 0 0 0 1 1 1 1 0 0 1 0 1 1 1 1 - -} - -@encoding (A1) { - - @word 1 1 1 1 0 1 0 1 0 1 1 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 1 1 1 1 1 - -} - diff --git a/src/arch/arm/v7/opdefs/clz_A8833.d b/src/arch/arm/v7/opdefs/clz_A8833.d deleted file mode 100644 index d4fdac6..0000000 --- a/src/arch/arm/v7/opdefs/clz_A8833.d +++ /dev/null @@ -1,63 +0,0 @@ - -/* Chrysalide - Outil d'analyse de fichiers binaires - * ##FILE## - traduction d'instructions ARMv7 - * - * Copyright (C) 2015 Cyrille Bagard - * - * This file is part of Chrysalide. - * - * Chrysalide is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Chrysalide is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Foobar. If not, see . - */ - - -@title CLZ - -@desc Count Leading Zeros returns the number of binary zero bits before the first binary one bit in a value. - -@encoding (T1) { - - @word 1 1 1 1 1 0 1 0 1 0 1 1 Rm(4) 1 1 1 1 Rd(4) 1 0 0 0 Rm(4) - - @syntax - - @conv { - - reg_D = Register(Rd) - reg_M = Register(Rm) - - } - -} - -@encoding (A1) { - - @word cond(4) 0 0 0 1 0 1 1 0 1 1 1 1 Rd(4) 1 1 1 1 0 0 0 1 Rm(4) - - @syntax - - @conv { - - reg_D = Register(Rd) - reg_M = Register(Rm) - - } - - @rules { - - chk_call StoreCondition(cond) - - } - -} - diff --git a/src/arch/arm/v7/opdefs/cmn_A8834.d b/src/arch/arm/v7/opdefs/cmn_A8834.d deleted file mode 100644 index fc0b19f..0000000 --- a/src/arch/arm/v7/opdefs/cmn_A8834.d +++ /dev/null @@ -1,63 +0,0 @@ - -/* Chrysalide - Outil d'analyse de fichiers binaires - * ##FILE## - traduction d'instructions ARMv7 - * - * Copyright (C) 2015 Cyrille Bagard - * - * This file is part of Chrysalide. - * - * Chrysalide is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Chrysalide is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Foobar. If not, see . - */ - - -@title CMN (immediate) - -@desc Compare Negative (immediate) adds a register value and an immediate value. It updates the condition flags based on the result, and discards the result. - -@encoding (T1) { - - @word 1 1 1 1 0 i(1) 0 1 0 0 0 1 Rn(4) 0 imm3(3) 1 1 1 1 imm8(8) - - @syntax - - @conv { - - reg_N = Register(Rn) - imm32 = ThumbExpandImm(i:imm3:imm8) - - } - -} - -@encoding (A1) { - - @word cond(4) 0 0 1 1 0 1 1 1 Rn(4) 0 0 0 0 imm12(12) - - @syntax - - @conv { - - reg_N = Register(Rn) - imm32 = ARMExpandImm(imm12) - - } - - @rules { - - chk_call StoreCondition(cond) - - } - -} - diff --git a/src/arch/arm/v7/opdefs/cmn_A8835.d b/src/arch/arm/v7/opdefs/cmn_A8835.d deleted file mode 100644 index cd228de..0000000 --- a/src/arch/arm/v7/opdefs/cmn_A8835.d +++ /dev/null @@ -1,80 +0,0 @@ - -/* Chrysalide - Outil d'analyse de fichiers binaires - * ##FILE## - traduction d'instructions ARMv7 - * - * Copyright (C) 2015 Cyrille Bagard - * - * This file is part of Chrysalide. - * - * Chrysalide is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Chrysalide is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Foobar. If not, see . - */ - - -@title CMN (register) - -@desc Compare Negative (register) adds a register value and an optionally-shifted register value. It updates the condition flags based on the result, and discards the result. - -@encoding (t1) { - - @half 0 1 0 0 0 0 1 0 1 1 Rm(3) Rn(3) - - @syntax - - @conv { - - reg_N = Register(Rn) - reg_M = Register(Rm) - - } - -} - -@encoding (T2) { - - @word 1 1 1 0 1 0 1 1 0 0 0 1 Rn(4) 0 imm3(3) 1 1 1 1 imm2(2) type(2) Rm(4) - - @syntax ".W" - - @conv { - - reg_N = Register(Rn) - reg_M = Register(Rm) - shift = DecodeImmShift(type, imm3:imm2) - - } - -} - -@encoding (A1) { - - @word cond(4) 0 0 0 1 0 1 1 1 Rn(4) 0 0 0 0 imm5(5) type(2) 0 Rm(4) - - @syntax - - @conv { - - reg_N = Register(Rn) - reg_M = Register(Rm) - shift = DecodeImmShift(type, imm5) - - } - - @rules { - - chk_call StoreCondition(cond) - - } - -} - diff --git a/src/arch/arm/v7/opdefs/cmn_A8836.d b/src/arch/arm/v7/opdefs/cmn_A8836.d deleted file mode 100644 index ad58482..0000000 --- a/src/arch/arm/v7/opdefs/cmn_A8836.d +++ /dev/null @@ -1,49 +0,0 @@ - -/* Chrysalide - Outil d'analyse de fichiers binaires - * ##FILE## - traduction d'instructions ARMv7 - * - * Copyright (C) 2015 Cyrille Bagard - * - * This file is part of Chrysalide. - * - * Chrysalide is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Chrysalide is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Foobar. If not, see . - */ - - -@title CMN (register-shifted register) - -@desc Compare Negative (register-shifted register) adds a register value and a register-shifted register value. It updates the condition flags based on the result, and discards the result. - -@encoding (A1) { - - @word cond(4) 0 0 0 1 0 1 1 1 Rn(4) 0 0 0 0 Rs(4) 0 type(2) 1 Rm(4) - - @syntax - - @conv { - - reg_shift = RegisterShift(type, Rs) - reg_N = Register(Rn) - reg_M = Register(Rm) - - } - - @rules { - - chk_call StoreCondition(cond) - - } - -} - diff --git a/src/arch/arm/v7/opdefs/cmp_A8837.d b/src/arch/arm/v7/opdefs/cmp_A8837.d deleted file mode 100644 index 76b7a76..0000000 --- a/src/arch/arm/v7/opdefs/cmp_A8837.d +++ /dev/null @@ -1,78 +0,0 @@ - -/* Chrysalide - Outil d'analyse de fichiers binaires - * ##FILE## - traduction d'instructions ARMv7 - * - * Copyright (C) 2015 Cyrille Bagard - * - * This file is part of Chrysalide. - * - * Chrysalide is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Chrysalide is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Foobar. If not, see . - */ - - -@title CMP (immediate) - -@desc Compare (immediate) subtracts an immediate value from a register value. It updates the condition flags based on the result, and discards the result. - -@encoding (t1) { - - @half 0 0 1 0 1 Rn(3) imm8(8) - - @syntax - - @conv { - - reg_N = Register(Rn) - imm32 = ZeroExtend(imm8, 32) - - } - -} - -@encoding (T2) { - - @word 1 1 1 1 0 i(1) 0 1 1 0 1 1 Rn(4) 0 imm3(3) 1 1 1 1 imm8(8) - - @syntax ".W" - - @conv { - - reg_N = Register(Rn) - imm32 = ThumbExpandImm(i:imm3:imm8) - - } - -} - -@encoding (A1) { - - @word cond(4) 0 0 1 1 0 1 0 1 Rn(4) 0 0 0 0 imm12(12) - - @syntax - - @conv { - - reg_N = Register(Rn) - imm32 = ARMExpandImm(imm12) - - } - - @rules { - - chk_call StoreCondition(cond) - - } - -} - diff --git a/src/arch/arm/v7/opdefs/cmp_A8838.d b/src/arch/arm/v7/opdefs/cmp_A8838.d deleted file mode 100644 index cd02543..0000000 --- a/src/arch/arm/v7/opdefs/cmp_A8838.d +++ /dev/null @@ -1,95 +0,0 @@ - -/* Chrysalide - Outil d'analyse de fichiers binaires - * ##FILE## - traduction d'instructions ARMv7 - * - * Copyright (C) 2015 Cyrille Bagard - * - * This file is part of Chrysalide. - * - * Chrysalide is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Chrysalide is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Foobar. If not, see . - */ - - -@title CMP (register) - -@desc Compare (register) subtracts an optionally-shifted register value from a register value. It updates the condition flags based on the result, and discards the result. - -@encoding (t1) { - - @half 0 1 0 0 0 0 1 0 1 0 Rm(3) Rn(3) - - @syntax - - @conv { - - reg_N = Register(Rn) - reg_M = Register(Rm) - - } - -} - -@encoding (t2) { - - @half 0 1 0 0 0 1 0 1 N(1) Rm(4) Rn(3) - - @syntax - - @conv { - - reg_N = Register(N:Rn) - reg_M = Register(Rm) - - } - -} - -@encoding (T3) { - - @word 1 1 1 0 1 0 1 1 1 0 1 1 Rn(4) 0 imm3(3) 1 1 1 1 imm2(2) type(2) Rm(4) - - @syntax ".W" - - @conv { - - reg_N = Register(Rn) - reg_M = Register(Rm) - shift = DecodeImmShift(type, imm3:imm2) - - } - -} - -@encoding (A1) { - - @word cond(4) 0 0 0 1 0 1 0 1 Rn(4) 0 0 0 0 imm5(5) type(2) 0 Rm(4) - - @syntax - - @conv { - - reg_N = Register(Rn) - reg_M = Register(Rm) - shift = DecodeImmShift(type, imm5) - - } - - @rules { - - chk_call StoreCondition(cond) - - } - -} - diff --git a/src/arch/arm/v7/opdefs/cmp_A8839.d b/src/arch/arm/v7/opdefs/cmp_A8839.d deleted file mode 100644 index 45ed0f9..0000000 --- a/src/arch/arm/v7/opdefs/cmp_A8839.d +++ /dev/null @@ -1,49 +0,0 @@ - -/* Chrysalide - Outil d'analyse de fichiers binaires - * ##FILE## - traduction d'instructions ARMv7 - * - * Copyright (C) 2015 Cyrille Bagard - * - * This file is part of Chrysalide. - * - * Chrysalide is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Chrysalide is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Foobar. If not, see . - */ - - -@title CMP (register-shifted register) - -@desc Compare (register-shifted register) subtracts a register-shifted register value from a register value. It updates the condition flags based on the result, and discards the result. - -@encoding (A1) { - - @word cond(4) 0 0 0 1 0 1 0 1 Rn(4) 0 0 0 0 Rs(4) 0 type(2) 1 Rm(4) - - @syntax - - @conv { - - reg_shift = RegisterShift(type, Rs) - reg_N = Register(Rn) - reg_M = Register(Rm) - - } - - @rules { - - chk_call StoreCondition(cond) - - } - -} - diff --git a/src/arch/arm/v7/opdefs/dbg_A8842.d b/src/arch/arm/v7/opdefs/dbg_A8842.d deleted file mode 100644 index 62142f5..0000000 --- a/src/arch/arm/v7/opdefs/dbg_A8842.d +++ /dev/null @@ -1,61 +0,0 @@ - -/* Chrysalide - Outil d'analyse de fichiers binaires - * ##FILE## - traduction d'instructions ARMv7 - * - * Copyright (C) 2015 Cyrille Bagard - * - * This file is part of Chrysalide. - * - * Chrysalide is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Chrysalide is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Foobar. If not, see . - */ - - -@title DBG - -@desc Debug Hint provides a hint to debug and related systems. See their documentation for what use (if any) they make of this instruction. - -@encoding (T1) { - - @word 1 1 1 1 0 0 1 1 1 0 1 0 1 1 1 1 1 0 0 0 0 0 0 0 1 1 1 1 option(4) - - @syntax - - @conv { - - undef_option = RawValue(option) - - } - -} - -@encoding (A1) { - - @word cond(4) 0 0 1 1 0 0 1 0 0 0 0 0 1 1 1 1 0 0 0 0 1 1 1 1 option(4) - - @syntax - - @conv { - - undef_option = RawValue(option) - - } - - @rules { - - chk_call StoreCondition(cond) - - } - -} - diff --git a/src/arch/arm/v7/opdefs/dmb_A8843.d b/src/arch/arm/v7/opdefs/dmb_A8843.d deleted file mode 100644 index 34f053a..0000000 --- a/src/arch/arm/v7/opdefs/dmb_A8843.d +++ /dev/null @@ -1,55 +0,0 @@ - -/* Chrysalide - Outil d'analyse de fichiers binaires - * ##FILE## - traduction d'instructions ARMv7 - * - * Copyright (C) 2015 Cyrille Bagard - * - * This file is part of Chrysalide. - * - * Chrysalide is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Chrysalide is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Foobar. If not, see . - */ - - -@title DMB - -@desc Data Memory Barrier is a memory barrier that ensures the ordering of observations of memory accesses, see Data Memory Barrier (DMB) on page A3-151. - -@encoding (T1) { - - @word 1 1 1 1 0 0 1 1 1 0 1 1 1 1 1 1 1 0 0 0 1 1 1 1 0 1 0 1 option(4) - - @syntax - - @conv { - - limitation = BarrierLimitation(option) - - } - -} - -@encoding (A1) { - - @word 1 1 1 1 0 1 0 1 0 1 1 1 1 1 1 1 1 1 1 1 0 0 0 0 0 1 0 1 option(4) - - @syntax - - @conv { - - limitation = BarrierLimitation(option) - - } - -} - diff --git a/src/arch/arm/v7/opdefs/dsb_A8844.d b/src/arch/arm/v7/opdefs/dsb_A8844.d deleted file mode 100644 index 512220c..0000000 --- a/src/arch/arm/v7/opdefs/dsb_A8844.d +++ /dev/null @@ -1,55 +0,0 @@ - -/* Chrysalide - Outil d'analyse de fichiers binaires - * ##FILE## - traduction d'instructions ARMv7 - * - * Copyright (C) 2015 Cyrille Bagard - * - * This file is part of Chrysalide. - * - * Chrysalide is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Chrysalide is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Foobar. If not, see . - */ - - -@title DSB - -@desc Data Synchronization Barrier is a memory barrier that ensures the completion of memory accesses, see Data Synchronization Barrier (DSB) on page A3-152. - -@encoding (T1) { - - @word 1 1 1 1 0 0 1 1 1 0 1 1 1 1 1 1 1 0 0 0 1 1 1 1 0 1 0 0 option(4) - - @syntax - - @conv { - - limitation = BarrierLimitation(option) - - } - -} - -@encoding (A1) { - - @word 1 1 1 1 0 1 0 1 0 1 1 1 1 1 1 1 1 1 1 1 0 0 0 0 0 1 0 0 option(4) - - @syntax - - @conv { - - limitation = BarrierLimitation(option) - - } - -} - diff --git a/src/arch/arm/v7/opdefs/eor_A8846.d b/src/arch/arm/v7/opdefs/eor_A8846.d deleted file mode 100644 index 38dc858..0000000 --- a/src/arch/arm/v7/opdefs/eor_A8846.d +++ /dev/null @@ -1,74 +0,0 @@ - -/* Chrysalide - Outil d'analyse de fichiers binaires - * ##FILE## - traduction d'instructions ARMv7 - * - * Copyright (C) 2015 Cyrille Bagard - * - * This file is part of Chrysalide. - * - * Chrysalide is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Chrysalide is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Foobar. If not, see . - */ - - -@title EOR (immediate) - -@desc Bitwise Exclusive OR (immediate) performs a bitwise Exclusive OR of a register value and an immediate value, and writes the result to the destination register. It can optionally update the condition flags based on the result. - -@encoding (T1) { - - @word 1 1 1 1 0 i(1) 0 0 1 0 0 S(1) Rn(4) 0 imm3(3) Rd(4) imm8(8) - - @syntax - - @conv { - - reg_D = Register(Rd) - reg_N = Register(Rn) - setflags = (S == '1') - imm32 = ThumbExpandImm_C(i:imm3:imm8, 0) - - } - - @rules { - - if (setflags); chk_call ExtendKeyword("s") - - } - -} - -@encoding (A1) { - - @word cond(4) 0 0 1 0 0 0 1 S(1) Rn(4) Rd(4) imm12(12) - - @syntax - - @conv { - - reg_D = Register(Rd) - reg_N = Register(Rn) - setflags = (S == '1') - imm32 = ARMExpandImm_C(imm12, 0) - - } - - @rules { - - if (setflags); chk_call ExtendKeyword("s") - chk_call StoreCondition(cond) - - } - -} - diff --git a/src/arch/arm/v7/opdefs/eor_A8847.d b/src/arch/arm/v7/opdefs/eor_A8847.d deleted file mode 100644 index 66643a1..0000000 --- a/src/arch/arm/v7/opdefs/eor_A8847.d +++ /dev/null @@ -1,92 +0,0 @@ - -/* Chrysalide - Outil d'analyse de fichiers binaires - * ##FILE## - traduction d'instructions ARMv7 - * - * Copyright (C) 2015 Cyrille Bagard - * - * This file is part of Chrysalide. - * - * Chrysalide is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Chrysalide is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Foobar. If not, see . - */ - - -@title EOR (register) - -@desc Bitwise Exclusive OR (register) performs a bitwise Exclusive OR of a register value and an optionally-shifted register value, and writes the result to the destination register. It can optionally update the condition flags based on the result. - -@encoding (t1) { - - @half 0 1 0 0 0 0 0 0 0 1 Rm(3) Rdn(3) - - @syntax "eors" - - @conv { - - reg_DN = Register(Rdn) - reg_M = Register(Rm) - - } - -} - -@encoding (T2) { - - @word 1 1 1 0 1 0 1 0 1 0 0 S(1) Rn(4) 0 imm3(3) Rd(4) imm2(2) type(2) Rm(4) - - @syntax - - @conv { - - reg_D = Register(Rd) - reg_N = Register(Rn) - reg_M = Register(Rm) - setflags = (S == '1') - shift = DecodeImmShift(type, imm3:imm2) - - } - - @rules { - - if (setflags); chk_call ExtendKeyword("s") - chk_call ExtendKeyword(".w") - - } - -} - -@encoding (A1) { - - @word cond(4) 0 0 0 0 0 0 1 S(1) Rn(4) Rd(4) imm5(5) type(2) 0 Rm(4) - - @syntax - - @conv { - - reg_D = Register(Rd) - reg_N = Register(Rn) - reg_M = Register(Rm) - setflags = (S == '1') - shift = DecodeImmShift(type, imm5) - - } - - @rules { - - if (setflags); chk_call ExtendKeyword("s") - chk_call StoreCondition(cond) - - } - -} - diff --git a/src/arch/arm/v7/opdefs/eor_A8848.d b/src/arch/arm/v7/opdefs/eor_A8848.d deleted file mode 100644 index f38fa74..0000000 --- a/src/arch/arm/v7/opdefs/eor_A8848.d +++ /dev/null @@ -1,52 +0,0 @@ - -/* Chrysalide - Outil d'analyse de fichiers binaires - * ##FILE## - traduction d'instructions ARMv7 - * - * Copyright (C) 2015 Cyrille Bagard - * - * This file is part of Chrysalide. - * - * Chrysalide is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Chrysalide is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Foobar. If not, see . - */ - - -@title EOR (register-shifted register) - -@desc Bitwise Exclusive OR (register-shifted register) performs a bitwise Exclusive OR of a register value and a register-shifted register value. It writes the result to the destination register, and can optionally update the condition flags based on the result. - -@encoding (A1) { - - @word cond(4) 0 0 0 0 0 0 1 S(1) Rn(4) Rd(4) Rs(4) 0 type(2) 1 Rm(4) - - @syntax - - @conv { - - reg_shift = RegisterShift(type, Rs) - reg_D = Register(Rd) - reg_N = Register(Rn) - reg_M = Register(Rm) - setflags = (S == '1') - - } - - @rules { - - if (setflags); chk_call ExtendKeyword("s") - chk_call StoreCondition(cond) - - } - -} - diff --git a/src/arch/arm/v7/opdefs/ldr_A8862.d b/src/arch/arm/v7/opdefs/ldr_A8862.d deleted file mode 100644 index 03df506..0000000 --- a/src/arch/arm/v7/opdefs/ldr_A8862.d +++ /dev/null @@ -1,98 +0,0 @@ - -/* Chrysalide - Outil d'analyse de fichiers binaires - * ##FILE## - traduction d'instructions ARMv7 - * - * Copyright (C) 2015 Cyrille Bagard - * - * This file is part of Chrysalide. - * - * Chrysalide is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Chrysalide is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Foobar. If not, see . - */ - - -@title LDR (immediate, Thumb) - -@desc Load Register (immediate) calculates an address from a base register value and an immediate offset, loads a word from memory, and writes it to a register. It can use offset, post-indexed, or pre-indexed addressing. For information about memory accesses see Memory accesses on page A8-294. - -@encoding (t1) { - - @half 0 1 1 0 1 imm5(5) Rn(3) Rt(3) - - @syntax - - @conv { - - reg_T = Register(Rt) - reg_N = Register(Rn) - imm32 = ZeroExtend(imm5:'00', 32) - mem_access = MakeMemoryAccess(reg_N, imm32, NULL, true, true, false) - - } - -} - -@encoding (t2) { - - @half 1 0 0 1 1 Rt(3) imm8(8) - - @syntax - - @conv { - - reg_T = Register(Rt) - imm32 = ZeroExtend(imm8:'00', 32) - SP = Register(13) - mem_access = MakeMemoryAccess(SP, imm32, NULL, true, true, false) - - } - -} - -@encoding (T3) { - - @word 1 1 1 1 1 0 0 0 1 1 0 1 Rn(4) Rt(4) imm12(12) - - @syntax ".W" - - @conv { - - reg_T = Register(Rt) - reg_N = Register(Rn) - imm32 = ZeroExtend(imm12, 32) - mem_access = MakeMemoryAccess(reg_N, imm32, NULL, true, true, false) - - } - -} - -@encoding (T4) { - - @word 1 1 1 1 1 0 0 0 0 1 0 1 Rn(4) Rt(4) 1 P(1) U(1) W(1) imm8(8) - - @syntax - - @conv { - - reg_T = Register(Rt) - reg_N = Register(Rn) - imm32 = ZeroExtend(imm8, 32) - index = (P == '1') - add = (U == '1') - wback = (W == '1') - mem_access = MakeMemoryAccess(reg_N, imm32, NULL, index, add, wback) - - } - -} - diff --git a/src/arch/arm/v7/opdefs/ldr_A8863.d b/src/arch/arm/v7/opdefs/ldr_A8863.d deleted file mode 100644 index 0d0ce1f..0000000 --- a/src/arch/arm/v7/opdefs/ldr_A8863.d +++ /dev/null @@ -1,53 +0,0 @@ - -/* Chrysalide - Outil d'analyse de fichiers binaires - * ##FILE## - traduction d'instructions ARMv7 - * - * Copyright (C) 2015 Cyrille Bagard - * - * This file is part of Chrysalide. - * - * Chrysalide is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Chrysalide is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Foobar. If not, see . - */ - - -@title LDR (immediate, ARM) - -@desc Load Register (immediate) calculates an address from a base register value and an immediate offset, loads a word from memory, and writes it to a register. It can use offset, post-indexed, or pre-indexed addressing. For information about memory accesses see Memory accesses on page A8-294. - -@encoding (A1) { - - @word cond(4) 0 1 0 P(1) U(1) 0 W(1) 1 Rn(4) Rt(4) imm12(12) - - @syntax - - @conv { - - reg_T = Register(Rt) - reg_N = Register(Rn) - imm32 = ZeroExtend(imm12, 32) - index = (P == '1') - add = (U == '1') - wback = (P == '0') || (W == '1') - mem_access = MakeMemoryAccess(reg_N, imm32, NULL, index, add, wback) - - } - - @rules { - - chk_call StoreCondition(cond) - - } - -} - diff --git a/src/arch/arm/v7/opdefs/ldr_A8864.d b/src/arch/arm/v7/opdefs/ldr_A8864.d deleted file mode 100644 index 74afa2d..0000000 --- a/src/arch/arm/v7/opdefs/ldr_A8864.d +++ /dev/null @@ -1,99 +0,0 @@ - -/* Chrysalide - Outil d'analyse de fichiers binaires - * ##FILE## - traduction d'instructions ARMv7 - * - * Copyright (C) 2015 Cyrille Bagard - * - * This file is part of Chrysalide. - * - * Chrysalide is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Chrysalide is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Foobar. If not, see . - */ - - -@title LDR (literal) - -@desc Load Register (literal) calculates an address from the PC value and an immediate offset, loads a word from memory, and writes it to a register. For information about memory accesses see Memory accesses on page A8-294. - -@encoding (t1) { - - @half 0 1 0 0 1 Rt(3) imm8(8) - - @syntax - - @conv { - - reg_T = Register(Rt) - imm32 = ZeroExtend(imm8:'00', 32) - - } - - @hooks { - - fetch = help_fetching_with_instruction_ldr_literal_from_thumb - post = post_process_ldr_instructions - - } - -} - -@encoding (T2) { - - @word 1 1 1 1 1 0 0 0 U(1) 1 0 1 1 1 1 1 Rt(4) imm12(12) - - @syntax ".W" - - @conv { - - reg_T = Register(Rt) - imm32 = ZeroExtend(imm12, 32) - - } - - @hooks { - - fetch = help_fetching_with_instruction_ldr_literal_from_thumb - post = post_process_ldr_instructions - - } - -} - -@encoding (A1) { - - @word cond(4) 0 1 0 1 U(1) 0 0 1 1 1 1 1 Rt(4) imm12(12) - - @syntax - - @conv { - - reg_T = Register(Rt) - imm32 = ZeroExtend(imm12, 32) - - } - - @rules { - - chk_call StoreCondition(cond) - - } - - @hooks { - - fetch = help_fetching_with_instruction_ldr_literal_from_arm - post = post_process_ldr_instructions - - } - -} - diff --git a/src/arch/arm/v7/opdefs/ldr_A8865.d b/src/arch/arm/v7/opdefs/ldr_A8865.d deleted file mode 100644 index ebb4e09..0000000 --- a/src/arch/arm/v7/opdefs/ldr_A8865.d +++ /dev/null @@ -1,62 +0,0 @@ - -/* Chrysalide - Outil d'analyse de fichiers binaires - * ##FILE## - traduction d'instructions ARMv7 - * - * Copyright (C) 2015 Cyrille Bagard - * - * This file is part of Chrysalide. - * - * Chrysalide is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Chrysalide is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Foobar. If not, see . - */ - - -@title LDR (register, Thumb) - -@desc Load Register (register) calculates an address from a base register value and an offset register value, loads a word from memory, and writes it to a register. The offset register value can optionally be shifted. For information about memory accesses, see Memory accesses on page A8-294. The Thumb form of LDR (register) does not support register writeback. - -@encoding (t1) { - - @half 0 1 0 1 1 0 0 Rm(3) Rn(3) Rt(3) - - @syntax - - @conv { - - reg_T = Register(Rt) - reg_N = Register(Rn) - reg_M = Register(Rm) - mem_access = MakeMemoryAccess(reg_N, reg_M, NULL, true, false, false) - - } - -} - -@encoding (T2) { - - @word 1 1 1 1 1 0 0 0 0 1 0 1 Rn(4) Rt(4) 0 0 0 0 0 0 imm2(2) Rm(4) - - @syntax ".W" - - @conv { - - reg_T = Register(Rt) - reg_N = Register(Rn) - reg_M = Register(Rm) - shift = DecodeImmShift(0, imm2) - mem_access = MakeMemoryAccess(reg_N, reg_M, shift, true, false, false) - - } - -} - diff --git a/src/arch/arm/v7/opdefs/ldr_A8866.d b/src/arch/arm/v7/opdefs/ldr_A8866.d deleted file mode 100644 index b161043..0000000 --- a/src/arch/arm/v7/opdefs/ldr_A8866.d +++ /dev/null @@ -1,54 +0,0 @@ - -/* Chrysalide - Outil d'analyse de fichiers binaires - * ##FILE## - traduction d'instructions ARMv7 - * - * Copyright (C) 2015 Cyrille Bagard - * - * This file is part of Chrysalide. - * - * Chrysalide is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Chrysalide is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Foobar. If not, see . - */ - - -@title LDR (register, ARM) - -@desc Load Register (register) calculates an address from a base register value and an offset register value, loads a word from memory, and writes it to a register. The offset register value can optionally be shifted. For information about memory accesses, see Memory accesses on page A8-294. - -@encoding (A1) { - - @word cond(4) 0 1 1 P(1) U(1) 0 W(1) 1 Rn(4) Rt(4) imm5(5) type(2) 0 Rm(4) - - @syntax - - @conv { - - reg_T = Register(Rt) - reg_N = Register(Rn) - reg_M = Register(Rm) - index = (P == '1') - add = (U == '1') - wback = (P == '0') || (W == '1') - shift = DecodeImmShift(type, imm5) - mem_access = MakeMemoryAccess(reg_N, reg_M, shift, index, add, wback) - - } - - @rules { - - chk_call StoreCondition(cond) - - } - -} - diff --git a/src/arch/arm/v7/opdefs/ldrb_A8867.d b/src/arch/arm/v7/opdefs/ldrb_A8867.d deleted file mode 100644 index 2dea64e..0000000 --- a/src/arch/arm/v7/opdefs/ldrb_A8867.d +++ /dev/null @@ -1,81 +0,0 @@ - -/* Chrysalide - Outil d'analyse de fichiers binaires - * ##FILE## - traduction d'instructions ARMv7 - * - * Copyright (C) 2015 Cyrille Bagard - * - * This file is part of Chrysalide. - * - * Chrysalide is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Chrysalide is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Foobar. If not, see . - */ - - -@title LDRB (immediate, Thumb) - -@desc Load Register Byte (immediate) calculates an address from a base register value and an immediate offset, loads a byte from memory, zero-extends it to form a 32-bit word, and writes it to a register. It can use offset, post-indexed, or pre-indexed addressing. For information about memory accesses see Memory accesses on page A8-294. - -@encoding (t1) { - - @half 0 1 1 1 1 imm5(5) Rn(3) Rt(3) - - @syntax - - @conv { - - reg_T = Register(Rt) - reg_N = Register(Rn) - imm32 = ZeroExtend(imm5, 32) - mem_access = MakeMemoryAccess(reg_N, imm32, NULL, true, true, false) - - } - -} - -@encoding (T2) { - - @word 1 1 1 1 1 0 0 0 1 0 0 1 Rn(4) Rt(4) imm12(12) - - @syntax ".W" - - @conv { - - reg_T = Register(Rt) - reg_N = Register(Rn) - imm32 = ZeroExtend(imm12, 32) - mem_access = MakeMemoryAccess(reg_N, imm32, NULL, true, true, false) - - } - -} - -@encoding (T3) { - - @word 1 1 1 1 1 0 0 0 0 0 0 1 Rn(4) Rt(4) 1 P(1) U(1) W(1) imm8(8) - - @syntax - - @conv { - - reg_T = Register(Rt) - reg_N = Register(Rn) - imm32 = ZeroExtend(imm8, 32) - index = (P == '1') - add = (U == '1') - wback = (W == '1') - mem_access = MakeMemoryAccess(reg_N, imm32, NULL, index, add, wback) - - } - -} - diff --git a/src/arch/arm/v7/opdefs/ldrb_A8868.d b/src/arch/arm/v7/opdefs/ldrb_A8868.d deleted file mode 100644 index 519c309..0000000 --- a/src/arch/arm/v7/opdefs/ldrb_A8868.d +++ /dev/null @@ -1,53 +0,0 @@ - -/* Chrysalide - Outil d'analyse de fichiers binaires - * ##FILE## - traduction d'instructions ARMv7 - * - * Copyright (C) 2015 Cyrille Bagard - * - * This file is part of Chrysalide. - * - * Chrysalide is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Chrysalide is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Foobar. If not, see . - */ - - -@title LDRB (immediate, ARM) - -@desc Load Register Byte (immediate) calculates an address from a base register value and an immediate offset, loads a byte from memory, zero-extends it to form a 32-bit word, and writes it to a register. It can use offset, post-indexed, or pre-indexed addressing. For information about memory accesses see Memory accesses on page A8-294. - -@encoding (A1) { - - @word cond(4) 0 1 0 P(1) U(1) 1 W(1) 1 Rn(4) Rt(4) imm12(12) - - @syntax - - @conv { - - reg_T = Register(Rt) - reg_N = Register(Rn) - imm32 = ZeroExtend(imm12, 32) - index = (P == '1') - add = (U == '1') - wback = (P == '0') || (W == '1') - mem_access = MakeMemoryAccess(reg_N, imm32, NULL, index, add, wback) - - } - - @rules { - - chk_call StoreCondition(cond) - - } - -} - diff --git a/src/arch/arm/v7/opdefs/ldrb_A8869.d b/src/arch/arm/v7/opdefs/ldrb_A8869.d deleted file mode 100644 index fb80049..0000000 --- a/src/arch/arm/v7/opdefs/ldrb_A8869.d +++ /dev/null @@ -1,63 +0,0 @@ - -/* Chrysalide - Outil d'analyse de fichiers binaires - * ##FILE## - traduction d'instructions ARMv7 - * - * Copyright (C) 2015 Cyrille Bagard - * - * This file is part of Chrysalide. - * - * Chrysalide is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Chrysalide is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Foobar. If not, see . - */ - - -@title LDRB (literal) - -@desc Load Register Byte (literal) calculates an address from the PC value and an immediate offset, loads a byte from memory, zero-extends it to form a 32-bit word, and writes it to a register. For information about memory accesses see Memory accesses on page A8-294. - -@encoding (T1) { - - @word 1 1 1 1 1 0 0 0 U(1) 0 0 1 1 1 1 1 Rt(4) imm12(12) - - @syntax - - @conv { - - reg_T = Register(Rt) - imm32 = ZeroExtend(imm12, 32) - - } - -} - -@encoding (A1) { - - @word cond(4) 0 1 0 1 U(1) 1 0 1 1 1 1 1 Rt(4) imm12(12) - - @syntax - - @conv { - - reg_T = Register(Rt) - imm32 = ZeroExtend(imm12, 32) - - } - - @rules { - - chk_call StoreCondition(cond) - - } - -} - diff --git a/src/arch/arm/v7/opdefs/ldrb_A8870.d b/src/arch/arm/v7/opdefs/ldrb_A8870.d deleted file mode 100644 index 35f95ab..0000000 --- a/src/arch/arm/v7/opdefs/ldrb_A8870.d +++ /dev/null @@ -1,89 +0,0 @@ - -/* Chrysalide - Outil d'analyse de fichiers binaires - * ##FILE## - traduction d'instructions ARMv7 - * - * Copyright (C) 2015 Cyrille Bagard - * - * This file is part of Chrysalide. - * - * Chrysalide is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Chrysalide is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Foobar. If not, see . - */ - - -@title LDRB (register) - -@desc Load Register Byte (register) calculates an address from a base register value and an offset register value, loads a byte from memory, zero-extends it to form a 32-bit word, and writes it to a register. The offset register value can optionally be shifted. For information about memory accesses see Memory accesses on page A8-294. - -@encoding (t1) { - - @half 0 1 0 1 1 1 0 Rm(3) Rn(3) Rt(3) - - @syntax - - @conv { - - reg_T = Register(Rt) - reg_N = Register(Rn) - reg_M = Register(Rm) - mem_access = MakeMemoryAccess(reg_N, reg_M, NULL, true, true, false) - - } - -} - -@encoding (T2) { - - @word 1 1 1 1 1 0 0 0 0 0 0 1 Rn(4) Rt(4) 0 0 0 0 0 0 imm2(2) Rm(4) - - @syntax ".W" - - @conv { - - reg_T = Register(Rt) - reg_N = Register(Rn) - reg_M = Register(Rm) - shift = DecodeImmShift(0, imm2) - mem_access = MakeMemoryAccess(reg_N, reg_M, shift, true, true, false) - - } - -} - -@encoding (A1) { - - @word cond(4) 0 1 1 P(1) U(1) 1 W(1) 1 Rn(4) Rt(4) imm5(5) type(2) 0 Rm(4) - - @syntax - - @conv { - - reg_T = Register(Rt) - reg_N = Register(Rn) - reg_M = Register(Rm) - index = (P == '1') - add = (U == '1') - wback = (P == '0') || (W == '1') - shift = DecodeImmShift(type, imm5) - mem_access = MakeMemoryAccess(reg_N, reg_M, shift, index, add, wback) - - } - - @rules { - - chk_call StoreCondition(cond) - - } - -} - diff --git a/src/arch/arm/v7/opdefs/ldrbt_A8871.d b/src/arch/arm/v7/opdefs/ldrbt_A8871.d deleted file mode 100644 index 0bf9c3c..0000000 --- a/src/arch/arm/v7/opdefs/ldrbt_A8871.d +++ /dev/null @@ -1,93 +0,0 @@ - -/* Chrysalide - Outil d'analyse de fichiers binaires - * ##FILE## - traduction d'instructions ARMv7 - * - * Copyright (C) 2015 Cyrille Bagard - * - * This file is part of Chrysalide. - * - * Chrysalide is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Chrysalide is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Foobar. If not, see . - */ - - -@title LDRBT - -@desc Load Register Byte Unprivileged loads a byte from memory, zero-extends it to form a 32-bit word, and writes it to a register. For information about memory accesses see Memory accesses on page A8-294. The memory access is restricted as if the processor were running in User mode. This makes no difference if the processor is actually running in User mode. LDRBT is UNPREDICTABLE in Hyp mode. The Thumb instruction uses an offset addressing mode, that calculates the address used for the memory access from a base register value and an immediate offset, and leaves the base register unchanged. The ARM instruction uses a post-indexed addressing mode, that uses a base register value as the address for the memory access, and calculates a new address from a base register value and an offset and writes it back to the base register. The offset can be an immediate value or an optionally-shifted register value. - -@encoding (T1) { - - @word 1 1 1 1 1 0 0 0 0 0 0 1 Rn(4) Rt(4) 1 1 1 0 imm8(8) - - @syntax - - @conv { - - reg_T = Register(Rt) - reg_N = Register(Rn) - imm32 = ZeroExtend(imm8, 32) - mem_access = MakeMemoryAccess(reg_N, imm32, NULL, true, true, false) - - } - -} - -@encoding (A1) { - - @word cond(4) 0 1 0 0 U(1) 1 1 1 Rn(4) Rt(4) imm12(12) - - @syntax - - @conv { - - reg_T = Register(Rt) - reg_N = Register(Rn) - add = (U == '1') - imm32 = ZeroExtend(imm12, 32) - mem_access = MakeMemoryAccess(reg_N, imm32, NULL, false, add, false) - - } - - @rules { - - chk_call StoreCondition(cond) - - } - -} - -@encoding (A2) { - - @word cond(4) 0 1 1 0 U(1) 1 1 1 Rn(4) Rt(4) imm5(5) type(2) 0 Rm(4) - - @syntax - - @conv { - - reg_T = Register(Rt) - reg_N = Register(Rn) - reg_M = Register(Rm) - add = (U == '1') - shift = DecodeImmShift(type, imm5) - mem_access = MakeMemoryAccess(reg_N, reg_M, shift, false, add, false) - - } - - @rules { - - chk_call StoreCondition(cond) - - } - -} - diff --git a/src/arch/arm/v7/opdefs/ldrd_A8872.d b/src/arch/arm/v7/opdefs/ldrd_A8872.d deleted file mode 100644 index c73fdca..0000000 --- a/src/arch/arm/v7/opdefs/ldrd_A8872.d +++ /dev/null @@ -1,75 +0,0 @@ - -/* Chrysalide - Outil d'analyse de fichiers binaires - * ##FILE## - traduction d'instructions ARMv7 - * - * Copyright (C) 2015 Cyrille Bagard - * - * This file is part of Chrysalide. - * - * Chrysalide is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Chrysalide is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Foobar. If not, see . - */ - - -@title LDRD (immediate) - -@desc Load Register Dual (immediate) calculates an address from a base register value and an immediate offset, loads two words from memory, and writes them to two registers. It can use offset, post-indexed, or pre-indexed addressing. For information about memory accesses see Memory accesses on page A8-294. - -@encoding (T1) { - - @word 1 1 1 0 1 0 0 P(1) U(1) 1 W(1) 1 Rn(4) Rt(4) Rt2(4) imm8(8) - - @syntax - - @conv { - - reg_T = Register(Rt) - reg_T2 = Register(Rt2) - reg_N = Register(Rn) - imm32 = ZeroExtend(imm8:'00', 32) - index = (P == '1') - add = (U == '1') - wback = (W == '1') - mem_access = MakeMemoryAccess(reg_N, imm32, NULL, index, add, wback) - - } - -} - -@encoding (A1) { - - @word cond(4) 0 0 0 P(1) U(1) 1 W(1) 0 Rn(4) Rt(4) imm4H(4) 1 1 0 1 imm4L(4) - - @syntax - - @conv { - - reg_T = Register(Rt) - reg_T2 = NextRegister(reg_T) - reg_N = Register(Rn) - imm32 = ZeroExtend(imm4H:imm4L, 32) - index = (P == '1') - add = (U == '1') - wback = (P == '0') || (W == '1') - mem_access = MakeMemoryAccess(reg_N, imm32, NULL, index, add, wback) - - } - - @rules { - - chk_call StoreCondition(cond) - - } - -} - diff --git a/src/arch/arm/v7/opdefs/ldrd_A8873.d b/src/arch/arm/v7/opdefs/ldrd_A8873.d deleted file mode 100644 index 828e4a3..0000000 --- a/src/arch/arm/v7/opdefs/ldrd_A8873.d +++ /dev/null @@ -1,65 +0,0 @@ - -/* Chrysalide - Outil d'analyse de fichiers binaires - * ##FILE## - traduction d'instructions ARMv7 - * - * Copyright (C) 2015 Cyrille Bagard - * - * This file is part of Chrysalide. - * - * Chrysalide is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Chrysalide is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Foobar. If not, see . - */ - - -@title LDRD (literal) - -@desc Load Register Dual (literal) calculates an address from the PC value and an immediate offset, loads two words from memory, and writes them to two registers. For information about memory accesses see Memory accesses on page A8-294. - -@encoding (T1) { - - @word 1 1 1 0 1 0 0 P(1) U(1) 1 W(1) 1 1 1 1 1 Rt(4) Rt2(4) imm8(8) - - @syntax - - @conv { - - reg_T = Register(Rt) - reg_T2 = Register(Rt2) - imm32 = ZeroExtend(imm8:'00', 32) - - } - -} - -@encoding (A1) { - - @word cond(4) 0 0 0 1 U(1) 1 0 0 1 1 1 1 Rt(4) imm4H(4) 1 1 0 1 imm4L(4) - - @syntax - - @conv { - - reg_T = Register(Rt) - reg_T2 = NextRegister(reg_T) - imm32 = ZeroExtend(imm4H:imm4L, 32) - - } - - @rules { - - chk_call StoreCondition(cond) - - } - -} - diff --git a/src/arch/arm/v7/opdefs/ldrd_A8874.d b/src/arch/arm/v7/opdefs/ldrd_A8874.d deleted file mode 100644 index ed055a6..0000000 --- a/src/arch/arm/v7/opdefs/ldrd_A8874.d +++ /dev/null @@ -1,54 +0,0 @@ - -/* Chrysalide - Outil d'analyse de fichiers binaires - * ##FILE## - traduction d'instructions ARMv7 - * - * Copyright (C) 2015 Cyrille Bagard - * - * This file is part of Chrysalide. - * - * Chrysalide is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Chrysalide is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Foobar. If not, see . - */ - - -@title LDRD (register) - -@desc Load Register Dual (register) calculates an address from a base register value and a register offset, loads two words from memory, and writes them to two registers. It can use offset, post-indexed, or pre-indexed addressing. For information about memory accesses see Memory accesses on page A8-294. - -@encoding (A1) { - - @word cond(4) 0 0 0 P(1) U(1) 0 W(1) 0 Rn(4) Rt(4) 0 0 0 0 1 1 0 1 Rm(4) - - @syntax - - @conv { - - reg_T = Register(Rt) - reg_T2 = NextRegister(reg_T) - reg_N = Register(Rn) - reg_M = Register(Rm) - index = (P == '1') - add = (U == '1') - wback = (P == '0') || (W == '1') - mem_access = MakeMemoryAccess(reg_N, reg_M, NULL, index, add, wback) - - } - - @rules { - - chk_call StoreCondition(cond) - - } - -} - diff --git a/src/arch/arm/v7/opdefs/ldrex_A8875.d b/src/arch/arm/v7/opdefs/ldrex_A8875.d deleted file mode 100644 index b915061..0000000 --- a/src/arch/arm/v7/opdefs/ldrex_A8875.d +++ /dev/null @@ -1,66 +0,0 @@ - -/* Chrysalide - Outil d'analyse de fichiers binaires - * ##FILE## - traduction d'instructions ARMv7 - * - * Copyright (C) 2015 Cyrille Bagard - * - * This file is part of Chrysalide. - * - * Chrysalide is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Chrysalide is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Foobar. If not, see . - */ - - -@title LDREX - -@desc Load Register Exclusive calculates an address from a base register value and an immediate offset, loads a word from memory, writes it to a register and: • if the address has the Shared Memory attribute, marks the physical address as exclusive access for the executing processor in a global monitor • causes the executing processor to indicate an active exclusive access in the local monitor. For more information about support for shared memory see Synchronization and semaphores on page A3-114. For information about memory accesses see Memory accesses on page A8-294. - -@encoding (T1) { - - @word 1 1 1 0 1 0 0 0 0 1 0 1 Rn(4) Rt(4) 1 1 1 1 imm8(8) - - @syntax - - @conv { - - reg_T = Register(Rt) - reg_N = Register(Rn) - imm32 = ZeroExtend(imm8:'00', 32) - mem_access = MakeMemoryAccess(reg_N, imm32, NULL, true, false, false) - - } - -} - -@encoding (A1) { - - @word cond(4) 0 0 0 1 1 0 0 1 Rn(4) Rt(4) 1 1 1 1 1 0 0 1 1 1 1 1 - - @syntax - - @conv { - - reg_T = Register(Rt) - reg_N = Register(Rn) - mem_access = MakeMemoryAccess(reg_N, NULL, NULL, true, false, false) - - } - - @rules { - - chk_call StoreCondition(cond) - - } - -} - diff --git a/src/arch/arm/v7/opdefs/ldrexb_A8876.d b/src/arch/arm/v7/opdefs/ldrexb_A8876.d deleted file mode 100644 index e398ef2..0000000 --- a/src/arch/arm/v7/opdefs/ldrexb_A8876.d +++ /dev/null @@ -1,65 +0,0 @@ - -/* Chrysalide - Outil d'analyse de fichiers binaires - * ##FILE## - traduction d'instructions ARMv7 - * - * Copyright (C) 2015 Cyrille Bagard - * - * This file is part of Chrysalide. - * - * Chrysalide is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Chrysalide is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Foobar. If not, see . - */ - - -@title LDREXB - -@desc Load Register Exclusive Byte derives an address from a base register value, loads a byte from memory, zero-extends it to form a 32-bit word, writes it to a register and: • if the address has the Shared Memory attribute, marks the physical address as exclusive access for the executing processor in a global monitor • causes the executing processor to indicate an active exclusive access in the local monitor. For more information about support for shared memory see Synchronization and semaphores on page A3-114. For information about memory accesses see Memory accesses on page A8-294. - -@encoding (T1) { - - @word 1 1 1 0 1 0 0 0 1 1 0 1 Rn(4) Rt(4) 1 1 1 1 0 1 0 0 1 1 1 1 - - @syntax - - @conv { - - reg_T = Register(Rt) - reg_N = Register(Rn) - mem_access = MakeMemoryAccess(reg_N, NULL, NULL, true, false, false) - - } - -} - -@encoding (A1) { - - @word cond(4) 0 0 0 1 1 1 0 1 Rn(4) Rt(4) 1 1 1 1 1 0 0 1 1 1 1 1 - - @syntax - - @conv { - - reg_T = Register(Rt) - reg_N = Register(Rn) - mem_access = MakeMemoryAccess(reg_N, NULL, NULL, true, false, false) - - } - - @rules { - - chk_call StoreCondition(cond) - - } - -} - diff --git a/src/arch/arm/v7/opdefs/ldrexd_A8877.d b/src/arch/arm/v7/opdefs/ldrexd_A8877.d deleted file mode 100644 index 0188cb7..0000000 --- a/src/arch/arm/v7/opdefs/ldrexd_A8877.d +++ /dev/null @@ -1,67 +0,0 @@ - -/* Chrysalide - Outil d'analyse de fichiers binaires - * ##FILE## - traduction d'instructions ARMv7 - * - * Copyright (C) 2015 Cyrille Bagard - * - * This file is part of Chrysalide. - * - * Chrysalide is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Chrysalide is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Foobar. If not, see . - */ - - -@title LDREXD - -@desc Load Register Exclusive Doubleword derives an address from a base register value, loads a 64-bit doubleword from memory, writes it to two registers and: • if the address has the Shared Memory attribute, marks the physical address as exclusive access for the executing processor in a global monitor • causes the executing processor to indicate an active exclusive access in the local monitor. For more information about support for shared memory see Synchronization and semaphores on page A3-114. For information about memory accesses see Memory accesses on page A8-294. - -@encoding (T1) { - - @word 1 1 1 0 1 0 0 0 1 1 0 1 Rn(4) Rt(4) Rt2(4) 0 1 1 1 1 1 1 1 - - @syntax - - @conv { - - reg_T = Register(Rt) - reg_T2 = Register(Rt2) - reg_N = Register(Rn) - mem_access = MakeMemoryAccess(reg_N, NULL, NULL, true, false, false) - - } - -} - -@encoding (A1) { - - @word cond(4) 0 0 0 1 1 0 1 1 Rn(4) Rt(4) 1 1 1 1 1 0 0 1 1 1 1 1 - - @syntax - - @conv { - - reg_T = Register(Rt) - reg_T2 = NextRegister(reg_T) - reg_N = Register(Rn) - mem_access = MakeMemoryAccess(reg_N, NULL, NULL, true, false, false) - - } - - @rules { - - chk_call StoreCondition(cond) - - } - -} - diff --git a/src/arch/arm/v7/opdefs/ldrexh_A8878.d b/src/arch/arm/v7/opdefs/ldrexh_A8878.d deleted file mode 100644 index 8e9366f..0000000 --- a/src/arch/arm/v7/opdefs/ldrexh_A8878.d +++ /dev/null @@ -1,65 +0,0 @@ - -/* Chrysalide - Outil d'analyse de fichiers binaires - * ##FILE## - traduction d'instructions ARMv7 - * - * Copyright (C) 2015 Cyrille Bagard - * - * This file is part of Chrysalide. - * - * Chrysalide is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Chrysalide is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Foobar. If not, see . - */ - - -@title LDREXH - -@desc Load Register Exclusive Halfword derives an address from a base register value, loads a halfword from memory, zero-extends it to form a 32-bit word, writes it to a register and: • if the address has the Shared Memory attribute, marks the physical address as exclusive access for the executing processor in a global monitor • causes the executing processor to indicate an active exclusive access in the local monitor. For more information about support for shared memory see Synchronization and semaphores on page A3-114. For information about memory accesses see Memory accesses on page A8-294. - -@encoding (T1) { - - @word 1 1 1 0 1 0 0 0 1 1 0 1 Rn(4) Rt(4) 1 1 1 1 0 1 0 1 1 1 1 1 - - @syntax - - @conv { - - reg_T = Register(Rt) - reg_N = Register(Rn) - mem_access = MakeMemoryAccess(reg_N, NULL, NULL, true, false, false) - - } - -} - -@encoding (A1) { - - @word cond(4) 0 0 0 1 1 1 1 1 Rn(4) Rt(4) 1 1 1 1 1 0 0 1 1 1 1 1 - - @syntax - - @conv { - - reg_T = Register(Rt) - reg_N = Register(Rn) - mem_access = MakeMemoryAccess(reg_N, NULL, NULL, true, false, false) - - } - - @rules { - - chk_call StoreCondition(cond) - - } - -} - diff --git a/src/arch/arm/v7/opdefs/ldrh_A8879.d b/src/arch/arm/v7/opdefs/ldrh_A8879.d deleted file mode 100644 index 3b57bf8..0000000 --- a/src/arch/arm/v7/opdefs/ldrh_A8879.d +++ /dev/null @@ -1,81 +0,0 @@ - -/* Chrysalide - Outil d'analyse de fichiers binaires - * ##FILE## - traduction d'instructions ARMv7 - * - * Copyright (C) 2015 Cyrille Bagard - * - * This file is part of Chrysalide. - * - * Chrysalide is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Chrysalide is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Foobar. If not, see . - */ - - -@title LDRH (immediate, Thumb) - -@desc Load Register Halfword (immediate) calculates an address from a base register value and an immediate offset, loads a halfword from memory, zero-extends it to form a 32-bit word, and writes it to a register. It can use offset, post-indexed, or pre-indexed addressing. For information about memory accesses see Memory accesses on page A8-294. - -@encoding (t1) { - - @half 1 0 0 0 1 imm5(5) Rn(3) Rt(3) - - @syntax - - @conv { - - reg_T = Register(Rt) - reg_N = Register(Rn) - imm32 = ZeroExtend(imm5:'0', 32) - mem_access = MakeMemoryAccess(reg_N, imm32, NULL, true, true, false) - - } - -} - -@encoding (T2) { - - @word 1 1 1 1 1 0 0 0 1 0 1 1 Rn(4) Rt(4) imm12(12) - - @syntax ".W" - - @conv { - - reg_T = Register(Rt) - reg_N = Register(Rn) - imm32 = ZeroExtend(imm12, 32) - mem_access = MakeMemoryAccess(reg_N, imm32, NULL, true, true, false) - - } - -} - -@encoding (T3) { - - @word 1 1 1 1 1 0 0 0 0 0 1 1 Rn(4) Rt(4) 1 P(1) U(1) W(1) imm8(8) - - @syntax - - @conv { - - reg_T = Register(Rt) - reg_N = Register(Rn) - imm32 = ZeroExtend(imm8, 32) - index = (P == '1') - add = (U == '1') - wback = (W == '1') - mem_access = MakeMemoryAccess(reg_N, imm32, NULL, index, add, wback) - - } - -} - diff --git a/src/arch/arm/v7/opdefs/ldrh_A8880.d b/src/arch/arm/v7/opdefs/ldrh_A8880.d deleted file mode 100644 index f5f7ab0..0000000 --- a/src/arch/arm/v7/opdefs/ldrh_A8880.d +++ /dev/null @@ -1,53 +0,0 @@ - -/* Chrysalide - Outil d'analyse de fichiers binaires - * ##FILE## - traduction d'instructions ARMv7 - * - * Copyright (C) 2015 Cyrille Bagard - * - * This file is part of Chrysalide. - * - * Chrysalide is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Chrysalide is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Foobar. If not, see . - */ - - -@title LDRH (immediate, ARM) - -@desc Load Register Halfword (immediate) calculates an address from a base register value and an immediate offset, loads a halfword from memory, zero-extends it to form a 32-bit word, and writes it to a register. It can use offset, post-indexed, or pre-indexed addressing. For information about memory accesses see Memory accesses on page A8-294. - -@encoding (A1) { - - @word cond(4) 0 0 0 P(1) U(1) 1 W(1) 1 Rn(4) Rt(4) imm4H(4) 1 0 1 1 imm4L(4) - - @syntax - - @conv { - - reg_T = Register(Rt) - reg_N = Register(Rn) - imm32 = ZeroExtend(imm4H:imm4L, 32) - index = (P == '1') - add = (U == '1') - wback = (P == '0') || (W == '1') - mem_access = MakeMemoryAccess(reg_N, imm32, NULL, index, add, wback) - - } - - @rules { - - chk_call StoreCondition(cond) - - } - -} - diff --git a/src/arch/arm/v7/opdefs/ldrh_A8881.d b/src/arch/arm/v7/opdefs/ldrh_A8881.d deleted file mode 100644 index 59005e4..0000000 --- a/src/arch/arm/v7/opdefs/ldrh_A8881.d +++ /dev/null @@ -1,63 +0,0 @@ - -/* Chrysalide - Outil d'analyse de fichiers binaires - * ##FILE## - traduction d'instructions ARMv7 - * - * Copyright (C) 2015 Cyrille Bagard - * - * This file is part of Chrysalide. - * - * Chrysalide is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Chrysalide is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Foobar. If not, see . - */ - - -@title LDRH (literal) - -@desc Load Register Halfword (literal) calculates an address from the PC value and an immediate offset, loads a halfword from memory, zero-extends it to form a 32-bit word, and writes it to a register. For information about memory accesses see Memory accesses on page A8-294. - -@encoding (T1) { - - @word 1 1 1 1 1 0 0 0 U(1) 0 1 1 1 1 1 1 Rt(4) imm12(12) - - @syntax - - @conv { - - reg_T = Register(Rt) - imm32 = ZeroExtend(imm12, 32) - - } - -} - -@encoding (A1) { - - @word cond(4) 0 0 0 P(1) U(1) 1 W(1) 1 1 1 1 1 Rt(4) imm4H(4) 1 0 1 1 imm4L(4) - - @syntax - - @conv { - - reg_T = Register(Rt) - imm32 = ZeroExtend(imm4H:imm4L, 32) - - } - - @rules { - - chk_call StoreCondition(cond) - - } - -} - diff --git a/src/arch/arm/v7/opdefs/ldrh_A8882.d b/src/arch/arm/v7/opdefs/ldrh_A8882.d deleted file mode 100644 index 823bf24..0000000 --- a/src/arch/arm/v7/opdefs/ldrh_A8882.d +++ /dev/null @@ -1,88 +0,0 @@ - -/* Chrysalide - Outil d'analyse de fichiers binaires - * ##FILE## - traduction d'instructions ARMv7 - * - * Copyright (C) 2015 Cyrille Bagard - * - * This file is part of Chrysalide. - * - * Chrysalide is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Chrysalide is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Foobar. If not, see . - */ - - -@title LDRH (register) - -@desc Load Register Halfword (register) calculates an address from a base register value and an offset register value, loads a halfword from memory, zero-extends it to form a 32-bit word, and writes it to a register. The offset register value can be shifted left by 0, 1, 2, or 3 bits. For information about memory accesses see Memory accesses on page A8-294. - -@encoding (t1) { - - @half 0 1 0 1 1 0 1 Rm(3) Rn(3) Rt(3) - - @syntax - - @conv { - - reg_T = Register(Rt) - reg_N = Register(Rn) - reg_M = Register(Rm) - mem_access = MakeMemoryAccess(reg_N, reg_M, NULL, true, true, false) - - } - -} - -@encoding (T2) { - - @word 1 1 1 1 1 0 0 0 0 0 1 1 Rn(4) Rt(4) 0 0 0 0 0 0 imm2(2) Rm(4) - - @syntax ".W" - - @conv { - - reg_T = Register(Rt) - reg_N = Register(Rn) - reg_M = Register(Rm) - shift = DecodeImmShift(0, imm2) - mem_access = MakeMemoryAccess(reg_N, reg_M, shift, true, true, false) - - } - -} - -@encoding (A1) { - - @word cond(4) 0 0 0 P(1) U(1) 0 W(1) 1 Rn(4) Rt(4) 0 0 0 0 1 0 1 1 Rm(4) - - @syntax - - @conv { - - reg_T = Register(Rt) - reg_N = Register(Rn) - reg_M = Register(Rm) - index = (P == '1') - add = (U == '1') - wback = (P == '0') || (W == '1') - mem_access = MakeMemoryAccess(reg_N, reg_M, NULL, index, add, wback) - - } - - @rules { - - chk_call StoreCondition(cond) - - } - -} - diff --git a/src/arch/arm/v7/opdefs/ldrht_A8883.d b/src/arch/arm/v7/opdefs/ldrht_A8883.d deleted file mode 100644 index 8f8f015..0000000 --- a/src/arch/arm/v7/opdefs/ldrht_A8883.d +++ /dev/null @@ -1,92 +0,0 @@ - -/* Chrysalide - Outil d'analyse de fichiers binaires - * ##FILE## - traduction d'instructions ARMv7 - * - * Copyright (C) 2015 Cyrille Bagard - * - * This file is part of Chrysalide. - * - * Chrysalide is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Chrysalide is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Foobar. If not, see . - */ - - -@title LDRHT - -@desc Load Register Halfword Unprivileged loads a halfword from memory, zero-extends it to form a 32-bit word, and writes it to a register. For information about memory accesses see Memory accesses on page A8-294. The memory access is restricted as if the processor were running in User mode. This makes no difference if the processor is actually running in User mode. LDRHT is UNPREDICTABLE in Hyp mode. The Thumb instruction uses an offset addressing mode, that calculates the address used for the memory access from a base register value and an immediate offset, and leaves the base register unchanged. The ARM instruction uses a post-indexed addressing mode, that uses a base register value as the address for the memory access, and calculates a new address from a base register value and an offset and writes it back to the base register. The offset can be an immediate value or a register value. - -@encoding (T1) { - - @word 1 1 1 1 1 0 0 0 0 0 1 1 Rn(4) Rt(4) 1 1 1 0 imm8(8) - - @syntax - - @conv { - - reg_T = Register(Rt) - reg_N = Register(Rn) - imm32 = ZeroExtend(imm8, 32) - mem_access = MakeMemoryAccess(reg_N, imm32, NULL, true, true, false) - - } - -} - -@encoding (A1) { - - @word cond(4) 0 0 0 0 U(1) 1 1 1 Rn(4) Rt(4) imm4H(4) 1 0 1 1 imm4L(4) - - @syntax - - @conv { - - reg_T = Register(Rt) - reg_N = Register(Rn) - add = (U == '1') - imm32 = ZeroExtend(imm4H:imm4L, 32) - mem_access = MakeMemoryAccess(reg_N, imm32, NULL, false, add, false) - - } - - @rules { - - chk_call StoreCondition(cond) - - } - -} - -@encoding (A2) { - - @word cond(4) 0 0 0 0 U(1) 0 1 1 Rn(4) Rt(4) 0 0 0 0 1 0 1 1 Rm(4) - - @syntax - - @conv { - - reg_T = Register(Rt) - reg_N = Register(Rn) - reg_M = Register(Rm) - add = (U == '1') - mem_access = MakeMemoryAccess(reg_N, reg_M, NULL, false, add, false) - - } - - @rules { - - chk_call StoreCondition(cond) - - } - -} - diff --git a/src/arch/arm/v7/opdefs/ldrsb_A8884.d b/src/arch/arm/v7/opdefs/ldrsb_A8884.d deleted file mode 100644 index fc41134..0000000 --- a/src/arch/arm/v7/opdefs/ldrsb_A8884.d +++ /dev/null @@ -1,90 +0,0 @@ - -/* Chrysalide - Outil d'analyse de fichiers binaires - * ##FILE## - traduction d'instructions ARMv7 - * - * Copyright (C) 2015 Cyrille Bagard - * - * This file is part of Chrysalide. - * - * Chrysalide is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Chrysalide is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Foobar. If not, see . - */ - - -@title LDRSB (immediate) - -@desc Load Register Signed Byte (immediate) calculates an address from a base register value and an immediate offset, loads a byte from memory, sign-extends it to form a 32-bit word, and writes it to a register. It can use offset, post-indexed, or pre-indexed addressing. For information about memory accesses see Memory accesses on page A8-294. - -@encoding (T1) { - - @word 1 1 1 1 1 0 0 1 1 0 0 1 Rn(4) Rt(4) imm12(12) - - @syntax - - @conv { - - reg_T = Register(Rt) - reg_N = Register(Rn) - imm32 = ZeroExtend(imm12, 32) - mem_access = MakeMemoryAccess(reg_N, imm32, NULL, true, true, false) - - } - -} - -@encoding (T2) { - - @word 1 1 1 1 1 0 0 1 0 0 0 1 Rn(4) Rt(4) 1 P(1) U(1) W(1) imm8(8) - - @syntax - - @conv { - - reg_T = Register(Rt) - reg_N = Register(Rn) - imm32 = ZeroExtend(imm8, 32) - index = (P == '1') - add = (U == '1') - wback = (W == '1') - mem_access = MakeMemoryAccess(reg_N, imm32, NULL, index, add, wback) - - } - -} - -@encoding (A1) { - - @word cond(4) 0 0 0 P(1) U(1) 1 W(1) 1 Rn(4) Rt(4) imm4H(4) 1 1 0 1 imm4L(4) - - @syntax - - @conv { - - reg_T = Register(Rt) - reg_N = Register(Rn) - imm32 = ZeroExtend(imm4H:imm4L, 32) - index = (P == '1') - add = (U == '1') - wback = (P == '0') || (W == '1') - mem_access = MakeMemoryAccess(reg_N, imm32, NULL, index, add, wback) - - } - - @rules { - - chk_call StoreCondition(cond) - - } - -} - diff --git a/src/arch/arm/v7/opdefs/ldrsb_A8885.d b/src/arch/arm/v7/opdefs/ldrsb_A8885.d deleted file mode 100644 index 6cb1d34..0000000 --- a/src/arch/arm/v7/opdefs/ldrsb_A8885.d +++ /dev/null @@ -1,63 +0,0 @@ - -/* Chrysalide - Outil d'analyse de fichiers binaires - * ##FILE## - traduction d'instructions ARMv7 - * - * Copyright (C) 2015 Cyrille Bagard - * - * This file is part of Chrysalide. - * - * Chrysalide is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Chrysalide is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Foobar. If not, see . - */ - - -@title LDRSB (literal) - -@desc Load Register Signed Byte (literal) calculates an address from the PC value and an immediate offset, loads a byte from memory, sign-extends it to form a 32-bit word, and writes it to a register. For information about memory accesses see Memory accesses on page A8-294. - -@encoding (T1) { - - @word 1 1 1 1 1 0 0 1 U(1) 0 0 1 1 1 1 1 Rt(4) imm12(12) - - @syntax - - @conv { - - reg_T = Register(Rt) - imm32 = ZeroExtend(imm12, 32) - - } - -} - -@encoding (A1) { - - @word cond(4) 0 0 0 1 U(1) 1 0 1 1 1 1 1 Rt(4) imm4H(4) 1 1 0 1 imm4L(4) - - @syntax - - @conv { - - reg_T = Register(Rt) - imm32 = ZeroExtend(imm4H:imm4L, 32) - - } - - @rules { - - chk_call StoreCondition(cond) - - } - -} - diff --git a/src/arch/arm/v7/opdefs/ldrsb_A8886.d b/src/arch/arm/v7/opdefs/ldrsb_A8886.d deleted file mode 100644 index 4a66278..0000000 --- a/src/arch/arm/v7/opdefs/ldrsb_A8886.d +++ /dev/null @@ -1,88 +0,0 @@ - -/* Chrysalide - Outil d'analyse de fichiers binaires - * ##FILE## - traduction d'instructions ARMv7 - * - * Copyright (C) 2015 Cyrille Bagard - * - * This file is part of Chrysalide. - * - * Chrysalide is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Chrysalide is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Foobar. If not, see . - */ - - -@title LDRSB (register) - -@desc Load Register Signed Byte (register) calculates an address from a base register value and an offset register value, loads a byte from memory, sign-extends it to form a 32-bit word, and writes it to a register. The offset register value can be shifted left by 0, 1, 2, or 3 bits. For information about memory accesses see Memory accesses on page A8-294. - -@encoding (t1) { - - @half 0 1 0 1 0 1 1 Rm(3) Rn(3) Rt(3) - - @syntax - - @conv { - - reg_T = Register(Rt) - reg_N = Register(Rn) - reg_M = Register(Rm) - mem_access = MakeMemoryAccess(reg_N, reg_M, NULL, true, true, false) - - } - -} - -@encoding (T2) { - - @word 1 1 1 1 1 0 0 1 0 0 0 1 Rn(4) Rt(4) 0 0 0 0 0 0 imm2(2) Rm(4) - - @syntax ".W" - - @conv { - - reg_T = Register(Rt) - reg_N = Register(Rn) - reg_M = Register(Rm) - shift = DecodeImmShift(0, imm2) - mem_access = MakeMemoryAccess(reg_N, reg_M, shift, true, true, false) - - } - -} - -@encoding (A1) { - - @word cond(4) 0 0 0 P(1) U(1) 0 W(1) 1 Rn(4) Rt(4) 0 0 0 0 1 1 0 1 Rm(4) - - @syntax - - @conv { - - reg_T = Register(Rt) - reg_N = Register(Rn) - reg_M = Register(Rm) - index = (P == '1') - add = (U == '1') - wback = (P == '0') || (W == '1') - mem_access = MakeMemoryAccess(reg_N, reg_M, NULL, index, add, wback) - - } - - @rules { - - chk_call StoreCondition(cond) - - } - -} - diff --git a/src/arch/arm/v7/opdefs/ldrsbt_A8887.d b/src/arch/arm/v7/opdefs/ldrsbt_A8887.d deleted file mode 100644 index b545f32..0000000 --- a/src/arch/arm/v7/opdefs/ldrsbt_A8887.d +++ /dev/null @@ -1,92 +0,0 @@ - -/* Chrysalide - Outil d'analyse de fichiers binaires - * ##FILE## - traduction d'instructions ARMv7 - * - * Copyright (C) 2015 Cyrille Bagard - * - * This file is part of Chrysalide. - * - * Chrysalide is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Chrysalide is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Foobar. If not, see . - */ - - -@title LDRSBT - -@desc Load Register Signed Byte Unprivileged loads a byte from memory, sign-extends it to form a 32-bit word, and writes it to a register. For information about memory accesses see Memory accesses on page A8-294. The memory access is restricted as if the processor were running in User mode. This makes no difference if the processor is actually running in User mode. LDRSBT is UNPREDICTABLE in Hyp mode. The Thumb instruction uses an offset addressing mode, that calculates the address used for the memory access from a base register value and an immediate offset, and leaves the base register unchanged. The ARM instruction uses a post-indexed addressing mode, that uses a base register value as the address for the memory access, and calculates a new address from a base register value and an offset and writes it back to the base register. The offset can be an immediate value or a register value. - -@encoding (T1) { - - @word 1 1 1 1 1 0 0 1 0 0 0 1 Rn(4) Rt(4) 1 1 1 0 imm8(8) - - @syntax - - @conv { - - reg_T = Register(Rt) - reg_N = Register(Rn) - imm32 = ZeroExtend(imm8, 32) - mem_access = MakeMemoryAccess(reg_N, imm32, NULL, true, true, false) - - } - -} - -@encoding (A1) { - - @word cond(4) 0 0 0 0 U(1) 1 1 1 Rn(4) Rt(4) imm4H(4) 1 1 0 1 imm4L(4) - - @syntax - - @conv { - - reg_T = Register(Rt) - reg_N = Register(Rn) - add = (U == '1') - imm32 = ZeroExtend(imm4H:imm4L, 32) - mem_access = MakeMemoryAccess(reg_N, imm32, NULL, false, add, false) - - } - - @rules { - - chk_call StoreCondition(cond) - - } - -} - -@encoding (A2) { - - @word cond(4) 0 0 0 0 U(1) 0 1 1 Rn(4) Rt(4) 0 0 0 0 1 1 0 1 Rm(4) - - @syntax - - @conv { - - reg_T = Register(Rt) - reg_N = Register(Rn) - reg_M = Register(Rm) - add = (U == '1') - mem_access = MakeMemoryAccess(reg_N, reg_M, NULL, false, add, false) - - } - - @rules { - - chk_call StoreCondition(cond) - - } - -} - diff --git a/src/arch/arm/v7/opdefs/ldrsh_A8888.d b/src/arch/arm/v7/opdefs/ldrsh_A8888.d deleted file mode 100644 index f01024c..0000000 --- a/src/arch/arm/v7/opdefs/ldrsh_A8888.d +++ /dev/null @@ -1,90 +0,0 @@ - -/* Chrysalide - Outil d'analyse de fichiers binaires - * ##FILE## - traduction d'instructions ARMv7 - * - * Copyright (C) 2015 Cyrille Bagard - * - * This file is part of Chrysalide. - * - * Chrysalide is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Chrysalide is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Foobar. If not, see . - */ - - -@title LDRSH (immediate) - -@desc Load Register Signed Halfword (immediate) calculates an address from a base register value and an immediate offset, loads a halfword from memory, sign-extends it to form a 32-bit word, and writes it to a register. It can use offset, post-indexed, or pre-indexed addressing. For information about memory accesses see Memory accesses on page A8-294. - -@encoding (T1) { - - @word 1 1 1 1 1 0 0 1 1 0 1 1 Rn(4) Rt(4) imm12(12) - - @syntax - - @conv { - - reg_T = Register(Rt) - reg_N = Register(Rn) - imm32 = ZeroExtend(imm12, 32) - mem_access = MakeMemoryAccess(reg_N, imm32, NULL, true, true, false) - - } - -} - -@encoding (T2) { - - @word 1 1 1 1 1 0 0 1 0 0 1 1 Rn(4) Rt(4) 1 P(1) U(1) W(1) imm8(8) - - @syntax - - @conv { - - reg_T = Register(Rt) - reg_N = Register(Rn) - imm32 = ZeroExtend(imm8, 32) - index = (P == '1') - add = (U == '1') - wback = (W == '1') - mem_access = MakeMemoryAccess(reg_N, imm32, NULL, index, add, wback) - - } - -} - -@encoding (A1) { - - @word cond(4) 0 0 0 P(1) U(1) 1 W(1) 1 Rn(4) Rt(4) imm4H(4) 1 1 1 1 imm4L(4) - - @syntax - - @conv { - - reg_T = Register(Rt) - reg_N = Register(Rn) - imm32 = ZeroExtend(imm4H:imm4L, 32) - index = (P == '1') - add = (U == '1') - wback = (P == '0') || (W == '1') - mem_access = MakeMemoryAccess(reg_N, imm32, NULL, index, add, wback) - - } - - @rules { - - chk_call StoreCondition(cond) - - } - -} - diff --git a/src/arch/arm/v7/opdefs/ldrsh_A8889.d b/src/arch/arm/v7/opdefs/ldrsh_A8889.d deleted file mode 100644 index 074cd5c..0000000 --- a/src/arch/arm/v7/opdefs/ldrsh_A8889.d +++ /dev/null @@ -1,63 +0,0 @@ - -/* Chrysalide - Outil d'analyse de fichiers binaires - * ##FILE## - traduction d'instructions ARMv7 - * - * Copyright (C) 2015 Cyrille Bagard - * - * This file is part of Chrysalide. - * - * Chrysalide is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Chrysalide is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Foobar. If not, see . - */ - - -@title LDRSH (literal) - -@desc Load Register Signed Halfword (literal) calculates an address from the PC value and an immediate offset, loads a halfword from memory, sign-extends it to form a 32-bit word, and writes it to a register. For information about memory accesses see Memory accesses on page A8-294. - -@encoding (T1) { - - @word 1 1 1 1 1 0 0 1 U(1) 0 1 1 1 1 1 1 Rt(4) imm12(12) - - @syntax - - @conv { - - reg_T = Register(Rt) - imm32 = ZeroExtend(imm12, 32) - - } - -} - -@encoding (A1) { - - @word cond(4) 0 0 0 1 U(1) 1 0 1 1 1 1 1 Rt(4) imm4H(4) 1 1 1 1 imm4L(4) - - @syntax - - @conv { - - reg_T = Register(Rt) - imm32 = ZeroExtend(imm4H:imm4L, 32) - - } - - @rules { - - chk_call StoreCondition(cond) - - } - -} - diff --git a/src/arch/arm/v7/opdefs/ldrsh_A8890.d b/src/arch/arm/v7/opdefs/ldrsh_A8890.d deleted file mode 100644 index eac6c09..0000000 --- a/src/arch/arm/v7/opdefs/ldrsh_A8890.d +++ /dev/null @@ -1,88 +0,0 @@ - -/* Chrysalide - Outil d'analyse de fichiers binaires - * ##FILE## - traduction d'instructions ARMv7 - * - * Copyright (C) 2015 Cyrille Bagard - * - * This file is part of Chrysalide. - * - * Chrysalide is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Chrysalide is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Foobar. If not, see . - */ - - -@title LDRSH (register) - -@desc Load Register Signed Halfword (register) calculates an address from a base register value and an offset register value, loads a halfword from memory, sign-extends it to form a 32-bit word, and writes it to a register. The offset register value can be shifted left by 0, 1, 2, or 3 bits. For information about memory accesses see Memory accesses on page A8-294. - -@encoding (t1) { - - @half 0 1 0 1 1 1 1 Rm(3) Rn(3) Rt(3) - - @syntax - - @conv { - - reg_T = Register(Rt) - reg_N = Register(Rn) - reg_M = Register(Rm) - mem_access = MakeMemoryAccess(reg_N, reg_M, NULL, true, true, false) - - } - -} - -@encoding (T2) { - - @word 1 1 1 1 1 0 0 1 0 0 1 1 Rn(4) Rt(4) 0 0 0 0 0 0 imm2(2) Rm(4) - - @syntax ".W" - - @conv { - - reg_T = Register(Rt) - reg_N = Register(Rn) - reg_M = Register(Rm) - shift = DecodeImmShift(0, imm2) - mem_access = MakeMemoryAccess(reg_N, reg_M, shift, true, true, false) - - } - -} - -@encoding (A1) { - - @word cond(4) 0 0 0 P(1) U(1) 0 W(1) 1 Rn(4) Rt(4) 0 0 0 0 1 1 1 1 Rm(4) - - @syntax - - @conv { - - reg_T = Register(Rt) - reg_N = Register(Rn) - reg_M = Register(Rm) - index = (P == '1') - add = (U == '1') - wback = (P == '0') || (W == '1') - mem_access = MakeMemoryAccess(reg_N, reg_M, NULL, index, add, wback) - - } - - @rules { - - chk_call StoreCondition(cond) - - } - -} - diff --git a/src/arch/arm/v7/opdefs/ldrsht_A8891.d b/src/arch/arm/v7/opdefs/ldrsht_A8891.d deleted file mode 100644 index 355178b..0000000 --- a/src/arch/arm/v7/opdefs/ldrsht_A8891.d +++ /dev/null @@ -1,92 +0,0 @@ - -/* Chrysalide - Outil d'analyse de fichiers binaires - * ##FILE## - traduction d'instructions ARMv7 - * - * Copyright (C) 2015 Cyrille Bagard - * - * This file is part of Chrysalide. - * - * Chrysalide is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Chrysalide is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Foobar. If not, see . - */ - - -@title LDRSHT - -@desc Load Register Signed Halfword Unprivileged loads a halfword from memory, sign-extends it to form a 32-bit word, and writes it to a register. For information about memory accesses see Memory accesses on page A8-294. The memory access is restricted as if the processor were running in User mode. This makes no difference if the processor is actually running in User mode. LDRSHT is UNPREDICTABLE in Hyp mode. The Thumb instruction uses an offset addressing mode, that calculates the address used for the memory access from a base register value and an immediate offset, and leaves the base register unchanged. The ARM instruction uses a post-indexed addressing mode, that uses a base register value as the address for the memory access, and calculates a new address from a base register value and an offset and writes it back to the base register. The offset can be an immediate value or a register value. - -@encoding (T1) { - - @word 1 1 1 1 1 0 0 1 0 0 1 1 Rn(4) Rt(4) 1 1 1 0 imm8(8) - - @syntax - - @conv { - - reg_T = Register(Rt) - reg_N = Register(Rn) - imm32 = ZeroExtend(imm8, 32) - mem_access = MakeMemoryAccess(reg_N, imm32, NULL, true, true, false) - - } - -} - -@encoding (A1) { - - @word cond(4) 0 0 0 0 U(1) 1 1 1 Rn(4) Rt(4) imm4H(4) 1 1 1 1 imm4L(4) - - @syntax - - @conv { - - reg_T = Register(Rt) - reg_N = Register(Rn) - add = (U == '1') - imm32 = ZeroExtend(imm4H:imm4L, 32) - mem_access = MakeMemoryAccess(reg_N, imm32, NULL, false, add, false) - - } - - @rules { - - chk_call StoreCondition(cond) - - } - -} - -@encoding (A2) { - - @word cond(4) 0 0 0 0 U(1) 0 1 1 Rn(4) Rt(4) 0 0 0 0 1 1 1 1 Rm(4) - - @syntax - - @conv { - - reg_T = Register(Rt) - reg_N = Register(Rn) - reg_M = Register(Rm) - add = (U == '1') - mem_access = MakeMemoryAccess(reg_N, reg_M, NULL, false, add, false) - - } - - @rules { - - chk_call StoreCondition(cond) - - } - -} - diff --git a/src/arch/arm/v7/opdefs/ldrt_A8892.d b/src/arch/arm/v7/opdefs/ldrt_A8892.d deleted file mode 100644 index e13f0e7..0000000 --- a/src/arch/arm/v7/opdefs/ldrt_A8892.d +++ /dev/null @@ -1,93 +0,0 @@ - -/* Chrysalide - Outil d'analyse de fichiers binaires - * ##FILE## - traduction d'instructions ARMv7 - * - * Copyright (C) 2015 Cyrille Bagard - * - * This file is part of Chrysalide. - * - * Chrysalide is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Chrysalide is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Foobar. If not, see . - */ - - -@title LDRT - -@desc Load Register Unprivileged loads a word from memory, and writes it to a register. For information about memory accesses see Memory accesses on page A8-294. The memory access is restricted as if the processor were running in User mode. This makes no difference if the processor is actually running in User mode. LDRT is UNPREDICTABLE in Hyp mode. The Thumb instruction uses an offset addressing mode, that calculates the address used for the memory access from a base register value and an immediate offset, and leaves the base register unchanged. The ARM instruction uses a post-indexed addressing mode, that uses a base register value as the address for the memory access, and calculates a new address from a base register value and an offset and writes it back to the base register. The offset can be an immediate value or an optionally-shifted register value. - -@encoding (T1) { - - @word 1 1 1 1 1 0 0 0 0 1 0 1 Rn(4) Rt(4) 1 1 1 0 imm8(8) - - @syntax - - @conv { - - reg_T = Register(Rt) - reg_N = Register(Rn) - imm32 = ZeroExtend(imm8, 32) - mem_access = MakeMemoryAccess(reg_N, imm32, NULL, true, true, false) - - } - -} - -@encoding (A1) { - - @word cond(4) 0 1 0 0 U(1) 0 1 1 Rn(4) Rt(4) imm12(12) - - @syntax - - @conv { - - reg_T = Register(Rt) - reg_N = Register(Rn) - add = (U == '1') - imm32 = ZeroExtend(imm12, 32) - mem_access = MakeMemoryAccess(reg_N, imm32, NULL, false, add, false) - - } - - @rules { - - chk_call StoreCondition(cond) - - } - -} - -@encoding (A2) { - - @word cond(4) 0 1 1 0 U(1) 0 1 1 Rn(4) Rt(4) imm5(5) type(2) 0 Rm(4) - - @syntax - - @conv { - - reg_T = Register(Rt) - reg_N = Register(Rn) - reg_M = Register(Rm) - add = (U == '1') - shift = DecodeImmShift(type, imm5) - mem_access = MakeMemoryAccess(reg_N, reg_M, shift, false, add, false) - - } - - @rules { - - chk_call StoreCondition(cond) - - } - -} - diff --git a/src/arch/arm/v7/opdefs/lsl_A8894.d b/src/arch/arm/v7/opdefs/lsl_A8894.d deleted file mode 100644 index 89924c6..0000000 --- a/src/arch/arm/v7/opdefs/lsl_A8894.d +++ /dev/null @@ -1,91 +0,0 @@ - -/* Chrysalide - Outil d'analyse de fichiers binaires - * ##FILE## - traduction d'instructions ARMv7 - * - * Copyright (C) 2015 Cyrille Bagard - * - * This file is part of Chrysalide. - * - * Chrysalide is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Chrysalide is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Foobar. If not, see . - */ - - -@title LSL (immediate) - -@desc Logical Shift Left (immediate) shifts a register value left by an immediate number of bits, shifting in zeros, and writes the result to the destination register. It can optionally update the condition flags based on the result. - -@encoding (t1) { - - @half 0 0 0 0 0 imm5(5) Rm(3) Rd(3) - - @syntax "lsls" - - @conv { - - reg_D = Register(Rd) - reg_M = Register(Rm) - shift_imm = DecodeImmShift('00', imm5) - - } - -} - -@encoding (T2) { - - @word 1 1 1 0 1 0 1 0 0 1 0 S(1) 1 1 1 1 0 imm3(3) Rd(4) imm2(2) 0 0 Rm(4) - - @syntax - - @conv { - - reg_D = Register(Rd) - reg_M = Register(Rm) - setflags = (S == '1') - shift_imm = DecodeImmShift('00', imm3:imm2) - - } - - @rules { - - if (setflags); chk_call ExtendKeyword("s") - chk_call ExtendKeyword(".w") - - } - -} - -@encoding (A1) { - - @word cond(4) 0 0 0 1 1 0 1 S(1) 0 0 0 0 Rd(4) imm5(5) 0 0 0 Rm(4) - - @syntax - - @conv { - - reg_D = Register(Rd) - reg_M = Register(Rm) - setflags = (S == '1') - shift_imm = DecodeImmShift('00', imm5) - - } - - @rules { - - if (setflags); chk_call ExtendKeyword("s") - chk_call StoreCondition(cond) - - } - -} - diff --git a/src/arch/arm/v7/opdefs/lsl_A8895.d b/src/arch/arm/v7/opdefs/lsl_A8895.d deleted file mode 100644 index 4ac5ab6..0000000 --- a/src/arch/arm/v7/opdefs/lsl_A8895.d +++ /dev/null @@ -1,90 +0,0 @@ - -/* Chrysalide - Outil d'analyse de fichiers binaires - * ##FILE## - traduction d'instructions ARMv7 - * - * Copyright (C) 2015 Cyrille Bagard - * - * This file is part of Chrysalide. - * - * Chrysalide is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Chrysalide is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Foobar. If not, see . - */ - - -@title LSL (register) - -@desc Logical Shift Left (register) shifts a register value left by a variable number of bits, shifting in zeros, and writes the result to the destination register. The variable number of bits is read from the bottom byte of a register. It can optionally update the condition flags based on the result. - -@encoding (t1) { - - @half 0 1 0 0 0 0 0 0 1 0 Rm(3) Rdn(3) - - @syntax "lsls" - - @conv { - - reg_DN = Register(Rdn) - reg_M = Register(Rm) - - } - -} - -@encoding (T2) { - - @word 1 1 1 1 1 0 1 0 0 0 0 S(1) Rn(4) 1 1 1 1 Rd(4) 0 0 0 0 Rm(4) - - @syntax - - @conv { - - reg_D = Register(Rd) - reg_N = Register(Rn) - reg_M = Register(Rm) - setflags = (S == '1') - - } - - @rules { - - if (setflags); chk_call ExtendKeyword("s") - chk_call ExtendKeyword(".w") - - } - -} - -@encoding (A1) { - - @word cond(4) 0 0 0 1 1 0 1 S(1) 0 0 0 0 Rd(4) Rm(4) 0 0 0 1 Rn(4) - - @syntax - - @conv { - - reg_D = Register(Rd) - reg_N = Register(Rn) - reg_M = Register(Rm) - setflags = (S == '1') - - } - - @rules { - - if (setflags); chk_call ExtendKeyword("s") - chk_call StoreCondition(cond) - - } - -} - diff --git a/src/arch/arm/v7/opdefs/lsr_A8896.d b/src/arch/arm/v7/opdefs/lsr_A8896.d deleted file mode 100644 index acb9e25..0000000 --- a/src/arch/arm/v7/opdefs/lsr_A8896.d +++ /dev/null @@ -1,91 +0,0 @@ - -/* Chrysalide - Outil d'analyse de fichiers binaires - * ##FILE## - traduction d'instructions ARMv7 - * - * Copyright (C) 2015 Cyrille Bagard - * - * This file is part of Chrysalide. - * - * Chrysalide is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Chrysalide is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Foobar. If not, see . - */ - - -@title LSR (immediate) - -@desc Logical Shift Right (immediate) shifts a register value right by an immediate number of bits, shifting in zeros, and writes the result to the destination register. It can optionally update the condition flags based on the result. - -@encoding (t1) { - - @half 0 0 0 0 1 imm5(5) Rm(3) Rd(3) - - @syntax "lsrs" - - @conv { - - reg_D = Register(Rd) - reg_M = Register(Rm) - shift_imm = DecodeImmShift('01', imm5) - - } - -} - -@encoding (T2) { - - @word 1 1 1 0 1 0 1 0 0 1 0 S(1) 1 1 1 1 0 imm3(3) Rd(4) imm2(2) 0 1 Rm(4) - - @syntax - - @conv { - - reg_D = Register(Rd) - reg_M = Register(Rm) - setflags = (S == '1') - shift_imm = DecodeImmShift('01', imm3:imm2) - - } - - @rules { - - if (setflags); chk_call ExtendKeyword("s") - chk_call ExtendKeyword(".w") - - } - -} - -@encoding (A1) { - - @word cond(4) 0 0 0 1 1 0 1 S(1) 0 0 0 0 Rd(4) imm5(5) 0 1 0 Rm(4) - - @syntax - - @conv { - - reg_D = Register(Rd) - reg_M = Register(Rm) - setflags = (S == '1') - shift_imm = DecodeImmShift('01', imm5) - - } - - @rules { - - if (setflags); chk_call ExtendKeyword("s") - chk_call StoreCondition(cond) - - } - -} - diff --git a/src/arch/arm/v7/opdefs/lsr_A8897.d b/src/arch/arm/v7/opdefs/lsr_A8897.d deleted file mode 100644 index 070a152..0000000 --- a/src/arch/arm/v7/opdefs/lsr_A8897.d +++ /dev/null @@ -1,90 +0,0 @@ - -/* Chrysalide - Outil d'analyse de fichiers binaires - * ##FILE## - traduction d'instructions ARMv7 - * - * Copyright (C) 2015 Cyrille Bagard - * - * This file is part of Chrysalide. - * - * Chrysalide is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Chrysalide is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Foobar. If not, see . - */ - - -@title LSR (register) - -@desc Logical Shift Right (register) shifts a register value right by a variable number of bits, shifting in zeros, and writes the result to the destination register. The variable number of bits is read from the bottom byte of a register. It can optionally update the condition flags based on the result. - -@encoding (t1) { - - @half 0 1 0 0 0 0 0 0 1 1 Rm(3) Rdn(3) - - @syntax "lsrs" - - @conv { - - reg_DN = Register(Rdn) - reg_M = Register(Rm) - - } - -} - -@encoding (T2) { - - @word 1 1 1 1 1 0 1 0 0 0 1 S(1) Rn(4) 1 1 1 1 Rd(4) 0 0 0 0 Rm(4) - - @syntax - - @conv { - - reg_D = Register(Rd) - reg_N = Register(Rn) - reg_M = Register(Rm) - setflags = (S == '1') - - } - - @rules { - - if (setflags); chk_call ExtendKeyword("s") - chk_call ExtendKeyword(".w") - - } - -} - -@encoding (A1) { - - @word cond(4) 0 0 0 1 1 0 1 S(1) 0 0 0 0 Rd(4) Rm(4) 0 0 1 1 Rn(4) - - @syntax - - @conv { - - reg_D = Register(Rd) - reg_N = Register(Rn) - reg_M = Register(Rm) - setflags = (S == '1') - - } - - @rules { - - if (setflags); chk_call ExtendKeyword("s") - chk_call StoreCondition(cond) - - } - -} - diff --git a/src/arch/arm/v7/opdefs/mcr_A8898.d b/src/arch/arm/v7/opdefs/mcr_A8898.d deleted file mode 100644 index f710d5d..0000000 --- a/src/arch/arm/v7/opdefs/mcr_A8898.d +++ /dev/null @@ -1,109 +0,0 @@ - -/* Chrysalide - Outil d'analyse de fichiers binaires - * ##FILE## - traduction d'instructions ARMv7 - * - * Copyright (C) 2015 Cyrille Bagard - * - * This file is part of Chrysalide. - * - * Chrysalide is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Chrysalide is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Foobar. If not, see . - */ - - -@title MCR, MCR2 - -@desc Move to Coprocessor from ARM core register passes the value of an ARM core register to a coprocessor. If no coprocessor can execute the instruction, an Undefined Instruction exception is generated. This is a generic coprocessor instruction. Some of the fields have no functionality defined by the architecture and are free for use by the coprocessor instruction set designer. These are the opc1, opc2, CRn, and CRm fields. However, coprocessors CP8-CP15 are reserved for use by ARM, and this manual defines the valid MCR and MCR2 instructions when coproc is in the range p8-p15. For more information see Coprocessor support on page A2-94. In an implementation that includes the Virtualization Extensions, MCR accesses to system control registers can be trapped to Hyp mode, meaning that an attempt to execute an MCR instruction in a Non-secure mode other than Hyp mode, that would be permitted in the absence of the Hyp trap controls, generates a Hyp Trap exception. For more information, see Traps to the hypervisor on page B1-1247. Note Because of the range of possible traps to Hyp mode, the MCR pseudocode does not show these possible traps. - -@encoding (T1) { - - @word 1 1 1 0 1 1 1 0 opc1(3) 0 CRn(4) Rt(4) coproc(4) opc2(3) 1 CRm(4) - - @syntax - - @conv { - - reg_T = Register(Rt) - cp = CoProcessor(coproc) - undef_opc1 = RawValue(opc1) - creg_N = CRegister(CRn) - creg_M = CRegister(CRm) - undef_opc2 = RawValue(opc2) - - } - -} - -@encoding (A1) { - - @word cond(4) 1 1 1 0 opc1(3) 0 CRn(4) Rt(4) coproc(4) opc2(3) 1 CRm(4) - - @syntax - - @conv { - - reg_T = Register(Rt) - cp = CoProcessor(coproc) - undef_opc1 = RawValue(opc1) - creg_N = CRegister(CRn) - creg_M = CRegister(CRm) - undef_opc2 = RawValue(opc2) - - } - - @rules { - - chk_call StoreCondition(cond) - - } - -} - -@encoding (T2) { - - @word 1 1 1 1 1 1 1 0 opc1(3) 0 CRn(4) Rt(4) coproc(4) opc2(3) 1 CRm(4) - - @syntax "mcr2" - - @conv { - - reg_T = Register(Rt) - cp = CoProcessor(coproc) - undef_opc1 = RawValue(opc1) - creg_N = CRegister(CRn) - creg_M = CRegister(CRm) - undef_opc2 = RawValue(opc2) - - } - -} - -@encoding (A2) { - - @word 1 1 1 1 1 1 1 0 opc1(3) 0 CRn(4) Rt(4) coproc(4) opc2(3) 1 CRm(4) - - @syntax "mcr2" - - @conv { - - reg_T = Register(Rt) - cp = CoProcessor(coproc) - undef_opc1 = RawValue(opc1) - creg_N = CRegister(CRn) - creg_M = CRegister(CRm) - undef_opc2 = RawValue(opc2) - - } - -} - diff --git a/src/arch/arm/v7/opdefs/mcrr_A8899.d b/src/arch/arm/v7/opdefs/mcrr_A8899.d deleted file mode 100644 index f643826..0000000 --- a/src/arch/arm/v7/opdefs/mcrr_A8899.d +++ /dev/null @@ -1,105 +0,0 @@ - -/* Chrysalide - Outil d'analyse de fichiers binaires - * ##FILE## - traduction d'instructions ARMv7 - * - * Copyright (C) 2015 Cyrille Bagard - * - * This file is part of Chrysalide. - * - * Chrysalide is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Chrysalide is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Foobar. If not, see . - */ - - -@title MCRR, MCRR2 - -@desc Move to Coprocessor from two ARM core registers passes the values of two ARM core registers to a coprocessor. If no coprocessor can execute the instruction, an Undefined Instruction exception is generated. This is a generic coprocessor instruction. Some of the fields have no functionality defined by the architecture and are free for use by the coprocessor instruction set designer. These are the opc1 and CRm fields. However, coprocessors CP8-CP15 are reserved for use by ARM, and this manual defines the valid MCRR and MCRR2 instructions when coproc is in the range p8-p15. For more information see Coprocessor support on page A2-94. In an implementation that includes the Virtualization Extensions, MCRR accesses to system control registers can be trapped to Hyp mode, meaning that an attempt to execute an MCRR instruction in a Non-secure mode other than Hyp mode, that would be permitted in the absence of the Hyp trap controls, generates a Hyp Trap exception. For more information, see Traps to the hypervisor on page B1-1247. Note Because of the range of possible traps to Hyp mode, the MCRR pseudocode does not show these possible traps. - -@encoding (T1) { - - @word 1 1 1 0 1 1 0 0 0 1 0 0 Rt2(4) Rt(4) coproc(4) opc1(4) CRm(4) - - @syntax - - @conv { - - reg_T = Register(Rt) - reg_T2 = Register(Rt2) - cp = CoProcessor(coproc) - undef_opc1 = RawValue(opc1) - creg_M = CRegister(CRm) - - } - -} - -@encoding (A1) { - - @word cond(4) 1 1 0 0 0 1 0 0 Rt2(4) Rt(4) coproc(4) opc1(4) CRm(4) - - @syntax - - @conv { - - reg_T = Register(Rt) - reg_T2 = Register(Rt2) - cp = CoProcessor(coproc) - undef_opc1 = RawValue(opc1) - creg_M = CRegister(CRm) - - } - - @rules { - - chk_call StoreCondition(cond) - - } - -} - -@encoding (T2) { - - @word 1 1 1 1 1 1 0 0 0 1 0 0 Rt2(4) Rt(4) coproc(4) opc1(4) CRm(4) - - @syntax "mcrr2" - - @conv { - - reg_T = Register(Rt) - reg_T2 = Register(Rt2) - cp = CoProcessor(coproc) - undef_opc1 = RawValue(opc1) - creg_M = CRegister(CRm) - - } - -} - -@encoding (A2) { - - @word 1 1 1 1 1 1 0 0 0 1 0 0 Rt2(4) Rt(4) coproc(4) opc1(4) CRm(4) - - @syntax "mcrr2" - - @conv { - - reg_T = Register(Rt) - reg_T2 = Register(Rt2) - cp = CoProcessor(coproc) - undef_opc1 = RawValue(opc1) - creg_M = CRegister(CRm) - - } - -} - diff --git a/src/arch/arm/v7/opdefs/mla_A88100.d b/src/arch/arm/v7/opdefs/mla_A88100.d deleted file mode 100644 index 5d4b4e4..0000000 --- a/src/arch/arm/v7/opdefs/mla_A88100.d +++ /dev/null @@ -1,69 +0,0 @@ - -/* Chrysalide - Outil d'analyse de fichiers binaires - * ##FILE## - traduction d'instructions ARMv7 - * - * Copyright (C) 2015 Cyrille Bagard - * - * This file is part of Chrysalide. - * - * Chrysalide is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Chrysalide is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Foobar. If not, see . - */ - - -@title MLA - -@desc Multiply Accumulate multiplies two register values, and adds a third register value. The least significant 32 bits of the result are written to the destination register. These 32 bits do not depend on whether the source register values are considered to be signed values or unsigned values. In an ARM instruction, the condition flags can optionally be updated based on the result. Use of this option adversely affects performance on many processor implementations. - -@encoding (T1) { - - @word 1 1 1 1 1 0 1 1 0 0 0 0 Rn(4) Ra(4) Rd(4) 0 0 0 0 Rm(4) - - @syntax - - @conv { - - reg_D = Register(Rd) - reg_N = Register(Rn) - reg_M = Register(Rm) - reg_A = Register(Ra) - - } - -} - -@encoding (A1) { - - @word cond(4) 0 0 0 0 0 0 1 S(1) Rd(4) Ra(4) Rm(4) 1 0 0 1 Rn(4) - - @syntax - - @conv { - - reg_D = Register(Rd) - reg_N = Register(Rn) - reg_M = Register(Rm) - reg_A = Register(Ra) - setflags = (S == '1') - - } - - @rules { - - if (setflags); chk_call ExtendKeyword("s") - chk_call StoreCondition(cond) - - } - -} - diff --git a/src/arch/arm/v7/opdefs/mls_A88101.d b/src/arch/arm/v7/opdefs/mls_A88101.d deleted file mode 100644 index 4d10be8..0000000 --- a/src/arch/arm/v7/opdefs/mls_A88101.d +++ /dev/null @@ -1,67 +0,0 @@ - -/* Chrysalide - Outil d'analyse de fichiers binaires - * ##FILE## - traduction d'instructions ARMv7 - * - * Copyright (C) 2015 Cyrille Bagard - * - * This file is part of Chrysalide. - * - * Chrysalide is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Chrysalide is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Foobar. If not, see . - */ - - -@title MLS - -@desc Multiply and Subtract multiplies two register values, and subtracts the product from a third register value. The least significant 32 bits of the result are written to the destination register. These 32 bits do not depend on whether the source register values are considered to be signed values or unsigned values. - -@encoding (T1) { - - @word 1 1 1 1 1 0 1 1 0 0 0 0 Rn(4) Ra(4) Rd(4) 0 0 0 1 Rm(4) - - @syntax - - @conv { - - reg_D = Register(Rd) - reg_N = Register(Rn) - reg_M = Register(Rm) - reg_A = Register(Ra) - - } - -} - -@encoding (A1) { - - @word cond(4) 0 0 0 0 0 1 1 0 Rd(4) Ra(4) Rm(4) 1 0 0 1 Rn(4) - - @syntax - - @conv { - - reg_D = Register(Rd) - reg_N = Register(Rn) - reg_M = Register(Rm) - reg_A = Register(Ra) - - } - - @rules { - - chk_call StoreCondition(cond) - - } - -} - diff --git a/src/arch/arm/v7/opdefs/mov_A88102.d b/src/arch/arm/v7/opdefs/mov_A88102.d deleted file mode 100644 index d96baab..0000000 --- a/src/arch/arm/v7/opdefs/mov_A88102.d +++ /dev/null @@ -1,124 +0,0 @@ - -/* Chrysalide - Outil d'analyse de fichiers binaires - * ##FILE## - traduction d'instructions ARMv7 - * - * Copyright (C) 2015 Cyrille Bagard - * - * This file is part of Chrysalide. - * - * Chrysalide is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Chrysalide is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Foobar. If not, see . - */ - - -@title MOV (immediate) - -@desc Move (immediate) writes an immediate value to the destination register. It can optionally update the condition flags based on the value. - -@encoding (t1) { - - @half 0 0 1 0 0 Rd(3) imm8(8) - - @syntax "movs" - - @conv { - - reg_D = Register(Rd) - imm32 = ZeroExtend(imm8, 32) - - } - -} - -@encoding (T2) { - - @word 1 1 1 1 0 i(1) 0 0 0 1 0 S(1) 1 1 1 1 0 imm3(3) Rd(4) imm8(8) - - @syntax - - @conv { - - reg_D = Register(Rd) - setflags = (S == '1') - imm32 = ThumbExpandImm_C(i:imm3:imm8, 0) - - } - - @rules { - - if (setflags); chk_call ExtendKeyword("s") - chk_call ExtendKeyword(".w") - - } - -} - -@encoding (T3) { - - @word 1 1 1 1 0 i(1) 1 0 0 1 0 0 imm4(4) 0 imm3(3) Rd(4) imm8(8) - - @syntax "movw" - - @conv { - - reg_D = Register(Rd) - imm32 = ZeroExtend(imm4:i:imm3:imm8, 32) - - } - -} - -@encoding (A1) { - - @word cond(4) 0 0 1 1 1 0 1 S(1) 0 0 0 0 Rd(4) imm12(12) - - @syntax - - @conv { - - reg_D = Register(Rd) - setflags = (S == '1') - imm32 = ARMExpandImm_C(imm12, 0) - - } - - @rules { - - if (setflags); chk_call ExtendKeyword("s") - chk_call StoreCondition(cond) - - } - -} - -@encoding (A2) { - - @word cond(4) 0 0 1 1 0 0 0 0 imm4(4) Rd(4) imm12(12) - - @syntax "movw" - - @conv { - - reg_D = Register(Rd) - imm32 = ZeroExtend(imm4:imm12, 32) - - } - - @rules { - - chk_call StoreCondition(cond) - - } - -} - diff --git a/src/arch/arm/v7/opdefs/mov_A88103.d b/src/arch/arm/v7/opdefs/mov_A88103.d deleted file mode 100644 index cd3d75a..0000000 --- a/src/arch/arm/v7/opdefs/mov_A88103.d +++ /dev/null @@ -1,80 +0,0 @@ - -/* Chrysalide - Outil d'analyse de fichiers binaires - * ##FILE## - traduction d'instructions ARMv7 - * - * Copyright (C) 2015 Cyrille Bagard - * - * This file is part of Chrysalide. - * - * Chrysalide is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Chrysalide is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Foobar. If not, see . - */ - - -@title MOV (register, Thumb) - -@desc Move (register) copies a value from a register to the destination register. It can optionally update the condition flags based on the value. - -@encoding (t1) { - - @half 0 1 0 0 0 1 1 0 D(1) Rm(4) Rd(3) - - @syntax - - @conv { - - reg_D = Register(D:Rd) - reg_M = Register(Rm) - - } - -} - -@encoding (t2) { - - @half 0 0 0 0 0 0 0 0 0 0 Rm(3) Rd(3) - - @syntax "movs" - - @conv { - - reg_D = Register(Rd) - reg_M = Register(Rm) - - } - -} - -@encoding (T3) { - - @word 1 1 1 0 1 0 1 0 0 1 0 S(1) 1 1 1 1 0 0 0 0 Rd(4) 0 0 0 0 Rm(4) - - @syntax - - @conv { - - reg_D = Register(Rd) - reg_M = Register(Rm) - setflags = (S == '1') - - } - - @rules { - - if (setflags); chk_call ExtendKeyword("s") - chk_call ExtendKeyword(".w") - - } - -} - diff --git a/src/arch/arm/v7/opdefs/mov_A88104.d b/src/arch/arm/v7/opdefs/mov_A88104.d deleted file mode 100644 index d164983..0000000 --- a/src/arch/arm/v7/opdefs/mov_A88104.d +++ /dev/null @@ -1,50 +0,0 @@ - -/* Chrysalide - Outil d'analyse de fichiers binaires - * ##FILE## - traduction d'instructions ARMv7 - * - * Copyright (C) 2015 Cyrille Bagard - * - * This file is part of Chrysalide. - * - * Chrysalide is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Chrysalide is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Foobar. If not, see . - */ - - -@title MOV (register, ARM) - -@desc Move (register) copies a value from a register to the destination register. It can optionally update the condition flags based on the value. - -@encoding (A1) { - - @word cond(4) 0 0 0 1 1 0 1 S(1) 0 0 0 0 Rd(4) 0 0 0 0 0 0 0 0 Rm(4) - - @syntax - - @conv { - - reg_D = Register(Rd) - reg_M = Register(Rm) - setflags = (S == '1') - - } - - @rules { - - if (setflags); chk_call ExtendKeyword("s") - chk_call StoreCondition(cond) - - } - -} - diff --git a/src/arch/arm/v7/opdefs/movt_A88106.d b/src/arch/arm/v7/opdefs/movt_A88106.d deleted file mode 100644 index 265d008..0000000 --- a/src/arch/arm/v7/opdefs/movt_A88106.d +++ /dev/null @@ -1,63 +0,0 @@ - -/* Chrysalide - Outil d'analyse de fichiers binaires - * ##FILE## - traduction d'instructions ARMv7 - * - * Copyright (C) 2015 Cyrille Bagard - * - * This file is part of Chrysalide. - * - * Chrysalide is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Chrysalide is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Foobar. If not, see . - */ - - -@title MOVT - -@desc Move Top writes an immediate value to the top halfword of the destination register. It does not affect the contents of the bottom halfword. - -@encoding (T1) { - - @word 1 1 1 1 0 i(1) 1 0 1 1 0 0 imm4(4) 0 imm3(3) Rd(4) imm8(8) - - @syntax - - @conv { - - reg_D = Register(Rd) - imm16 = BuildImm16(imm4:i:imm3:imm8) - - } - -} - -@encoding (A1) { - - @word cond(4) 0 0 1 1 0 1 0 0 imm4(4) Rd(4) imm12(12) - - @syntax - - @conv { - - reg_D = Register(Rd) - imm16 = BuildImm16(imm4:imm12) - - } - - @rules { - - chk_call StoreCondition(cond) - - } - -} - diff --git a/src/arch/arm/v7/opdefs/mrc_A88107.d b/src/arch/arm/v7/opdefs/mrc_A88107.d deleted file mode 100644 index fb9714c..0000000 --- a/src/arch/arm/v7/opdefs/mrc_A88107.d +++ /dev/null @@ -1,109 +0,0 @@ - -/* Chrysalide - Outil d'analyse de fichiers binaires - * ##FILE## - traduction d'instructions ARMv7 - * - * Copyright (C) 2015 Cyrille Bagard - * - * This file is part of Chrysalide. - * - * Chrysalide is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Chrysalide is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Foobar. If not, see . - */ - - -@title MRC, MRC2 - -@desc Move to ARM core register from Coprocessor causes a coprocessor to transfer a value to an ARM core register or to the condition flags. If no coprocessor can execute the instruction, an Undefined Instruction exception is generated. This is a generic coprocessor instruction. Some of the fields have no functionality defined by the architecture and are free for use by the coprocessor instruction set designer. These are the opc1, opc2, CRn, and CRm fields. However, coprocessors CP8-CP15 are reserved for use by ARM, and this manual defines the valid MRC and MRC2 instructions when coproc is in the range p8-p15. For more information see Coprocessor support on page A2-94. In an implementation that includes the Virtualization Extensions, MRC accesses to system control registers can be trapped to Hyp mode, meaning that an attempt to execute an MRC instruction in a Non-secure mode other than Hyp mode, that would be permitted in the absence of the Hyp trap controls, generates a Hyp Trap exception. For more information, see Traps to the hypervisor on page B1-1247. Note Because of the range of possible traps to Hyp mode, the MRC pseudocode does not show these possible traps. - -@encoding (T1) { - - @word 1 1 1 0 1 1 1 0 opc1(3) 1 CRn(4) Rt(4) coproc(4) opc2(3) 1 CRm(4) - - @syntax - - @conv { - - reg_T = Register(Rt) - cp = CoProcessor(coproc) - undef_opc1 = RawValue(opc1) - creg_N = CRegister(CRn) - creg_M = CRegister(CRm) - undef_opc2 = RawValue(opc2) - - } - -} - -@encoding (A1) { - - @word cond(4) 1 1 1 0 opc1(3) 1 CRn(4) Rt(4) coproc(4) opc2(3) 1 CRm(4) - - @syntax - - @conv { - - reg_T = Register(Rt) - cp = CoProcessor(coproc) - undef_opc1 = RawValue(opc1) - creg_N = CRegister(CRn) - creg_M = CRegister(CRm) - undef_opc2 = RawValue(opc2) - - } - - @rules { - - chk_call StoreCondition(cond) - - } - -} - -@encoding (T2) { - - @word 1 1 1 1 1 1 1 0 opc1(3) 1 CRn(4) Rt(4) coproc(4) opc2(3) 1 CRm(4) - - @syntax "mrc2" - - @conv { - - reg_T = Register(Rt) - cp = CoProcessor(coproc) - undef_opc1 = RawValue(opc1) - creg_N = CRegister(CRn) - creg_M = CRegister(CRm) - undef_opc2 = RawValue(opc2) - - } - -} - -@encoding (A2) { - - @word 1 1 1 1 1 1 1 0 opc1(3) 1 CRn(4) Rt(4) coproc(4) opc2(3) 1 CRm(4) - - @syntax "mrc2" - - @conv { - - reg_T = Register(Rt) - cp = CoProcessor(coproc) - undef_opc1 = RawValue(opc1) - creg_N = CRegister(CRn) - creg_M = CRegister(CRm) - undef_opc2 = RawValue(opc2) - - } - -} - diff --git a/src/arch/arm/v7/opdefs/mrrc_A88108.d b/src/arch/arm/v7/opdefs/mrrc_A88108.d deleted file mode 100644 index 026c0ef..0000000 --- a/src/arch/arm/v7/opdefs/mrrc_A88108.d +++ /dev/null @@ -1,105 +0,0 @@ - -/* Chrysalide - Outil d'analyse de fichiers binaires - * ##FILE## - traduction d'instructions ARMv7 - * - * Copyright (C) 2015 Cyrille Bagard - * - * This file is part of Chrysalide. - * - * Chrysalide is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Chrysalide is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Foobar. If not, see . - */ - - -@title MRRC, MRRC2 - -@desc Move to two ARM core registers from Coprocessor causes a coprocessor to transfer values to two ARM core registers. If no coprocessor can execute the instruction, an Undefined Instruction exception is generated. This is a generic coprocessor instruction. Some of the fields have no functionality defined by the architecture and are free for use by the coprocessor instruction set designer. These are the opc1 and CRm fields. However, coprocessors CP8-CP15 are reserved for use by ARM, and this manual defines the valid MRRC and MRRC2 instructions when coproc is in the range p8-p15. For more information see Coprocessor support on page A2-94. In an implementation that includes the Virtualization Extensions, MRRC accesses to system control registers can be trapped to Hyp mode, meaning that an attempt to execute an MRRC instruction in a Non-secure mode other than Hyp mode, that would be permitted in the absence of the Hyp trap controls, generates a Hyp Trap exception. For more information, see Traps to the hypervisor on page B1-1247. Note Because of the range of possible traps to Hyp mode, the MRRC pseudocode does not show these possible traps. - -@encoding (T1) { - - @word 1 1 1 0 1 1 0 0 0 1 0 1 Rt2(4) Rt(4) coproc(4) opc1(4) CRm(4) - - @syntax - - @conv { - - reg_T = Register(Rt) - reg_T2 = Register(Rt2) - cp = CoProcessor(coproc) - opc = RawValue(opc1) - creg_M = CRegister(CRm) - - } - -} - -@encoding (A1) { - - @word cond(4) 1 1 0 0 0 1 0 1 Rt2(4) Rt(4) coproc(4) opc1(4) CRm(4) - - @syntax - - @conv { - - reg_T = Register(Rt) - reg_T2 = Register(Rt2) - cp = CoProcessor(coproc) - opc = RawValue(opc1) - creg_M = CRegister(CRm) - - } - - @rules { - - chk_call StoreCondition(cond) - - } - -} - -@encoding (T2) { - - @word 1 1 1 1 1 1 0 0 0 1 0 1 Rt2(4) Rt(4) coproc(4) opc1(4) CRm(4) - - @syntax "mrrc2" - - @conv { - - reg_T = Register(Rt) - reg_T2 = Register(Rt2) - cp = CoProcessor(coproc) - opc = RawValue(opc1) - creg_M = CRegister(CRm) - - } - -} - -@encoding (A2) { - - @word 1 1 1 1 1 1 0 0 0 1 0 1 Rt2(4) Rt(4) coproc(4) opc1(4) CRm(4) - - @syntax "mrrc2" - - @conv { - - reg_T = Register(Rt) - reg_T2 = Register(Rt2) - cp = CoProcessor(coproc) - opc = RawValue(opc1) - creg_M = CRegister(CRm) - - } - -} - diff --git a/src/arch/arm/v7/opdefs/mul_A88114.d b/src/arch/arm/v7/opdefs/mul_A88114.d deleted file mode 100644 index fa250b7..0000000 --- a/src/arch/arm/v7/opdefs/mul_A88114.d +++ /dev/null @@ -1,83 +0,0 @@ - -/* Chrysalide - Outil d'analyse de fichiers binaires - * ##FILE## - traduction d'instructions ARMv7 - * - * Copyright (C) 2015 Cyrille Bagard - * - * This file is part of Chrysalide. - * - * Chrysalide is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Chrysalide is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Foobar. If not, see . - */ - - -@title MUL - -@desc Multiply multiplies two register values. The least significant 32 bits of the result are written to the destination register. These 32 bits do not depend on whether the source register values are considered to be signed values or unsigned values. Optionally, it can update the condition flags based on the result. In the Thumb instruction set, this option is limited to only a few forms of the instruction. Use of this option adversely affects performance on many processor implementations. - -@encoding (t1) { - - @half 0 1 0 0 0 0 1 1 0 1 Rn(3) Rdm(3) - - @syntax "muls" - - @conv { - - reg_N = Register(Rn) - reg_DM_1 = Register(Rdm) - reg_DM_2 = Register(Rdm) - - } - -} - -@encoding (T2) { - - @word 1 1 1 1 1 0 1 1 0 0 0 0 Rn(4) 1 1 1 1 Rd(4) 0 0 0 0 Rm(4) - - @syntax - - @conv { - - reg_D = Register(Rd) - reg_N = Register(Rn) - reg_M = Register(Rm) - - } - -} - -@encoding (A1) { - - @word cond(4) 0 0 0 0 0 0 0 S(1) Rd(4) 0 0 0 0 Rm(4) 1 0 0 1 Rn(4) - - @syntax - - @conv { - - reg_D = Register(Rd) - reg_N = Register(Rn) - reg_M = Register(Rm) - setflags = (S == '1') - - } - - @rules { - - if (setflags); chk_call ExtendKeyword("s") - chk_call StoreCondition(cond) - - } - -} - diff --git a/src/arch/arm/v7/opdefs/mvn_A88115.d b/src/arch/arm/v7/opdefs/mvn_A88115.d deleted file mode 100644 index 2955439..0000000 --- a/src/arch/arm/v7/opdefs/mvn_A88115.d +++ /dev/null @@ -1,72 +0,0 @@ - -/* Chrysalide - Outil d'analyse de fichiers binaires - * ##FILE## - traduction d'instructions ARMv7 - * - * Copyright (C) 2015 Cyrille Bagard - * - * This file is part of Chrysalide. - * - * Chrysalide is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Chrysalide is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Foobar. If not, see . - */ - - -@title MVN (immediate) - -@desc Bitwise NOT (immediate) writes the bitwise inverse of an immediate value to the destination register. It can optionally update the condition flags based on the value. - -@encoding (T1) { - - @word 1 1 1 1 0 i(1) 0 0 0 1 1 S(1) 1 1 1 1 0 imm3(3) Rd(4) imm8(8) - - @syntax - - @conv { - - reg_D = Register(Rd) - setflags = (S == '1') - imm32 = ThumbExpandImm_C(i:imm3:imm8, 0) - - } - - @rules { - - if (setflags); chk_call ExtendKeyword("s") - - } - -} - -@encoding (A1) { - - @word cond(4) 0 0 1 1 1 1 1 S(1) 0 0 0 0 Rd(4) imm12(12) - - @syntax - - @conv { - - reg_D = Register(Rd) - setflags = (S == '1') - imm32 = ARMExpandImm_C(imm12, 0) - - } - - @rules { - - if (setflags); chk_call ExtendKeyword("s") - chk_call StoreCondition(cond) - - } - -} - diff --git a/src/arch/arm/v7/opdefs/mvn_A88116.d b/src/arch/arm/v7/opdefs/mvn_A88116.d deleted file mode 100644 index 1f3f390..0000000 --- a/src/arch/arm/v7/opdefs/mvn_A88116.d +++ /dev/null @@ -1,90 +0,0 @@ - -/* Chrysalide - Outil d'analyse de fichiers binaires - * ##FILE## - traduction d'instructions ARMv7 - * - * Copyright (C) 2015 Cyrille Bagard - * - * This file is part of Chrysalide. - * - * Chrysalide is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Chrysalide is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Foobar. If not, see . - */ - - -@title MVN (register) - -@desc Bitwise NOT (register) writes the bitwise inverse of a register value to the destination register. It can optionally update the condition flags based on the result. - -@encoding (t1) { - - @half 0 1 0 0 0 0 1 1 1 1 Rm(3) Rd(3) - - @syntax "mvns" - - @conv { - - reg_D = Register(Rd) - reg_M = Register(Rm) - - } - -} - -@encoding (T2) { - - @word 1 1 1 0 1 0 1 0 0 1 1 S(1) 1 1 1 1 0 imm3(3) Rd(4) imm2(2) type(2) Rm(4) - - @syntax - - @conv { - - reg_D = Register(Rd) - reg_M = Register(Rm) - setflags = (S == '1') - shift = DecodeImmShift(type, imm3:imm2) - - } - - @rules { - - if (setflags); chk_call ExtendKeyword("s") - chk_call ExtendKeyword(".w") - - } - -} - -@encoding (A1) { - - @word cond(4) 0 0 0 1 1 1 1 S(1) 0 0 0 0 Rd(4) imm5(5) type(2) 0 Rm(4) - - @syntax - - @conv { - - reg_D = Register(Rd) - reg_M = Register(Rm) - setflags = (S == '1') - shift = DecodeImmShift(type, imm5) - - } - - @rules { - - if (setflags); chk_call ExtendKeyword("s") - chk_call StoreCondition(cond) - - } - -} - diff --git a/src/arch/arm/v7/opdefs/mvn_A88117.d b/src/arch/arm/v7/opdefs/mvn_A88117.d deleted file mode 100644 index cc6ef16..0000000 --- a/src/arch/arm/v7/opdefs/mvn_A88117.d +++ /dev/null @@ -1,51 +0,0 @@ - -/* Chrysalide - Outil d'analyse de fichiers binaires - * ##FILE## - traduction d'instructions ARMv7 - * - * Copyright (C) 2015 Cyrille Bagard - * - * This file is part of Chrysalide. - * - * Chrysalide is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Chrysalide is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Foobar. If not, see . - */ - - -@title MVN (register-shifted register) - -@desc Bitwise NOT (register-shifted register) writes the bitwise inverse of a register-shifted register value to the destination register. It can optionally update the condition flags based on the result. - -@encoding (A1) { - - @word cond(4) 0 0 0 1 1 1 1 S(1) 0 0 0 0 Rd(4) Rs(4) 0 type(2) 1 Rm(4) - - @syntax - - @conv { - - reg_shift = RegisterShift(type, Rs) - reg_D = Register(Rd) - reg_M = Register(Rm) - setflags = (S == '1') - - } - - @rules { - - if (setflags); chk_call ExtendKeyword("s") - chk_call StoreCondition(cond) - - } - -} - diff --git a/src/arch/arm/v7/opdefs/nop_A88119.d b/src/arch/arm/v7/opdefs/nop_A88119.d deleted file mode 100644 index 84c495a..0000000 --- a/src/arch/arm/v7/opdefs/nop_A88119.d +++ /dev/null @@ -1,53 +0,0 @@ - -/* Chrysalide - Outil d'analyse de fichiers binaires - * ##FILE## - traduction d'instructions ARMv7 - * - * Copyright (C) 2015 Cyrille Bagard - * - * This file is part of Chrysalide. - * - * Chrysalide is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Chrysalide is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Foobar. If not, see . - */ - - -@title NOP - -@desc No Operation does nothing. This instruction can be used for instruction alignment purposes. See Pre-UAL pseudo-instruction NOP on page AppxH-2472 for details of NOP before the introduction of UAL and the ARMv6K and ARMv6T2 architecture variants. Note The timing effects of including a NOP instruction in a program are not guaranteed. It can increase execution time, leave it unchanged, or even reduce it. Therefore, NOP instructions are not suitable for timing loops. - -@encoding (t1) { - - @half 1 0 1 1 1 1 1 1 0 0 0 0 0 0 0 0 - -} - -@encoding (T2) { - - @word 1 1 1 1 0 0 1 1 1 0 1 0 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - - @syntax ".W" - -} - -@encoding (A1) { - - @word cond(4) 0 0 1 1 0 0 1 0 0 0 0 0 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 - - @rules { - - chk_call StoreCondition(cond) - - } - -} - diff --git a/src/arch/arm/v7/opdefs/orn_A88120.d b/src/arch/arm/v7/opdefs/orn_A88120.d deleted file mode 100644 index b823b6c..0000000 --- a/src/arch/arm/v7/opdefs/orn_A88120.d +++ /dev/null @@ -1,50 +0,0 @@ - -/* Chrysalide - Outil d'analyse de fichiers binaires - * ##FILE## - traduction d'instructions ARMv7 - * - * Copyright (C) 2015 Cyrille Bagard - * - * This file is part of Chrysalide. - * - * Chrysalide is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Chrysalide is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Foobar. If not, see . - */ - - -@title ORN (immediate) - -@desc Bitwise OR NOT (immediate) performs a bitwise (inclusive) OR of a register value and the complement of an immediate value, and writes the result to the destination register. It can optionally update the condition flags based on the result. - -@encoding (T1) { - - @word 1 1 1 1 0 i(1) 0 0 0 1 1 S(1) Rn(4) 0 imm3(3) Rd(4) imm8(8) - - @syntax - - @conv { - - reg_D = Register(Rd) - reg_N = Register(Rn) - setflags = (S == '1') - imm32 = ThumbExpandImm_C(i:imm3:imm8, 0) - - } - - @rules { - - if (setflags); chk_call ExtendKeyword("s") - - } - -} - diff --git a/src/arch/arm/v7/opdefs/orn_A88121.d b/src/arch/arm/v7/opdefs/orn_A88121.d deleted file mode 100644 index f1523ec..0000000 --- a/src/arch/arm/v7/opdefs/orn_A88121.d +++ /dev/null @@ -1,51 +0,0 @@ - -/* Chrysalide - Outil d'analyse de fichiers binaires - * ##FILE## - traduction d'instructions ARMv7 - * - * Copyright (C) 2015 Cyrille Bagard - * - * This file is part of Chrysalide. - * - * Chrysalide is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Chrysalide is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Foobar. If not, see . - */ - - -@title ORN (register) - -@desc Bitwise OR NOT (register) performs a bitwise (inclusive) OR of a register value and the complement of an optionally-shifted register value, and writes the result to the destination register. It can optionally update the condition flags based on the result. - -@encoding (T1) { - - @word 1 1 1 0 1 0 1 0 0 1 1 S(1) Rn(4) 0 imm3(3) Rd(4) imm2(2) type(2) Rm(4) - - @syntax - - @conv { - - reg_D = Register(Rd) - reg_N = Register(Rn) - reg_M = Register(Rm) - setflags = (S == '1') - shift = DecodeImmShift(type, imm3:imm2) - - } - - @rules { - - if (setflags); chk_call ExtendKeyword("s") - - } - -} - diff --git a/src/arch/arm/v7/opdefs/orr_A88122.d b/src/arch/arm/v7/opdefs/orr_A88122.d deleted file mode 100644 index 766b5ee..0000000 --- a/src/arch/arm/v7/opdefs/orr_A88122.d +++ /dev/null @@ -1,74 +0,0 @@ - -/* Chrysalide - Outil d'analyse de fichiers binaires - * ##FILE## - traduction d'instructions ARMv7 - * - * Copyright (C) 2015 Cyrille Bagard - * - * This file is part of Chrysalide. - * - * Chrysalide is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Chrysalide is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Foobar. If not, see . - */ - - -@title ORR (immediate) - -@desc Bitwise OR (immediate) performs a bitwise (inclusive) OR of a register value and an immediate value, and writes the result to the destination register. It can optionally update the condition flags based on the result. - -@encoding (T1) { - - @word 1 1 1 1 0 i(1) 0 0 0 1 0 S(1) Rn(4) 0 imm3(3) Rd(4) imm8(8) - - @syntax - - @conv { - - reg_D = Register(Rd) - reg_N = Register(Rn) - setflags = (S == '1') - imm32 = ThumbExpandImm_C(i:imm3:imm8, 0) - - } - - @rules { - - if (setflags); chk_call ExtendKeyword("s") - - } - -} - -@encoding (A1) { - - @word cond(4) 0 0 1 1 1 0 0 S(1) Rn(4) Rd(4) imm12(12) - - @syntax - - @conv { - - reg_D = Register(Rd) - reg_N = Register(Rn) - setflags = (S == '1') - imm32 = ARMExpandImm_C(imm12, 0) - - } - - @rules { - - if (setflags); chk_call ExtendKeyword("s") - chk_call StoreCondition(cond) - - } - -} - diff --git a/src/arch/arm/v7/opdefs/orr_A88123.d b/src/arch/arm/v7/opdefs/orr_A88123.d deleted file mode 100644 index 2395c89..0000000 --- a/src/arch/arm/v7/opdefs/orr_A88123.d +++ /dev/null @@ -1,92 +0,0 @@ - -/* Chrysalide - Outil d'analyse de fichiers binaires - * ##FILE## - traduction d'instructions ARMv7 - * - * Copyright (C) 2015 Cyrille Bagard - * - * This file is part of Chrysalide. - * - * Chrysalide is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Chrysalide is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Foobar. If not, see . - */ - - -@title ORR (register) - -@desc Bitwise OR (register) performs a bitwise (inclusive) OR of a register value and an optionally-shifted register value, and writes the result to the destination register. It can optionally update the condition flags based on the result. - -@encoding (t1) { - - @half 0 1 0 0 0 0 1 1 0 0 Rm(3) Rdn(3) - - @syntax "orrs" - - @conv { - - reg_DN = Register(Rdn) - reg_M = Register(Rm) - - } - -} - -@encoding (T2) { - - @word 1 1 1 0 1 0 1 0 0 1 0 S(1) Rn(4) 0 imm3(3) Rd(4) imm2(2) type(2) Rm(4) - - @syntax - - @conv { - - reg_D = Register(Rd) - reg_N = Register(Rn) - reg_M = Register(Rm) - setflags = (S == '1') - shift = DecodeImmShift(type, imm3:imm2) - - } - - @rules { - - if (setflags); chk_call ExtendKeyword("s") - chk_call ExtendKeyword(".w") - - } - -} - -@encoding (A1) { - - @word cond(4) 0 0 0 1 1 0 0 S(1) Rn(4) Rd(4) imm5(5) type(2) 0 Rm(4) - - @syntax - - @conv { - - reg_D = Register(Rd) - reg_N = Register(Rn) - reg_M = Register(Rm) - setflags = (S == '1') - shift = DecodeImmShift(type, imm5) - - } - - @rules { - - if (setflags); chk_call ExtendKeyword("s") - chk_call StoreCondition(cond) - - } - -} - diff --git a/src/arch/arm/v7/opdefs/orr_A88124.d b/src/arch/arm/v7/opdefs/orr_A88124.d deleted file mode 100644 index f4d78b9..0000000 --- a/src/arch/arm/v7/opdefs/orr_A88124.d +++ /dev/null @@ -1,52 +0,0 @@ - -/* Chrysalide - Outil d'analyse de fichiers binaires - * ##FILE## - traduction d'instructions ARMv7 - * - * Copyright (C) 2015 Cyrille Bagard - * - * This file is part of Chrysalide. - * - * Chrysalide is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Chrysalide is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Foobar. If not, see . - */ - - -@title ORR (register-shifted register) - -@desc Bitwise OR (register-shifted register) performs a bitwise (inclusive) OR of a register value and a register-shifted register value, and writes the result to the destination register. It can optionally update the condition flags based on the result. - -@encoding (A1) { - - @word cond(4) 0 0 0 1 1 0 0 S(1) Rn(4) Rd(4) Rs(4) 0 type(2) 1 Rm(4) - - @syntax - - @conv { - - reg_shift = RegisterShift(type, Rs) - reg_D = Register(Rd) - reg_N = Register(Rn) - reg_M = Register(Rm) - setflags = (S == '1') - - } - - @rules { - - if (setflags); chk_call ExtendKeyword("s") - chk_call StoreCondition(cond) - - } - -} - diff --git a/src/arch/arm/v7/opdefs/pop_A88131.d b/src/arch/arm/v7/opdefs/pop_A88131.d deleted file mode 100644 index 2dee09a..0000000 --- a/src/arch/arm/v7/opdefs/pop_A88131.d +++ /dev/null @@ -1,87 +0,0 @@ - -/* Chrysalide - Outil d'analyse de fichiers binaires - * ##FILE## - traduction d'instructions ARMv7 - * - * Copyright (C) 2015 Cyrille Bagard - * - * This file is part of Chrysalide. - * - * Chrysalide is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Chrysalide is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Foobar. If not, see . - */ - - -@title POP (Thumb) - -@desc Pop Multiple Registers loads multiple registers from the stack, loading from consecutive memory locations starting at the address in SP, and updates SP to point just above the loaded data. - -@encoding (t1) { - - @half 1 0 1 1 1 1 0 P(1) register_list(8) - - @syntax - - @conv { - - registers = RegistersList(P:'0000000':register_list) - - } - - @hooks { - - link = handle_armv7_return_from_pop - - } - -} - -@encoding (T2) { - - @word 1 1 1 0 1 0 0 0 1 0 1 1 1 1 0 1 P(1) M(1) 0 register_list(13) - - @syntax ".W" - - @conv { - - registers = RegistersList(P:M:'0':register_list) - - } - - @hooks { - - link = handle_armv7_return_from_pop - - } - -} - -@encoding (T3) { - - @word 1 1 1 1 1 0 0 0 0 1 0 1 1 1 0 1 Rt(4) 1 0 1 1 0 0 0 0 0 1 0 0 - - @syntax ".W" - - @conv { - - registers = RegistersList(1 << Rt) - - } - - @hooks { - - link = handle_armv7_return_from_pop - - } - -} - diff --git a/src/arch/arm/v7/opdefs/pop_A88132.d b/src/arch/arm/v7/opdefs/pop_A88132.d deleted file mode 100644 index 27bbf3b..0000000 --- a/src/arch/arm/v7/opdefs/pop_A88132.d +++ /dev/null @@ -1,79 +0,0 @@ - -/* Chrysalide - Outil d'analyse de fichiers binaires - * ##FILE## - traduction d'instructions ARMv7 - * - * Copyright (C) 2015 Cyrille Bagard - * - * This file is part of Chrysalide. - * - * Chrysalide is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Chrysalide is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Foobar. If not, see . - */ - - -@title POP (ARM) - -@desc Pop Multiple Registers loads multiple registers from the stack, loading from consecutive memory locations starting at the address in SP, and updates SP to point just above the loaded data. - -@encoding (A1) { - - @word cond(4) 1 0 0 0 1 0 1 1 1 1 0 1 register_list(16) - - @syntax - - @conv { - - registers = RegistersList(register_list) - - } - - @rules { - - chk_call StoreCondition(cond) - - } - - @hooks { - - link = handle_armv7_return_from_pop - - } - -} - -@encoding (A2) { - - @word cond(4) 0 1 0 0 1 0 0 1 1 1 0 1 Rt(4) 0 0 0 0 0 0 0 0 0 1 0 0 - - @syntax - - @conv { - - registers = RegistersList(1 << Rt) - - } - - @rules { - - chk_call StoreCondition(cond) - - } - - @hooks { - - link = handle_armv7_return_from_pop - - } - -} - diff --git a/src/arch/arm/v7/opdefs/push_A88133.d b/src/arch/arm/v7/opdefs/push_A88133.d deleted file mode 100644 index 14fc3e9..0000000 --- a/src/arch/arm/v7/opdefs/push_A88133.d +++ /dev/null @@ -1,109 +0,0 @@ - -/* Chrysalide - Outil d'analyse de fichiers binaires - * ##FILE## - traduction d'instructions ARMv7 - * - * Copyright (C) 2015 Cyrille Bagard - * - * This file is part of Chrysalide. - * - * Chrysalide is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Chrysalide is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Foobar. If not, see . - */ - - -@title PUSH - -@desc Push Multiple Registers stores multiple registers to the stack, storing to consecutive memory locations ending just below the address in SP, and updates SP to point to the start of the stored data. - -@encoding (t1) { - - @half 1 0 1 1 0 1 0 M(1) register_list(8) - - @syntax - - @conv { - - registers = RegistersList('0':M:'000000':register_list) - - } - -} - -@encoding (T2) { - - @word 1 1 1 0 1 0 0 1 0 0 1 0 1 1 0 1 0 M(1) 0 register_list(13) - - @syntax ".W" - - @conv { - - registers = RegistersList('0':M:'0':register_list) - - } - -} - -@encoding (T3) { - - @word 1 1 1 1 1 0 0 0 0 1 0 0 1 1 0 1 Rt(4) 1 1 0 1 0 0 0 0 0 1 0 0 - - @syntax ".W" - - @conv { - - registers = Zeros(16) - - } - -} - -@encoding (A1) { - - @word cond(4) 1 0 0 1 0 0 1 0 1 1 0 1 register_list(16) - - @syntax - - @conv { - - registers = RegistersList(register_list) - - } - - @rules { - - chk_call StoreCondition(cond) - - } - -} - -@encoding (A2) { - - @word cond(4) 0 1 0 1 0 0 1 0 1 1 0 1 Rt(4) 0 0 0 0 0 0 0 0 0 1 0 0 - - @syntax - - @conv { - - registers = Zeros(16) - - } - - @rules { - - chk_call StoreCondition(cond) - - } - -} - diff --git a/src/arch/arm/v7/opdefs/qadd16_A88135.d b/src/arch/arm/v7/opdefs/qadd16_A88135.d deleted file mode 100644 index 15af29d..0000000 --- a/src/arch/arm/v7/opdefs/qadd16_A88135.d +++ /dev/null @@ -1,65 +0,0 @@ - -/* Chrysalide - Outil d'analyse de fichiers binaires - * ##FILE## - traduction d'instructions ARMv7 - * - * Copyright (C) 2015 Cyrille Bagard - * - * This file is part of Chrysalide. - * - * Chrysalide is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Chrysalide is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Foobar. If not, see . - */ - - -@title QADD16 - -@desc Saturating Add 16 performs two 16-bit integer additions, saturates the results to the 16-bit signed integer range –215 ≤ x ≤ 215 – 1, and writes the results to the destination register. - -@encoding (T1) { - - @word 1 1 1 1 1 0 1 0 1 0 0 1 Rn(4) 1 1 1 1 Rd(4) 0 0 0 1 Rm(4) - - @syntax - - @conv { - - reg_D = Register(Rd) - reg_N = Register(Rn) - reg_M = Register(Rm) - - } - -} - -@encoding (A1) { - - @word cond(4) 0 1 1 0 0 0 1 0 Rn(4) Rd(4) 1 1 1 1 0 0 0 1 Rm(4) - - @syntax - - @conv { - - reg_D = Register(Rd) - reg_N = Register(Rn) - reg_M = Register(Rm) - - } - - @rules { - - chk_call StoreCondition(cond) - - } - -} - diff --git a/src/arch/arm/v7/opdefs/qadd8_A88136.d b/src/arch/arm/v7/opdefs/qadd8_A88136.d deleted file mode 100644 index a71b251..0000000 --- a/src/arch/arm/v7/opdefs/qadd8_A88136.d +++ /dev/null @@ -1,65 +0,0 @@ - -/* Chrysalide - Outil d'analyse de fichiers binaires - * ##FILE## - traduction d'instructions ARMv7 - * - * Copyright (C) 2015 Cyrille Bagard - * - * This file is part of Chrysalide. - * - * Chrysalide is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Chrysalide is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Foobar. If not, see . - */ - - -@title QADD8 - -@desc Saturating Add 8 performs four 8-bit integer additions, saturates the results to the 8-bit signed integer range –27 ≤ x ≤ 27 – 1, and writes the results to the destination register. - -@encoding (T1) { - - @word 1 1 1 1 1 0 1 0 1 0 0 0 Rn(4) 1 1 1 1 Rd(4) 0 0 0 1 Rm(4) - - @syntax - - @conv { - - reg_D = Register(Rd) - reg_N = Register(Rn) - reg_M = Register(Rm) - - } - -} - -@encoding (A1) { - - @word cond(4) 0 1 1 0 0 0 1 0 Rn(4) Rd(4) 1 1 1 1 1 0 0 1 Rm(4) - - @syntax - - @conv { - - reg_D = Register(Rd) - reg_N = Register(Rn) - reg_M = Register(Rm) - - } - - @rules { - - chk_call StoreCondition(cond) - - } - -} - diff --git a/src/arch/arm/v7/opdefs/qadd_A88134.d b/src/arch/arm/v7/opdefs/qadd_A88134.d deleted file mode 100644 index f932983..0000000 --- a/src/arch/arm/v7/opdefs/qadd_A88134.d +++ /dev/null @@ -1,65 +0,0 @@ - -/* Chrysalide - Outil d'analyse de fichiers binaires - * ##FILE## - traduction d'instructions ARMv7 - * - * Copyright (C) 2015 Cyrille Bagard - * - * This file is part of Chrysalide. - * - * Chrysalide is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Chrysalide is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Foobar. If not, see . - */ - - -@title QADD - -@desc Saturating Add adds two register values, saturates the result to the 32-bit signed integer range –231 to (231 – 1), and writes the result to the destination register. If saturation occurs, it sets the Q flag in the APSR. - -@encoding (T1) { - - @word 1 1 1 1 1 0 1 0 1 0 0 0 Rn(4) 1 1 1 1 Rd(4) 1 0 0 0 Rm(4) - - @syntax - - @conv { - - reg_D = Register(Rd) - reg_N = Register(Rn) - reg_M = Register(Rm) - - } - -} - -@encoding (A1) { - - @word cond(4) 0 0 0 1 0 0 0 0 Rn(4) Rd(4) 0 0 0 0 0 1 0 1 Rm(4) - - @syntax - - @conv { - - reg_D = Register(Rd) - reg_N = Register(Rn) - reg_M = Register(Rm) - - } - - @rules { - - chk_call StoreCondition(cond) - - } - -} - diff --git a/src/arch/arm/v7/opdefs/qasx_A88137.d b/src/arch/arm/v7/opdefs/qasx_A88137.d deleted file mode 100644 index 68251ca..0000000 --- a/src/arch/arm/v7/opdefs/qasx_A88137.d +++ /dev/null @@ -1,65 +0,0 @@ - -/* Chrysalide - Outil d'analyse de fichiers binaires - * ##FILE## - traduction d'instructions ARMv7 - * - * Copyright (C) 2015 Cyrille Bagard - * - * This file is part of Chrysalide. - * - * Chrysalide is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Chrysalide is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Foobar. If not, see . - */ - - -@title QASX - -@desc Saturating Add and Subtract with Exchange exchanges the two halfwords of the second operand, performs one 16-bit integer addition and one 16-bit subtraction, saturates the results to the 16-bit signed integer range –215 ≤ x ≤ 215 – 1, and writes the results to the destination register. - -@encoding (T1) { - - @word 1 1 1 1 1 0 1 0 1 0 1 0 Rn(4) 1 1 1 1 Rd(4) 0 0 0 1 Rm(4) - - @syntax - - @conv { - - reg_D = Register(Rd) - reg_N = Register(Rn) - reg_M = Register(Rm) - - } - -} - -@encoding (A1) { - - @word cond(4) 0 1 1 0 0 0 1 0 Rn(4) Rd(4) 1 1 1 1 0 0 1 1 Rm(4) - - @syntax - - @conv { - - reg_D = Register(Rd) - reg_N = Register(Rn) - reg_M = Register(Rm) - - } - - @rules { - - chk_call StoreCondition(cond) - - } - -} - diff --git a/src/arch/arm/v7/opdefs/qdadd_A88138.d b/src/arch/arm/v7/opdefs/qdadd_A88138.d deleted file mode 100644 index c40cdcd..0000000 --- a/src/arch/arm/v7/opdefs/qdadd_A88138.d +++ /dev/null @@ -1,65 +0,0 @@ - -/* Chrysalide - Outil d'analyse de fichiers binaires - * ##FILE## - traduction d'instructions ARMv7 - * - * Copyright (C) 2015 Cyrille Bagard - * - * This file is part of Chrysalide. - * - * Chrysalide is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Chrysalide is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Foobar. If not, see . - */ - - -@title QDADD - -@desc Saturating Double and Add adds a doubled register value to another register value, and writes the result to the destination register. Both the doubling and the addition have their results saturated to the 32-bit signed integer range –231 ≤ x ≤ 231 – 1. If saturation occurs in either operation, it sets the Q flag in the APSR. - -@encoding (T1) { - - @word 1 1 1 1 1 0 1 0 1 0 0 0 Rn(4) 1 1 1 1 Rd(4) 1 0 0 1 Rm(4) - - @syntax - - @conv { - - reg_D = Register(Rd) - reg_N = Register(Rn) - reg_M = Register(Rm) - - } - -} - -@encoding (A1) { - - @word cond(4) 0 0 0 1 0 1 0 0 Rn(4) Rd(4) 0 0 0 0 0 1 0 1 Rm(4) - - @syntax - - @conv { - - reg_D = Register(Rd) - reg_N = Register(Rn) - reg_M = Register(Rm) - - } - - @rules { - - chk_call StoreCondition(cond) - - } - -} - diff --git a/src/arch/arm/v7/opdefs/qdsub_A88139.d b/src/arch/arm/v7/opdefs/qdsub_A88139.d deleted file mode 100644 index 87bd083..0000000 --- a/src/arch/arm/v7/opdefs/qdsub_A88139.d +++ /dev/null @@ -1,65 +0,0 @@ - -/* Chrysalide - Outil d'analyse de fichiers binaires - * ##FILE## - traduction d'instructions ARMv7 - * - * Copyright (C) 2015 Cyrille Bagard - * - * This file is part of Chrysalide. - * - * Chrysalide is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Chrysalide is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Foobar. If not, see . - */ - - -@title QDSUB - -@desc Saturating Double and Subtract subtracts a doubled register value from another register value, and writes the result to the destination register. Both the doubling and the subtraction have their results saturated to the 32-bit signed integer range –231 ≤ x ≤ 231 – 1. If saturation occurs in either operation, it sets the Q flag in the APSR. - -@encoding (T1) { - - @word 1 1 1 1 1 0 1 0 1 0 0 0 Rn(4) 1 1 1 1 Rd(4) 1 0 1 1 Rm(4) - - @syntax - - @conv { - - reg_D = Register(Rd) - reg_N = Register(Rn) - reg_M = Register(Rm) - - } - -} - -@encoding (A1) { - - @word cond(4) 0 0 0 1 0 1 1 0 Rn(4) Rd(4) 0 0 0 0 0 1 0 1 Rm(4) - - @syntax - - @conv { - - reg_D = Register(Rd) - reg_N = Register(Rn) - reg_M = Register(Rm) - - } - - @rules { - - chk_call StoreCondition(cond) - - } - -} - diff --git a/src/arch/arm/v7/opdefs/qsax_A88140.d b/src/arch/arm/v7/opdefs/qsax_A88140.d deleted file mode 100644 index df24cf8..0000000 --- a/src/arch/arm/v7/opdefs/qsax_A88140.d +++ /dev/null @@ -1,65 +0,0 @@ - -/* Chrysalide - Outil d'analyse de fichiers binaires - * ##FILE## - traduction d'instructions ARMv7 - * - * Copyright (C) 2015 Cyrille Bagard - * - * This file is part of Chrysalide. - * - * Chrysalide is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Chrysalide is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Foobar. If not, see . - */ - - -@title QSAX - -@desc Saturating Subtract and Add with Exchange exchanges the two halfwords of the second operand, performs one 16-bit integer subtraction and one 16-bit addition, saturates the results to the 16-bit signed integer range –215 ≤ x ≤ 215 – 1, and writes the results to the destination register. - -@encoding (T1) { - - @word 1 1 1 1 1 0 1 0 1 1 1 0 Rn(4) 1 1 1 1 Rd(4) 0 0 0 1 Rm(4) - - @syntax - - @conv { - - reg_D = Register(Rd) - reg_N = Register(Rn) - reg_M = Register(Rm) - - } - -} - -@encoding (A1) { - - @word cond(4) 0 1 1 0 0 0 1 0 Rn(4) Rd(4) 1 1 1 1 0 1 0 1 Rm(4) - - @syntax - - @conv { - - reg_D = Register(Rd) - reg_N = Register(Rn) - reg_M = Register(Rm) - - } - - @rules { - - chk_call StoreCondition(cond) - - } - -} - diff --git a/src/arch/arm/v7/opdefs/qsub16_A88142.d b/src/arch/arm/v7/opdefs/qsub16_A88142.d deleted file mode 100644 index 5b2c96b..0000000 --- a/src/arch/arm/v7/opdefs/qsub16_A88142.d +++ /dev/null @@ -1,65 +0,0 @@ - -/* Chrysalide - Outil d'analyse de fichiers binaires - * ##FILE## - traduction d'instructions ARMv7 - * - * Copyright (C) 2015 Cyrille Bagard - * - * This file is part of Chrysalide. - * - * Chrysalide is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Chrysalide is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Foobar. If not, see . - */ - - -@title QSUB16 - -@desc Saturating Subtract 16 performs two 16-bit integer subtractions, saturates the results to the 16-bit signed integer range –215 ≤ x ≤ 215 – 1, and writes the results to the destination register. - -@encoding (T1) { - - @word 1 1 1 1 1 0 1 0 1 1 0 1 Rn(4) 1 1 1 1 Rd(4) 0 0 0 1 Rm(4) - - @syntax - - @conv { - - reg_D = Register(Rd) - reg_N = Register(Rn) - reg_M = Register(Rm) - - } - -} - -@encoding (A1) { - - @word cond(4) 0 1 1 0 0 0 1 0 Rn(4) Rd(4) 1 1 1 1 0 1 1 1 Rm(4) - - @syntax - - @conv { - - reg_D = Register(Rd) - reg_N = Register(Rn) - reg_M = Register(Rm) - - } - - @rules { - - chk_call StoreCondition(cond) - - } - -} - diff --git a/src/arch/arm/v7/opdefs/qsub8_A88143.d b/src/arch/arm/v7/opdefs/qsub8_A88143.d deleted file mode 100644 index 270a99d..0000000 --- a/src/arch/arm/v7/opdefs/qsub8_A88143.d +++ /dev/null @@ -1,65 +0,0 @@ - -/* Chrysalide - Outil d'analyse de fichiers binaires - * ##FILE## - traduction d'instructions ARMv7 - * - * Copyright (C) 2015 Cyrille Bagard - * - * This file is part of Chrysalide. - * - * Chrysalide is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Chrysalide is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Foobar. If not, see . - */ - - -@title QSUB8 - -@desc Saturating Subtract 8 performs four 8-bit integer subtractions, saturates the results to the 8-bit signed integer range –27 ≤ x ≤ 27 – 1, and writes the results to the destination register. - -@encoding (T1) { - - @word 1 1 1 1 1 0 1 0 1 1 0 0 Rn(4) 1 1 1 1 Rd(4) 0 0 0 1 Rm(4) - - @syntax - - @conv { - - reg_D = Register(Rd) - reg_N = Register(Rn) - reg_M = Register(Rm) - - } - -} - -@encoding (A1) { - - @word cond(4) 0 1 1 0 0 0 1 0 Rn(4) Rd(4) 1 1 1 1 1 1 1 1 Rm(4) - - @syntax - - @conv { - - reg_D = Register(Rd) - reg_N = Register(Rn) - reg_M = Register(Rm) - - } - - @rules { - - chk_call StoreCondition(cond) - - } - -} - diff --git a/src/arch/arm/v7/opdefs/qsub_A88141.d b/src/arch/arm/v7/opdefs/qsub_A88141.d deleted file mode 100644 index c60ec57..0000000 --- a/src/arch/arm/v7/opdefs/qsub_A88141.d +++ /dev/null @@ -1,65 +0,0 @@ - -/* Chrysalide - Outil d'analyse de fichiers binaires - * ##FILE## - traduction d'instructions ARMv7 - * - * Copyright (C) 2015 Cyrille Bagard - * - * This file is part of Chrysalide. - * - * Chrysalide is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Chrysalide is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Foobar. If not, see . - */ - - -@title QSUB - -@desc Saturating Subtract subtracts one register value from another register value, saturates the result to the 32-bit signed integer range –231 ≤ x ≤ 231 – 1, and writes the result to the destination register. If saturation occurs, it sets the Q flag in the APSR. - -@encoding (T1) { - - @word 1 1 1 1 1 0 1 0 1 0 0 0 Rn(4) 1 1 1 1 Rd(4) 1 0 1 0 Rm(4) - - @syntax - - @conv { - - reg_D = Register(Rd) - reg_N = Register(Rn) - reg_M = Register(Rm) - - } - -} - -@encoding (A1) { - - @word cond(4) 0 0 0 1 0 0 1 0 Rn(4) Rd(4) 0 0 0 0 0 1 0 1 Rm(4) - - @syntax - - @conv { - - reg_D = Register(Rd) - reg_N = Register(Rn) - reg_M = Register(Rm) - - } - - @rules { - - chk_call StoreCondition(cond) - - } - -} - diff --git a/src/arch/arm/v7/opdefs/rbit_A88144.d b/src/arch/arm/v7/opdefs/rbit_A88144.d deleted file mode 100644 index 7f2bdb6..0000000 --- a/src/arch/arm/v7/opdefs/rbit_A88144.d +++ /dev/null @@ -1,63 +0,0 @@ - -/* Chrysalide - Outil d'analyse de fichiers binaires - * ##FILE## - traduction d'instructions ARMv7 - * - * Copyright (C) 2015 Cyrille Bagard - * - * This file is part of Chrysalide. - * - * Chrysalide is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Chrysalide is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Foobar. If not, see . - */ - - -@title RBIT - -@desc Reverse Bits reverses the bit order in a 32-bit register. - -@encoding (T1) { - - @word 1 1 1 1 1 0 1 0 1 0 0 1 Rm(4) 1 1 1 1 Rd(4) 1 0 1 0 Rm(4) - - @syntax - - @conv { - - reg_D = Register(Rd) - reg_M = Register(Rm) - - } - -} - -@encoding (A1) { - - @word cond(4) 0 1 1 0 1 1 1 1 1 1 1 1 Rd(4) 1 1 1 1 0 0 1 1 Rm(4) - - @syntax - - @conv { - - reg_D = Register(Rd) - reg_M = Register(Rm) - - } - - @rules { - - chk_call StoreCondition(cond) - - } - -} - diff --git a/src/arch/arm/v7/opdefs/rev16_A88146.d b/src/arch/arm/v7/opdefs/rev16_A88146.d deleted file mode 100644 index 53b9a82..0000000 --- a/src/arch/arm/v7/opdefs/rev16_A88146.d +++ /dev/null @@ -1,78 +0,0 @@ - -/* Chrysalide - Outil d'analyse de fichiers binaires - * ##FILE## - traduction d'instructions ARMv7 - * - * Copyright (C) 2015 Cyrille Bagard - * - * This file is part of Chrysalide. - * - * Chrysalide is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Chrysalide is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Foobar. If not, see . - */ - - -@title REV16 - -@desc Byte-Reverse Packed Halfword reverses the byte order in each16-bit halfword of a 32-bit register. - -@encoding (t1) { - - @half 1 0 1 1 1 0 1 0 0 1 Rm(3) Rd(3) - - @syntax - - @conv { - - reg_D = Register(Rd) - reg_M = Register(Rm) - - } - -} - -@encoding (T2) { - - @word 1 1 1 1 1 0 1 0 1 0 0 1 Rm(4) 1 1 1 1 Rd(4) 1 0 0 1 Rm(4) - - @syntax ".W" - - @conv { - - reg_D = Register(Rd) - reg_M = Register(Rm) - - } - -} - -@encoding (A1) { - - @word cond(4) 0 1 1 0 1 0 1 1 1 1 1 1 Rd(4) 1 1 1 1 1 0 1 1 Rm(4) - - @syntax - - @conv { - - reg_D = Register(Rd) - reg_M = Register(Rm) - - } - - @rules { - - chk_call StoreCondition(cond) - - } - -} - diff --git a/src/arch/arm/v7/opdefs/rev_A88145.d b/src/arch/arm/v7/opdefs/rev_A88145.d deleted file mode 100644 index 2fe305d..0000000 --- a/src/arch/arm/v7/opdefs/rev_A88145.d +++ /dev/null @@ -1,78 +0,0 @@ - -/* Chrysalide - Outil d'analyse de fichiers binaires - * ##FILE## - traduction d'instructions ARMv7 - * - * Copyright (C) 2015 Cyrille Bagard - * - * This file is part of Chrysalide. - * - * Chrysalide is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Chrysalide is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Foobar. If not, see . - */ - - -@title REV - -@desc Byte-Reverse Word reverses the byte order in a 32-bit register. - -@encoding (t1) { - - @half 1 0 1 1 1 0 1 0 0 0 Rm(3) Rd(3) - - @syntax - - @conv { - - reg_D = Register(Rd) - reg_M = Register(Rm) - - } - -} - -@encoding (T2) { - - @word 1 1 1 1 1 0 1 0 1 0 0 1 Rm(4) 1 1 1 1 Rd(4) 1 0 0 0 Rm(4) - - @syntax ".W" - - @conv { - - reg_D = Register(Rd) - reg_M = Register(Rm) - - } - -} - -@encoding (A1) { - - @word cond(4) 0 1 1 0 1 0 1 1 1 1 1 1 Rd(4) 1 1 1 1 0 0 1 1 Rm(4) - - @syntax - - @conv { - - reg_D = Register(Rd) - reg_M = Register(Rm) - - } - - @rules { - - chk_call StoreCondition(cond) - - } - -} - diff --git a/src/arch/arm/v7/opdefs/revsh_A88147.d b/src/arch/arm/v7/opdefs/revsh_A88147.d deleted file mode 100644 index 551582c..0000000 --- a/src/arch/arm/v7/opdefs/revsh_A88147.d +++ /dev/null @@ -1,78 +0,0 @@ - -/* Chrysalide - Outil d'analyse de fichiers binaires - * ##FILE## - traduction d'instructions ARMv7 - * - * Copyright (C) 2015 Cyrille Bagard - * - * This file is part of Chrysalide. - * - * Chrysalide is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Chrysalide is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Foobar. If not, see . - */ - - -@title REVSH - -@desc Byte-Reverse Signed Halfword reverses the byte order in the lower 16-bit halfword of a 32-bit register, and sign-extends the result to 32 bits. - -@encoding (t1) { - - @half 1 0 1 1 1 0 1 0 1 1 Rm(3) Rd(3) - - @syntax - - @conv { - - reg_D = Register(Rd) - reg_M = Register(Rm) - - } - -} - -@encoding (T2) { - - @word 1 1 1 1 1 0 1 0 1 0 0 1 Rm(4) 1 1 1 1 Rd(4) 1 0 1 1 Rm(4) - - @syntax ".W" - - @conv { - - reg_D = Register(Rd) - reg_M = Register(Rm) - - } - -} - -@encoding (A1) { - - @word cond(4) 0 1 1 0 1 1 1 1 1 1 1 1 Rd(4) 1 1 1 1 1 0 1 1 Rm(4) - - @syntax - - @conv { - - reg_D = Register(Rd) - reg_M = Register(Rm) - - } - - @rules { - - chk_call StoreCondition(cond) - - } - -} - diff --git a/src/arch/arm/v7/opdefs/ror_A88149.d b/src/arch/arm/v7/opdefs/ror_A88149.d deleted file mode 100644 index 7e061c6..0000000 --- a/src/arch/arm/v7/opdefs/ror_A88149.d +++ /dev/null @@ -1,74 +0,0 @@ - -/* Chrysalide - Outil d'analyse de fichiers binaires - * ##FILE## - traduction d'instructions ARMv7 - * - * Copyright (C) 2015 Cyrille Bagard - * - * This file is part of Chrysalide. - * - * Chrysalide is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Chrysalide is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Foobar. If not, see . - */ - - -@title ROR (immediate) - -@desc Rotate Right (immediate) provides the value of the contents of a register rotated by a constant value. The bits that are rotated off the right end are inserted into the vacated bit positions on the left. It can optionally update the condition flags based on the result. - -@encoding (T1) { - - @word 1 1 1 0 1 0 1 0 0 1 0 S(1) 1 1 1 1 0 imm3(3) Rd(4) imm2(2) 1 1 Rm(4) - - @syntax - - @conv { - - reg_D = Register(Rd) - reg_M = Register(Rm) - setflags = (S == '1') - shift_imm = DecodeImmShift('11', imm3:imm2) - - } - - @rules { - - if (setflags); chk_call ExtendKeyword("s") - - } - -} - -@encoding (A1) { - - @word cond(4) 0 0 0 1 1 0 1 S(1) 0 0 0 0 Rd(4) imm5(5) 1 1 0 Rm(4) - - @syntax - - @conv { - - reg_D = Register(Rd) - reg_M = Register(Rm) - setflags = (S == '1') - shift_imm = DecodeImmShift('11', imm5) - - } - - @rules { - - if (setflags); chk_call ExtendKeyword("s") - chk_call StoreCondition(cond) - - } - -} - diff --git a/src/arch/arm/v7/opdefs/ror_A88150.d b/src/arch/arm/v7/opdefs/ror_A88150.d deleted file mode 100644 index c046bf7..0000000 --- a/src/arch/arm/v7/opdefs/ror_A88150.d +++ /dev/null @@ -1,90 +0,0 @@ - -/* Chrysalide - Outil d'analyse de fichiers binaires - * ##FILE## - traduction d'instructions ARMv7 - * - * Copyright (C) 2015 Cyrille Bagard - * - * This file is part of Chrysalide. - * - * Chrysalide is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Chrysalide is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Foobar. If not, see . - */ - - -@title ROR (register) - -@desc Rotate Right (register) provides the value of the contents of a register rotated by a variable number of bits. The bits that are rotated off the right end are inserted into the vacated bit positions on the left. The variable number of bits is read from the bottom byte of a register. It can optionally update the condition flags based on the result. - -@encoding (t1) { - - @half 0 1 0 0 0 0 0 1 1 1 Rm(3) Rdn(3) - - @syntax "rors" - - @conv { - - reg_DN = Register(Rdn) - reg_M = Register(Rm) - - } - -} - -@encoding (T2) { - - @word 1 1 1 1 1 0 1 0 0 1 1 S(1) Rn(4) 1 1 1 1 Rd(4) 0 0 0 0 Rm(4) - - @syntax - - @conv { - - reg_D = Register(Rd) - reg_N = Register(Rn) - reg_M = Register(Rm) - setflags = (S == '1') - - } - - @rules { - - if (setflags); chk_call ExtendKeyword("s") - chk_call ExtendKeyword(".w") - - } - -} - -@encoding (A1) { - - @word cond(4) 0 0 0 1 1 0 1 S(1) 0 0 0 0 Rd(4) Rm(4) 0 1 1 1 Rn(4) - - @syntax - - @conv { - - reg_D = Register(Rd) - reg_N = Register(Rn) - reg_M = Register(Rm) - setflags = (S == '1') - - } - - @rules { - - if (setflags); chk_call ExtendKeyword("s") - chk_call StoreCondition(cond) - - } - -} - diff --git a/src/arch/arm/v7/opdefs/rrx_A88151.d b/src/arch/arm/v7/opdefs/rrx_A88151.d deleted file mode 100644 index 4debd42..0000000 --- a/src/arch/arm/v7/opdefs/rrx_A88151.d +++ /dev/null @@ -1,72 +0,0 @@ - -/* Chrysalide - Outil d'analyse de fichiers binaires - * ##FILE## - traduction d'instructions ARMv7 - * - * Copyright (C) 2015 Cyrille Bagard - * - * This file is part of Chrysalide. - * - * Chrysalide is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Chrysalide is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Foobar. If not, see . - */ - - -@title RRX - -@desc Rotate Right with Extend provides the value of the contents of a register shifted right by one place, with the Carry flag shifted into bit[31]. RRX can optionally update the condition flags based on the result. In that case, bit[0] is shifted into the Carry flag. - -@encoding (T1) { - - @word 1 1 1 0 1 0 1 0 0 1 0 S(1) 1 1 1 1 0 0 0 0 Rd(4) 0 0 1 1 Rm(4) - - @syntax - - @conv { - - reg_D = Register(Rd) - reg_M = Register(Rm) - setflags = (S == '1') - - } - - @rules { - - if (setflags); chk_call ExtendKeyword("s") - - } - -} - -@encoding (A1) { - - @word cond(4) 0 0 0 1 1 0 1 S(1) 0 0 0 0 Rd(4) 0 0 0 0 0 1 1 0 Rm(4) - - @syntax - - @conv { - - reg_D = Register(Rd) - reg_M = Register(Rm) - setflags = (S == '1') - - } - - @rules { - - if (setflags); chk_call ExtendKeyword("s") - chk_call StoreCondition(cond) - - } - -} - diff --git a/src/arch/arm/v7/opdefs/rsb_A88152.d b/src/arch/arm/v7/opdefs/rsb_A88152.d deleted file mode 100644 index ea53373..0000000 --- a/src/arch/arm/v7/opdefs/rsb_A88152.d +++ /dev/null @@ -1,91 +0,0 @@ - -/* Chrysalide - Outil d'analyse de fichiers binaires - * ##FILE## - traduction d'instructions ARMv7 - * - * Copyright (C) 2015 Cyrille Bagard - * - * This file is part of Chrysalide. - * - * Chrysalide is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Chrysalide is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Foobar. If not, see . - */ - - -@title RSB (immediate) - -@desc Reverse Subtract (immediate) subtracts a register value from an immediate value, and writes the result to the destination register. It can optionally update the condition flags based on the result. - -@encoding (t1) { - - @half 0 1 0 0 0 0 1 0 0 1 Rn(3) Rd(3) - - @syntax "rsbs" - - @conv { - - reg_D = Register(Rd) - reg_N = Register(Rn) - imm32 = Zeros(32) - - } - -} - -@encoding (T2) { - - @word 1 1 1 1 0 i(1) 0 1 1 1 0 S(1) Rn(4) 0 imm3(3) Rd(4) imm8(8) - - @syntax - - @conv { - - reg_D = Register(Rd) - reg_N = Register(Rn) - setflags = (S == '1') - imm32 = ThumbExpandImm(i:imm3:imm8) - - } - - @rules { - - if (setflags); chk_call ExtendKeyword("s") - chk_call ExtendKeyword(".w") - - } - -} - -@encoding (A1) { - - @word cond(4) 0 0 1 0 0 1 1 S(1) Rn(4) Rd(4) imm12(12) - - @syntax - - @conv { - - reg_D = Register(Rd) - reg_N = Register(Rn) - setflags = (S == '1') - imm32 = ARMExpandImm(imm12) - - } - - @rules { - - if (setflags); chk_call ExtendKeyword("s") - chk_call StoreCondition(cond) - - } - -} - diff --git a/src/arch/arm/v7/opdefs/rsb_A88153.d b/src/arch/arm/v7/opdefs/rsb_A88153.d deleted file mode 100644 index f4a6d61..0000000 --- a/src/arch/arm/v7/opdefs/rsb_A88153.d +++ /dev/null @@ -1,76 +0,0 @@ - -/* Chrysalide - Outil d'analyse de fichiers binaires - * ##FILE## - traduction d'instructions ARMv7 - * - * Copyright (C) 2015 Cyrille Bagard - * - * This file is part of Chrysalide. - * - * Chrysalide is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Chrysalide is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Foobar. If not, see . - */ - - -@title RSB (register) - -@desc Reverse Subtract (register) subtracts a register value from an optionally-shifted register value, and writes the result to the destination register. It can optionally update the condition flags based on the result. - -@encoding (T1) { - - @word 1 1 1 0 1 0 1 1 1 1 0 S(1) Rn(4) 0 imm3(3) Rd(4) imm2(2) type(2) Rm(4) - - @syntax - - @conv { - - reg_D = Register(Rd) - reg_N = Register(Rn) - reg_M = Register(Rm) - setflags = (S == '1') - shift = DecodeImmShift(type, imm3:imm2) - - } - - @rules { - - if (setflags); chk_call ExtendKeyword("s") - - } - -} - -@encoding (A1) { - - @word cond(4) 0 0 0 0 0 1 1 S(1) Rn(4) Rd(4) imm5(5) type(2) 0 Rm(4) - - @syntax - - @conv { - - reg_D = Register(Rd) - reg_N = Register(Rn) - reg_M = Register(Rm) - setflags = (S == '1') - shift = DecodeImmShift(type, imm5) - - } - - @rules { - - if (setflags); chk_call ExtendKeyword("s") - chk_call StoreCondition(cond) - - } - -} - diff --git a/src/arch/arm/v7/opdefs/rsb_A88154.d b/src/arch/arm/v7/opdefs/rsb_A88154.d deleted file mode 100644 index 9ccf559..0000000 --- a/src/arch/arm/v7/opdefs/rsb_A88154.d +++ /dev/null @@ -1,52 +0,0 @@ - -/* Chrysalide - Outil d'analyse de fichiers binaires - * ##FILE## - traduction d'instructions ARMv7 - * - * Copyright (C) 2015 Cyrille Bagard - * - * This file is part of Chrysalide. - * - * Chrysalide is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Chrysalide is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Foobar. If not, see . - */ - - -@title RSB (register-shifted register) - -@desc Reverse Subtract (register-shifted register) subtracts a register value from a register-shifted register value, and writes the result to the destination register. It can optionally update the condition flags based on the result. - -@encoding (A1) { - - @word cond(4) 0 0 0 0 0 1 1 S(1) Rn(4) Rd(4) Rs(4) 0 type(2) 1 Rm(4) - - @syntax - - @conv { - - reg_shift = RegisterShift(type, Rs) - reg_D = Register(Rd) - reg_N = Register(Rn) - reg_M = Register(Rm) - setflags = (S == '1') - - } - - @rules { - - if (setflags); chk_call ExtendKeyword("s") - chk_call StoreCondition(cond) - - } - -} - diff --git a/src/arch/arm/v7/opdefs/rsc_A88155.d b/src/arch/arm/v7/opdefs/rsc_A88155.d deleted file mode 100644 index fc5f8b6..0000000 --- a/src/arch/arm/v7/opdefs/rsc_A88155.d +++ /dev/null @@ -1,51 +0,0 @@ - -/* Chrysalide - Outil d'analyse de fichiers binaires - * ##FILE## - traduction d'instructions ARMv7 - * - * Copyright (C) 2015 Cyrille Bagard - * - * This file is part of Chrysalide. - * - * Chrysalide is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Chrysalide is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Foobar. If not, see . - */ - - -@title RSC (immediate) - -@desc Reverse Subtract with Carry (immediate) subtracts a register value and the value of NOT (Carry flag) from an immediate value, and writes the result to the destination register. It can optionally update the condition flags based on the result. - -@encoding (A1) { - - @word cond(4) 0 0 1 0 1 1 1 S(1) Rn(4) Rd(4) imm12(12) - - @syntax - - @conv { - - reg_D = Register(Rd) - reg_N = Register(Rn) - setflags = (S == '1') - imm32 = ARMExpandImm(imm12) - - } - - @rules { - - if (setflags); chk_call ExtendKeyword("s") - chk_call StoreCondition(cond) - - } - -} - diff --git a/src/arch/arm/v7/opdefs/rsc_A88156.d b/src/arch/arm/v7/opdefs/rsc_A88156.d deleted file mode 100644 index 70829cd..0000000 --- a/src/arch/arm/v7/opdefs/rsc_A88156.d +++ /dev/null @@ -1,52 +0,0 @@ - -/* Chrysalide - Outil d'analyse de fichiers binaires - * ##FILE## - traduction d'instructions ARMv7 - * - * Copyright (C) 2015 Cyrille Bagard - * - * This file is part of Chrysalide. - * - * Chrysalide is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Chrysalide is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Foobar. If not, see . - */ - - -@title RSC (register) - -@desc Reverse Subtract with Carry (register) subtracts a register value and the value of NOT (Carry flag) from an optionally-shifted register value, and writes the result to the destination register. It can optionally update the condition flags based on the result. - -@encoding (A1) { - - @word cond(4) 0 0 0 0 1 1 1 S(1) Rn(4) Rd(4) imm5(5) type(2) 0 Rm(4) - - @syntax - - @conv { - - reg_D = Register(Rd) - reg_N = Register(Rn) - reg_M = Register(Rm) - setflags = (S == '1') - shift = DecodeImmShift(type, imm5) - - } - - @rules { - - if (setflags); chk_call ExtendKeyword("s") - chk_call StoreCondition(cond) - - } - -} - diff --git a/src/arch/arm/v7/opdefs/rsc_A88157.d b/src/arch/arm/v7/opdefs/rsc_A88157.d deleted file mode 100644 index 4fa276d..0000000 --- a/src/arch/arm/v7/opdefs/rsc_A88157.d +++ /dev/null @@ -1,52 +0,0 @@ - -/* Chrysalide - Outil d'analyse de fichiers binaires - * ##FILE## - traduction d'instructions ARMv7 - * - * Copyright (C) 2015 Cyrille Bagard - * - * This file is part of Chrysalide. - * - * Chrysalide is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Chrysalide is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Foobar. If not, see . - */ - - -@title RSC (register-shifted register) - -@desc Reverse Subtract (register-shifted register) subtracts a register value and the value of NOT (Carry flag) from a register-shifted register value, and writes the result to the destination register. It can optionally update the condition flags based on the result. - -@encoding (A1) { - - @word cond(4) 0 0 0 0 1 1 1 S(1) Rn(4) Rd(4) Rs(4) 0 type(2) 1 Rm(4) - - @syntax - - @conv { - - reg_shift = RegisterShift(type, Rs) - reg_D = Register(Rd) - reg_N = Register(Rn) - reg_M = Register(Rm) - setflags = (S == '1') - - } - - @rules { - - if (setflags); chk_call ExtendKeyword("s") - chk_call StoreCondition(cond) - - } - -} - diff --git a/src/arch/arm/v7/opdefs/sadd16_A88158.d b/src/arch/arm/v7/opdefs/sadd16_A88158.d deleted file mode 100644 index 51ad948..0000000 --- a/src/arch/arm/v7/opdefs/sadd16_A88158.d +++ /dev/null @@ -1,65 +0,0 @@ - -/* Chrysalide - Outil d'analyse de fichiers binaires - * ##FILE## - traduction d'instructions ARMv7 - * - * Copyright (C) 2015 Cyrille Bagard - * - * This file is part of Chrysalide. - * - * Chrysalide is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Chrysalide is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Foobar. If not, see . - */ - - -@title SADD16 - -@desc Signed Add 16 performs two 16-bit signed integer additions, and writes the results to the destination register. It sets the APSR.GE bits according to the results of the additions. - -@encoding (T1) { - - @word 1 1 1 1 1 0 1 0 1 0 0 1 Rn(4) 1 1 1 1 Rd(4) 0 0 0 0 Rm(4) - - @syntax - - @conv { - - reg_D = Register(Rd) - reg_N = Register(Rn) - reg_M = Register(Rm) - - } - -} - -@encoding (A1) { - - @word cond(4) 0 1 1 0 0 0 0 1 Rn(4) Rd(4) 1 1 1 1 0 0 0 1 Rm(4) - - @syntax - - @conv { - - reg_D = Register(Rd) - reg_N = Register(Rn) - reg_M = Register(Rm) - - } - - @rules { - - chk_call StoreCondition(cond) - - } - -} - diff --git a/src/arch/arm/v7/opdefs/sadd8_A88159.d b/src/arch/arm/v7/opdefs/sadd8_A88159.d deleted file mode 100644 index 463c968..0000000 --- a/src/arch/arm/v7/opdefs/sadd8_A88159.d +++ /dev/null @@ -1,65 +0,0 @@ - -/* Chrysalide - Outil d'analyse de fichiers binaires - * ##FILE## - traduction d'instructions ARMv7 - * - * Copyright (C) 2015 Cyrille Bagard - * - * This file is part of Chrysalide. - * - * Chrysalide is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Chrysalide is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Foobar. If not, see . - */ - - -@title SADD8 - -@desc Signed Add 8 performs four 8-bit signed integer additions, and writes the results to the destination register. It sets the APSR.GE bits according to the results of the additions. - -@encoding (T1) { - - @word 1 1 1 1 1 0 1 0 1 0 0 0 Rn(4) 1 1 1 1 Rd(4) 0 0 0 0 Rm(4) - - @syntax - - @conv { - - reg_D = Register(Rd) - reg_N = Register(Rn) - reg_M = Register(Rm) - - } - -} - -@encoding (A1) { - - @word cond(4) 0 1 1 0 0 0 0 1 Rn(4) Rd(4) 1 1 1 1 1 0 0 1 Rm(4) - - @syntax - - @conv { - - reg_D = Register(Rd) - reg_N = Register(Rn) - reg_M = Register(Rm) - - } - - @rules { - - chk_call StoreCondition(cond) - - } - -} - diff --git a/src/arch/arm/v7/opdefs/sasx_A88160.d b/src/arch/arm/v7/opdefs/sasx_A88160.d deleted file mode 100644 index a0529cb..0000000 --- a/src/arch/arm/v7/opdefs/sasx_A88160.d +++ /dev/null @@ -1,65 +0,0 @@ - -/* Chrysalide - Outil d'analyse de fichiers binaires - * ##FILE## - traduction d'instructions ARMv7 - * - * Copyright (C) 2015 Cyrille Bagard - * - * This file is part of Chrysalide. - * - * Chrysalide is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Chrysalide is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Foobar. If not, see . - */ - - -@title SASX - -@desc Signed Add and Subtract with Exchange exchanges the two halfwords of the second operand, performs one 16-bit integer addition and one 16-bit subtraction, and writes the results to the destination register. It sets the APSR.GE bits according to the results. - -@encoding (T1) { - - @word 1 1 1 1 1 0 1 0 1 0 1 0 Rn(4) 1 1 1 1 Rd(4) 0 0 0 0 Rm(4) - - @syntax - - @conv { - - reg_D = Register(Rd) - reg_N = Register(Rn) - reg_M = Register(Rm) - - } - -} - -@encoding (A1) { - - @word cond(4) 0 1 1 0 0 0 0 1 Rn(4) Rd(4) 1 1 1 1 0 0 1 1 Rm(4) - - @syntax - - @conv { - - reg_D = Register(Rd) - reg_N = Register(Rn) - reg_M = Register(Rm) - - } - - @rules { - - chk_call StoreCondition(cond) - - } - -} - diff --git a/src/arch/arm/v7/opdefs/sbc_A88161.d b/src/arch/arm/v7/opdefs/sbc_A88161.d deleted file mode 100644 index 4ea776a..0000000 --- a/src/arch/arm/v7/opdefs/sbc_A88161.d +++ /dev/null @@ -1,74 +0,0 @@ - -/* Chrysalide - Outil d'analyse de fichiers binaires - * ##FILE## - traduction d'instructions ARMv7 - * - * Copyright (C) 2015 Cyrille Bagard - * - * This file is part of Chrysalide. - * - * Chrysalide is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Chrysalide is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Foobar. If not, see . - */ - - -@title SBC (immediate) - -@desc Subtract with Carry (immediate) subtracts an immediate value and the value of NOT (Carry flag) from a register value, and writes the result to the destination register. It can optionally update the condition flags based on the result. - -@encoding (T1) { - - @word 1 1 1 1 0 i(1) 0 1 0 1 1 S(1) Rn(4) 0 imm3(3) Rd(4) imm8(8) - - @syntax - - @conv { - - reg_D = Register(Rd) - reg_N = Register(Rn) - setflags = (S == '1') - imm32 = ThumbExpandImm(i:imm3:imm8) - - } - - @rules { - - if (setflags); chk_call ExtendKeyword("s") - - } - -} - -@encoding (A1) { - - @word cond(4) 0 0 1 0 1 1 0 S(1) Rn(4) Rd(4) imm12(12) - - @syntax - - @conv { - - reg_D = Register(Rd) - reg_N = Register(Rn) - setflags = (S == '1') - imm32 = ARMExpandImm(imm12) - - } - - @rules { - - if (setflags); chk_call ExtendKeyword("s") - chk_call StoreCondition(cond) - - } - -} - diff --git a/src/arch/arm/v7/opdefs/sbc_A88162.d b/src/arch/arm/v7/opdefs/sbc_A88162.d deleted file mode 100644 index b6e660a..0000000 --- a/src/arch/arm/v7/opdefs/sbc_A88162.d +++ /dev/null @@ -1,92 +0,0 @@ - -/* Chrysalide - Outil d'analyse de fichiers binaires - * ##FILE## - traduction d'instructions ARMv7 - * - * Copyright (C) 2015 Cyrille Bagard - * - * This file is part of Chrysalide. - * - * Chrysalide is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Chrysalide is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Foobar. If not, see . - */ - - -@title SBC (register) - -@desc Subtract with Carry (register) subtracts an optionally-shifted register value and the value of NOT (Carry flag) from a register value, and writes the result to the destination register. It can optionally update the condition flags based on the result. - -@encoding (t1) { - - @half 0 1 0 0 0 0 0 1 1 0 Rm(3) Rdn(3) - - @syntax "sbcs" - - @conv { - - reg_DN = Register(Rdn) - reg_M = Register(Rm) - - } - -} - -@encoding (T2) { - - @word 1 1 1 0 1 0 1 1 0 1 1 S(1) Rn(4) 0 imm3(3) Rd(4) imm2(2) type(2) Rm(4) - - @syntax - - @conv { - - reg_D = Register(Rd) - reg_N = Register(Rn) - reg_M = Register(Rm) - setflags = (S == '1') - shift = DecodeImmShift(type, imm3:imm2) - - } - - @rules { - - if (setflags); chk_call ExtendKeyword("s") - chk_call ExtendKeyword(".w") - - } - -} - -@encoding (A1) { - - @word cond(4) 0 0 0 0 1 1 0 S(1) Rn(4) Rd(4) imm5(5) type(2) 0 Rm(4) - - @syntax - - @conv { - - reg_D = Register(Rd) - reg_N = Register(Rn) - reg_M = Register(Rm) - setflags = (S == '1') - shift = DecodeImmShift(type, imm5) - - } - - @rules { - - if (setflags); chk_call ExtendKeyword("s") - chk_call StoreCondition(cond) - - } - -} - diff --git a/src/arch/arm/v7/opdefs/sbc_A88163.d b/src/arch/arm/v7/opdefs/sbc_A88163.d deleted file mode 100644 index 0500edc..0000000 --- a/src/arch/arm/v7/opdefs/sbc_A88163.d +++ /dev/null @@ -1,52 +0,0 @@ - -/* Chrysalide - Outil d'analyse de fichiers binaires - * ##FILE## - traduction d'instructions ARMv7 - * - * Copyright (C) 2015 Cyrille Bagard - * - * This file is part of Chrysalide. - * - * Chrysalide is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Chrysalide is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Foobar. If not, see . - */ - - -@title SBC (register-shifted register) - -@desc Subtract with Carry (register-shifted register) subtracts a register-shifted register value and the value of NOT (Carry flag) from a register value, and writes the result to the destination register. It can optionally update the condition flags based on the result. - -@encoding (A1) { - - @word cond(4) 0 0 0 0 1 1 0 S(1) Rn(4) Rd(4) Rs(4) 0 type(2) 1 Rm(4) - - @syntax - - @conv { - - reg_shift = RegisterShift(type, Rs) - reg_D = Register(Rd) - reg_N = Register(Rn) - reg_M = Register(Rm) - setflags = (S == '1') - - } - - @rules { - - if (setflags); chk_call ExtendKeyword("s") - chk_call StoreCondition(cond) - - } - -} - diff --git a/src/arch/arm/v7/opdefs/sbfx_A88164.d b/src/arch/arm/v7/opdefs/sbfx_A88164.d deleted file mode 100644 index 486db3c..0000000 --- a/src/arch/arm/v7/opdefs/sbfx_A88164.d +++ /dev/null @@ -1,67 +0,0 @@ - -/* Chrysalide - Outil d'analyse de fichiers binaires - * ##FILE## - traduction d'instructions ARMv7 - * - * Copyright (C) 2015 Cyrille Bagard - * - * This file is part of Chrysalide. - * - * Chrysalide is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Chrysalide is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Foobar. If not, see . - */ - - -@title SBFX - -@desc Signed Bit Field Extract extracts any number of adjacent bits at any position from a register, sign-extends them to 32 bits, and writes the result to the destination register. - -@encoding (T1) { - - @word 1 1 1 1 0 0 1 1 0 1 0 0 Rn(4) 0 imm3(3) Rd(4) imm2(2) 0 widthm1(5) - - @syntax - - @conv { - - reg_D = Register(Rd) - reg_N = Register(Rn) - lsbit = UInt(imm3:imm2) - width = IncWidth(widthm1) - - } - -} - -@encoding (A1) { - - @word cond(4) 0 1 1 1 1 0 1 widthm1(5) Rd(4) lsb(5) 1 0 1 Rn(4) - - @syntax - - @conv { - - reg_D = Register(Rd) - reg_N = Register(Rn) - lsbit = UInt(lsb) - width = IncWidth(widthm1) - - } - - @rules { - - chk_call StoreCondition(cond) - - } - -} - diff --git a/src/arch/arm/v7/opdefs/sdiv_A88165.d b/src/arch/arm/v7/opdefs/sdiv_A88165.d deleted file mode 100644 index 19ebfa9..0000000 --- a/src/arch/arm/v7/opdefs/sdiv_A88165.d +++ /dev/null @@ -1,65 +0,0 @@ - -/* Chrysalide - Outil d'analyse de fichiers binaires - * ##FILE## - traduction d'instructions ARMv7 - * - * Copyright (C) 2015 Cyrille Bagard - * - * This file is part of Chrysalide. - * - * Chrysalide is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Chrysalide is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Foobar. If not, see . - */ - - -@title SDIV - -@desc Signed Divide divides a 32-bit signed integer register value by a 32-bit signed integer register value, and writes the result to the destination register. The condition flags are not affected. See ARMv7 implementation requirements and options for the divide instructions on page A4-172 for more information about this instruction. - -@encoding (T1) { - - @word 1 1 1 1 1 0 1 1 1 0 0 1 Rn(4) 1 1 1 1 Rd(4) 1 1 1 1 Rm(4) - - @syntax - - @conv { - - reg_D = Register(Rd) - reg_N = Register(Rn) - reg_M = Register(Rm) - - } - -} - -@encoding (A1) { - - @word cond(4) 0 1 1 1 0 0 0 1 Rd(4) 1 1 1 1 Rm(4) 0 0 0 1 Rn(4) - - @syntax - - @conv { - - reg_D = Register(Rd) - reg_N = Register(Rn) - reg_M = Register(Rm) - - } - - @rules { - - chk_call StoreCondition(cond) - - } - -} - diff --git a/src/arch/arm/v7/opdefs/sel_A88166.d b/src/arch/arm/v7/opdefs/sel_A88166.d deleted file mode 100644 index cb32ed6..0000000 --- a/src/arch/arm/v7/opdefs/sel_A88166.d +++ /dev/null @@ -1,65 +0,0 @@ - -/* Chrysalide - Outil d'analyse de fichiers binaires - * ##FILE## - traduction d'instructions ARMv7 - * - * Copyright (C) 2015 Cyrille Bagard - * - * This file is part of Chrysalide. - * - * Chrysalide is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Chrysalide is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Foobar. If not, see . - */ - - -@title SEL - -@desc Select Bytes selects each byte of its result from either its first operand or its second operand, according to the values of the GE flags. - -@encoding (T1) { - - @word 1 1 1 1 1 0 1 0 1 0 1 0 Rn(4) 1 1 1 1 Rd(4) 1 0 0 0 Rm(4) - - @syntax - - @conv { - - reg_D = Register(Rd) - reg_N = Register(Rn) - reg_M = Register(Rm) - - } - -} - -@encoding (A1) { - - @word cond(4) 0 1 1 0 1 0 0 0 Rn(4) Rd(4) 1 1 1 1 1 0 1 1 Rm(4) - - @syntax - - @conv { - - reg_D = Register(Rd) - reg_N = Register(Rn) - reg_M = Register(Rm) - - } - - @rules { - - chk_call StoreCondition(cond) - - } - -} - diff --git a/src/arch/arm/v7/opdefs/setend_A88167.d b/src/arch/arm/v7/opdefs/setend_A88167.d deleted file mode 100644 index e549c50..0000000 --- a/src/arch/arm/v7/opdefs/setend_A88167.d +++ /dev/null @@ -1,55 +0,0 @@ - -/* Chrysalide - Outil d'analyse de fichiers binaires - * ##FILE## - traduction d'instructions ARMv7 - * - * Copyright (C) 2015 Cyrille Bagard - * - * This file is part of Chrysalide. - * - * Chrysalide is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Chrysalide is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Foobar. If not, see . - */ - - -@title SETEND - -@desc Set Endianness writes a new value to ENDIANSTATE. - -@encoding (t1) { - - @half 1 0 1 1 0 1 1 0 0 1 0 1 E(1) 0 0 0 - - @syntax - - @conv { - - set_bigend = EndianState(E == '1') - - } - -} - -@encoding (A1) { - - @word 1 1 1 1 0 0 0 1 0 0 0 0 0 0 0 1 0 0 0 0 0 0 E(1) 0 0 0 0 0 0 0 0 0 - - @syntax - - @conv { - - set_bigend = EndianState(E == '1') - - } - -} - diff --git a/src/arch/arm/v7/opdefs/sev_A88168.d b/src/arch/arm/v7/opdefs/sev_A88168.d deleted file mode 100644 index 2bd9af4..0000000 --- a/src/arch/arm/v7/opdefs/sev_A88168.d +++ /dev/null @@ -1,53 +0,0 @@ - -/* Chrysalide - Outil d'analyse de fichiers binaires - * ##FILE## - traduction d'instructions ARMv7 - * - * Copyright (C) 2015 Cyrille Bagard - * - * This file is part of Chrysalide. - * - * Chrysalide is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Chrysalide is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Foobar. If not, see . - */ - - -@title SEV - -@desc Send Event is a hint instruction. It causes an event to be signaled to all processors in the multiprocessor system. For more information, see Wait For Event and Send Event on page B1-1199. - -@encoding (t1) { - - @half 1 0 1 1 1 1 1 1 0 1 0 0 0 0 0 0 - -} - -@encoding (T2) { - - @word 1 1 1 1 0 0 1 1 1 0 1 0 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 - - @syntax ".W" - -} - -@encoding (A1) { - - @word cond(4) 0 0 1 1 0 0 1 0 0 0 0 0 1 1 1 1 0 0 0 0 0 0 0 0 0 1 0 0 - - @rules { - - chk_call StoreCondition(cond) - - } - -} - diff --git a/src/arch/arm/v7/opdefs/shadd16_A88169.d b/src/arch/arm/v7/opdefs/shadd16_A88169.d deleted file mode 100644 index 22baa05..0000000 --- a/src/arch/arm/v7/opdefs/shadd16_A88169.d +++ /dev/null @@ -1,65 +0,0 @@ - -/* Chrysalide - Outil d'analyse de fichiers binaires - * ##FILE## - traduction d'instructions ARMv7 - * - * Copyright (C) 2015 Cyrille Bagard - * - * This file is part of Chrysalide. - * - * Chrysalide is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Chrysalide is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Foobar. If not, see . - */ - - -@title SHADD16 - -@desc Signed Halving Add 16 performs two signed 16-bit integer additions, halves the results, and writes the results to the destination register. - -@encoding (T1) { - - @word 1 1 1 1 1 0 1 0 1 0 0 1 Rn(4) 1 1 1 1 Rd(4) 0 0 1 0 Rm(4) - - @syntax - - @conv { - - reg_D = Register(Rd) - reg_N = Register(Rn) - reg_M = Register(Rm) - - } - -} - -@encoding (A1) { - - @word cond(4) 0 1 1 0 0 0 1 1 Rn(4) Rd(4) 1 1 1 1 0 0 0 1 Rm(4) - - @syntax - - @conv { - - reg_D = Register(Rd) - reg_N = Register(Rn) - reg_M = Register(Rm) - - } - - @rules { - - chk_call StoreCondition(cond) - - } - -} - diff --git a/src/arch/arm/v7/opdefs/shadd8_A88170.d b/src/arch/arm/v7/opdefs/shadd8_A88170.d deleted file mode 100644 index bfc3031..0000000 --- a/src/arch/arm/v7/opdefs/shadd8_A88170.d +++ /dev/null @@ -1,65 +0,0 @@ - -/* Chrysalide - Outil d'analyse de fichiers binaires - * ##FILE## - traduction d'instructions ARMv7 - * - * Copyright (C) 2015 Cyrille Bagard - * - * This file is part of Chrysalide. - * - * Chrysalide is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Chrysalide is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Foobar. If not, see . - */ - - -@title SHADD8 - -@desc Signed Halving Add 8 performs four signed 8-bit integer additions, halves the results, and writes the results to the destination register. - -@encoding (T1) { - - @word 1 1 1 1 1 0 1 0 1 0 0 0 Rn(4) 1 1 1 1 Rd(4) 0 0 1 0 Rm(4) - - @syntax - - @conv { - - reg_D = Register(Rd) - reg_N = Register(Rn) - reg_M = Register(Rm) - - } - -} - -@encoding (A1) { - - @word cond(4) 0 1 1 0 0 0 1 1 Rn(4) Rd(4) 1 1 1 1 1 0 0 1 Rm(4) - - @syntax - - @conv { - - reg_D = Register(Rd) - reg_N = Register(Rn) - reg_M = Register(Rm) - - } - - @rules { - - chk_call StoreCondition(cond) - - } - -} - diff --git a/src/arch/arm/v7/opdefs/shasx_A88171.d b/src/arch/arm/v7/opdefs/shasx_A88171.d deleted file mode 100644 index 71d241b..0000000 --- a/src/arch/arm/v7/opdefs/shasx_A88171.d +++ /dev/null @@ -1,65 +0,0 @@ - -/* Chrysalide - Outil d'analyse de fichiers binaires - * ##FILE## - traduction d'instructions ARMv7 - * - * Copyright (C) 2015 Cyrille Bagard - * - * This file is part of Chrysalide. - * - * Chrysalide is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Chrysalide is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Foobar. If not, see . - */ - - -@title SHASX - -@desc Signed Halving Add and Subtract with Exchange exchanges the two halfwords of the second operand, performs one signed 16-bit integer addition and one signed 16-bit subtraction, halves the results, and writes the results to the destination register. - -@encoding (T1) { - - @word 1 1 1 1 1 0 1 0 1 0 1 0 Rn(4) 1 1 1 1 Rd(4) 0 0 1 0 Rm(4) - - @syntax - - @conv { - - reg_D = Register(Rd) - reg_N = Register(Rn) - reg_M = Register(Rm) - - } - -} - -@encoding (A1) { - - @word cond(4) 0 1 1 0 0 0 1 1 Rn(4) Rd(4) 1 1 1 1 0 0 1 1 Rm(4) - - @syntax - - @conv { - - reg_D = Register(Rd) - reg_N = Register(Rn) - reg_M = Register(Rm) - - } - - @rules { - - chk_call StoreCondition(cond) - - } - -} - diff --git a/src/arch/arm/v7/opdefs/shsax_A88172.d b/src/arch/arm/v7/opdefs/shsax_A88172.d deleted file mode 100644 index 8794738..0000000 --- a/src/arch/arm/v7/opdefs/shsax_A88172.d +++ /dev/null @@ -1,65 +0,0 @@ - -/* Chrysalide - Outil d'analyse de fichiers binaires - * ##FILE## - traduction d'instructions ARMv7 - * - * Copyright (C) 2015 Cyrille Bagard - * - * This file is part of Chrysalide. - * - * Chrysalide is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Chrysalide is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Foobar. If not, see . - */ - - -@title SHSAX - -@desc Signed Halving Subtract and Add with Exchange exchanges the two halfwords of the second operand, performs one signed 16-bit integer subtraction and one signed 16-bit addition, halves the results, and writes the results to the destination register. - -@encoding (T1) { - - @word 1 1 1 1 1 0 1 0 1 1 1 0 Rn(4) 1 1 1 1 Rd(4) 0 0 1 0 Rm(4) - - @syntax - - @conv { - - reg_D = Register(Rd) - reg_N = Register(Rn) - reg_M = Register(Rm) - - } - -} - -@encoding (A1) { - - @word cond(4) 0 1 1 0 0 0 1 1 Rn(4) Rd(4) 1 1 1 1 0 1 0 1 Rm(4) - - @syntax - - @conv { - - reg_D = Register(Rd) - reg_N = Register(Rn) - reg_M = Register(Rm) - - } - - @rules { - - chk_call StoreCondition(cond) - - } - -} - diff --git a/src/arch/arm/v7/opdefs/shsub16_A88173.d b/src/arch/arm/v7/opdefs/shsub16_A88173.d deleted file mode 100644 index f7099f2..0000000 --- a/src/arch/arm/v7/opdefs/shsub16_A88173.d +++ /dev/null @@ -1,65 +0,0 @@ - -/* Chrysalide - Outil d'analyse de fichiers binaires - * ##FILE## - traduction d'instructions ARMv7 - * - * Copyright (C) 2015 Cyrille Bagard - * - * This file is part of Chrysalide. - * - * Chrysalide is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Chrysalide is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Foobar. If not, see . - */ - - -@title SHSUB16 - -@desc Signed Halving Subtract 16 performs two signed 16-bit integer subtractions, halves the results, and writes the results to the destination register. - -@encoding (T1) { - - @word 1 1 1 1 1 0 1 0 1 1 0 1 Rn(4) 1 1 1 1 Rd(4) 0 0 1 0 Rm(4) - - @syntax - - @conv { - - reg_D = Register(Rd) - reg_N = Register(Rn) - reg_M = Register(Rm) - - } - -} - -@encoding (A1) { - - @word cond(4) 0 1 1 0 0 0 1 1 Rn(4) Rd(4) 1 1 1 1 0 1 1 1 Rm(4) - - @syntax - - @conv { - - reg_D = Register(Rd) - reg_N = Register(Rn) - reg_M = Register(Rm) - - } - - @rules { - - chk_call StoreCondition(cond) - - } - -} - diff --git a/src/arch/arm/v7/opdefs/shsub8_A88174.d b/src/arch/arm/v7/opdefs/shsub8_A88174.d deleted file mode 100644 index 99af65d..0000000 --- a/src/arch/arm/v7/opdefs/shsub8_A88174.d +++ /dev/null @@ -1,65 +0,0 @@ - -/* Chrysalide - Outil d'analyse de fichiers binaires - * ##FILE## - traduction d'instructions ARMv7 - * - * Copyright (C) 2015 Cyrille Bagard - * - * This file is part of Chrysalide. - * - * Chrysalide is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Chrysalide is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Foobar. If not, see . - */ - - -@title SHSUB8 - -@desc Signed Halving Subtract 8 performs four signed 8-bit integer subtractions, halves the results, and writes the results to the destination register. - -@encoding (T1) { - - @word 1 1 1 1 1 0 1 0 1 1 0 0 Rn(4) 1 1 1 1 Rd(4) 0 0 1 0 Rm(4) - - @syntax - - @conv { - - reg_D = Register(Rd) - reg_N = Register(Rn) - reg_M = Register(Rm) - - } - -} - -@encoding (A1) { - - @word cond(4) 0 1 1 0 0 0 1 1 Rn(4) Rd(4) 1 1 1 1 1 1 1 1 Rm(4) - - @syntax - - @conv { - - reg_D = Register(Rd) - reg_N = Register(Rn) - reg_M = Register(Rm) - - } - - @rules { - - chk_call StoreCondition(cond) - - } - -} - diff --git a/src/arch/arm/v7/opdefs/smlad_A88177.d b/src/arch/arm/v7/opdefs/smlad_A88177.d deleted file mode 100644 index 3eabaa9..0000000 --- a/src/arch/arm/v7/opdefs/smlad_A88177.d +++ /dev/null @@ -1,76 +0,0 @@ - -/* Chrysalide - Outil d'analyse de fichiers binaires - * ##FILE## - traduction d'instructions ARMv7 - * - * Copyright (C) 2015 Cyrille Bagard - * - * This file is part of Chrysalide. - * - * Chrysalide is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Chrysalide is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Foobar. If not, see . - */ - - -@title SMLAD - -@desc Signed Multiply Accumulate Dual performs two signed 16 × 16-bit multiplications. It adds the products to a 32-bit accumulate operand. Optionally, the instruction can exchange the halfwords of the second operand before performing the arithmetic. This produces top × bottom and bottom × top multiplication. This instruction sets the Q flag if the accumulate operation overflows. Overflow cannot occur during the multiplications. - -@encoding (T1) { - - @word 1 1 1 1 1 0 1 1 0 0 1 0 Rn(4) Ra(4) Rd(4) 0 0 0 M(1) Rm(4) - - @syntax - - @conv { - - reg_D = Register(Rd) - reg_N = Register(Rn) - reg_M = Register(Rm) - reg_A = Register(Ra) - m_swap = (M == '1') - - } - - @rules { - - if (m_swap); chk_call ExtendKeyword("x") - - } - -} - -@encoding (A1) { - - @word cond(4) 0 1 1 1 0 0 0 0 Rd(4) Ra(4) Rm(4) 0 0 M(1) 1 Rn(4) - - @syntax - - @conv { - - reg_D = Register(Rd) - reg_N = Register(Rn) - reg_M = Register(Rm) - reg_A = Register(Ra) - m_swap = (M == '1') - - } - - @rules { - - if (m_swap); chk_call ExtendKeyword("x") - chk_call StoreCondition(cond) - - } - -} - diff --git a/src/arch/arm/v7/opdefs/smlal_A88178.d b/src/arch/arm/v7/opdefs/smlal_A88178.d deleted file mode 100644 index 03da53c..0000000 --- a/src/arch/arm/v7/opdefs/smlal_A88178.d +++ /dev/null @@ -1,69 +0,0 @@ - -/* Chrysalide - Outil d'analyse de fichiers binaires - * ##FILE## - traduction d'instructions ARMv7 - * - * Copyright (C) 2015 Cyrille Bagard - * - * This file is part of Chrysalide. - * - * Chrysalide is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Chrysalide is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Foobar. If not, see . - */ - - -@title SMLAL - -@desc Signed Multiply Accumulate Long multiplies two signed 32-bit values to produce a 64-bit value, and accumulates this with a 64-bit value. In ARM instructions, the condition flags can optionally be updated based on the result. Use of this option adversely affects performance on many processor implementations. - -@encoding (T1) { - - @word 1 1 1 1 1 0 1 1 1 1 0 0 Rn(4) RdLo(4) RdHi(4) 0 0 0 0 Rm(4) - - @syntax - - @conv { - - reg_DLO = Register(RdLo) - reg_DHI = Register(RdHi) - reg_N = Register(Rn) - reg_M = Register(Rm) - - } - -} - -@encoding (A1) { - - @word cond(4) 0 0 0 0 1 1 1 S(1) RdHi(4) RdLo(4) Rm(4) 1 0 0 1 Rn(4) - - @syntax - - @conv { - - reg_DLO = Register(RdLo) - reg_DHI = Register(RdHi) - reg_N = Register(Rn) - reg_M = Register(Rm) - setflags = (S == '1') - - } - - @rules { - - if (setflags); chk_call ExtendKeyword("s") - chk_call StoreCondition(cond) - - } - -} - diff --git a/src/arch/arm/v7/opdefs/smlald_A88180.d b/src/arch/arm/v7/opdefs/smlald_A88180.d deleted file mode 100644 index fa6a473..0000000 --- a/src/arch/arm/v7/opdefs/smlald_A88180.d +++ /dev/null @@ -1,76 +0,0 @@ - -/* Chrysalide - Outil d'analyse de fichiers binaires - * ##FILE## - traduction d'instructions ARMv7 - * - * Copyright (C) 2015 Cyrille Bagard - * - * This file is part of Chrysalide. - * - * Chrysalide is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Chrysalide is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Foobar. If not, see . - */ - - -@title SMLALD - -@desc Signed Multiply Accumulate Long Dual performs two signed 16 × 16-bit multiplications. It adds the products to a 64-bit accumulate operand. Optionally, the instruction can exchange the halfwords of the second operand before performing the arithmetic. This produces top × bottom and bottom × top multiplication. Overflow is possible during this instruction, but only as a result of the 64-bit addition. This overflow is not detected if it occurs. Instead, the result wraps around modulo 264. - -@encoding (T1) { - - @word 1 1 1 1 1 0 1 1 1 1 0 0 Rn(4) RdLo(4) RdHi(4) 1 1 0 M(1) Rm(4) - - @syntax - - @conv { - - reg_DLO = Register(RdLo) - reg_DHI = Register(RdHi) - reg_N = Register(Rn) - reg_M = Register(Rm) - m_swap = (M == '1') - - } - - @rules { - - if (m_swap); chk_call ExtendKeyword("x") - - } - -} - -@encoding (A1) { - - @word cond(4) 0 1 1 1 0 1 0 0 RdHi(4) RdLo(4) Rm(4) 0 0 M(1) 1 Rn(4) - - @syntax - - @conv { - - reg_DLO = Register(RdLo) - reg_DHI = Register(RdHi) - reg_N = Register(Rn) - reg_M = Register(Rm) - m_swap = (M == '1') - - } - - @rules { - - if (m_swap); chk_call ExtendKeyword("x") - chk_call StoreCondition(cond) - - } - -} - diff --git a/src/arch/arm/v7/opdefs/smlsd_A88182.d b/src/arch/arm/v7/opdefs/smlsd_A88182.d deleted file mode 100644 index d458fa8..0000000 --- a/src/arch/arm/v7/opdefs/smlsd_A88182.d +++ /dev/null @@ -1,76 +0,0 @@ - -/* Chrysalide - Outil d'analyse de fichiers binaires - * ##FILE## - traduction d'instructions ARMv7 - * - * Copyright (C) 2015 Cyrille Bagard - * - * This file is part of Chrysalide. - * - * Chrysalide is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Chrysalide is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Foobar. If not, see . - */ - - -@title SMLSD - -@desc Signed Multiply Subtract Dual performs two signed 16 × 16-bit multiplications. It adds the difference of the products to a 32-bit accumulate operand. Optionally, the instruction can exchange the halfwords of the second operand before performing the arithmetic. This produces top × bottom and bottom × top multiplication. This instruction sets the Q flag if the accumulate operation overflows. Overflow cannot occur during the multiplications or subtraction. - -@encoding (T1) { - - @word 1 1 1 1 1 0 1 1 0 1 0 0 Rn(4) Ra(4) Rd(4) 0 0 0 M(1) Rm(4) - - @syntax - - @conv { - - reg_D = Register(Rd) - reg_N = Register(Rn) - reg_M = Register(Rm) - reg_A = Register(Ra) - m_swap = (M == '1') - - } - - @rules { - - if (m_swap); chk_call ExtendKeyword("x") - - } - -} - -@encoding (A1) { - - @word cond(4) 0 1 1 1 0 0 0 0 Rd(4) Ra(4) Rm(4) 0 1 M(1) 1 Rn(4) - - @syntax - - @conv { - - reg_D = Register(Rd) - reg_N = Register(Rn) - reg_M = Register(Rm) - reg_A = Register(Ra) - m_swap = (M == '1') - - } - - @rules { - - if (m_swap); chk_call ExtendKeyword("x") - chk_call StoreCondition(cond) - - } - -} - diff --git a/src/arch/arm/v7/opdefs/smlsld_A88183.d b/src/arch/arm/v7/opdefs/smlsld_A88183.d deleted file mode 100644 index 9f64eed..0000000 --- a/src/arch/arm/v7/opdefs/smlsld_A88183.d +++ /dev/null @@ -1,76 +0,0 @@ - -/* Chrysalide - Outil d'analyse de fichiers binaires - * ##FILE## - traduction d'instructions ARMv7 - * - * Copyright (C) 2015 Cyrille Bagard - * - * This file is part of Chrysalide. - * - * Chrysalide is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Chrysalide is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Foobar. If not, see . - */ - - -@title SMLSLD - -@desc Signed Multiply Subtract Long Dual performs two signed 16 × 16-bit multiplications. It adds the difference of the products to a 64-bit accumulate operand. Optionally, the instruction can exchange the halfwords of the second operand before performing the arithmetic. This produces top × bottom and bottom × top multiplication. Overflow is possible during this instruction, but only as a result of the 64-bit addition. This overflow is not detected if it occurs. Instead, the result wraps around modulo 264. - -@encoding (T1) { - - @word 1 1 1 1 1 0 1 1 1 1 0 1 Rn(4) RdLo(4) RdHi(4) 1 1 0 M(1) Rm(4) - - @syntax - - @conv { - - reg_DLO = Register(RdLo) - reg_DHI = Register(RdHi) - reg_N = Register(Rn) - reg_M = Register(Rm) - m_swap = (M == '1') - - } - - @rules { - - if (m_swap); chk_call ExtendKeyword("x") - - } - -} - -@encoding (A1) { - - @word cond(4) 0 1 1 1 0 1 0 0 RdHi(4) RdLo(4) Rm(4) 0 1 M(1) 1 Rn(4) - - @syntax - - @conv { - - reg_DLO = Register(RdLo) - reg_DHI = Register(RdHi) - reg_N = Register(Rn) - reg_M = Register(Rm) - m_swap = (M == '1') - - } - - @rules { - - if (m_swap); chk_call ExtendKeyword("x") - chk_call StoreCondition(cond) - - } - -} - diff --git a/src/arch/arm/v7/opdefs/smmla_A88184.d b/src/arch/arm/v7/opdefs/smmla_A88184.d deleted file mode 100644 index a4d29b8..0000000 --- a/src/arch/arm/v7/opdefs/smmla_A88184.d +++ /dev/null @@ -1,76 +0,0 @@ - -/* Chrysalide - Outil d'analyse de fichiers binaires - * ##FILE## - traduction d'instructions ARMv7 - * - * Copyright (C) 2015 Cyrille Bagard - * - * This file is part of Chrysalide. - * - * Chrysalide is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Chrysalide is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Foobar. If not, see . - */ - - -@title SMMLA - -@desc Signed Most Significant Word Multiply Accumulate multiplies two signed 32-bit values, extracts the most significant 32 bits of the result, and adds an accumulate value. Optionally, the instruction can specify that the result is rounded instead of being truncated. In this case, the constant 0x80000000 is added to the product before the high word is extracted. - -@encoding (T1) { - - @word 1 1 1 1 1 0 1 1 0 1 0 1 Rn(4) Ra(4) Rd(4) 0 0 0 R(1) Rm(4) - - @syntax - - @conv { - - reg_D = Register(Rd) - reg_N = Register(Rn) - reg_M = Register(Rm) - reg_A = Register(Ra) - round = (R == '1') - - } - - @rules { - - if (round); chk_call ExtendKeyword("r") - - } - -} - -@encoding (A1) { - - @word cond(4) 0 1 1 1 0 1 0 1 Rd(4) Ra(4) Rm(4) 0 0 R(1) 1 Rn(4) - - @syntax - - @conv { - - reg_D = Register(Rd) - reg_N = Register(Rn) - reg_M = Register(Rm) - reg_A = Register(Ra) - round = (R == '1') - - } - - @rules { - - if (round); chk_call ExtendKeyword("r") - chk_call StoreCondition(cond) - - } - -} - diff --git a/src/arch/arm/v7/opdefs/smmls_A88185.d b/src/arch/arm/v7/opdefs/smmls_A88185.d deleted file mode 100644 index d59617b..0000000 --- a/src/arch/arm/v7/opdefs/smmls_A88185.d +++ /dev/null @@ -1,76 +0,0 @@ - -/* Chrysalide - Outil d'analyse de fichiers binaires - * ##FILE## - traduction d'instructions ARMv7 - * - * Copyright (C) 2015 Cyrille Bagard - * - * This file is part of Chrysalide. - * - * Chrysalide is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Chrysalide is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Foobar. If not, see . - */ - - -@title SMMLS - -@desc Signed Most Significant Word Multiply Subtract multiplies two signed 32-bit values, subtracts the result from a 32-bit accumulate value that is shifted left by 32 bits, and extracts the most significant 32 bits of the result of that subtraction. Optionally, the instruction can specify that the result of the instruction is rounded instead of being truncated. In this case, the constant 0x80000000 is added to the result of the subtraction before the high word is extracted. - -@encoding (T1) { - - @word 1 1 1 1 1 0 1 1 0 1 1 0 Rn(4) Ra(4) Rd(4) 0 0 0 R(1) Rm(4) - - @syntax - - @conv { - - reg_D = Register(Rd) - reg_N = Register(Rn) - reg_M = Register(Rm) - reg_A = Register(Ra) - round = (R == '1') - - } - - @rules { - - if (round); chk_call ExtendKeyword("r") - - } - -} - -@encoding (A1) { - - @word cond(4) 0 1 1 1 0 1 0 1 Rd(4) Ra(4) Rm(4) 1 1 R(1) 1 Rn(4) - - @syntax - - @conv { - - reg_D = Register(Rd) - reg_N = Register(Rn) - reg_M = Register(Rm) - reg_A = Register(Ra) - round = (R == '1') - - } - - @rules { - - if (round); chk_call ExtendKeyword("r") - chk_call StoreCondition(cond) - - } - -} - diff --git a/src/arch/arm/v7/opdefs/smmul_A88186.d b/src/arch/arm/v7/opdefs/smmul_A88186.d deleted file mode 100644 index e02ca52..0000000 --- a/src/arch/arm/v7/opdefs/smmul_A88186.d +++ /dev/null @@ -1,74 +0,0 @@ - -/* Chrysalide - Outil d'analyse de fichiers binaires - * ##FILE## - traduction d'instructions ARMv7 - * - * Copyright (C) 2015 Cyrille Bagard - * - * This file is part of Chrysalide. - * - * Chrysalide is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Chrysalide is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Foobar. If not, see . - */ - - -@title SMMUL - -@desc Signed Most Significant Word Multiply multiplies two signed 32-bit values, extracts the most significant 32 bits of the result, and writes those bits to the destination register. Optionally, the instruction can specify that the result is rounded instead of being truncated. In this case, the constant 0x80000000 is added to the product before the high word is extracted. - -@encoding (T1) { - - @word 1 1 1 1 1 0 1 1 0 1 0 1 Rn(4) 1 1 1 1 Rd(4) 0 0 0 R(1) Rm(4) - - @syntax - - @conv { - - reg_D = Register(Rd) - reg_N = Register(Rn) - reg_M = Register(Rm) - round = (R == '1') - - } - - @rules { - - if (round); chk_call ExtendKeyword("r") - - } - -} - -@encoding (A1) { - - @word cond(4) 0 1 1 1 0 1 0 1 Rd(4) 1 1 1 1 Rm(4) 0 0 R(1) 1 Rn(4) - - @syntax - - @conv { - - reg_D = Register(Rd) - reg_N = Register(Rn) - reg_M = Register(Rm) - round = (R == '1') - - } - - @rules { - - if (round); chk_call ExtendKeyword("r") - chk_call StoreCondition(cond) - - } - -} - diff --git a/src/arch/arm/v7/opdefs/smuad_A88187.d b/src/arch/arm/v7/opdefs/smuad_A88187.d deleted file mode 100644 index 324e257..0000000 --- a/src/arch/arm/v7/opdefs/smuad_A88187.d +++ /dev/null @@ -1,74 +0,0 @@ - -/* Chrysalide - Outil d'analyse de fichiers binaires - * ##FILE## - traduction d'instructions ARMv7 - * - * Copyright (C) 2015 Cyrille Bagard - * - * This file is part of Chrysalide. - * - * Chrysalide is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Chrysalide is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Foobar. If not, see . - */ - - -@title SMUAD - -@desc Signed Dual Multiply Add performs two signed 16 × 16-bit multiplications. It adds the products together, and writes the result to the destination register. Optionally, the instruction can exchange the halfwords of the second operand before performing the arithmetic. This produces top × bottom and bottom × top multiplication. This instruction sets the Q flag if the addition overflows. The multiplications cannot overflow. - -@encoding (T1) { - - @word 1 1 1 1 1 0 1 1 0 0 1 0 Rn(4) 1 1 1 1 Rd(4) 0 0 0 M(1) Rm(4) - - @syntax - - @conv { - - reg_D = Register(Rd) - reg_N = Register(Rn) - reg_M = Register(Rm) - m_swap = (M == '1') - - } - - @rules { - - if (m_swap); chk_call ExtendKeyword("x") - - } - -} - -@encoding (A1) { - - @word cond(4) 0 1 1 1 0 0 0 0 Rd(4) 1 1 1 1 Rm(4) 0 0 M(1) 1 Rn(4) - - @syntax - - @conv { - - reg_D = Register(Rd) - reg_N = Register(Rn) - reg_M = Register(Rm) - m_swap = (M == '1') - - } - - @rules { - - if (m_swap); chk_call ExtendKeyword("x") - chk_call StoreCondition(cond) - - } - -} - diff --git a/src/arch/arm/v7/opdefs/smull_A88189.d b/src/arch/arm/v7/opdefs/smull_A88189.d deleted file mode 100644 index 5ab1c54..0000000 --- a/src/arch/arm/v7/opdefs/smull_A88189.d +++ /dev/null @@ -1,69 +0,0 @@ - -/* Chrysalide - Outil d'analyse de fichiers binaires - * ##FILE## - traduction d'instructions ARMv7 - * - * Copyright (C) 2015 Cyrille Bagard - * - * This file is part of Chrysalide. - * - * Chrysalide is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Chrysalide is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Foobar. If not, see . - */ - - -@title SMULL - -@desc Signed Multiply Long multiplies two 32-bit signed values to produce a 64-bit result. In ARM instructions, the condition flags can optionally be updated based on the result. Use of this option adversely affects performance on many processor implementations. - -@encoding (T1) { - - @word 1 1 1 1 1 0 1 1 1 0 0 0 Rn(4) RdLo(4) RdHi(4) 0 0 0 0 Rm(4) - - @syntax - - @conv { - - reg_DLO = Register(RdLo) - reg_DHI = Register(RdHi) - reg_N = Register(Rn) - reg_M = Register(Rm) - - } - -} - -@encoding (A1) { - - @word cond(4) 0 0 0 0 1 1 0 S(1) RdHi(4) RdLo(4) Rm(4) 1 0 0 1 Rn(4) - - @syntax - - @conv { - - reg_DLO = Register(RdLo) - reg_DHI = Register(RdHi) - reg_N = Register(Rn) - reg_M = Register(Rm) - setflags = (S == '1') - - } - - @rules { - - if (setflags); chk_call ExtendKeyword("s") - chk_call StoreCondition(cond) - - } - -} - diff --git a/src/arch/arm/v7/opdefs/str_A88203.d b/src/arch/arm/v7/opdefs/str_A88203.d deleted file mode 100644 index e3feaf7..0000000 --- a/src/arch/arm/v7/opdefs/str_A88203.d +++ /dev/null @@ -1,98 +0,0 @@ - -/* Chrysalide - Outil d'analyse de fichiers binaires - * ##FILE## - traduction d'instructions ARMv7 - * - * Copyright (C) 2015 Cyrille Bagard - * - * This file is part of Chrysalide. - * - * Chrysalide is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Chrysalide is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Foobar. If not, see . - */ - - -@title STR (immediate, Thumb) - -@desc Store Register (immediate) calculates an address from a base register value and an immediate offset, and stores a word from a register to memory. It can use offset, post-indexed, or pre-indexed addressing. For information about memory accesses see Memory accesses on page A8-294. - -@encoding (t1) { - - @half 0 1 1 0 0 imm5(5) Rn(3) Rt(3) - - @syntax - - @conv { - - reg_T = Register(Rt) - reg_N = Register(Rn) - imm32 = ZeroExtend(imm5:'00', 32) - mem_access = MakeMemoryAccess(reg_N, imm32, NULL, true, true, false) - - } - -} - -@encoding (t2) { - - @half 1 0 0 1 0 Rt(3) imm8(8) - - @syntax - - @conv { - - reg_T = Register(Rt) - imm32 = ZeroExtend(imm8:'00', 32) - SP = Register(13) - mem_access = MakeMemoryAccess(SP, imm32, NULL, true, true, false) - - } - -} - -@encoding (T3) { - - @word 1 1 1 1 1 0 0 0 1 1 0 0 Rn(4) Rt(4) imm12(12) - - @syntax ".W" - - @conv { - - reg_T = Register(Rt) - reg_N = Register(Rn) - imm32 = ZeroExtend(imm12, 32) - mem_access = MakeMemoryAccess(reg_N, imm32, NULL, true, true, false) - - } - -} - -@encoding (T4) { - - @word 1 1 1 1 1 0 0 0 0 1 0 0 Rn(4) Rt(4) 1 P(1) U(1) W(1) imm8(8) - - @syntax - - @conv { - - reg_T = Register(Rt) - reg_N = Register(Rn) - imm32 = ZeroExtend(imm8, 32) - index = (P == '1') - add = (U == '1') - wback = (W == '1') - mem_access = MakeMemoryAccess(reg_N, imm32, NULL, index, add, wback) - - } - -} - diff --git a/src/arch/arm/v7/opdefs/str_A88204.d b/src/arch/arm/v7/opdefs/str_A88204.d deleted file mode 100644 index d780ae3..0000000 --- a/src/arch/arm/v7/opdefs/str_A88204.d +++ /dev/null @@ -1,53 +0,0 @@ - -/* Chrysalide - Outil d'analyse de fichiers binaires - * ##FILE## - traduction d'instructions ARMv7 - * - * Copyright (C) 2015 Cyrille Bagard - * - * This file is part of Chrysalide. - * - * Chrysalide is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Chrysalide is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Foobar. If not, see . - */ - - -@title STR (immediate, ARM) - -@desc Store Register (immediate) calculates an address from a base register value and an immediate offset, and stores a word from a register to memory. It can use offset, post-indexed, or pre-indexed addressing. For information about memory accesses see Memory accesses on page A8-294. - -@encoding (A1) { - - @word cond(4) 0 1 0 P(1) U(1) 0 W(1) 0 Rn(4) Rt(4) imm12(12) - - @syntax - - @conv { - - reg_T = Register(Rt) - reg_N = Register(Rn) - imm32 = ZeroExtend(imm12, 32) - index = (P == '1') - add = (U == '1') - wback = (P == '0') || (W == '1') - mem_access = MakeMemoryAccess(reg_N, imm32, NULL, index, add, wback) - - } - - @rules { - - chk_call StoreCondition(cond) - - } - -} - diff --git a/src/arch/arm/v7/opdefs/str_A88205.d b/src/arch/arm/v7/opdefs/str_A88205.d deleted file mode 100644 index 55f154c..0000000 --- a/src/arch/arm/v7/opdefs/str_A88205.d +++ /dev/null @@ -1,89 +0,0 @@ - -/* Chrysalide - Outil d'analyse de fichiers binaires - * ##FILE## - traduction d'instructions ARMv7 - * - * Copyright (C) 2015 Cyrille Bagard - * - * This file is part of Chrysalide. - * - * Chrysalide is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Chrysalide is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Foobar. If not, see . - */ - - -@title STR (register) - -@desc Store Register (register) calculates an address from a base register value and an offset register value, stores a word from a register to memory. The offset register value can optionally be shifted. For information about memory accesses see Memory accesses on page A8-294. - -@encoding (t1) { - - @half 0 1 0 1 0 0 0 Rm(3) Rn(3) Rt(3) - - @syntax - - @conv { - - reg_T = Register(Rt) - reg_N = Register(Rn) - reg_M = Register(Rm) - mem_access = MakeMemoryAccess(reg_N, reg_M, NULL, true, true, false) - - } - -} - -@encoding (T2) { - - @word 1 1 1 1 1 0 0 0 0 1 0 0 Rn(4) Rt(4) 0 0 0 0 0 0 imm2(2) Rm(4) - - @syntax ".W" - - @conv { - - reg_T = Register(Rt) - reg_N = Register(Rn) - reg_M = Register(Rm) - shift = DecodeImmShift(0, imm2) - mem_access = MakeMemoryAccess(reg_N, reg_M, shift, true, true, false) - - } - -} - -@encoding (A1) { - - @word cond(4) 0 1 1 P(1) U(1) 0 W(1) 0 Rn(4) Rt(4) imm5(5) type(2) 0 Rm(4) - - @syntax - - @conv { - - reg_T = Register(Rt) - reg_N = Register(Rn) - reg_M = Register(Rm) - index = (P == '1') - add = (U == '1') - wback = (P == '0') || (W == '1') - shift = DecodeImmShift(type, imm5) - mem_access = MakeMemoryAccess(reg_N, reg_M, shift, index, add, wback) - - } - - @rules { - - chk_call StoreCondition(cond) - - } - -} - diff --git a/src/arch/arm/v7/opdefs/strb_A88206.d b/src/arch/arm/v7/opdefs/strb_A88206.d deleted file mode 100644 index 2caf94c..0000000 --- a/src/arch/arm/v7/opdefs/strb_A88206.d +++ /dev/null @@ -1,81 +0,0 @@ - -/* Chrysalide - Outil d'analyse de fichiers binaires - * ##FILE## - traduction d'instructions ARMv7 - * - * Copyright (C) 2015 Cyrille Bagard - * - * This file is part of Chrysalide. - * - * Chrysalide is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Chrysalide is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Foobar. If not, see . - */ - - -@title STRB (immediate, Thumb) - -@desc Store Register Byte (immediate) calculates an address from a base register value and an immediate offset, and stores a byte from a register to memory. It can use offset, post-indexed, or pre-indexed addressing. For information about memory accesses see Memory accesses on page A8-294. - -@encoding (t1) { - - @half 0 1 1 1 0 imm5(5) Rn(3) Rt(3) - - @syntax - - @conv { - - reg_T = Register(Rt) - reg_N = Register(Rn) - imm32 = ZeroExtend(imm5, 32) - mem_access = MakeMemoryAccess(reg_N, imm32, NULL, true, true, false) - - } - -} - -@encoding (T2) { - - @word 1 1 1 1 1 0 0 0 1 0 0 0 Rn(4) Rt(4) imm12(12) - - @syntax ".W" - - @conv { - - reg_T = Register(Rt) - reg_N = Register(Rn) - imm32 = ZeroExtend(imm12, 32) - mem_access = MakeMemoryAccess(reg_N, imm32, NULL, true, true, false) - - } - -} - -@encoding (T3) { - - @word 1 1 1 1 1 0 0 0 0 0 0 0 Rn(4) Rt(4) 1 P(1) U(1) W(1) imm8(8) - - @syntax - - @conv { - - reg_T = Register(Rt) - reg_N = Register(Rn) - imm32 = ZeroExtend(imm8, 32) - index = (P == '1') - add = (U == '1') - wback = (W == '1') - mem_access = MakeMemoryAccess(reg_N, imm32, NULL, index, add, wback) - - } - -} - diff --git a/src/arch/arm/v7/opdefs/strb_A88207.d b/src/arch/arm/v7/opdefs/strb_A88207.d deleted file mode 100644 index 4e893fb..0000000 --- a/src/arch/arm/v7/opdefs/strb_A88207.d +++ /dev/null @@ -1,53 +0,0 @@ - -/* Chrysalide - Outil d'analyse de fichiers binaires - * ##FILE## - traduction d'instructions ARMv7 - * - * Copyright (C) 2015 Cyrille Bagard - * - * This file is part of Chrysalide. - * - * Chrysalide is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Chrysalide is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Foobar. If not, see . - */ - - -@title STRB (immediate, ARM) - -@desc Store Register Byte (immediate) calculates an address from a base register value and an immediate offset, and stores a byte from a register to memory. It can use offset, post-indexed, or pre-indexed addressing. For information about memory accesses see Memory accesses on page A8-294. - -@encoding (A1) { - - @word cond(4) 0 1 0 P(1) U(1) 1 W(1) 0 Rn(4) Rt(4) imm12(12) - - @syntax - - @conv { - - reg_T = Register(Rt) - reg_N = Register(Rn) - imm32 = ZeroExtend(imm12, 32) - index = (P == '1') - add = (U == '1') - wback = (P == '0') || (W == '1') - mem_access = MakeMemoryAccess(reg_N, imm32, NULL, index, add, wback) - - } - - @rules { - - chk_call StoreCondition(cond) - - } - -} - diff --git a/src/arch/arm/v7/opdefs/strb_A88208.d b/src/arch/arm/v7/opdefs/strb_A88208.d deleted file mode 100644 index 36f6134..0000000 --- a/src/arch/arm/v7/opdefs/strb_A88208.d +++ /dev/null @@ -1,89 +0,0 @@ - -/* Chrysalide - Outil d'analyse de fichiers binaires - * ##FILE## - traduction d'instructions ARMv7 - * - * Copyright (C) 2015 Cyrille Bagard - * - * This file is part of Chrysalide. - * - * Chrysalide is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Chrysalide is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Foobar. If not, see . - */ - - -@title STRB (register) - -@desc Store Register Byte (register) calculates an address from a base register value and an offset register value, and stores a byte from a register to memory. The offset register value can optionally be shifted. For information about memory accesses see Memory accesses on page A8-294. - -@encoding (t1) { - - @half 0 1 0 1 0 1 0 Rm(3) Rn(3) Rt(3) - - @syntax - - @conv { - - reg_T = Register(Rt) - reg_N = Register(Rn) - reg_M = Register(Rm) - mem_access = MakeMemoryAccess(reg_N, reg_M, NULL, true, true, false) - - } - -} - -@encoding (T2) { - - @word 1 1 1 1 1 0 0 0 0 0 0 0 Rn(4) Rt(4) 0 0 0 0 0 0 imm2(2) Rm(4) - - @syntax ".W" - - @conv { - - reg_T = Register(Rt) - reg_N = Register(Rn) - reg_M = Register(Rm) - shift = DecodeImmShift(0, imm2) - mem_access = MakeMemoryAccess(reg_N, reg_M, shift, true, true, false) - - } - -} - -@encoding (A1) { - - @word cond(4) 0 1 1 P(1) U(1) 1 W(1) 0 Rn(4) Rt(4) imm5(5) type(2) 0 Rm(4) - - @syntax - - @conv { - - reg_T = Register(Rt) - reg_N = Register(Rn) - reg_M = Register(Rm) - index = (P == '1') - add = (U == '1') - wback = (P == '0') || (W == '1') - shift = DecodeImmShift(type, imm5) - mem_access = MakeMemoryAccess(reg_N, reg_M, shift, index, add, wback) - - } - - @rules { - - chk_call StoreCondition(cond) - - } - -} - diff --git a/src/arch/arm/v7/opdefs/strbt_A88209.d b/src/arch/arm/v7/opdefs/strbt_A88209.d deleted file mode 100644 index 2bcb260..0000000 --- a/src/arch/arm/v7/opdefs/strbt_A88209.d +++ /dev/null @@ -1,93 +0,0 @@ - -/* Chrysalide - Outil d'analyse de fichiers binaires - * ##FILE## - traduction d'instructions ARMv7 - * - * Copyright (C) 2015 Cyrille Bagard - * - * This file is part of Chrysalide. - * - * Chrysalide is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Chrysalide is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Foobar. If not, see . - */ - - -@title STRBT - -@desc Store Register Byte Unprivileged stores a byte from a register to memory. For information about memory accesses see Memory accesses on page A8-294. The memory access is restricted as if the processor were running in User mode. This makes no difference if the processor is actually running in User mode. STRBT is UNPREDICTABLE in Hyp mode. The Thumb instruction uses an offset addressing mode, that calculates the address used for the memory access from a base register value and an immediate offset, and leaves the base register unchanged. The ARM instruction uses a post-indexed addressing mode, that uses a base register value as the address for the memory access, and calculates a new address from a base register value and an offset and writes it back to the base register. The offset can be an immediate value or an optionally-shifted register value. - -@encoding (T1) { - - @word 1 1 1 1 1 0 0 0 0 0 0 0 Rn(4) Rt(4) 1 1 1 0 imm8(8) - - @syntax - - @conv { - - reg_T = Register(Rt) - reg_N = Register(Rn) - imm32 = ZeroExtend(imm8, 32) - mem_access = MakeMemoryAccess(reg_N, imm32, NULL, true, true, false) - - } - -} - -@encoding (A1) { - - @word cond(4) 0 1 0 0 U(1) 1 1 0 Rn(4) Rt(4) imm12(12) - - @syntax - - @conv { - - reg_T = Register(Rt) - reg_N = Register(Rn) - add = (U == '1') - imm32 = ZeroExtend(imm12, 32) - mem_access = MakeMemoryAccess(reg_N, imm32, NULL, false, add, false) - - } - - @rules { - - chk_call StoreCondition(cond) - - } - -} - -@encoding (A2) { - - @word cond(4) 0 1 1 0 U(1) 1 1 0 Rn(4) Rt(4) imm5(5) type(2) 0 Rm(4) - - @syntax - - @conv { - - reg_T = Register(Rt) - reg_N = Register(Rn) - reg_M = Register(Rm) - add = (U == '1') - shift = DecodeImmShift(type, imm5) - mem_access = MakeMemoryAccess(reg_N, reg_M, shift, false, add, false) - - } - - @rules { - - chk_call StoreCondition(cond) - - } - -} - diff --git a/src/arch/arm/v7/opdefs/strd_A88210.d b/src/arch/arm/v7/opdefs/strd_A88210.d deleted file mode 100644 index 437bcb3..0000000 --- a/src/arch/arm/v7/opdefs/strd_A88210.d +++ /dev/null @@ -1,75 +0,0 @@ - -/* Chrysalide - Outil d'analyse de fichiers binaires - * ##FILE## - traduction d'instructions ARMv7 - * - * Copyright (C) 2015 Cyrille Bagard - * - * This file is part of Chrysalide. - * - * Chrysalide is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Chrysalide is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Foobar. If not, see . - */ - - -@title STRD (immediate) - -@desc Store Register Dual (immediate) calculates an address from a base register value and an immediate offset, and stores two words from two registers to memory. It can use offset, post-indexed, or pre-indexed addressing. For information about memory accesses see Memory accesses on page A8-294. - -@encoding (T1) { - - @word 1 1 1 0 1 0 0 P(1) U(1) 1 W(1) 0 Rn(4) Rt(4) Rt2(4) imm8(8) - - @syntax - - @conv { - - reg_T = Register(Rt) - reg_T2 = Register(Rt2) - reg_N = Register(Rn) - imm32 = ZeroExtend(imm8:'00', 32) - index = (P == '1') - add = (U == '1') - wback = (W == '1') - mem_access = MakeMemoryAccess(reg_N, imm32, NULL, index, add, wback) - - } - -} - -@encoding (A1) { - - @word cond(4) 0 0 0 P(1) U(1) 1 W(1) 0 Rn(4) Rt(4) imm4H(4) 1 1 1 1 imm4L(4) - - @syntax - - @conv { - - reg_T = Register(Rt) - reg_T2 = NextRegister(reg_T) - reg_N = Register(Rn) - imm32 = ZeroExtend(imm4H:imm4L, 32) - index = (P == '1') - add = (U == '1') - wback = (P == '0') || (W == '1') - mem_access = MakeMemoryAccess(reg_N, imm32, NULL, index, add, wback) - - } - - @rules { - - chk_call StoreCondition(cond) - - } - -} - diff --git a/src/arch/arm/v7/opdefs/strd_A88211.d b/src/arch/arm/v7/opdefs/strd_A88211.d deleted file mode 100644 index b30d4a5..0000000 --- a/src/arch/arm/v7/opdefs/strd_A88211.d +++ /dev/null @@ -1,54 +0,0 @@ - -/* Chrysalide - Outil d'analyse de fichiers binaires - * ##FILE## - traduction d'instructions ARMv7 - * - * Copyright (C) 2015 Cyrille Bagard - * - * This file is part of Chrysalide. - * - * Chrysalide is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Chrysalide is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Foobar. If not, see . - */ - - -@title STRD (register) - -@desc Store Register Dual (register) calculates an address from a base register value and a register offset, and stores two words from two registers to memory. It can use offset, post-indexed, or pre-indexed addressing. For information about memory accesses see Memory accesses on page A8-294. - -@encoding (A1) { - - @word cond(4) 0 0 0 P(1) U(1) 0 W(1) 0 Rn(4) Rt(4) 0 0 0 0 1 1 1 1 Rm(4) - - @syntax - - @conv { - - reg_T = Register(Rt) - reg_T2 = NextRegister(reg_T) - reg_N = Register(Rn) - reg_M = Register(Rm) - index = (P == '1') - add = (U == '1') - wback = (P == '0') || (W == '1') - mem_access = MakeMemoryAccess(reg_N, reg_M, NULL, index, add, wback) - - } - - @rules { - - chk_call StoreCondition(cond) - - } - -} - diff --git a/src/arch/arm/v7/opdefs/strex_A88212.d b/src/arch/arm/v7/opdefs/strex_A88212.d deleted file mode 100644 index 65a7dfe..0000000 --- a/src/arch/arm/v7/opdefs/strex_A88212.d +++ /dev/null @@ -1,68 +0,0 @@ - -/* Chrysalide - Outil d'analyse de fichiers binaires - * ##FILE## - traduction d'instructions ARMv7 - * - * Copyright (C) 2015 Cyrille Bagard - * - * This file is part of Chrysalide. - * - * Chrysalide is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Chrysalide is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Foobar. If not, see . - */ - - -@title STREX - -@desc Store Register Exclusive calculates an address from a base register value and an immediate offset, and stores a word from a register to memory if the executing processor has exclusive access to the memory addressed. For more information about support for shared memory see Synchronization and semaphores on page A3-114. For information about memory accesses see Memory accesses on page A8-294. - -@encoding (T1) { - - @word 1 1 1 0 1 0 0 0 0 1 0 0 Rn(4) Rt(4) Rd(4) imm8(8) - - @syntax - - @conv { - - reg_D = Register(Rd) - reg_T = Register(Rt) - reg_N = Register(Rn) - imm32 = ZeroExtend(imm8:'00', 32) - mem_access = MakeMemoryAccess(reg_N, imm32, NULL, true, false, false) - - } - -} - -@encoding (A1) { - - @word cond(4) 0 0 0 1 1 0 0 0 Rn(4) Rd(4) 1 1 1 1 1 0 0 1 Rt(4) - - @syntax - - @conv { - - reg_D = Register(Rd) - reg_T = Register(Rt) - reg_N = Register(Rn) - mem_access = MakeMemoryAccess(reg_N, NULL, NULL, true, false, false) - - } - - @rules { - - chk_call StoreCondition(cond) - - } - -} - diff --git a/src/arch/arm/v7/opdefs/strexb_A88213.d b/src/arch/arm/v7/opdefs/strexb_A88213.d deleted file mode 100644 index 0197d6c..0000000 --- a/src/arch/arm/v7/opdefs/strexb_A88213.d +++ /dev/null @@ -1,67 +0,0 @@ - -/* Chrysalide - Outil d'analyse de fichiers binaires - * ##FILE## - traduction d'instructions ARMv7 - * - * Copyright (C) 2015 Cyrille Bagard - * - * This file is part of Chrysalide. - * - * Chrysalide is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Chrysalide is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Foobar. If not, see . - */ - - -@title STREXB - -@desc Store Register Exclusive Byte derives an address from a base register value, and stores a byte from a register to memory if the executing processor has exclusive access to the memory addressed. For more information about support for shared memory see Synchronization and semaphores on page A3-114. For information about memory accesses see Memory accesses on page A8-294. - -@encoding (T1) { - - @word 1 1 1 0 1 0 0 0 1 1 0 0 Rn(4) Rt(4) 1 1 1 1 0 1 0 0 Rd(4) - - @syntax - - @conv { - - reg_D = Register(Rd) - reg_T = Register(Rt) - reg_N = Register(Rn) - mem_access = MakeMemoryAccess(reg_N, NULL, NULL, true, false, false) - - } - -} - -@encoding (A1) { - - @word cond(4) 0 0 0 1 1 1 0 0 Rn(4) Rd(4) 1 1 1 1 1 0 0 1 Rt(4) - - @syntax - - @conv { - - reg_D = Register(Rd) - reg_T = Register(Rt) - reg_N = Register(Rn) - mem_access = MakeMemoryAccess(reg_N, NULL, NULL, true, false, false) - - } - - @rules { - - chk_call StoreCondition(cond) - - } - -} - diff --git a/src/arch/arm/v7/opdefs/strexd_A88214.d b/src/arch/arm/v7/opdefs/strexd_A88214.d deleted file mode 100644 index 2867cea..0000000 --- a/src/arch/arm/v7/opdefs/strexd_A88214.d +++ /dev/null @@ -1,69 +0,0 @@ - -/* Chrysalide - Outil d'analyse de fichiers binaires - * ##FILE## - traduction d'instructions ARMv7 - * - * Copyright (C) 2015 Cyrille Bagard - * - * This file is part of Chrysalide. - * - * Chrysalide is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Chrysalide is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Foobar. If not, see . - */ - - -@title STREXD - -@desc Store Register Exclusive Doubleword derives an address from a base register value, and stores a 64-bit doubleword from two registers to memory if the executing processor has exclusive access to the memory addressed. For more information about support for shared memory see Synchronization and semaphores on page A3-114. For information about memory accesses see Memory accesses on page A8-294. - -@encoding (T1) { - - @word 1 1 1 0 1 0 0 0 1 1 0 0 Rn(4) Rt(4) Rt2(4) 0 1 1 1 Rd(4) - - @syntax - - @conv { - - reg_D = Register(Rd) - reg_T = Register(Rt) - reg_T2 = Register(Rt2) - reg_N = Register(Rn) - mem_access = MakeMemoryAccess(reg_N, NULL, NULL, true, false, false) - - } - -} - -@encoding (A1) { - - @word cond(4) 0 0 0 1 1 0 1 0 Rn(4) Rd(4) 1 1 1 1 1 0 0 1 Rt(4) - - @syntax - - @conv { - - reg_D = Register(Rd) - reg_T = Register(Rt) - reg_T2 = NextRegister(reg_T) - reg_N = Register(Rn) - mem_access = MakeMemoryAccess(reg_N, NULL, NULL, true, false, false) - - } - - @rules { - - chk_call StoreCondition(cond) - - } - -} - diff --git a/src/arch/arm/v7/opdefs/strexh_A88215.d b/src/arch/arm/v7/opdefs/strexh_A88215.d deleted file mode 100644 index 4ca0b6f..0000000 --- a/src/arch/arm/v7/opdefs/strexh_A88215.d +++ /dev/null @@ -1,67 +0,0 @@ - -/* Chrysalide - Outil d'analyse de fichiers binaires - * ##FILE## - traduction d'instructions ARMv7 - * - * Copyright (C) 2015 Cyrille Bagard - * - * This file is part of Chrysalide. - * - * Chrysalide is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Chrysalide is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Foobar. If not, see . - */ - - -@title STREXH - -@desc Store Register Exclusive Halfword derives an address from a base register value, and stores a halfword from a register to memory if the executing processor has exclusive access to the memory addressed. For more information about support for shared memory see Synchronization and semaphores on page A3-114. For information about memory accesses see Memory accesses on page A8-294. - -@encoding (T1) { - - @word 1 1 1 0 1 0 0 0 1 1 0 0 Rn(4) Rt(4) 1 1 1 1 0 1 0 1 Rd(4) - - @syntax - - @conv { - - reg_D = Register(Rd) - reg_T = Register(Rt) - reg_N = Register(Rn) - mem_access = MakeMemoryAccess(reg_N, NULL, NULL, true, false, false) - - } - -} - -@encoding (A1) { - - @word cond(4) 0 0 0 1 1 1 1 0 Rn(4) Rd(4) 1 1 1 1 1 0 0 1 Rt(4) - - @syntax - - @conv { - - reg_D = Register(Rd) - reg_T = Register(Rt) - reg_N = Register(Rn) - mem_access = MakeMemoryAccess(reg_N, NULL, NULL, true, false, false) - - } - - @rules { - - chk_call StoreCondition(cond) - - } - -} - diff --git a/src/arch/arm/v7/opdefs/strh_A88216.d b/src/arch/arm/v7/opdefs/strh_A88216.d deleted file mode 100644 index 624b483..0000000 --- a/src/arch/arm/v7/opdefs/strh_A88216.d +++ /dev/null @@ -1,81 +0,0 @@ - -/* Chrysalide - Outil d'analyse de fichiers binaires - * ##FILE## - traduction d'instructions ARMv7 - * - * Copyright (C) 2015 Cyrille Bagard - * - * This file is part of Chrysalide. - * - * Chrysalide is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Chrysalide is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Foobar. If not, see . - */ - - -@title STRH (immediate, Thumb) - -@desc Store Register Halfword (immediate) calculates an address from a base register value and an immediate offset, and stores a halfword from a register to memory. It can use offset, post-indexed, or pre-indexed addressing. For information about memory accesses see Memory accesses on page A8-294. - -@encoding (t1) { - - @half 1 0 0 0 0 imm5(5) Rn(3) Rt(3) - - @syntax - - @conv { - - reg_T = Register(Rt) - reg_N = Register(Rn) - imm32 = ZeroExtend(imm5:'0', 32) - mem_access = MakeMemoryAccess(reg_N, imm32, NULL, true, true, false) - - } - -} - -@encoding (T2) { - - @word 1 1 1 1 1 0 0 0 1 0 1 0 Rn(4) Rt(4) imm12(12) - - @syntax ".W" - - @conv { - - reg_T = Register(Rt) - reg_N = Register(Rn) - imm32 = ZeroExtend(imm12, 32) - mem_access = MakeMemoryAccess(reg_N, imm32, NULL, true, true, false) - - } - -} - -@encoding (T3) { - - @word 1 1 1 1 1 0 0 0 0 0 1 0 Rn(4) Rt(4) 1 P(1) U(1) W(1) imm8(8) - - @syntax - - @conv { - - reg_T = Register(Rt) - reg_N = Register(Rn) - imm32 = ZeroExtend(imm8, 32) - index = (P == '1') - add = (U == '1') - wback = (W == '1') - mem_access = MakeMemoryAccess(reg_N, imm32, NULL, index, add, wback) - - } - -} - diff --git a/src/arch/arm/v7/opdefs/strh_A88217.d b/src/arch/arm/v7/opdefs/strh_A88217.d deleted file mode 100644 index 3b5f97c..0000000 --- a/src/arch/arm/v7/opdefs/strh_A88217.d +++ /dev/null @@ -1,53 +0,0 @@ - -/* Chrysalide - Outil d'analyse de fichiers binaires - * ##FILE## - traduction d'instructions ARMv7 - * - * Copyright (C) 2015 Cyrille Bagard - * - * This file is part of Chrysalide. - * - * Chrysalide is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Chrysalide is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Foobar. If not, see . - */ - - -@title STRH (immediate, ARM) - -@desc Store Register Halfword (immediate) calculates an address from a base register value and an immediate offset, and stores a halfword from a register to memory. It can use offset, post-indexed, or pre-indexed addressing. For information about memory accesses see Memory accesses on page A8-294. - -@encoding (A1) { - - @word cond(4) 0 0 0 P(1) U(1) 1 W(1) 0 Rn(4) Rt(4) imm4H(4) 1 0 1 1 imm4L(4) - - @syntax - - @conv { - - reg_T = Register(Rt) - reg_N = Register(Rn) - imm32 = ZeroExtend(imm4H:imm4L, 32) - index = (P == '1') - add = (U == '1') - wback = (P == '0') || (W == '1') - mem_access = MakeMemoryAccess(reg_N, imm32, NULL, index, add, wback) - - } - - @rules { - - chk_call StoreCondition(cond) - - } - -} - diff --git a/src/arch/arm/v7/opdefs/strh_A88218.d b/src/arch/arm/v7/opdefs/strh_A88218.d deleted file mode 100644 index 1e9dc1f..0000000 --- a/src/arch/arm/v7/opdefs/strh_A88218.d +++ /dev/null @@ -1,88 +0,0 @@ - -/* Chrysalide - Outil d'analyse de fichiers binaires - * ##FILE## - traduction d'instructions ARMv7 - * - * Copyright (C) 2015 Cyrille Bagard - * - * This file is part of Chrysalide. - * - * Chrysalide is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Chrysalide is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Foobar. If not, see . - */ - - -@title STRH (register) - -@desc Store Register Halfword (register) calculates an address from a base register value and an offset register value, and stores a halfword from a register to memory. The offset register value can be shifted left by 0, 1, 2, or 3 bits. For information about memory accesses see Memory accesses on page A8-294. - -@encoding (t1) { - - @half 0 1 0 1 0 0 1 Rm(3) Rn(3) Rt(3) - - @syntax - - @conv { - - reg_T = Register(Rt) - reg_N = Register(Rn) - reg_M = Register(Rm) - mem_access = MakeMemoryAccess(reg_N, reg_M, NULL, true, true, false) - - } - -} - -@encoding (T2) { - - @word 1 1 1 1 1 0 0 0 0 0 1 0 Rn(4) Rt(4) 0 0 0 0 0 0 imm2(2) Rm(4) - - @syntax ".W" - - @conv { - - reg_T = Register(Rt) - reg_N = Register(Rn) - reg_M = Register(Rm) - shift = DecodeImmShift(0, imm2) - mem_access = MakeMemoryAccess(reg_N, reg_M, shift, true, true, false) - - } - -} - -@encoding (A1) { - - @word cond(4) 0 0 0 P(1) U(1) 0 W(1) 0 Rn(4) Rt(4) 0 0 0 0 1 0 1 1 Rm(4) - - @syntax - - @conv { - - reg_T = Register(Rt) - reg_N = Register(Rn) - reg_M = Register(Rm) - index = (P == '1') - add = (U == '1') - wback = (P == '0') || (W == '1') - mem_access = MakeMemoryAccess(reg_N, reg_M, NULL, index, add, wback) - - } - - @rules { - - chk_call StoreCondition(cond) - - } - -} - diff --git a/src/arch/arm/v7/opdefs/strht_A88219.d b/src/arch/arm/v7/opdefs/strht_A88219.d deleted file mode 100644 index 3811572..0000000 --- a/src/arch/arm/v7/opdefs/strht_A88219.d +++ /dev/null @@ -1,92 +0,0 @@ - -/* Chrysalide - Outil d'analyse de fichiers binaires - * ##FILE## - traduction d'instructions ARMv7 - * - * Copyright (C) 2015 Cyrille Bagard - * - * This file is part of Chrysalide. - * - * Chrysalide is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Chrysalide is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Foobar. If not, see . - */ - - -@title STRHT - -@desc Store Register Halfword Unprivileged stores a halfword from a register to memory. For information about memory accesses see Memory accesses on page A8-294. The memory access is restricted as if the processor were running in User mode. This makes no difference if the processor is actually running in User mode. STRHT is UNPREDICTABLE in Hyp mode. The Thumb instruction uses an offset addressing mode, that calculates the address used for the memory access from a base register value and an immediate offset, and leaves the base register unchanged. The ARM instruction uses a post-indexed addressing mode, that uses a base register value as the address for the memory access, and calculates a new address from a base register value and an offset and writes it back to the base register. The offset can be an immediate value or a register value. - -@encoding (T1) { - - @word 1 1 1 1 1 0 0 0 0 0 1 0 Rn(4) Rt(4) 1 1 1 0 imm8(8) - - @syntax - - @conv { - - reg_T = Register(Rt) - reg_N = Register(Rn) - imm32 = ZeroExtend(imm8, 32) - mem_access = MakeMemoryAccess(reg_N, imm32, NULL, true, true, false) - - } - -} - -@encoding (A1) { - - @word cond(4) 0 0 0 0 U(1) 1 1 0 Rn(4) Rt(4) imm4H(4) 1 0 1 1 imm4L(4) - - @syntax - - @conv { - - reg_T = Register(Rt) - reg_N = Register(Rn) - add = (U == '1') - imm32 = ZeroExtend(imm4H:imm4L, 32) - mem_access = MakeMemoryAccess(reg_N, imm32, NULL, false, add, false) - - } - - @rules { - - chk_call StoreCondition(cond) - - } - -} - -@encoding (A2) { - - @word cond(4) 0 0 0 0 U(1) 0 1 0 Rn(4) Rt(4) 0 0 0 0 1 0 1 1 Rm(4) - - @syntax - - @conv { - - reg_T = Register(Rt) - reg_N = Register(Rn) - reg_M = Register(Rm) - add = (U == '1') - mem_access = MakeMemoryAccess(reg_N, reg_M, NULL, false, add, false) - - } - - @rules { - - chk_call StoreCondition(cond) - - } - -} - diff --git a/src/arch/arm/v7/opdefs/strt_A88220.d b/src/arch/arm/v7/opdefs/strt_A88220.d deleted file mode 100644 index 794a0fa..0000000 --- a/src/arch/arm/v7/opdefs/strt_A88220.d +++ /dev/null @@ -1,93 +0,0 @@ - -/* Chrysalide - Outil d'analyse de fichiers binaires - * ##FILE## - traduction d'instructions ARMv7 - * - * Copyright (C) 2015 Cyrille Bagard - * - * This file is part of Chrysalide. - * - * Chrysalide is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Chrysalide is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Foobar. If not, see . - */ - - -@title STRT - -@desc Store Register Unprivileged stores a word from a register to memory. For information about memory accesses see Memory accesses on page A8-294. The memory access is restricted as if the processor were running in User mode. This makes no difference if the processor is actually running in User mode. STRT is UNPREDICTABLE in Hyp mode. The Thumb instruction uses an offset addressing mode, that calculates the address used for the memory access from a base register value and an immediate offset, and leaves the base register unchanged. The ARM instruction uses a post-indexed addressing mode, that uses a base register value as the address for the memory access, and calculates a new address from a base register value and an offset and writes it back to the base register. The offset can be an immediate value or an optionally-shifted register value. - -@encoding (T1) { - - @word 1 1 1 1 1 0 0 0 0 1 0 0 Rn(4) Rt(4) 1 1 1 0 imm8(8) - - @syntax - - @conv { - - reg_T = Register(Rt) - reg_N = Register(Rn) - imm32 = ZeroExtend(imm8, 32) - mem_access = MakeMemoryAccess(reg_N, imm32, NULL, true, true, false) - - } - -} - -@encoding (A1) { - - @word cond(4) 0 1 0 0 U(1) 0 1 0 Rn(4) Rt(4) imm12(12) - - @syntax - - @conv { - - reg_T = Register(Rt) - reg_N = Register(Rn) - add = (U == '1') - imm32 = ZeroExtend(imm12, 32) - mem_access = MakeMemoryAccess(reg_N, imm32, NULL, false, add, false) - - } - - @rules { - - chk_call StoreCondition(cond) - - } - -} - -@encoding (A2) { - - @word cond(4) 0 1 1 0 U(1) 0 1 0 Rn(4) Rt(4) imm5(5) type(2) 0 Rm(4) - - @syntax - - @conv { - - reg_T = Register(Rt) - reg_N = Register(Rn) - reg_M = Register(Rm) - add = (U == '1') - shift = DecodeImmShift(type, imm5) - mem_access = MakeMemoryAccess(reg_N, reg_M, shift, false, add, false) - - } - - @rules { - - chk_call StoreCondition(cond) - - } - -} - diff --git a/src/arch/arm/v7/opdefs/sub_A88221.d b/src/arch/arm/v7/opdefs/sub_A88221.d deleted file mode 100644 index 41ce6b3..0000000 --- a/src/arch/arm/v7/opdefs/sub_A88221.d +++ /dev/null @@ -1,98 +0,0 @@ - -/* Chrysalide - Outil d'analyse de fichiers binaires - * ##FILE## - traduction d'instructions ARMv7 - * - * Copyright (C) 2015 Cyrille Bagard - * - * This file is part of Chrysalide. - * - * Chrysalide is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Chrysalide is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Foobar. If not, see . - */ - - -@title SUB (immediate, Thumb) - -@desc This instruction subtracts an immediate value from a register value, and writes the result to the destination register. It can optionally update the condition flags based on the result. - -@encoding (t1) { - - @half 0 0 0 1 1 1 1 imm3(3) Rn(3) Rd(3) - - @syntax "subs" - - @conv { - - reg_D = Register(Rd) - reg_N = Register(Rn) - imm32 = ZeroExtend(imm3, 32) - - } - -} - -@encoding (t2) { - - @half 0 0 1 1 1 Rdn(3) imm8(8) - - @syntax "subs" - - @conv { - - reg_DN = Register(Rdn) - imm32 = ZeroExtend(imm8, 32) - - } - -} - -@encoding (T3) { - - @word 1 1 1 1 0 i(1) 0 1 1 0 1 S(1) Rn(4) 0 imm3(3) Rd(4) imm8(8) - - @syntax - - @conv { - - reg_D = Register(Rd) - reg_N = Register(Rn) - setflags = (S == '1') - imm32 = ThumbExpandImm(i:imm3:imm8) - - } - - @rules { - - if (setflags); chk_call ExtendKeyword("s") - chk_call ExtendKeyword(".w") - - } - -} - -@encoding (T4) { - - @word 1 1 1 1 0 i(1) 1 0 1 0 1 0 Rn(4) 0 imm3(3) Rd(4) imm8(8) - - @syntax "subw" - - @conv { - - reg_D = Register(Rd) - reg_N = Register(Rn) - imm32 = ZeroExtend(i:imm3:imm8, 32) - - } - -} - diff --git a/src/arch/arm/v7/opdefs/sub_A88222.d b/src/arch/arm/v7/opdefs/sub_A88222.d deleted file mode 100644 index ef326b8..0000000 --- a/src/arch/arm/v7/opdefs/sub_A88222.d +++ /dev/null @@ -1,51 +0,0 @@ - -/* Chrysalide - Outil d'analyse de fichiers binaires - * ##FILE## - traduction d'instructions ARMv7 - * - * Copyright (C) 2015 Cyrille Bagard - * - * This file is part of Chrysalide. - * - * Chrysalide is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Chrysalide is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Foobar. If not, see . - */ - - -@title SUB (immediate, ARM) - -@desc This instruction subtracts an immediate value from a register value, and writes the result to the destination register. It can optionally update the condition flags based on the result. - -@encoding (A1) { - - @word cond(4) 0 0 1 0 0 1 0 S(1) Rn(4) Rd(4) imm12(12) - - @syntax - - @conv { - - reg_D = Register(Rd) - reg_N = Register(Rn) - setflags = (S == '1') - imm32 = ARMExpandImm(imm12) - - } - - @rules { - - if (setflags); chk_call ExtendKeyword("s") - chk_call StoreCondition(cond) - - } - -} - diff --git a/src/arch/arm/v7/opdefs/sub_A88223.d b/src/arch/arm/v7/opdefs/sub_A88223.d deleted file mode 100644 index a629250..0000000 --- a/src/arch/arm/v7/opdefs/sub_A88223.d +++ /dev/null @@ -1,93 +0,0 @@ - -/* Chrysalide - Outil d'analyse de fichiers binaires - * ##FILE## - traduction d'instructions ARMv7 - * - * Copyright (C) 2015 Cyrille Bagard - * - * This file is part of Chrysalide. - * - * Chrysalide is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Chrysalide is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Foobar. If not, see . - */ - - -@title SUB (register) - -@desc This instruction subtracts an optionally-shifted register value from a register value, and writes the result to the destination register. It can optionally update the condition flags based on the result. - -@encoding (t1) { - - @half 0 0 0 1 1 0 1 Rm(3) Rn(3) Rd(3) - - @syntax "subs" - - @conv { - - reg_D = Register(Rd) - reg_N = Register(Rn) - reg_M = Register(Rm) - - } - -} - -@encoding (T2) { - - @word 1 1 1 0 1 0 1 1 1 0 1 S(1) Rn(4) 0 imm3(3) Rd(4) imm2(2) type(2) Rm(4) - - @syntax - - @conv { - - reg_D = Register(Rd) - reg_N = Register(Rn) - reg_M = Register(Rm) - setflags = (S == '1') - shift = DecodeImmShift(type, imm3:imm2) - - } - - @rules { - - if (setflags); chk_call ExtendKeyword("s") - chk_call ExtendKeyword(".w") - - } - -} - -@encoding (A1) { - - @word cond(4) 0 0 0 0 0 1 0 S(1) Rn(4) Rd(4) imm5(5) type(2) 0 Rm(4) - - @syntax - - @conv { - - reg_D = Register(Rd) - reg_N = Register(Rn) - reg_M = Register(Rm) - setflags = (S == '1') - shift = DecodeImmShift(type, imm5) - - } - - @rules { - - if (setflags); chk_call ExtendKeyword("s") - chk_call StoreCondition(cond) - - } - -} - diff --git a/src/arch/arm/v7/opdefs/sub_A88224.d b/src/arch/arm/v7/opdefs/sub_A88224.d deleted file mode 100644 index 5ef4e4d..0000000 --- a/src/arch/arm/v7/opdefs/sub_A88224.d +++ /dev/null @@ -1,52 +0,0 @@ - -/* Chrysalide - Outil d'analyse de fichiers binaires - * ##FILE## - traduction d'instructions ARMv7 - * - * Copyright (C) 2015 Cyrille Bagard - * - * This file is part of Chrysalide. - * - * Chrysalide is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Chrysalide is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Foobar. If not, see . - */ - - -@title SUB (register-shifted register) - -@desc This instruction subtracts a register-shifted register value from a register value, and writes the result to the destination register. It can optionally update the condition flags based on the result. - -@encoding (A1) { - - @word cond(4) 0 0 0 0 0 1 0 S(1) Rn(4) Rd(4) Rs(4) 0 type(2) 1 Rm(4) - - @syntax - - @conv { - - reg_shift = RegisterShift(type, Rs) - reg_D = Register(Rd) - reg_N = Register(Rn) - reg_M = Register(Rm) - setflags = (S == '1') - - } - - @rules { - - if (setflags); chk_call ExtendKeyword("s") - chk_call StoreCondition(cond) - - } - -} - diff --git a/src/arch/arm/v7/opdefs/sub_A88225.d b/src/arch/arm/v7/opdefs/sub_A88225.d deleted file mode 100644 index dc54c6b..0000000 --- a/src/arch/arm/v7/opdefs/sub_A88225.d +++ /dev/null @@ -1,107 +0,0 @@ - -/* Chrysalide - Outil d'analyse de fichiers binaires - * ##FILE## - traduction d'instructions ARMv7 - * - * Copyright (C) 2015 Cyrille Bagard - * - * This file is part of Chrysalide. - * - * Chrysalide is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Chrysalide is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Foobar. If not, see . - */ - - -@title SUB (SP minus immediate) - -@desc This instruction subtracts an immediate value from the SP value, and writes the result to the destination register. - -@encoding (t1) { - - @half 1 0 1 1 0 0 0 0 1 imm7(7) - - @syntax - - @conv { - - imm32 = ZeroExtend(imm7:'00', 32) - SP_0 = Register(13) - SP_1 = Register(13) - - } - -} - -@encoding (T2) { - - @word 1 1 1 1 0 i(1) 0 1 1 0 1 S(1) 1 1 0 1 0 imm3(3) Rd(4) imm8(8) - - @syntax - - @conv { - - reg_D = Register(Rd) - setflags = (S == '1') - imm32 = ThumbExpandImm(i:imm3:imm8) - SP = Register(13) - - } - - @rules { - - if (setflags); chk_call ExtendKeyword("s") - chk_call ExtendKeyword(".w") - - } - -} - -@encoding (T3) { - - @word 1 1 1 1 0 i(1) 1 0 1 0 1 0 1 1 0 1 0 imm3(3) Rd(4) imm8(8) - - @syntax "subw" - - @conv { - - reg_D = Register(Rd) - imm32 = ZeroExtend(i:imm3:imm8, 32) - SP = Register(13) - - } - -} - -@encoding (A1) { - - @word cond(4) 0 0 1 0 0 1 0 S(1) 1 1 0 1 Rd(4) imm12(12) - - @syntax - - @conv { - - reg_D = Register(Rd) - setflags = (S == '1') - imm32 = ARMExpandImm(imm12) - SP = Register(13) - - } - - @rules { - - if (setflags); chk_call ExtendKeyword("s") - chk_call StoreCondition(cond) - - } - -} - diff --git a/src/arch/arm/v7/opdefs/sub_A88226.d b/src/arch/arm/v7/opdefs/sub_A88226.d deleted file mode 100644 index 02ecada..0000000 --- a/src/arch/arm/v7/opdefs/sub_A88226.d +++ /dev/null @@ -1,76 +0,0 @@ - -/* Chrysalide - Outil d'analyse de fichiers binaires - * ##FILE## - traduction d'instructions ARMv7 - * - * Copyright (C) 2015 Cyrille Bagard - * - * This file is part of Chrysalide. - * - * Chrysalide is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Chrysalide is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Foobar. If not, see . - */ - - -@title SUB (SP minus register) - -@desc This instruction subtracts an optionally-shifted register value from the SP value, and writes the result to the destination register. - -@encoding (T1) { - - @word 1 1 1 0 1 0 1 1 1 0 1 S(1) 1 1 0 1 0 imm3(3) Rd(4) imm2(2) type(2) Rm(4) - - @syntax - - @conv { - - reg_D = Register(Rd) - reg_M = Register(Rm) - setflags = (S == '1') - shift = DecodeImmShift(type, imm3:imm2) - SP = Register(13) - - } - - @rules { - - if (setflags); chk_call ExtendKeyword("s") - - } - -} - -@encoding (A1) { - - @word cond(4) 0 0 0 0 0 1 0 S(1) 1 1 0 1 Rd(4) imm5(5) type(2) 0 Rm(4) - - @syntax - - @conv { - - reg_D = Register(Rd) - reg_M = Register(Rm) - setflags = (S == '1') - shift = DecodeImmShift(type, imm5) - SP = Register(13) - - } - - @rules { - - if (setflags); chk_call ExtendKeyword("s") - chk_call StoreCondition(cond) - - } - -} - diff --git a/src/arch/arm/v7/opdefs/subs_B9320.d b/src/arch/arm/v7/opdefs/subs_B9320.d deleted file mode 100644 index 335e614..0000000 --- a/src/arch/arm/v7/opdefs/subs_B9320.d +++ /dev/null @@ -1,44 +0,0 @@ - -/* Chrysalide - Outil d'analyse de fichiers binaires - * ##FILE## - traduction d'instructions ARMv7 - * - * Copyright (C) 2014 Cyrille Bagard - * - * This file is part of Chrysalide. - * - * Chrysalide is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Chrysalide is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Foobar. If not, see . - */ - - -@title SUBS PC, LR and related instructions (ARM) - -@encoding(A1) { - - @word cond(4) 0 0 1 opcode(4) 1 Rn(4) 1 1 1 1 imm12(12) - - @syntax {c} <#const> - - @conv { - - c = Condition(cond) - Rn = Register(Rn) - const = ExpandImmC32(imm12) - - } - - @rules { - - } - -} diff --git a/src/arch/arm/v7/opdefs/svc_A88228.d b/src/arch/arm/v7/opdefs/svc_A88228.d deleted file mode 100644 index be48545..0000000 --- a/src/arch/arm/v7/opdefs/svc_A88228.d +++ /dev/null @@ -1,61 +0,0 @@ - -/* Chrysalide - Outil d'analyse de fichiers binaires - * ##FILE## - traduction d'instructions ARMv7 - * - * Copyright (C) 2015 Cyrille Bagard - * - * This file is part of Chrysalide. - * - * Chrysalide is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Chrysalide is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Foobar. If not, see . - */ - - -@title SVC (previously SWI) - -@desc Supervisor Call, previously called Software Interrupt, causes a Supervisor Call exception. For more information, see Supervisor Call (SVC) exception on page B1-1209. Software can use this instruction as a call to an operating system to provide a service. In the following cases, the Supervisor Call exception generated by the SVC instruction is taken to Hyp mode: • If the SVC is executed in Hyp mode. • If HCR.TGE is set to 1, and the SVC is executed in Non-secure User mode. For more information, see Supervisor Call exception, when HCR.TGE is set to 1 on page B1-1191 In these cases, the HSR identifies that the exception entry was caused by a Supervisor Call exception, EC value 0x11, see Use of the HSR on page B3-1424. The immediate field in the HSR: • if the SVC is unconditional: — for the Thumb instruction, is the zero-extended value of the imm8 field — for the ARM instruction, is the least-significant 16 bits the imm24 field • if the SVC is conditional, is UNKNOWN. - -@encoding (t1) { - - @half 1 1 0 1 1 1 1 1 imm8(8) - - @syntax - - @conv { - - imm32 = ZeroExtend(imm8, 32) - - } - -} - -@encoding (A1) { - - @word cond(4) 1 1 1 1 imm24(24) - - @syntax - - @conv { - - imm32 = ZeroExtend(imm24, 32) - - } - - @rules { - - chk_call StoreCondition(cond) - - } - -} - diff --git a/src/arch/arm/v7/opdefs/swp_A88229.d b/src/arch/arm/v7/opdefs/swp_A88229.d deleted file mode 100644 index 2e39015..0000000 --- a/src/arch/arm/v7/opdefs/swp_A88229.d +++ /dev/null @@ -1,52 +0,0 @@ - -/* Chrysalide - Outil d'analyse de fichiers binaires - * ##FILE## - traduction d'instructions ARMv7 - * - * Copyright (C) 2015 Cyrille Bagard - * - * This file is part of Chrysalide. - * - * Chrysalide is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Chrysalide is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Foobar. If not, see . - */ - - -@title SWP, SWPB - -@desc SWP (Swap) swaps a word between registers and memory. SWP loads a word from the memory address given by the value of register . The value of register is then stored to the memory address given by the value of , and the original loaded value is written to register . If the same register is specified for and , this instruction swaps the value of the register and the value at the memory address. SWPB (Swap Byte) swaps a byte between registers and memory. SWPB loads a byte from the memory address given by the value of register . The value of the least significant byte of register is stored to the memory address given by , the original loaded value is zero-extended to a 32-bit word, and the word is written to register . If the same register is specified for and , this instruction swaps the value of the least significant byte of the register and the byte value at the memory address, and clears the most significant three bytes of the register. For both instructions, the memory system ensures that no other memory access can occur to the memory location between the load access and the store access. Note • The SWP and SWPB instructions rely on the properties of the system beyond the processor to ensure that no stores from other observers can occur between the load access and the store access, and this might not be implemented for all regions of memory on some system implementations. In all cases, SWP and SWPB do ensure that no stores from the processor that executed the SWP or SWPB instruction can occur between the load access and the store access of the SWP or SWPB. • ARM deprecates the use of SWP and SWPB, and strongly recommends that new software uses: LDREX/STREX in preference to SWP — LDREXB/STREXB in preference to SWPB. — • If the translation table entries that relate to a memory location accessed by the SWP or SWPB instruction change, or are seen to change by the executing processor as a result of TLB eviction, this might mean that the translation table attributes, permissions or addresses for the load are different to those for the store. In this case, the architecture makes no guarantee that no memory access occur to these memory locations between the load and store. The Virtualization Extensions make the SWP and SWPB instructions OPTIONAL and deprecated: • If an implementation does not include the SWP and SWPB instructions, the ID_ISAR0.Swap_instrs and ID_ISAR4.SWP_frac fields are zero, see About the Instruction Set Attribute registers on page B7-1950. • In an implementation that includes SWP and SWPB, both instructions are UNDEFINED in Hyp mode. - -@encoding (A1) { - - @word cond(4) 0 0 0 1 0 B(1) 0 0 Rn(4) Rt(4) 0 0 0 0 1 0 0 1 Rt2(4) - - @syntax - - @conv { - - reg_T = Register(Rt) - reg_T2 = Register(Rt2) - reg_N = Register(Rn) - size = (B != 4) - mem_access = MakeMemoryAccess(reg_N, NULL, NULL, true, false, false) - - } - - @rules { - - if (size); chk_call ExtendKeyword("b") - chk_call StoreCondition(cond) - - } - -} - diff --git a/src/arch/arm/v7/opdefs/teq_A88237.d b/src/arch/arm/v7/opdefs/teq_A88237.d deleted file mode 100644 index 89073f6..0000000 --- a/src/arch/arm/v7/opdefs/teq_A88237.d +++ /dev/null @@ -1,63 +0,0 @@ - -/* Chrysalide - Outil d'analyse de fichiers binaires - * ##FILE## - traduction d'instructions ARMv7 - * - * Copyright (C) 2015 Cyrille Bagard - * - * This file is part of Chrysalide. - * - * Chrysalide is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Chrysalide is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Foobar. If not, see . - */ - - -@title TEQ (immediate) - -@desc Test Equivalence (immediate) performs a bitwise exclusive OR operation on a register value and an immediate value. It updates the condition flags based on the result, and discards the result. - -@encoding (T1) { - - @word 1 1 1 1 0 i(1) 0 0 1 0 0 1 Rn(4) 0 imm3(3) 1 1 1 1 imm8(8) - - @syntax - - @conv { - - reg_N = Register(Rn) - imm32 = ThumbExpandImm_C(i:imm3:imm8, 0) - - } - -} - -@encoding (A1) { - - @word cond(4) 0 0 1 1 0 0 1 1 Rn(4) 0 0 0 0 imm12(12) - - @syntax - - @conv { - - reg_N = Register(Rn) - imm32 = ARMExpandImm_C(imm12, 0) - - } - - @rules { - - chk_call StoreCondition(cond) - - } - -} - diff --git a/src/arch/arm/v7/opdefs/teq_A88238.d b/src/arch/arm/v7/opdefs/teq_A88238.d deleted file mode 100644 index 8187d81..0000000 --- a/src/arch/arm/v7/opdefs/teq_A88238.d +++ /dev/null @@ -1,65 +0,0 @@ - -/* Chrysalide - Outil d'analyse de fichiers binaires - * ##FILE## - traduction d'instructions ARMv7 - * - * Copyright (C) 2015 Cyrille Bagard - * - * This file is part of Chrysalide. - * - * Chrysalide is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Chrysalide is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Foobar. If not, see . - */ - - -@title TEQ (register) - -@desc Test Equivalence (register) performs a bitwise exclusive OR operation on a register value and an optionally-shifted register value. It updates the condition flags based on the result, and discards the result. - -@encoding (T1) { - - @word 1 1 1 0 1 0 1 0 1 0 0 1 Rn(4) 0 imm3(3) 1 1 1 1 imm2(2) type(2) Rm(4) - - @syntax - - @conv { - - reg_N = Register(Rn) - reg_M = Register(Rm) - shift = DecodeImmShift(type, imm3:imm2) - - } - -} - -@encoding (A1) { - - @word cond(4) 0 0 0 1 0 0 1 1 Rn(4) 0 0 0 0 imm5(5) type(2) 0 Rm(4) - - @syntax - - @conv { - - reg_N = Register(Rn) - reg_M = Register(Rm) - shift = DecodeImmShift(type, imm5) - - } - - @rules { - - chk_call StoreCondition(cond) - - } - -} - diff --git a/src/arch/arm/v7/opdefs/teq_A88239.d b/src/arch/arm/v7/opdefs/teq_A88239.d deleted file mode 100644 index 986a7f0..0000000 --- a/src/arch/arm/v7/opdefs/teq_A88239.d +++ /dev/null @@ -1,49 +0,0 @@ - -/* Chrysalide - Outil d'analyse de fichiers binaires - * ##FILE## - traduction d'instructions ARMv7 - * - * Copyright (C) 2015 Cyrille Bagard - * - * This file is part of Chrysalide. - * - * Chrysalide is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Chrysalide is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Foobar. If not, see . - */ - - -@title TEQ (register-shifted register) - -@desc Test Equivalence (register-shifted register) performs a bitwise exclusive OR operation on a register value and a register-shifted register value. It updates the condition flags based on the result, and discards the result. - -@encoding (A1) { - - @word cond(4) 0 0 0 1 0 0 1 1 Rn(4) 0 0 0 0 Rs(4) 0 type(2) 1 Rm(4) - - @syntax - - @conv { - - reg_shift = RegisterShift(type, Rs) - reg_N = Register(Rn) - reg_M = Register(Rm) - - } - - @rules { - - chk_call StoreCondition(cond) - - } - -} - diff --git a/src/arch/arm/v7/opdefs/tst_A88240.d b/src/arch/arm/v7/opdefs/tst_A88240.d deleted file mode 100644 index 0ff5121..0000000 --- a/src/arch/arm/v7/opdefs/tst_A88240.d +++ /dev/null @@ -1,63 +0,0 @@ - -/* Chrysalide - Outil d'analyse de fichiers binaires - * ##FILE## - traduction d'instructions ARMv7 - * - * Copyright (C) 2015 Cyrille Bagard - * - * This file is part of Chrysalide. - * - * Chrysalide is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Chrysalide is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Foobar. If not, see . - */ - - -@title TST (immediate) - -@desc Test (immediate) performs a bitwise AND operation on a register value and an immediate value. It updates the condition flags based on the result, and discards the result. - -@encoding (T1) { - - @word 1 1 1 1 0 i(1) 0 0 0 0 0 1 Rn(4) 0 imm3(3) 1 1 1 1 imm8(8) - - @syntax - - @conv { - - reg_N = Register(Rn) - imm32 = ThumbExpandImm_C(i:imm3:imm8, 0) - - } - -} - -@encoding (A1) { - - @word cond(4) 0 0 1 1 0 0 0 1 Rn(4) 0 0 0 0 imm12(12) - - @syntax - - @conv { - - reg_N = Register(Rn) - imm32 = ARMExpandImm_C(imm12, 0) - - } - - @rules { - - chk_call StoreCondition(cond) - - } - -} - diff --git a/src/arch/arm/v7/opdefs/tst_A88241.d b/src/arch/arm/v7/opdefs/tst_A88241.d deleted file mode 100644 index 8777d06..0000000 --- a/src/arch/arm/v7/opdefs/tst_A88241.d +++ /dev/null @@ -1,80 +0,0 @@ - -/* Chrysalide - Outil d'analyse de fichiers binaires - * ##FILE## - traduction d'instructions ARMv7 - * - * Copyright (C) 2015 Cyrille Bagard - * - * This file is part of Chrysalide. - * - * Chrysalide is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Chrysalide is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Foobar. If not, see . - */ - - -@title TST (register) - -@desc Test (register) performs a bitwise AND operation on a register value and an optionally-shifted register value. It updates the condition flags based on the result, and discards the result. - -@encoding (t1) { - - @half 0 1 0 0 0 0 1 0 0 0 Rm(3) Rn(3) - - @syntax - - @conv { - - reg_N = Register(Rn) - reg_M = Register(Rm) - - } - -} - -@encoding (T2) { - - @word 1 1 1 0 1 0 1 0 0 0 0 1 Rn(4) 0 imm3(3) 1 1 1 1 imm2(2) type(2) Rm(4) - - @syntax ".W" - - @conv { - - reg_N = Register(Rn) - reg_M = Register(Rm) - shift = DecodeImmShift(type, imm3:imm2) - - } - -} - -@encoding (A1) { - - @word cond(4) 0 0 0 1 0 0 0 1 Rn(4) 0 0 0 0 imm5(5) type(2) 0 Rm(4) - - @syntax - - @conv { - - reg_N = Register(Rn) - reg_M = Register(Rm) - shift = DecodeImmShift(type, imm5) - - } - - @rules { - - chk_call StoreCondition(cond) - - } - -} - diff --git a/src/arch/arm/v7/opdefs/tst_A88242.d b/src/arch/arm/v7/opdefs/tst_A88242.d deleted file mode 100644 index d3fdd9c..0000000 --- a/src/arch/arm/v7/opdefs/tst_A88242.d +++ /dev/null @@ -1,49 +0,0 @@ - -/* Chrysalide - Outil d'analyse de fichiers binaires - * ##FILE## - traduction d'instructions ARMv7 - * - * Copyright (C) 2015 Cyrille Bagard - * - * This file is part of Chrysalide. - * - * Chrysalide is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Chrysalide is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Foobar. If not, see . - */ - - -@title TST (register-shifted register) - -@desc Test (register-shifted register) performs a bitwise AND operation on a register value and a register-shifted register value. It updates the condition flags based on the result, and discards the result. - -@encoding (A1) { - - @word cond(4) 0 0 0 1 0 0 0 1 Rn(4) 0 0 0 0 Rs(4) 0 type(2) 1 Rm(4) - - @syntax - - @conv { - - reg_shift = RegisterShift(type, Rs) - reg_N = Register(Rn) - reg_M = Register(Rm) - - } - - @rules { - - chk_call StoreCondition(cond) - - } - -} - diff --git a/src/arch/arm/v7/opdefs/uadd16_A88243.d b/src/arch/arm/v7/opdefs/uadd16_A88243.d deleted file mode 100644 index fcaadee..0000000 --- a/src/arch/arm/v7/opdefs/uadd16_A88243.d +++ /dev/null @@ -1,65 +0,0 @@ - -/* Chrysalide - Outil d'analyse de fichiers binaires - * ##FILE## - traduction d'instructions ARMv7 - * - * Copyright (C) 2015 Cyrille Bagard - * - * This file is part of Chrysalide. - * - * Chrysalide is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Chrysalide is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Foobar. If not, see . - */ - - -@title UADD16 - -@desc Unsigned Add 16 performs two 16-bit unsigned integer additions, and writes the results to the destination register. It sets the APSR.GE bits according to the results of the additions. - -@encoding (T1) { - - @word 1 1 1 1 1 0 1 0 1 0 0 1 Rn(4) 1 1 1 1 Rd(4) 0 1 0 0 Rm(4) - - @syntax - - @conv { - - reg_D = Register(Rd) - reg_N = Register(Rn) - reg_M = Register(Rm) - - } - -} - -@encoding (A1) { - - @word cond(4) 0 1 1 0 0 1 0 1 Rn(4) Rd(4) 1 1 1 1 0 0 0 1 Rm(4) - - @syntax - - @conv { - - reg_D = Register(Rd) - reg_N = Register(Rn) - reg_M = Register(Rm) - - } - - @rules { - - chk_call StoreCondition(cond) - - } - -} - diff --git a/src/arch/arm/v7/opdefs/uadd8_A88244.d b/src/arch/arm/v7/opdefs/uadd8_A88244.d deleted file mode 100644 index 451ca79..0000000 --- a/src/arch/arm/v7/opdefs/uadd8_A88244.d +++ /dev/null @@ -1,65 +0,0 @@ - -/* Chrysalide - Outil d'analyse de fichiers binaires - * ##FILE## - traduction d'instructions ARMv7 - * - * Copyright (C) 2015 Cyrille Bagard - * - * This file is part of Chrysalide. - * - * Chrysalide is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Chrysalide is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Foobar. If not, see . - */ - - -@title UADD8 - -@desc Unsigned Add 8 performs four unsigned 8-bit integer additions, and writes the results to the destination register. It sets the APSR.GE bits according to the results of the additions. - -@encoding (T1) { - - @word 1 1 1 1 1 0 1 0 1 0 0 0 Rn(4) 1 1 1 1 Rd(4) 0 1 0 0 Rm(4) - - @syntax - - @conv { - - reg_D = Register(Rd) - reg_N = Register(Rn) - reg_M = Register(Rm) - - } - -} - -@encoding (A1) { - - @word cond(4) 0 1 1 0 0 1 0 1 Rn(4) Rd(4) 1 1 1 1 1 0 0 1 Rm(4) - - @syntax - - @conv { - - reg_D = Register(Rd) - reg_N = Register(Rn) - reg_M = Register(Rm) - - } - - @rules { - - chk_call StoreCondition(cond) - - } - -} - diff --git a/src/arch/arm/v7/opdefs/uasx_A88245.d b/src/arch/arm/v7/opdefs/uasx_A88245.d deleted file mode 100644 index f968527..0000000 --- a/src/arch/arm/v7/opdefs/uasx_A88245.d +++ /dev/null @@ -1,65 +0,0 @@ - -/* Chrysalide - Outil d'analyse de fichiers binaires - * ##FILE## - traduction d'instructions ARMv7 - * - * Copyright (C) 2015 Cyrille Bagard - * - * This file is part of Chrysalide. - * - * Chrysalide is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Chrysalide is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Foobar. If not, see . - */ - - -@title UASX - -@desc Unsigned Add and Subtract with Exchange exchanges the two halfwords of the second operand, performs one unsigned 16-bit integer addition and one unsigned 16-bit subtraction, and writes the results to the destination register. It sets the APSR.GE bits according to the results. - -@encoding (T1) { - - @word 1 1 1 1 1 0 1 0 1 0 1 0 Rn(4) 1 1 1 1 Rd(4) 0 1 0 0 Rm(4) - - @syntax - - @conv { - - reg_D = Register(Rd) - reg_N = Register(Rn) - reg_M = Register(Rm) - - } - -} - -@encoding (A1) { - - @word cond(4) 0 1 1 0 0 1 0 1 Rn(4) Rd(4) 1 1 1 1 0 0 1 1 Rm(4) - - @syntax - - @conv { - - reg_D = Register(Rd) - reg_N = Register(Rn) - reg_M = Register(Rm) - - } - - @rules { - - chk_call StoreCondition(cond) - - } - -} - diff --git a/src/arch/arm/v7/opdefs/ubfx_A88246.d b/src/arch/arm/v7/opdefs/ubfx_A88246.d deleted file mode 100644 index 1f9488e..0000000 --- a/src/arch/arm/v7/opdefs/ubfx_A88246.d +++ /dev/null @@ -1,67 +0,0 @@ - -/* Chrysalide - Outil d'analyse de fichiers binaires - * ##FILE## - traduction d'instructions ARMv7 - * - * Copyright (C) 2015 Cyrille Bagard - * - * This file is part of Chrysalide. - * - * Chrysalide is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Chrysalide is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Foobar. If not, see . - */ - - -@title UBFX - -@desc Unsigned Bit Field Extract extracts any number of adjacent bits at any position from a register, zero-extends them to 32 bits, and writes the result to the destination register. - -@encoding (T1) { - - @word 1 1 1 1 0 0 1 1 1 1 0 0 Rn(4) 0 imm3(3) Rd(4) imm2(2) 0 widthm1(5) - - @syntax - - @conv { - - reg_D = Register(Rd) - reg_N = Register(Rn) - lsbit = UInt(imm3:imm2) - width = IncWidth(widthm1) - - } - -} - -@encoding (A1) { - - @word cond(4) 0 1 1 1 1 1 1 widthm1(5) Rd(4) lsb(5) 1 0 1 Rn(4) - - @syntax - - @conv { - - reg_D = Register(Rd) - reg_N = Register(Rn) - lsbit = UInt(lsb) - width = IncWidth(widthm1) - - } - - @rules { - - chk_call StoreCondition(cond) - - } - -} - diff --git a/src/arch/arm/v7/opdefs/udf_A88247.d b/src/arch/arm/v7/opdefs/udf_A88247.d deleted file mode 100644 index 38f818c..0000000 --- a/src/arch/arm/v7/opdefs/udf_A88247.d +++ /dev/null @@ -1,69 +0,0 @@ - -/* Chrysalide - Outil d'analyse de fichiers binaires - * ##FILE## - traduction d'instructions ARMv7 - * - * Copyright (C) 2015 Cyrille Bagard - * - * This file is part of Chrysalide. - * - * Chrysalide is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Chrysalide is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Foobar. If not, see . - */ - - -@title UDF - -@desc Permanently Undefined generates an Undefined Instruction exception. The encodings for UDF used in this section are defined as permanently UNDEFINED in the versions of the architecture specified in this section. Issue C.a of this manual first defines an assembler mnemonic for these encodings. However: • with the Thumb instruction set, ARM deprecates using the UDF instruction in an IT block • in the ARM instruction set, UDF is not conditional. - -@encoding (t1) { - - @half 1 1 0 1 1 1 1 0 imm8(8) - - @syntax - - @conv { - - imm32 = ZeroExtend(imm8, 32) - - } - -} - -@encoding (T2) { - - @word 1 1 1 1 0 1 1 1 1 1 1 1 imm4(4) 1 0 1 0 imm12(12) - - @syntax ".W" - - @conv { - - imm32 = ZeroExtend(imm4:imm12, 32) - - } - -} - -@encoding (A1) { - - @word 1 1 1 0 0 1 1 1 1 1 1 1 imm12(12) 1 1 1 1 imm4(4) - - @syntax - - @conv { - - imm32 = ZeroExtend(imm12:imm4, 32) - - } - -} - diff --git a/src/arch/arm/v7/opdefs/udiv_A88248.d b/src/arch/arm/v7/opdefs/udiv_A88248.d deleted file mode 100644 index eea7947..0000000 --- a/src/arch/arm/v7/opdefs/udiv_A88248.d +++ /dev/null @@ -1,65 +0,0 @@ - -/* Chrysalide - Outil d'analyse de fichiers binaires - * ##FILE## - traduction d'instructions ARMv7 - * - * Copyright (C) 2015 Cyrille Bagard - * - * This file is part of Chrysalide. - * - * Chrysalide is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Chrysalide is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Foobar. If not, see . - */ - - -@title UDIV - -@desc Unsigned Divide divides a 32-bit unsigned integer register value by a 32-bit unsigned integer register value, and writes the result to the destination register. The condition flags are not affected. See ARMv7 implementation requirements and options for the divide instructions on page A4-172 for more information about this instruction. - -@encoding (T1) { - - @word 1 1 1 1 1 0 1 1 1 0 1 1 Rn(4) 1 1 1 1 Rd(4) 1 1 1 1 Rm(4) - - @syntax - - @conv { - - reg_D = Register(Rd) - reg_N = Register(Rn) - reg_M = Register(Rm) - - } - -} - -@encoding (A1) { - - @word cond(4) 0 1 1 1 0 0 1 1 Rd(4) 1 1 1 1 Rm(4) 0 0 0 1 Rn(4) - - @syntax - - @conv { - - reg_D = Register(Rd) - reg_N = Register(Rn) - reg_M = Register(Rm) - - } - - @rules { - - chk_call StoreCondition(cond) - - } - -} - diff --git a/src/arch/arm/v7/opdefs/uhadd16_A88249.d b/src/arch/arm/v7/opdefs/uhadd16_A88249.d deleted file mode 100644 index 54da5b0..0000000 --- a/src/arch/arm/v7/opdefs/uhadd16_A88249.d +++ /dev/null @@ -1,65 +0,0 @@ - -/* Chrysalide - Outil d'analyse de fichiers binaires - * ##FILE## - traduction d'instructions ARMv7 - * - * Copyright (C) 2015 Cyrille Bagard - * - * This file is part of Chrysalide. - * - * Chrysalide is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Chrysalide is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Foobar. If not, see . - */ - - -@title UHADD16 - -@desc Unsigned Halving Add 16 performs two unsigned 16-bit integer additions, halves the results, and writes the results to the destination register. - -@encoding (T1) { - - @word 1 1 1 1 1 0 1 0 1 0 0 1 Rn(4) 1 1 1 1 Rd(4) 0 1 1 0 Rm(4) - - @syntax - - @conv { - - reg_D = Register(Rd) - reg_N = Register(Rn) - reg_M = Register(Rm) - - } - -} - -@encoding (A1) { - - @word cond(4) 0 1 1 0 0 1 1 1 Rn(4) Rd(4) 1 1 1 1 0 0 0 1 Rm(4) - - @syntax - - @conv { - - reg_D = Register(Rd) - reg_N = Register(Rn) - reg_M = Register(Rm) - - } - - @rules { - - chk_call StoreCondition(cond) - - } - -} - diff --git a/src/arch/arm/v7/opdefs/uhadd8_A88250.d b/src/arch/arm/v7/opdefs/uhadd8_A88250.d deleted file mode 100644 index 759a0a7..0000000 --- a/src/arch/arm/v7/opdefs/uhadd8_A88250.d +++ /dev/null @@ -1,65 +0,0 @@ - -/* Chrysalide - Outil d'analyse de fichiers binaires - * ##FILE## - traduction d'instructions ARMv7 - * - * Copyright (C) 2015 Cyrille Bagard - * - * This file is part of Chrysalide. - * - * Chrysalide is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Chrysalide is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Foobar. If not, see . - */ - - -@title UHADD8 - -@desc Unsigned Halving Add 8 performs four unsigned 8-bit integer additions, halves the results, and writes the results to the destination register. - -@encoding (T1) { - - @word 1 1 1 1 1 0 1 0 1 0 0 0 Rn(4) 1 1 1 1 Rd(4) 0 1 1 0 Rm(4) - - @syntax - - @conv { - - reg_D = Register(Rd) - reg_N = Register(Rn) - reg_M = Register(Rm) - - } - -} - -@encoding (A1) { - - @word cond(4) 0 1 1 0 0 1 1 1 Rn(4) Rd(4) 1 1 1 1 1 0 0 1 Rm(4) - - @syntax - - @conv { - - reg_D = Register(Rd) - reg_N = Register(Rn) - reg_M = Register(Rm) - - } - - @rules { - - chk_call StoreCondition(cond) - - } - -} - diff --git a/src/arch/arm/v7/opdefs/uhasx_A88251.d b/src/arch/arm/v7/opdefs/uhasx_A88251.d deleted file mode 100644 index 3751394..0000000 --- a/src/arch/arm/v7/opdefs/uhasx_A88251.d +++ /dev/null @@ -1,65 +0,0 @@ - -/* Chrysalide - Outil d'analyse de fichiers binaires - * ##FILE## - traduction d'instructions ARMv7 - * - * Copyright (C) 2015 Cyrille Bagard - * - * This file is part of Chrysalide. - * - * Chrysalide is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Chrysalide is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Foobar. If not, see . - */ - - -@title UHASX - -@desc Unsigned Halving Add and Subtract with Exchange exchanges the two halfwords of the second operand, performs one unsigned 16-bit integer addition and one unsigned 16-bit subtraction, halves the results, and writes the results to the destination register. - -@encoding (T1) { - - @word 1 1 1 1 1 0 1 0 1 0 1 0 Rn(4) 1 1 1 1 Rd(4) 0 1 1 0 Rm(4) - - @syntax - - @conv { - - reg_D = Register(Rd) - reg_N = Register(Rn) - reg_M = Register(Rm) - - } - -} - -@encoding (A1) { - - @word cond(4) 0 1 1 0 0 1 1 1 Rn(4) Rd(4) 1 1 1 1 0 0 1 1 Rm(4) - - @syntax - - @conv { - - reg_D = Register(Rd) - reg_N = Register(Rn) - reg_M = Register(Rm) - - } - - @rules { - - chk_call StoreCondition(cond) - - } - -} - diff --git a/src/arch/arm/v7/opdefs/uhsax_A88252.d b/src/arch/arm/v7/opdefs/uhsax_A88252.d deleted file mode 100644 index f06b2ba..0000000 --- a/src/arch/arm/v7/opdefs/uhsax_A88252.d +++ /dev/null @@ -1,65 +0,0 @@ - -/* Chrysalide - Outil d'analyse de fichiers binaires - * ##FILE## - traduction d'instructions ARMv7 - * - * Copyright (C) 2015 Cyrille Bagard - * - * This file is part of Chrysalide. - * - * Chrysalide is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Chrysalide is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Foobar. If not, see . - */ - - -@title UHSAX - -@desc Unsigned Halving Subtract and Add with Exchange exchanges the two halfwords of the second operand, performs one unsigned 16-bit integer subtraction and one unsigned 16-bit addition, halves the results, and writes the results to the destination register. - -@encoding (T1) { - - @word 1 1 1 1 1 0 1 0 1 1 1 0 Rn(4) 1 1 1 1 Rd(4) 0 1 1 0 Rm(4) - - @syntax - - @conv { - - reg_D = Register(Rd) - reg_N = Register(Rn) - reg_M = Register(Rm) - - } - -} - -@encoding (A1) { - - @word cond(4) 0 1 1 0 0 1 1 1 Rn(4) Rd(4) 1 1 1 1 0 1 0 1 Rm(4) - - @syntax - - @conv { - - reg_D = Register(Rd) - reg_N = Register(Rn) - reg_M = Register(Rm) - - } - - @rules { - - chk_call StoreCondition(cond) - - } - -} - diff --git a/src/arch/arm/v7/opdefs/uhsub16_A88253.d b/src/arch/arm/v7/opdefs/uhsub16_A88253.d deleted file mode 100644 index 93f92f7..0000000 --- a/src/arch/arm/v7/opdefs/uhsub16_A88253.d +++ /dev/null @@ -1,65 +0,0 @@ - -/* Chrysalide - Outil d'analyse de fichiers binaires - * ##FILE## - traduction d'instructions ARMv7 - * - * Copyright (C) 2015 Cyrille Bagard - * - * This file is part of Chrysalide. - * - * Chrysalide is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Chrysalide is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Foobar. If not, see . - */ - - -@title UHSUB16 - -@desc Unsigned Halving Subtract 16 performs two unsigned 16-bit integer subtractions, halves the results, and writes the results to the destination register. - -@encoding (T1) { - - @word 1 1 1 1 1 0 1 0 1 1 0 1 Rn(4) 1 1 1 1 Rd(4) 0 1 1 0 Rm(4) - - @syntax - - @conv { - - reg_D = Register(Rd) - reg_N = Register(Rn) - reg_M = Register(Rm) - - } - -} - -@encoding (A1) { - - @word cond(4) 0 1 1 0 0 1 1 1 Rn(4) Rd(4) 1 1 1 1 0 1 1 1 Rm(4) - - @syntax - - @conv { - - reg_D = Register(Rd) - reg_N = Register(Rn) - reg_M = Register(Rm) - - } - - @rules { - - chk_call StoreCondition(cond) - - } - -} - diff --git a/src/arch/arm/v7/opdefs/uhsub8_A88254.d b/src/arch/arm/v7/opdefs/uhsub8_A88254.d deleted file mode 100644 index 198a095..0000000 --- a/src/arch/arm/v7/opdefs/uhsub8_A88254.d +++ /dev/null @@ -1,65 +0,0 @@ - -/* Chrysalide - Outil d'analyse de fichiers binaires - * ##FILE## - traduction d'instructions ARMv7 - * - * Copyright (C) 2015 Cyrille Bagard - * - * This file is part of Chrysalide. - * - * Chrysalide is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Chrysalide is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Foobar. If not, see . - */ - - -@title UHSUB8 - -@desc Unsigned Halving Subtract 8 performs four unsigned 8-bit integer subtractions, halves the results, and writes the results to the destination register. - -@encoding (T1) { - - @word 1 1 1 1 1 0 1 0 1 1 0 0 Rn(4) 1 1 1 1 Rd(4) 0 1 1 0 Rm(4) - - @syntax - - @conv { - - reg_D = Register(Rd) - reg_N = Register(Rn) - reg_M = Register(Rm) - - } - -} - -@encoding (A1) { - - @word cond(4) 0 1 1 0 0 1 1 1 Rn(4) Rd(4) 1 1 1 1 1 1 1 1 Rm(4) - - @syntax - - @conv { - - reg_D = Register(Rd) - reg_N = Register(Rn) - reg_M = Register(Rm) - - } - - @rules { - - chk_call StoreCondition(cond) - - } - -} - diff --git a/src/arch/arm/v7/opdefs/umaal_A88255.d b/src/arch/arm/v7/opdefs/umaal_A88255.d deleted file mode 100644 index 34cb707..0000000 --- a/src/arch/arm/v7/opdefs/umaal_A88255.d +++ /dev/null @@ -1,67 +0,0 @@ - -/* Chrysalide - Outil d'analyse de fichiers binaires - * ##FILE## - traduction d'instructions ARMv7 - * - * Copyright (C) 2015 Cyrille Bagard - * - * This file is part of Chrysalide. - * - * Chrysalide is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Chrysalide is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Foobar. If not, see . - */ - - -@title UMAAL - -@desc Unsigned Multiply Accumulate Accumulate Long multiplies two unsigned 32-bit values to produce a 64-bit value, adds two unsigned 32-bit values, and writes the 64-bit result to two registers. - -@encoding (T1) { - - @word 1 1 1 1 1 0 1 1 1 1 1 0 Rn(4) RdLo(4) RdHi(4) 0 1 1 0 Rm(4) - - @syntax - - @conv { - - reg_DLO = Register(RdLo) - reg_DHI = Register(RdHi) - reg_N = Register(Rn) - reg_M = Register(Rm) - - } - -} - -@encoding (A1) { - - @word cond(4) 0 0 0 0 0 1 0 0 RdHi(4) RdLo(4) Rm(4) 1 0 0 1 Rn(4) - - @syntax - - @conv { - - reg_DLO = Register(RdLo) - reg_DHI = Register(RdHi) - reg_N = Register(Rn) - reg_M = Register(Rm) - - } - - @rules { - - chk_call StoreCondition(cond) - - } - -} - diff --git a/src/arch/arm/v7/opdefs/umlal_A88256.d b/src/arch/arm/v7/opdefs/umlal_A88256.d deleted file mode 100644 index 00d1903..0000000 --- a/src/arch/arm/v7/opdefs/umlal_A88256.d +++ /dev/null @@ -1,69 +0,0 @@ - -/* Chrysalide - Outil d'analyse de fichiers binaires - * ##FILE## - traduction d'instructions ARMv7 - * - * Copyright (C) 2015 Cyrille Bagard - * - * This file is part of Chrysalide. - * - * Chrysalide is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Chrysalide is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Foobar. If not, see . - */ - - -@title UMLAL - -@desc Unsigned Multiply Accumulate Long multiplies two unsigned 32-bit values to produce a 64-bit value, and accumulates this with a 64-bit value. In ARM instructions, the condition flags can optionally be updated based on the result. Use of this option adversely affects performance on many processor implementations. - -@encoding (T1) { - - @word 1 1 1 1 1 0 1 1 1 1 1 0 Rn(4) RdLo(4) RdHi(4) 0 0 0 0 Rm(4) - - @syntax - - @conv { - - reg_DLO = Register(RdLo) - reg_DHI = Register(RdHi) - reg_N = Register(Rn) - reg_M = Register(Rm) - - } - -} - -@encoding (A1) { - - @word cond(4) 0 0 0 0 1 0 1 S(1) RdHi(4) RdLo(4) Rm(4) 1 0 0 1 Rn(4) - - @syntax - - @conv { - - reg_DLO = Register(RdLo) - reg_DHI = Register(RdHi) - reg_N = Register(Rn) - reg_M = Register(Rm) - setflags = (S == '1') - - } - - @rules { - - if (setflags); chk_call ExtendKeyword("s") - chk_call StoreCondition(cond) - - } - -} - diff --git a/src/arch/arm/v7/opdefs/umull_A88257.d b/src/arch/arm/v7/opdefs/umull_A88257.d deleted file mode 100644 index d2cc321..0000000 --- a/src/arch/arm/v7/opdefs/umull_A88257.d +++ /dev/null @@ -1,69 +0,0 @@ - -/* Chrysalide - Outil d'analyse de fichiers binaires - * ##FILE## - traduction d'instructions ARMv7 - * - * Copyright (C) 2015 Cyrille Bagard - * - * This file is part of Chrysalide. - * - * Chrysalide is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Chrysalide is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Foobar. If not, see . - */ - - -@title UMULL - -@desc Unsigned Multiply Long multiplies two 32-bit unsigned values to produce a 64-bit result. In ARM instructions, the condition flags can optionally be updated based on the result. Use of this option adversely affects performance on many processor implementations. - -@encoding (T1) { - - @word 1 1 1 1 1 0 1 1 1 0 1 0 Rn(4) RdLo(4) RdHi(4) 0 0 0 0 Rm(4) - - @syntax - - @conv { - - reg_DLO = Register(RdLo) - reg_DHI = Register(RdHi) - reg_N = Register(Rn) - reg_M = Register(Rm) - - } - -} - -@encoding (A1) { - - @word cond(4) 0 0 0 0 1 0 0 S(1) RdHi(4) RdLo(4) Rm(4) 1 0 0 1 Rn(4) - - @syntax - - @conv { - - reg_DLO = Register(RdLo) - reg_DHI = Register(RdHi) - reg_N = Register(Rn) - reg_M = Register(Rm) - setflags = (S == '1') - - } - - @rules { - - if (setflags); chk_call ExtendKeyword("s") - chk_call StoreCondition(cond) - - } - -} - diff --git a/src/arch/arm/v7/opdefs/uqadd16_A88258.d b/src/arch/arm/v7/opdefs/uqadd16_A88258.d deleted file mode 100644 index 14528c8..0000000 --- a/src/arch/arm/v7/opdefs/uqadd16_A88258.d +++ /dev/null @@ -1,65 +0,0 @@ - -/* Chrysalide - Outil d'analyse de fichiers binaires - * ##FILE## - traduction d'instructions ARMv7 - * - * Copyright (C) 2015 Cyrille Bagard - * - * This file is part of Chrysalide. - * - * Chrysalide is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Chrysalide is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Foobar. If not, see . - */ - - -@title UQADD16 - -@desc Unsigned Saturating Add 16 performs two unsigned 16-bit integer additions, saturates the results to the 16-bit unsigned integer range 0 ≤ x ≤ 216 – 1, and writes the results to the destination register. - -@encoding (T1) { - - @word 1 1 1 1 1 0 1 0 1 0 0 1 Rn(4) 1 1 1 1 Rd(4) 0 1 0 1 Rm(4) - - @syntax - - @conv { - - reg_D = Register(Rd) - reg_N = Register(Rn) - reg_M = Register(Rm) - - } - -} - -@encoding (A1) { - - @word cond(4) 0 1 1 0 0 1 1 0 Rn(4) Rd(4) 1 1 1 1 0 0 0 1 Rm(4) - - @syntax - - @conv { - - reg_D = Register(Rd) - reg_N = Register(Rn) - reg_M = Register(Rm) - - } - - @rules { - - chk_call StoreCondition(cond) - - } - -} - diff --git a/src/arch/arm/v7/opdefs/uqadd8_A88259.d b/src/arch/arm/v7/opdefs/uqadd8_A88259.d deleted file mode 100644 index 94b8e39..0000000 --- a/src/arch/arm/v7/opdefs/uqadd8_A88259.d +++ /dev/null @@ -1,65 +0,0 @@ - -/* Chrysalide - Outil d'analyse de fichiers binaires - * ##FILE## - traduction d'instructions ARMv7 - * - * Copyright (C) 2015 Cyrille Bagard - * - * This file is part of Chrysalide. - * - * Chrysalide is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Chrysalide is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Foobar. If not, see . - */ - - -@title UQADD8 - -@desc Unsigned Saturating Add 8 performs four unsigned 8-bit integer additions, saturates the results to the 8-bit unsigned integer range 0 ≤ x ≤ 28 – 1, and writes the results to the destination register. - -@encoding (T1) { - - @word 1 1 1 1 1 0 1 0 1 0 0 0 Rn(4) 1 1 1 1 Rd(4) 0 1 0 1 Rm(4) - - @syntax - - @conv { - - reg_D = Register(Rd) - reg_N = Register(Rn) - reg_M = Register(Rm) - - } - -} - -@encoding (A1) { - - @word cond(4) 0 1 1 0 0 1 1 0 Rn(4) Rd(4) 1 1 1 1 1 0 0 1 Rm(4) - - @syntax - - @conv { - - reg_D = Register(Rd) - reg_N = Register(Rn) - reg_M = Register(Rm) - - } - - @rules { - - chk_call StoreCondition(cond) - - } - -} - diff --git a/src/arch/arm/v7/opdefs/uqasx_A88260.d b/src/arch/arm/v7/opdefs/uqasx_A88260.d deleted file mode 100644 index 174b08c..0000000 --- a/src/arch/arm/v7/opdefs/uqasx_A88260.d +++ /dev/null @@ -1,65 +0,0 @@ - -/* Chrysalide - Outil d'analyse de fichiers binaires - * ##FILE## - traduction d'instructions ARMv7 - * - * Copyright (C) 2015 Cyrille Bagard - * - * This file is part of Chrysalide. - * - * Chrysalide is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Chrysalide is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Foobar. If not, see . - */ - - -@title UQASX - -@desc Unsigned Saturating Add and Subtract with Exchange exchanges the two halfwords of the second operand, performs one unsigned 16-bit integer addition and one unsigned 16-bit subtraction, saturates the results to the 16-bit unsigned integer range 0 ≤ x ≤ 216 – 1, and writes the results to the destination register. - -@encoding (T1) { - - @word 1 1 1 1 1 0 1 0 1 0 1 0 Rn(4) 1 1 1 1 Rd(4) 0 1 0 1 Rm(4) - - @syntax - - @conv { - - reg_D = Register(Rd) - reg_N = Register(Rn) - reg_M = Register(Rm) - - } - -} - -@encoding (A1) { - - @word cond(4) 0 1 1 0 0 1 1 0 Rn(4) Rd(4) 1 1 1 1 0 0 1 1 Rm(4) - - @syntax - - @conv { - - reg_D = Register(Rd) - reg_N = Register(Rn) - reg_M = Register(Rm) - - } - - @rules { - - chk_call StoreCondition(cond) - - } - -} - diff --git a/src/arch/arm/v7/opdefs/uqsax_A88261.d b/src/arch/arm/v7/opdefs/uqsax_A88261.d deleted file mode 100644 index 6092e51..0000000 --- a/src/arch/arm/v7/opdefs/uqsax_A88261.d +++ /dev/null @@ -1,65 +0,0 @@ - -/* Chrysalide - Outil d'analyse de fichiers binaires - * ##FILE## - traduction d'instructions ARMv7 - * - * Copyright (C) 2015 Cyrille Bagard - * - * This file is part of Chrysalide. - * - * Chrysalide is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Chrysalide is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Foobar. If not, see . - */ - - -@title UQSAX - -@desc Unsigned Saturating Subtract and Add with Exchange exchanges the two halfwords of the second operand, performs one unsigned 16-bit integer subtraction and one unsigned 16-bit addition, saturates the results to the 16-bit unsigned integer range 0 ≤ x ≤ 216 – 1, and writes the results to the destination register. - -@encoding (T1) { - - @word 1 1 1 1 1 0 1 0 1 1 1 0 Rn(4) 1 1 1 1 Rd(4) 0 1 0 1 Rm(4) - - @syntax - - @conv { - - reg_D = Register(Rd) - reg_N = Register(Rn) - reg_M = Register(Rm) - - } - -} - -@encoding (A1) { - - @word cond(4) 0 1 1 0 0 1 1 0 Rn(4) Rd(4) 1 1 1 1 0 1 0 1 Rm(4) - - @syntax - - @conv { - - reg_D = Register(Rd) - reg_N = Register(Rn) - reg_M = Register(Rm) - - } - - @rules { - - chk_call StoreCondition(cond) - - } - -} - diff --git a/src/arch/arm/v7/opdefs/uqsub16_A88262.d b/src/arch/arm/v7/opdefs/uqsub16_A88262.d deleted file mode 100644 index 1f458ff..0000000 --- a/src/arch/arm/v7/opdefs/uqsub16_A88262.d +++ /dev/null @@ -1,65 +0,0 @@ - -/* Chrysalide - Outil d'analyse de fichiers binaires - * ##FILE## - traduction d'instructions ARMv7 - * - * Copyright (C) 2015 Cyrille Bagard - * - * This file is part of Chrysalide. - * - * Chrysalide is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Chrysalide is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Foobar. If not, see . - */ - - -@title UQSUB16 - -@desc Unsigned Saturating Subtract 16 performs two unsigned 16-bit integer subtractions, saturates the results to the 16-bit unsigned integer range 0 ≤ x ≤ 216 – 1, and writes the results to the destination register. - -@encoding (T1) { - - @word 1 1 1 1 1 0 1 0 1 1 0 1 Rn(4) 1 1 1 1 Rd(4) 0 1 0 1 Rm(4) - - @syntax - - @conv { - - reg_D = Register(Rd) - reg_N = Register(Rn) - reg_M = Register(Rm) - - } - -} - -@encoding (A1) { - - @word cond(4) 0 1 1 0 0 1 1 0 Rn(4) Rd(4) 1 1 1 1 0 1 1 1 Rm(4) - - @syntax - - @conv { - - reg_D = Register(Rd) - reg_N = Register(Rn) - reg_M = Register(Rm) - - } - - @rules { - - chk_call StoreCondition(cond) - - } - -} - diff --git a/src/arch/arm/v7/opdefs/uqsub8_A88263.d b/src/arch/arm/v7/opdefs/uqsub8_A88263.d deleted file mode 100644 index 37d96e7..0000000 --- a/src/arch/arm/v7/opdefs/uqsub8_A88263.d +++ /dev/null @@ -1,65 +0,0 @@ - -/* Chrysalide - Outil d'analyse de fichiers binaires - * ##FILE## - traduction d'instructions ARMv7 - * - * Copyright (C) 2015 Cyrille Bagard - * - * This file is part of Chrysalide. - * - * Chrysalide is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Chrysalide is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Foobar. If not, see . - */ - - -@title UQSUB8 - -@desc Unsigned Saturating Subtract 8 performs four unsigned 8-bit integer subtractions, saturates the results to the 8-bit unsigned integer range 0 ≤ x ≤ 28 – 1, and writes the results to the destination register. - -@encoding (T1) { - - @word 1 1 1 1 1 0 1 0 1 1 0 0 Rn(4) 1 1 1 1 Rd(4) 0 1 0 1 Rm(4) - - @syntax - - @conv { - - reg_D = Register(Rd) - reg_N = Register(Rn) - reg_M = Register(Rm) - - } - -} - -@encoding (A1) { - - @word cond(4) 0 1 1 0 0 1 1 0 Rn(4) Rd(4) 1 1 1 1 1 1 1 1 Rm(4) - - @syntax - - @conv { - - reg_D = Register(Rd) - reg_N = Register(Rn) - reg_M = Register(Rm) - - } - - @rules { - - chk_call StoreCondition(cond) - - } - -} - diff --git a/src/arch/arm/v7/opdefs/usad8_A88264.d b/src/arch/arm/v7/opdefs/usad8_A88264.d deleted file mode 100644 index 09d7ece..0000000 --- a/src/arch/arm/v7/opdefs/usad8_A88264.d +++ /dev/null @@ -1,65 +0,0 @@ - -/* Chrysalide - Outil d'analyse de fichiers binaires - * ##FILE## - traduction d'instructions ARMv7 - * - * Copyright (C) 2015 Cyrille Bagard - * - * This file is part of Chrysalide. - * - * Chrysalide is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Chrysalide is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Foobar. If not, see . - */ - - -@title USAD8 - -@desc Unsigned Sum of Absolute Differences performs four unsigned 8-bit subtractions, and adds the absolute values of the differences together. - -@encoding (T1) { - - @word 1 1 1 1 1 0 1 1 0 1 1 1 Rn(4) 1 1 1 1 Rd(4) 0 0 0 0 Rm(4) - - @syntax - - @conv { - - reg_D = Register(Rd) - reg_N = Register(Rn) - reg_M = Register(Rm) - - } - -} - -@encoding (A1) { - - @word cond(4) 0 1 1 1 1 0 0 0 Rd(4) 1 1 1 1 Rm(4) 0 0 0 1 Rn(4) - - @syntax - - @conv { - - reg_D = Register(Rd) - reg_N = Register(Rn) - reg_M = Register(Rm) - - } - - @rules { - - chk_call StoreCondition(cond) - - } - -} - diff --git a/src/arch/arm/v7/opdefs/usada8_A88265.d b/src/arch/arm/v7/opdefs/usada8_A88265.d deleted file mode 100644 index dd1efdb..0000000 --- a/src/arch/arm/v7/opdefs/usada8_A88265.d +++ /dev/null @@ -1,67 +0,0 @@ - -/* Chrysalide - Outil d'analyse de fichiers binaires - * ##FILE## - traduction d'instructions ARMv7 - * - * Copyright (C) 2015 Cyrille Bagard - * - * This file is part of Chrysalide. - * - * Chrysalide is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Chrysalide is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Foobar. If not, see . - */ - - -@title USADA8 - -@desc Unsigned Sum of Absolute Differences and Accumulate performs four unsigned 8-bit subtractions, and adds the absolute values of the differences to a 32-bit accumulate operand. - -@encoding (T1) { - - @word 1 1 1 1 1 0 1 1 0 1 1 1 Rn(4) Ra(4) Rd(4) 0 0 0 0 Rm(4) - - @syntax - - @conv { - - reg_D = Register(Rd) - reg_N = Register(Rn) - reg_M = Register(Rm) - reg_A = Register(Ra) - - } - -} - -@encoding (A1) { - - @word cond(4) 0 1 1 1 1 0 0 0 Rd(4) Ra(4) Rm(4) 0 0 0 1 Rn(4) - - @syntax - - @conv { - - reg_D = Register(Rd) - reg_N = Register(Rn) - reg_M = Register(Rm) - reg_A = Register(Ra) - - } - - @rules { - - chk_call StoreCondition(cond) - - } - -} - diff --git a/src/arch/arm/v7/opdefs/usat16_A88267.d b/src/arch/arm/v7/opdefs/usat16_A88267.d deleted file mode 100644 index c091dc6..0000000 --- a/src/arch/arm/v7/opdefs/usat16_A88267.d +++ /dev/null @@ -1,65 +0,0 @@ - -/* Chrysalide - Outil d'analyse de fichiers binaires - * ##FILE## - traduction d'instructions ARMv7 - * - * Copyright (C) 2015 Cyrille Bagard - * - * This file is part of Chrysalide. - * - * Chrysalide is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Chrysalide is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Foobar. If not, see . - */ - - -@title USAT16 - -@desc Unsigned Saturate 16 saturates two signed 16-bit values to a selected unsigned range. The Q flag is set if the operation saturates. - -@encoding (T1) { - - @word 1 1 1 1 0 0 1 1 1 0 1 0 Rn(4) 0 0 0 0 Rd(4) 0 0 0 0 sat_imm(4) - - @syntax - - @conv { - - reg_D = Register(Rd) - reg_N = Register(Rn) - saturate_to = UInt(sat_imm) - - } - -} - -@encoding (A1) { - - @word cond(4) 0 1 1 0 1 1 1 0 sat_imm(4) Rd(4) 1 1 1 1 0 0 1 1 Rn(4) - - @syntax - - @conv { - - reg_D = Register(Rd) - reg_N = Register(Rn) - saturate_to = UInt(sat_imm) - - } - - @rules { - - chk_call StoreCondition(cond) - - } - -} - diff --git a/src/arch/arm/v7/opdefs/usat_A88266.d b/src/arch/arm/v7/opdefs/usat_A88266.d deleted file mode 100644 index 55de21a..0000000 --- a/src/arch/arm/v7/opdefs/usat_A88266.d +++ /dev/null @@ -1,67 +0,0 @@ - -/* Chrysalide - Outil d'analyse de fichiers binaires - * ##FILE## - traduction d'instructions ARMv7 - * - * Copyright (C) 2015 Cyrille Bagard - * - * This file is part of Chrysalide. - * - * Chrysalide is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Chrysalide is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Foobar. If not, see . - */ - - -@title USAT - -@desc Unsigned Saturate saturates an optionally-shifted signed value to a selected unsigned range. The Q flag is set if the operation saturates. - -@encoding (T1) { - - @word 1 1 1 1 0 0 1 1 1 0 sh(1) 0 Rn(4) 0 imm3(3) Rd(4) imm2(2) 0 sat_imm(5) - - @syntax - - @conv { - - reg_D = Register(Rd) - reg_N = Register(Rn) - saturate_to = UInt(sat_imm) - shift = DecodeImmShift(sh:'0', imm3:imm2) - - } - -} - -@encoding (A1) { - - @word cond(4) 0 1 1 0 1 1 1 sat_imm(5) Rd(4) imm5(5) sh(1) 0 1 Rn(4) - - @syntax - - @conv { - - reg_D = Register(Rd) - reg_N = Register(Rn) - saturate_to = UInt(sat_imm) - shift = DecodeImmShift(sh:'0', imm5) - - } - - @rules { - - chk_call StoreCondition(cond) - - } - -} - diff --git a/src/arch/arm/v7/opdefs/usax_A88268.d b/src/arch/arm/v7/opdefs/usax_A88268.d deleted file mode 100644 index 040eedc..0000000 --- a/src/arch/arm/v7/opdefs/usax_A88268.d +++ /dev/null @@ -1,65 +0,0 @@ - -/* Chrysalide - Outil d'analyse de fichiers binaires - * ##FILE## - traduction d'instructions ARMv7 - * - * Copyright (C) 2015 Cyrille Bagard - * - * This file is part of Chrysalide. - * - * Chrysalide is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Chrysalide is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Foobar. If not, see . - */ - - -@title USAX - -@desc Unsigned Subtract and Add with Exchange exchanges the two halfwords of the second operand, performs one unsigned 16-bit integer subtraction and one unsigned 16-bit addition, and writes the results to the destination register. It sets the APSR.GE bits according to the results. - -@encoding (T1) { - - @word 1 1 1 1 1 0 1 0 1 1 1 0 Rn(4) 1 1 1 1 Rd(4) 0 1 0 0 Rm(4) - - @syntax - - @conv { - - reg_D = Register(Rd) - reg_N = Register(Rn) - reg_M = Register(Rm) - - } - -} - -@encoding (A1) { - - @word cond(4) 0 1 1 0 0 1 0 1 Rn(4) Rd(4) 1 1 1 1 0 1 0 1 Rm(4) - - @syntax - - @conv { - - reg_D = Register(Rd) - reg_N = Register(Rn) - reg_M = Register(Rm) - - } - - @rules { - - chk_call StoreCondition(cond) - - } - -} - diff --git a/src/arch/arm/v7/opdefs/usub16_A88269.d b/src/arch/arm/v7/opdefs/usub16_A88269.d deleted file mode 100644 index 31796d9..0000000 --- a/src/arch/arm/v7/opdefs/usub16_A88269.d +++ /dev/null @@ -1,65 +0,0 @@ - -/* Chrysalide - Outil d'analyse de fichiers binaires - * ##FILE## - traduction d'instructions ARMv7 - * - * Copyright (C) 2015 Cyrille Bagard - * - * This file is part of Chrysalide. - * - * Chrysalide is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Chrysalide is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Foobar. If not, see . - */ - - -@title USUB16 - -@desc Unsigned Subtract 16 performs two 16-bit unsigned integer subtractions, and writes the results to the destination register. It sets the APSR.GE bits according to the results of the subtractions. - -@encoding (T1) { - - @word 1 1 1 1 1 0 1 0 1 1 0 1 Rn(4) 1 1 1 1 Rd(4) 0 1 0 0 Rm(4) - - @syntax - - @conv { - - reg_D = Register(Rd) - reg_N = Register(Rn) - reg_M = Register(Rm) - - } - -} - -@encoding (A1) { - - @word cond(4) 0 1 1 0 0 1 0 1 Rn(4) Rd(4) 1 1 1 1 0 1 1 1 Rm(4) - - @syntax - - @conv { - - reg_D = Register(Rd) - reg_N = Register(Rn) - reg_M = Register(Rm) - - } - - @rules { - - chk_call StoreCondition(cond) - - } - -} - diff --git a/src/arch/arm/v7/opdefs/usub8_A88270.d b/src/arch/arm/v7/opdefs/usub8_A88270.d deleted file mode 100644 index 576894c..0000000 --- a/src/arch/arm/v7/opdefs/usub8_A88270.d +++ /dev/null @@ -1,65 +0,0 @@ - -/* Chrysalide - Outil d'analyse de fichiers binaires - * ##FILE## - traduction d'instructions ARMv7 - * - * Copyright (C) 2015 Cyrille Bagard - * - * This file is part of Chrysalide. - * - * Chrysalide is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Chrysalide is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Foobar. If not, see . - */ - - -@title USUB8 - -@desc Unsigned Subtract 8 performs four 8-bit unsigned integer subtractions, and writes the results to the destination register. It sets the APSR.GE bits according to the results of the subtractions. - -@encoding (T1) { - - @word 1 1 1 1 1 0 1 0 1 1 0 0 Rn(4) 1 1 1 1 Rd(4) 0 1 0 0 Rm(4) - - @syntax - - @conv { - - reg_D = Register(Rd) - reg_N = Register(Rn) - reg_M = Register(Rm) - - } - -} - -@encoding (A1) { - - @word cond(4) 0 1 1 0 0 1 0 1 Rn(4) Rd(4) 1 1 1 1 1 1 1 1 Rm(4) - - @syntax - - @conv { - - reg_D = Register(Rd) - reg_N = Register(Rn) - reg_M = Register(Rm) - - } - - @rules { - - chk_call StoreCondition(cond) - - } - -} - diff --git a/src/arch/arm/v7/opdefs/uxtab16_A88272.d b/src/arch/arm/v7/opdefs/uxtab16_A88272.d deleted file mode 100644 index 4fc61d2..0000000 --- a/src/arch/arm/v7/opdefs/uxtab16_A88272.d +++ /dev/null @@ -1,67 +0,0 @@ - -/* Chrysalide - Outil d'analyse de fichiers binaires - * ##FILE## - traduction d'instructions ARMv7 - * - * Copyright (C) 2015 Cyrille Bagard - * - * This file is part of Chrysalide. - * - * Chrysalide is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Chrysalide is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Foobar. If not, see . - */ - - -@title UXTAB16 - -@desc Unsigned Extend and Add Byte 16 extracts two 8-bit values from a register, zero-extends them to 16 bits each, adds the results to two 16-bit values from another register, and writes the final results to the destination register. The instruction can specify a rotation by 0, 8, 16, or 24 bits before extracting the 8-bit values. - -@encoding (T1) { - - @word 1 1 1 1 1 0 1 0 0 0 1 1 Rn(4) 1 1 1 1 Rd(4) 1 0 rotate(2) Rm(4) - - @syntax - - @conv { - - reg_D = Register(Rd) - reg_N = Register(Rn) - reg_M = Register(Rm) - rotation = Rotation(rotate:'000') - - } - -} - -@encoding (A1) { - - @word cond(4) 0 1 1 0 1 1 0 0 Rn(4) Rd(4) rotate(2) 0 0 0 1 1 1 Rm(4) - - @syntax - - @conv { - - reg_D = Register(Rd) - reg_N = Register(Rn) - reg_M = Register(Rm) - rotation = Rotation(rotate:'000') - - } - - @rules { - - chk_call StoreCondition(cond) - - } - -} - diff --git a/src/arch/arm/v7/opdefs/uxtab_A88271.d b/src/arch/arm/v7/opdefs/uxtab_A88271.d deleted file mode 100644 index fe27d4b..0000000 --- a/src/arch/arm/v7/opdefs/uxtab_A88271.d +++ /dev/null @@ -1,67 +0,0 @@ - -/* Chrysalide - Outil d'analyse de fichiers binaires - * ##FILE## - traduction d'instructions ARMv7 - * - * Copyright (C) 2015 Cyrille Bagard - * - * This file is part of Chrysalide. - * - * Chrysalide is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Chrysalide is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Foobar. If not, see . - */ - - -@title UXTAB - -@desc Unsigned Extend and Add Byte extracts an 8-bit value from a register, zero-extends it to 32 bits, adds the result to the value in another register, and writes the final result to the destination register. The instruction can specify a rotation by 0, 8, 16, or 24 bits before extracting the 8-bit value. - -@encoding (T1) { - - @word 1 1 1 1 1 0 1 0 0 1 0 1 Rn(4) 1 1 1 1 Rd(4) 1 0 rotate(2) Rm(4) - - @syntax - - @conv { - - reg_D = Register(Rd) - reg_N = Register(Rn) - reg_M = Register(Rm) - rotation = Rotation(rotate:'000') - - } - -} - -@encoding (A1) { - - @word cond(4) 0 1 1 0 1 1 1 0 Rn(4) Rd(4) rotate(2) 0 0 0 1 1 1 Rm(4) - - @syntax - - @conv { - - reg_D = Register(Rd) - reg_N = Register(Rn) - reg_M = Register(Rm) - rotation = Rotation(rotate:'000') - - } - - @rules { - - chk_call StoreCondition(cond) - - } - -} - diff --git a/src/arch/arm/v7/opdefs/uxtah_A88273.d b/src/arch/arm/v7/opdefs/uxtah_A88273.d deleted file mode 100644 index 3c587d9..0000000 --- a/src/arch/arm/v7/opdefs/uxtah_A88273.d +++ /dev/null @@ -1,67 +0,0 @@ - -/* Chrysalide - Outil d'analyse de fichiers binaires - * ##FILE## - traduction d'instructions ARMv7 - * - * Copyright (C) 2015 Cyrille Bagard - * - * This file is part of Chrysalide. - * - * Chrysalide is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Chrysalide is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Foobar. If not, see . - */ - - -@title UXTAH - -@desc Unsigned Extend and Add Halfword extracts a 16-bit value from a register, zero-extends it to 32 bits, adds the result to a value from another register, and writes the final result to the destination register. The instruction can specify a rotation by 0, 8, 16, or 24 bits before extracting the 16-bit value. - -@encoding (T1) { - - @word 1 1 1 1 1 0 1 0 0 0 0 1 Rn(4) 1 1 1 1 Rd(4) 1 0 rotate(2) Rm(4) - - @syntax - - @conv { - - reg_D = Register(Rd) - reg_N = Register(Rn) - reg_M = Register(Rm) - rotation = Rotation(rotate:'000') - - } - -} - -@encoding (A1) { - - @word cond(4) 0 1 1 0 1 1 1 1 Rn(4) Rd(4) rotate(2) 0 0 0 1 1 1 Rm(4) - - @syntax - - @conv { - - reg_D = Register(Rd) - reg_N = Register(Rn) - reg_M = Register(Rm) - rotation = Rotation(rotate:'000') - - } - - @rules { - - chk_call StoreCondition(cond) - - } - -} - diff --git a/src/arch/arm/v7/opdefs/uxtb16_A88275.d b/src/arch/arm/v7/opdefs/uxtb16_A88275.d deleted file mode 100644 index a30d133..0000000 --- a/src/arch/arm/v7/opdefs/uxtb16_A88275.d +++ /dev/null @@ -1,65 +0,0 @@ - -/* Chrysalide - Outil d'analyse de fichiers binaires - * ##FILE## - traduction d'instructions ARMv7 - * - * Copyright (C) 2015 Cyrille Bagard - * - * This file is part of Chrysalide. - * - * Chrysalide is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Chrysalide is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Foobar. If not, see . - */ - - -@title UXTB16 - -@desc Unsigned Extend Byte 16 extracts two 8-bit values from a register, zero-extends them to 16 bits each, and writes the results to the destination register. The instruction can specify a rotation by 0, 8, 16, or 24 bits before extracting the 8-bit values. - -@encoding (T1) { - - @word 1 1 1 1 1 0 1 0 0 0 1 1 1 1 1 1 1 1 1 1 Rd(4) 1 0 rotate(2) Rm(4) - - @syntax - - @conv { - - reg_D = Register(Rd) - reg_M = Register(Rm) - rotation = Rotation(rotate:'000') - - } - -} - -@encoding (A1) { - - @word cond(4) 0 1 1 0 1 1 0 0 1 1 1 1 Rd(4) rotate(2) 0 0 0 1 1 1 Rm(4) - - @syntax - - @conv { - - reg_D = Register(Rd) - reg_M = Register(Rm) - rotation = Rotation(rotate:'000') - - } - - @rules { - - chk_call StoreCondition(cond) - - } - -} - diff --git a/src/arch/arm/v7/opdefs/uxtb_A88274.d b/src/arch/arm/v7/opdefs/uxtb_A88274.d deleted file mode 100644 index f49ba83..0000000 --- a/src/arch/arm/v7/opdefs/uxtb_A88274.d +++ /dev/null @@ -1,80 +0,0 @@ - -/* Chrysalide - Outil d'analyse de fichiers binaires - * ##FILE## - traduction d'instructions ARMv7 - * - * Copyright (C) 2015 Cyrille Bagard - * - * This file is part of Chrysalide. - * - * Chrysalide is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Chrysalide is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Foobar. If not, see . - */ - - -@title UXTB - -@desc Unsigned Extend Byte extracts an 8-bit value from a register, zero-extends it to 32 bits, and writes the result to the destination register. The instruction can specify a rotation by 0, 8, 16, or 24 bits before extracting the 8-bit value. - -@encoding (t1) { - - @half 1 0 1 1 0 0 1 0 1 1 Rm(3) Rd(3) - - @syntax - - @conv { - - reg_D = Register(Rd) - reg_M = Register(Rm) - - } - -} - -@encoding (T2) { - - @word 1 1 1 1 1 0 1 0 0 1 0 1 1 1 1 1 1 1 1 1 Rd(4) 1 0 rotate(2) Rm(4) - - @syntax ".W" - - @conv { - - reg_D = Register(Rd) - reg_M = Register(Rm) - rotation = Rotation(rotate:'000') - - } - -} - -@encoding (A1) { - - @word cond(4) 0 1 1 0 1 1 1 0 1 1 1 1 Rd(4) rotate(2) 0 0 0 1 1 1 Rm(4) - - @syntax - - @conv { - - reg_D = Register(Rd) - reg_M = Register(Rm) - rotation = Rotation(rotate:'000') - - } - - @rules { - - chk_call StoreCondition(cond) - - } - -} - diff --git a/src/arch/arm/v7/opdefs/uxth_A88276.d b/src/arch/arm/v7/opdefs/uxth_A88276.d deleted file mode 100644 index 5ae4f4f..0000000 --- a/src/arch/arm/v7/opdefs/uxth_A88276.d +++ /dev/null @@ -1,80 +0,0 @@ - -/* Chrysalide - Outil d'analyse de fichiers binaires - * ##FILE## - traduction d'instructions ARMv7 - * - * Copyright (C) 2015 Cyrille Bagard - * - * This file is part of Chrysalide. - * - * Chrysalide is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Chrysalide is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Foobar. If not, see . - */ - - -@title UXTH - -@desc Unsigned Extend Halfword extracts a 16-bit value from a register, zero-extends it to 32 bits, and writes the result to the destination register. The instruction can specify a rotation by 0, 8, 16, or 24 bits before extracting the 16-bit value. - -@encoding (t1) { - - @half 1 0 1 1 0 0 1 0 1 0 Rm(3) Rd(3) - - @syntax - - @conv { - - reg_D = Register(Rd) - reg_M = Register(Rm) - - } - -} - -@encoding (T2) { - - @word 1 1 1 1 1 0 1 0 0 0 0 1 1 1 1 1 1 1 1 1 Rd(4) 1 0 rotate(2) Rm(4) - - @syntax ".W" - - @conv { - - reg_D = Register(Rd) - reg_M = Register(Rm) - rotation = Rotation(rotate:'000') - - } - -} - -@encoding (A1) { - - @word cond(4) 0 1 1 0 1 1 1 1 1 1 1 1 Rd(4) rotate(2) 0 0 0 1 1 1 Rm(4) - - @syntax - - @conv { - - reg_D = Register(Rd) - reg_M = Register(Rm) - rotation = Rotation(rotate:'000') - - } - - @rules { - - chk_call StoreCondition(cond) - - } - -} - diff --git a/src/arch/arm/v7/opdefs/wfi_A88425.d b/src/arch/arm/v7/opdefs/wfi_A88425.d deleted file mode 100644 index f11d033..0000000 --- a/src/arch/arm/v7/opdefs/wfi_A88425.d +++ /dev/null @@ -1,53 +0,0 @@ - -/* Chrysalide - Outil d'analyse de fichiers binaires - * ##FILE## - traduction d'instructions ARMv7 - * - * Copyright (C) 2015 Cyrille Bagard - * - * This file is part of Chrysalide. - * - * Chrysalide is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Chrysalide is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Foobar. If not, see . - */ - - -@title WFI - -@desc Wait For Interrupt is a hint instruction that permits the processor to enter a low-power state until one of a number of asynchronous events occurs. For more information, see Wait For Interrupt on page B1-1202. In an implementation that includes the Virtualization Extensions, if HCR.TWI is set to 1, execution of a WFI instruction in a Non-secure mode other than Hyp mode generates a Hyp Trap exception if, ignoring the value of the HCR.TWI bit, conditions permit the processor to suspend execution. For more information see Trapping use of the WFI and WFE instructions on page B1-1255. - -@encoding (t1) { - - @half 1 0 1 1 1 1 1 1 0 0 1 1 0 0 0 0 - -} - -@encoding (T2) { - - @word 1 1 1 1 0 0 1 1 1 0 1 0 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 - - @syntax ".W" - -} - -@encoding (A1) { - - @word cond(4) 0 0 1 1 0 0 1 0 0 0 0 0 1 1 1 1 0 0 0 0 0 0 0 0 0 0 1 1 - - @rules { - - chk_call StoreCondition(cond) - - } - -} - diff --git a/src/arch/arm/v7/opdefs/yield_A88426.d b/src/arch/arm/v7/opdefs/yield_A88426.d deleted file mode 100644 index 252c018..0000000 --- a/src/arch/arm/v7/opdefs/yield_A88426.d +++ /dev/null @@ -1,53 +0,0 @@ - -/* Chrysalide - Outil d'analyse de fichiers binaires - * ##FILE## - traduction d'instructions ARMv7 - * - * Copyright (C) 2015 Cyrille Bagard - * - * This file is part of Chrysalide. - * - * Chrysalide is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Chrysalide is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Foobar. If not, see . - */ - - -@title YIELD - -@desc YIELD is a hint instruction. Software with a multithreading capability can use a YIELD instruction to indicate to the hardware that it is performing a task, for example a spin-lock, that could be swapped out to improve overall system performance. Hardware can use this hint to suspend and resume multiple software threads if it supports the capability. For more information about the recommended use of this instruction see The Yield instruction on page A4-178. - -@encoding (t1) { - - @half 1 0 1 1 1 1 1 1 0 0 0 1 0 0 0 0 - -} - -@encoding (T2) { - - @word 1 1 1 1 0 0 1 1 1 0 1 0 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 - - @syntax ".W" - -} - -@encoding (A1) { - - @word cond(4) 0 0 1 1 0 0 1 0 0 0 0 0 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 1 - - @rules { - - chk_call StoreCondition(cond) - - } - -} - diff --git a/src/arch/arm/v7/operands/Makefile.am b/src/arch/arm/v7/operands/Makefile.am deleted file mode 100644 index 8cf73b8..0000000 --- a/src/arch/arm/v7/operands/Makefile.am +++ /dev/null @@ -1,21 +0,0 @@ - -noinst_LTLIBRARIES = libarcharmv7operands.la - -libarcharmv7operands_la_SOURCES = \ - coproc.h coproc.c \ - estate.h estate.c \ - limitation.h limitation.c \ - maccess.h maccess.c \ - offset.h offset.c \ - reglist.h reglist.c \ - rotation.h rotation.c \ - shift.h shift.c - -libarcharmv7operands_la_LIBADD = - -libarcharmv7operands_la_CFLAGS = $(AM_CFLAGS) - - -AM_CPPFLAGS = $(LIBGTK_CFLAGS) $(LIBXML_CFLAGS) - -AM_CFLAGS = $(DEBUG_CFLAGS) $(WARNING_FLAGS) $(COMPLIANCE_FLAGS) diff --git a/src/arch/arm/v7/operands/coproc.c b/src/arch/arm/v7/operands/coproc.c deleted file mode 100644 index a0c0254..0000000 --- a/src/arch/arm/v7/operands/coproc.c +++ /dev/null @@ -1,250 +0,0 @@ - -/* Chrysalide - Outil d'analyse de fichiers binaires - * coproc.c - décallages de valeurs - * - * Copyright (C) 2016-2017 Cyrille Bagard - * - * This file is part of Chrysalide. - * - * Chrysalide is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Chrysalide is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Foobar. If not, see . - */ - - -#include "coproc.h" - - -#include "../../../operand-int.h" -#include "../../../../common/sort.h" - - - -/* Définition d'un opérande représentant un co-processeur (instance) */ -struct _GArmV7CoprocOperand -{ - GArchOperand parent; /* Instance parente */ - - uint8_t index; /* Indice du co-processeur */ - -}; - - -/* Définition d'un opérande représentant un co-processeur (classe) */ -struct _GArmV7CoprocOperandClass -{ - GArchOperandClass parent; /* Classe parente */ - -}; - - -/* Initialise la classe des coprocs de domaine et d'accès. */ -static void g_armv7_coproc_operand_class_init(GArmV7CoprocOperandClass *); - -/* Initialise une instance de coproc de domaine et d'accès. */ -static void g_armv7_coproc_operand_init(GArmV7CoprocOperand *); - -/* Supprime toutes les références externes. */ -static void g_armv7_coproc_operand_dispose(GArmV7CoprocOperand *); - -/* Procède à la libération totale de la mémoire. */ -static void g_armv7_coproc_operand_finalize(GArmV7CoprocOperand *); - -/* Compare un opérande avec un autre. */ -static int g_armv7_coproc_operand_compare(const GArmV7CoprocOperand *, const GArmV7CoprocOperand *); - -/* Traduit un opérande en version humainement lisible. */ -static void g_armv7_coproc_operand_print(const GArmV7CoprocOperand *, GBufferLine *, AsmSyntax); - - - -/* Indique le type défini par la GLib pour un co-processeur ARM. */ -G_DEFINE_TYPE(GArmV7CoprocOperand, g_armv7_coproc_operand, G_TYPE_ARCH_OPERAND); - - -/****************************************************************************** -* * -* Paramètres : klass = classe à initialiser. * -* * -* Description : Initialise la classe des co-processeurs ARM. * -* * -* Retour : - * -* * -* Remarques : - * -* * -******************************************************************************/ - -static void g_armv7_coproc_operand_class_init(GArmV7CoprocOperandClass *klass) -{ - GObjectClass *object; /* Autre version de la classe */ - GArchOperandClass *operand; /* Version de classe parente */ - - object = G_OBJECT_CLASS(klass); - operand = G_ARCH_OPERAND_CLASS(klass); - - object->dispose = (GObjectFinalizeFunc/* ! */)g_armv7_coproc_operand_dispose; - object->finalize = (GObjectFinalizeFunc)g_armv7_coproc_operand_finalize; - - operand->compare = (operand_compare_fc)g_armv7_coproc_operand_compare; - operand->print = (operand_print_fc)g_armv7_coproc_operand_print; - -} - - -/****************************************************************************** -* * -* Paramètres : operand = instance à initialiser. * -* * -* Description : Initialise une instance de co-processeur ARM. * -* * -* Retour : - * -* * -* Remarques : - * -* * -******************************************************************************/ - -static void g_armv7_coproc_operand_init(GArmV7CoprocOperand *operand) -{ - -} - - -/****************************************************************************** -* * -* Paramètres : operand = instance d'objet GLib à traiter. * -* * -* Description : Supprime toutes les références externes. * -* * -* Retour : - * -* * -* Remarques : - * -* * -******************************************************************************/ - -static void g_armv7_coproc_operand_dispose(GArmV7CoprocOperand *operand) -{ - G_OBJECT_CLASS(g_armv7_coproc_operand_parent_class)->dispose(G_OBJECT(operand)); - -} - - -/****************************************************************************** -* * -* Paramètres : operand = instance d'objet GLib à traiter. * -* * -* Description : Procède à la libération totale de la mémoire. * -* * -* Retour : - * -* * -* Remarques : - * -* * -******************************************************************************/ - -static void g_armv7_coproc_operand_finalize(GArmV7CoprocOperand *operand) -{ - G_OBJECT_CLASS(g_armv7_coproc_operand_parent_class)->finalize(G_OBJECT(operand)); - -} - - -/****************************************************************************** -* * -* Paramètres : a = premier opérande à consulter. * -* b = second opérande à consulter. * -* * -* Description : Compare un opérande avec un autre. * -* * -* Retour : Bilan de la comparaison. * -* * -* Remarques : - * -* * -******************************************************************************/ - -static int g_armv7_coproc_operand_compare(const GArmV7CoprocOperand *a, const GArmV7CoprocOperand *b) -{ - int result; /* Bilan à faire remonter */ - - result = sort_unsigned_long(a->index, b->index); - - return result; - -} - - -/****************************************************************************** -* * -* Paramètres : operand = opérande à traiter. * -* line = ligne tampon où imprimer l'opérande donné. * -* syntax = type de représentation demandée. * -* * -* Description : Traduit un opérande en version humainement lisible. * -* * -* Retour : - * -* * -* Remarques : - * -* * -******************************************************************************/ - -static void g_armv7_coproc_operand_print(const GArmV7CoprocOperand *operand, GBufferLine *line, AsmSyntax syntax) -{ - char name[5]; /* Mot clef principal */ - size_t nlen; /* Taille de ce mot clef */ - - nlen = snprintf(name, sizeof(name), "p%hhu", operand->index); - - g_buffer_line_append_text(line, BLC_ASSEMBLY, name, nlen, RTT_REGISTER, NULL); - -} - - -/****************************************************************************** -* * -* Paramètres : raw = valeur brute du co-processeur à considérer. * -* * -* Description : Crée une représentation d'un co-processeur ARM. * -* * -* Retour : Opérande mis en place. * -* * -* Remarques : - * -* * -******************************************************************************/ - -GArchOperand *g_armv7_coproc_operand_new(uint8_t raw) -{ - GArmV7CoprocOperand *result; /* Structure à retourner */ - - result = g_object_new(G_TYPE_ARMV7_COPROC_OPERAND, NULL); - - result->index = raw; - - return G_ARCH_OPERAND(result); - -} - - -/****************************************************************************** -* * -* Paramètres : operand = opérande à consulter. * -* * -* Description : Fournit l'indice d'un co-processeur ARM. * -* * -* Retour : Inditifiant représentant le co-processeur. * -* * -* Remarques : - * -* * -******************************************************************************/ - -uint8_t g_armv7_coproc_operand_get_index(const GArmV7CoprocOperand *operand) -{ - return operand->index; - -} diff --git a/src/arch/arm/v7/operands/coproc.h b/src/arch/arm/v7/operands/coproc.h deleted file mode 100644 index 07224d3..0000000 --- a/src/arch/arm/v7/operands/coproc.h +++ /dev/null @@ -1,61 +0,0 @@ - -/* Chrysalide - Outil d'analyse de fichiers binaires - * coproc.h - prototypes pour les décallages de valeurs - * - * Copyright (C) 2016-2017 Cyrille Bagard - * - * This file is part of Chrysalide. - * - * Chrysalide is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Chrysalide is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Foobar. If not, see . - */ - - -#ifndef _ARCH_ARM_V7_OPERANDS_COPROC_H -#define _ARCH_ARM_V7_OPERANDS_COPROC_H - - -#include - - -#include "../../../operand.h" - - - -#define G_TYPE_ARMV7_COPROC_OPERAND g_armv7_coproc_operand_get_type() -#define G_ARMV7_COPROC_OPERAND(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), g_armv7_coproc_operand_get_type(), GArmV7CoprocOperand)) -#define G_IS_ARMV7_COPROC_OPERAND(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), g_armv7_coproc_operand_get_type())) -#define G_ARMV7_COPROC_OPERAND_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), G_TYPE_ARMV7_COPROC_OPERAND, GArmV7CoprocOperandClass)) -#define G_IS_ARMV7_COPROC_OPERAND_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), G_TYPE_ARMV7_COPROC_OPERAND)) -#define G_ARMV7_COPROC_OPERAND_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), G_TYPE_ARMV7_COPROC_OPERAND, GArmV7CoprocOperandClass)) - - -/* Définition d'un opérande représentant un co-processeur (instance) */ -typedef struct _GArmV7CoprocOperand GArmV7CoprocOperand; - -/* Définition d'un opérande représentant un co-processeur (classe) */ -typedef struct _GArmV7CoprocOperandClass GArmV7CoprocOperandClass; - - -/* Indique le type défini par la GLib pour un co-processeur ARM. */ -GType g_armv7_coproc_operand_get_type(void); - -/* Crée une représentation d'un co-processeur ARM. */ -GArchOperand *g_armv7_coproc_operand_new(uint8_t); - -/* Fournit l'indice d'un co-processeur ARM. */ -uint8_t g_armv7_coproc_operand_get_index(const GArmV7CoprocOperand *); - - - -#endif /* _ARCH_ARM_V7_OPERANDS_COPROC_H */ diff --git a/src/arch/arm/v7/operands/estate.c b/src/arch/arm/v7/operands/estate.c deleted file mode 100644 index 0756110..0000000 --- a/src/arch/arm/v7/operands/estate.c +++ /dev/null @@ -1,248 +0,0 @@ - -/* Chrysalide - Outil d'analyse de fichiers binaires - * endian.c - décallages de valeurs - * - * Copyright (C) 2016-2017 Cyrille Bagard - * - * This file is part of Chrysalide. - * - * Chrysalide is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Chrysalide is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Foobar. If not, see . - */ - - -#include "estate.h" - - -#include "../../../operand-int.h" -#include "../../../../common/sort.h" - - - -/* Définition d'un opérande affichant le choix d'un boutisme (instance) */ -struct _GArmV7EndianOperand -{ - GArchOperand parent; /* Instance parente */ - - bool big; /* Grand boutisme à afficher ? */ - -}; - - -/* Définition d'un opérande affichant le choix d'un boutisme (classe) */ -struct _GArmV7EndianOperandClass -{ - GArchOperandClass parent; /* Classe parente */ - -}; - - -/* Initialise la classe des affichages de boutisme. */ -static void g_armv7_endian_operand_class_init(GArmV7EndianOperandClass *); - -/* Initialise une instance d'affichage de boutisme. */ -static void g_armv7_endian_operand_init(GArmV7EndianOperand *); - -/* Supprime toutes les références externes. */ -static void g_armv7_endian_operand_dispose(GArmV7EndianOperand *); - -/* Procède à la libération totale de la mémoire. */ -static void g_armv7_endian_operand_finalize(GArmV7EndianOperand *); - -/* Compare un opérande avec un autre. */ -static int g_armv7_endian_operand_compare(const GArmV7EndianOperand *, const GArmV7EndianOperand *); - -/* Traduit un opérande en version humainement lisible. */ -static void g_armv7_endian_operand_print(const GArmV7EndianOperand *, GBufferLine *, AsmSyntax); - - - -/* Indique le type défini par la GLib pour une endian de domaine et d'accès. */ -G_DEFINE_TYPE(GArmV7EndianOperand, g_armv7_endian_operand, G_TYPE_ARCH_OPERAND); - - -/****************************************************************************** -* * -* Paramètres : klass = classe à initialiser. * -* * -* Description : Initialise la classe des affichages de boutisme. * -* * -* Retour : - * -* * -* Remarques : - * -* * -******************************************************************************/ - -static void g_armv7_endian_operand_class_init(GArmV7EndianOperandClass *klass) -{ - GObjectClass *object; /* Autre version de la classe */ - GArchOperandClass *operand; /* Version de classe parente */ - - object = G_OBJECT_CLASS(klass); - operand = G_ARCH_OPERAND_CLASS(klass); - - object->dispose = (GObjectFinalizeFunc/* ! */)g_armv7_endian_operand_dispose; - object->finalize = (GObjectFinalizeFunc)g_armv7_endian_operand_finalize; - - operand->compare = (operand_compare_fc)g_armv7_endian_operand_compare; - operand->print = (operand_print_fc)g_armv7_endian_operand_print; - -} - - -/****************************************************************************** -* * -* Paramètres : operand = instance à initialiser. * -* * -* Description : Initialise une instance d'affichage de boutisme. * -* * -* Retour : - * -* * -* Remarques : - * -* * -******************************************************************************/ - -static void g_armv7_endian_operand_init(GArmV7EndianOperand *operand) -{ - -} - - -/****************************************************************************** -* * -* Paramètres : operand = instance d'objet GLib à traiter. * -* * -* Description : Supprime toutes les références externes. * -* * -* Retour : - * -* * -* Remarques : - * -* * -******************************************************************************/ - -static void g_armv7_endian_operand_dispose(GArmV7EndianOperand *operand) -{ - G_OBJECT_CLASS(g_armv7_endian_operand_parent_class)->dispose(G_OBJECT(operand)); - -} - - -/****************************************************************************** -* * -* Paramètres : operand = instance d'objet GLib à traiter. * -* * -* Description : Procède à la libération totale de la mémoire. * -* * -* Retour : - * -* * -* Remarques : - * -* * -******************************************************************************/ - -static void g_armv7_endian_operand_finalize(GArmV7EndianOperand *operand) -{ - G_OBJECT_CLASS(g_armv7_endian_operand_parent_class)->finalize(G_OBJECT(operand)); - -} - - -/****************************************************************************** -* * -* Paramètres : a = premier opérande à consulter. * -* b = second opérande à consulter. * -* * -* Description : Compare un opérande avec un autre. * -* * -* Retour : Bilan de la comparaison. * -* * -* Remarques : - * -* * -******************************************************************************/ - -static int g_armv7_endian_operand_compare(const GArmV7EndianOperand *a, const GArmV7EndianOperand *b) -{ - int result; /* Bilan à faire remonter */ - - result = sort_boolean(a->big, b->big); - - return result; - -} - - -/****************************************************************************** -* * -* Paramètres : operand = opérande à traiter. * -* line = ligne tampon où imprimer l'opérande donné. * -* syntax = type de représentation demandée. * -* * -* Description : Traduit un opérande en version humainement lisible. * -* * -* Retour : - * -* * -* Remarques : - * -* * -******************************************************************************/ - -static void g_armv7_endian_operand_print(const GArmV7EndianOperand *operand, GBufferLine *line, AsmSyntax syntax) -{ - if (operand->big) - g_buffer_line_append_text(line, BLC_ASSEMBLY, "BE", 2, RTT_KEY_WORD, NULL); - else - g_buffer_line_append_text(line, BLC_ASSEMBLY, "LE", 2, RTT_KEY_WORD, NULL); - -} - - -/****************************************************************************** -* * -* Paramètres : big = indication sur le boutisme à représenter. * -* * -* Description : Crée une représentation de boutisme ARMv7. * -* * -* Retour : Opérande mis en place. * -* * -* Remarques : - * -* * -******************************************************************************/ - -GArchOperand *g_armv7_endian_operand_new(bool big) -{ - GArmV7EndianOperand *result; /* Structure à retourner */ - - result = g_object_new(G_TYPE_ARMV7_ENDIAN_OPERAND, NULL); - - result->big = big; - - return G_ARCH_OPERAND(result); - -} - - -/****************************************************************************** -* * -* Paramètres : operand = opérande à consulter. * -* * -* Description : Indique le type de boutisme représenté. * -* * -* Retour : Type de boutisme. * -* * -* Remarques : - * -* * -******************************************************************************/ - -bool g_armv7_endian_operand_is_big_endian(const GArmV7EndianOperand *operand) -{ - return operand->big; - -} diff --git a/src/arch/arm/v7/operands/estate.h b/src/arch/arm/v7/operands/estate.h deleted file mode 100644 index a1726cf..0000000 --- a/src/arch/arm/v7/operands/estate.h +++ /dev/null @@ -1,61 +0,0 @@ - -/* Chrysalide - Outil d'analyse de fichiers binaires - * estate.h - prototypes pour le basculement de boutisme - * - * Copyright (C) 2016-2017 Cyrille Bagard - * - * This file is part of Chrysalide. - * - * Chrysalide is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Chrysalide is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Foobar. If not, see . - */ - - -#ifndef _ARCH_ARM_V7_OPERANDS_ESTATE_H -#define _ARCH_ARM_V7_OPERANDS_ESTATE_H - - -#include - - -#include "../../../operand.h" - - - -#define G_TYPE_ARMV7_ENDIAN_OPERAND g_armv7_endian_operand_get_type() -#define G_ARMV7_ENDIAN_OPERAND(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), g_armv7_endian_operand_get_type(), GArmV7EndianOperand)) -#define G_IS_ARMV7_ENDIAN_OPERAND(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), g_armv7_endian_operand_get_type())) -#define G_ARMV7_ENDIAN_OPERAND_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), G_TYPE_ARMV7_ENDIAN_OPERAND, GArmV7EndianOperandClass)) -#define G_IS_ARMV7_ENDIAN_OPERAND_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), G_TYPE_ARMV7_ENDIAN_OPERAND)) -#define G_ARMV7_ENDIAN_OPERAND_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), G_TYPE_ARMV7_ENDIAN_OPERAND, GArmV7EndianOperandClass)) - - -/* Définition d'un opérande affichant le choix d'un boutisme (instance) */ -typedef struct _GArmV7EndianOperand GArmV7EndianOperand; - -/* Définition d'un opérande affichant le choix d'un boutisme (classe) */ -typedef struct _GArmV7EndianOperandClass GArmV7EndianOperandClass; - - -/* Indique le type défini par la GLib pour une endian de domaine et d'accès. */ -GType g_armv7_endian_operand_get_type(void); - -/* Crée une représentation de boutisme ARMv7. */ -GArchOperand *g_armv7_endian_operand_new(bool); - -/* Indique le type de boutisme représenté. */ -bool g_armv7_endian_operand_is_big_endian(const GArmV7EndianOperand *); - - - -#endif /* _ARCH_ARM_V7_OPERANDS_ESTATE_H */ diff --git a/src/arch/arm/v7/operands/limitation.c b/src/arch/arm/v7/operands/limitation.c deleted file mode 100644 index 75e958f..0000000 --- a/src/arch/arm/v7/operands/limitation.c +++ /dev/null @@ -1,287 +0,0 @@ - -/* Chrysalide - Outil d'analyse de fichiers binaires - * limitation.c - décallages de valeurs - * - * Copyright (C) 2016-2017 Cyrille Bagard - * - * This file is part of Chrysalide. - * - * Chrysalide is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Chrysalide is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Foobar. If not, see . - */ - - -#include "limitation.h" - - -#include "../../../operand-int.h" -#include "../../../../common/sort.h" - - - -/* Définition d'un opérande déterminant une limitation de domaine et d'accès (instance) */ -struct _GArmV7LimitationOperand -{ - GArchOperand parent; /* Instance parente */ - - BarrierLimitationType type; /* Type de limitation */ - -}; - - -/* Définition d'un opérande déterminant une limitation de domaine et d'accès (classe) */ -struct _GArmV7LimitationOperandClass -{ - GArchOperandClass parent; /* Classe parente */ - -}; - - -/* Initialise la classe des co-processeurs ARM. */ -static void g_armv7_limitation_operand_class_init(GArmV7LimitationOperandClass *); - -/* Initialise une instance de co-processeur ARM. */ -static void g_armv7_limitation_operand_init(GArmV7LimitationOperand *); - -/* Supprime toutes les références externes. */ -static void g_armv7_limitation_operand_dispose(GArmV7LimitationOperand *); - -/* Procède à la libération totale de la mémoire. */ -static void g_armv7_limitation_operand_finalize(GArmV7LimitationOperand *); - -/* Compare un opérande avec un autre. */ -static int g_armv7_limitation_operand_compare(const GArmV7LimitationOperand *, const GArmV7LimitationOperand *); - -/* Traduit un opérande en version humainement lisible. */ -static void g_armv7_limitation_operand_print(const GArmV7LimitationOperand *, GBufferLine *, AsmSyntax); - - - -/* Indique le type défini par la GLib pour une limitation de domaine et d'accès. */ -G_DEFINE_TYPE(GArmV7LimitationOperand, g_armv7_limitation_operand, G_TYPE_ARCH_OPERAND); - - -/****************************************************************************** -* * -* Paramètres : klass = classe à initialiser. * -* * -* Description : Initialise la classe des limitations de domaine et d'accès. * -* * -* Retour : - * -* * -* Remarques : - * -* * -******************************************************************************/ - -static void g_armv7_limitation_operand_class_init(GArmV7LimitationOperandClass *klass) -{ - GObjectClass *object; /* Autre version de la classe */ - GArchOperandClass *operand; /* Version de classe parente */ - - object = G_OBJECT_CLASS(klass); - operand = G_ARCH_OPERAND_CLASS(klass); - - object->dispose = (GObjectFinalizeFunc/* ! */)g_armv7_limitation_operand_dispose; - object->finalize = (GObjectFinalizeFunc)g_armv7_limitation_operand_finalize; - - operand->compare = (operand_compare_fc)g_armv7_limitation_operand_compare; - operand->print = (operand_print_fc)g_armv7_limitation_operand_print; - -} - - -/****************************************************************************** -* * -* Paramètres : operand = instance à initialiser. * -* * -* Description : Initialise une instance de limitation de domaine et d'accès. * -* * -* Retour : - * -* * -* Remarques : - * -* * -******************************************************************************/ - -static void g_armv7_limitation_operand_init(GArmV7LimitationOperand *operand) -{ - -} - - -/****************************************************************************** -* * -* Paramètres : operand = instance d'objet GLib à traiter. * -* * -* Description : Supprime toutes les références externes. * -* * -* Retour : - * -* * -* Remarques : - * -* * -******************************************************************************/ - -static void g_armv7_limitation_operand_dispose(GArmV7LimitationOperand *operand) -{ - G_OBJECT_CLASS(g_armv7_limitation_operand_parent_class)->dispose(G_OBJECT(operand)); - -} - - -/****************************************************************************** -* * -* Paramètres : operand = instance d'objet GLib à traiter. * -* * -* Description : Procède à la libération totale de la mémoire. * -* * -* Retour : - * -* * -* Remarques : - * -* * -******************************************************************************/ - -static void g_armv7_limitation_operand_finalize(GArmV7LimitationOperand *operand) -{ - G_OBJECT_CLASS(g_armv7_limitation_operand_parent_class)->finalize(G_OBJECT(operand)); - -} - - -/****************************************************************************** -* * -* Paramètres : a = premier opérande à consulter. * -* b = second opérande à consulter. * -* * -* Description : Compare un opérande avec un autre. * -* * -* Retour : Bilan de la comparaison. * -* * -* Remarques : - * -* * -******************************************************************************/ - -static int g_armv7_limitation_operand_compare(const GArmV7LimitationOperand *a, const GArmV7LimitationOperand *b) -{ - int result; /* Bilan à faire remonter */ - - result = sort_unsigned_long(a->type, b->type); - - return result; - -} - - -/****************************************************************************** -* * -* Paramètres : operand = opérande à traiter. * -* line = ligne tampon où imprimer l'opérande donné. * -* syntax = type de représentation demandée. * -* * -* Description : Traduit un opérande en version humainement lisible. * -* * -* Retour : - * -* * -* Remarques : - * -* * -******************************************************************************/ - -static void g_armv7_limitation_operand_print(const GArmV7LimitationOperand *operand, GBufferLine *line, AsmSyntax syntax) -{ - switch (operand->type) - { - case BLT_SY: - g_buffer_line_append_text(line, BLC_ASSEMBLY, "SY", 2, RTT_KEY_WORD, NULL); - break; - - case BLT_ST: - g_buffer_line_append_text(line, BLC_ASSEMBLY, "ST", 2, RTT_KEY_WORD, NULL); - break; - - case BLT_ISH: - g_buffer_line_append_text(line, BLC_ASSEMBLY, "ISH", 3, RTT_KEY_WORD, NULL); - break; - - case BLT_ISHST: - g_buffer_line_append_text(line, BLC_ASSEMBLY, "ISHST", 5, RTT_KEY_WORD, NULL); - break; - - case BLT_NSH: - g_buffer_line_append_text(line, BLC_ASSEMBLY, "NSH", 3, RTT_KEY_WORD, NULL); - break; - - case BLT_NSHST: - g_buffer_line_append_text(line, BLC_ASSEMBLY, "NSHST", 5, RTT_KEY_WORD, NULL); - break; - - case BLT_OSH: - g_buffer_line_append_text(line, BLC_ASSEMBLY, "OSH", 3, RTT_KEY_WORD, NULL); - break; - - case BLT_OSHST: - g_buffer_line_append_text(line, BLC_ASSEMBLY, "OSHST", 5, RTT_KEY_WORD, NULL); - break; - - default: - g_buffer_line_append_text(line, BLC_ASSEMBLY, "(reserved)", 10, RTT_KEY_WORD, NULL); - break; - - } - -} - - -/****************************************************************************** -* * -* Paramètres : raw = valeur brute de la limitation à considérer. * -* * -* Description : Crée une représentation d'une limitation pour barrière. * -* * -* Retour : Opérande mis en place. * -* * -* Remarques : - * -* * -******************************************************************************/ - -GArchOperand *g_armv7_limitation_operand_new(uint8_t raw) -{ - GArmV7LimitationOperand *result; /* Structure à retourner */ - - result = g_object_new(G_TYPE_ARMV7_LIMITATION_OPERAND, NULL); - - if (raw < 0b0010 || raw > 0b1111) - result->type = BLT_RESERVED; - - else - result->type = raw; - - return G_ARCH_OPERAND(result); - -} - - -/****************************************************************************** -* * -* Paramètres : operand = opérande à consulter. * -* * -* Description : Indique le type de limitation représentée. * -* * -* Retour : Type de limitation d'accès et de domaine. * -* * -* Remarques : - * -* * -******************************************************************************/ - -BarrierLimitationType g_armv7_limitation_operand_get_value(const GArmV7LimitationOperand *operand) -{ - return operand->type; - -} diff --git a/src/arch/arm/v7/operands/limitation.h b/src/arch/arm/v7/operands/limitation.h deleted file mode 100644 index 4f7db88..0000000 --- a/src/arch/arm/v7/operands/limitation.h +++ /dev/null @@ -1,77 +0,0 @@ - -/* Chrysalide - Outil d'analyse de fichiers binaires - * limitation.h - prototypes pour les décallages de valeurs - * - * Copyright (C) 2016-2017 Cyrille Bagard - * - * This file is part of Chrysalide. - * - * Chrysalide is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Chrysalide is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Foobar. If not, see . - */ - - -#ifndef _ARCH_ARM_V7_OPERANDS_LIMITATION_H -#define _ARCH_ARM_V7_OPERANDS_LIMITATION_H - - -#include - - -#include "../../../operand.h" - - - -#define G_TYPE_ARMV7_LIMITATION_OPERAND g_armv7_limitation_operand_get_type() -#define G_ARMV7_LIMITATION_OPERAND(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), g_armv7_limitation_operand_get_type(), GArmV7LimitationOperand)) -#define G_IS_ARMV7_LIMITATION_OPERAND(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), g_armv7_limitation_operand_get_type())) -#define G_ARMV7_LIMITATION_OPERAND_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), G_TYPE_ARMV7_LIMITATION_OPERAND, GArmV7LimitationOperandClass)) -#define G_IS_ARMV7_LIMITATION_OPERAND_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), G_TYPE_ARMV7_LIMITATION_OPERAND)) -#define G_ARMV7_LIMITATION_OPERAND_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), G_TYPE_ARMV7_LIMITATION_OPERAND, GArmV7LimitationOperandClass)) - - -/* Définition d'un opérande déterminant une limitation de domaine et d'accès (instance) */ -typedef struct _GArmV7LimitationOperand GArmV7LimitationOperand; - -/* Définition d'un opérande déterminant une limitation de domaine et d'accès (classe) */ -typedef struct _GArmV7LimitationOperandClass GArmV7LimitationOperandClass; - - -/* Types de limitation domaine & accès */ -typedef enum _BarrierLimitationType -{ - BLT_RESERVED = 0, - BLT_SY = 0b1111, - BLT_ST = 0b1110, - BLT_ISH = 0b1011, - BLT_ISHST = 0b1010, - BLT_NSH = 0b0111, - BLT_NSHST = 0b0110, - BLT_OSH = 0b0011, - BLT_OSHST = 0b0010 - -} BarrierLimitationType; - - -/* Indique le type défini par la GLib pour une limitation de domaine et d'accès. */ -GType g_armv7_limitation_operand_get_type(void); - -/* Crée une représentation d'une limitation pour barrière. */ -GArchOperand *g_armv7_limitation_operand_new(uint8_t); - -/* Indique le type de limitation représentée. */ -BarrierLimitationType g_armv7_limitation_operand_get_value(const GArmV7LimitationOperand *); - - - -#endif /* _ARCH_ARM_V7_OPERANDS_LIMITATION_H */ diff --git a/src/arch/arm/v7/operands/maccess.c b/src/arch/arm/v7/operands/maccess.c deleted file mode 100644 index 6daf821..0000000 --- a/src/arch/arm/v7/operands/maccess.c +++ /dev/null @@ -1,385 +0,0 @@ - -/* Chrysalide - Outil d'analyse de fichiers binaires - * maccess.c - accès à la mémorie à partir d'un registre et d'un décallage - * - * Copyright (C) 2014-2017 Cyrille Bagard - * - * This file is part of Chrysalide. - * - * Chrysalide is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Chrysalide is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Foobar. If not, see . - */ - - -#include "maccess.h" - - -#include "../../../operand-int.h" -#include "../../../../common/sort.h" - - - -/* Définition d'un opérande offrant un accès à la mémoire depuis une base (instance) */ -struct _GArmV7MAccessOperand -{ - GArchOperand parent; /* Instance parente */ - - GArchOperand *base; /* Base de l'accès en mémoire */ - GArchOperand *offset; /* Décallage pour l'adresse */ - GArchOperand *shift; /* Décallage pour le décallage */ - bool not_post_indexed; /* Positio du décallage */ - bool write_back; /* Mise à jour de la base */ - -}; - - -/* Définition d'un opérande offrant un accès à la mémoire depuis une base (classe) */ -struct _GArmV7MAccessOperandClass -{ - GArchOperandClass parent; /* Classe parente */ - -}; - - -/* Initialise la classe des accès à la mémoire chez ARM. */ -static void g_armv7_maccess_operand_class_init(GArmV7MAccessOperandClass *); - -/* Initialise une instance d'accès à la mémoire chez ARM. */ -static void g_armv7_maccess_operand_init(GArmV7MAccessOperand *); - -/* Supprime toutes les références externes. */ -static void g_armv7_maccess_operand_dispose(GArmV7MAccessOperand *); - -/* Procède à la libération totale de la mémoire. */ -static void g_armv7_maccess_operand_finalize(GArmV7MAccessOperand *); - -/* Compare un opérande avec un autre. */ -static int g_armv7_maccess_operand_compare(const GArmV7MAccessOperand *, const GArmV7MAccessOperand *); - -/* Traduit un opérande en version humainement lisible. */ -static void g_armv7_maccess_operand_print(const GArmV7MAccessOperand *, GBufferLine *, AsmSyntax); - - - -/* Indique le type défini par la GLib pour un accès à la mémoire depuis une base. */ -G_DEFINE_TYPE(GArmV7MAccessOperand, g_armv7_maccess_operand, G_TYPE_ARCH_OPERAND); - - -/****************************************************************************** -* * -* Paramètres : klass = classe à initialiser. * -* * -* Description : Initialise la classe des accès à la mémoire chez ARM. * -* * -* Retour : - * -* * -* Remarques : - * -* * -******************************************************************************/ - -static void g_armv7_maccess_operand_class_init(GArmV7MAccessOperandClass *klass) -{ - GObjectClass *object; /* Autre version de la classe */ - GArchOperandClass *operand; /* Version de classe parente */ - - object = G_OBJECT_CLASS(klass); - operand = G_ARCH_OPERAND_CLASS(klass); - - object->dispose = (GObjectFinalizeFunc/* ! */)g_armv7_maccess_operand_dispose; - object->finalize = (GObjectFinalizeFunc)g_armv7_maccess_operand_finalize; - - operand->compare = (operand_compare_fc)g_armv7_maccess_operand_compare; - operand->print = (operand_print_fc)g_armv7_maccess_operand_print; - -} - - -/****************************************************************************** -* * -* Paramètres : operand = instance à initialiser. * -* * -* Description : Initialise une instance d'accès à la mémoire chez ARM. * -* * -* Retour : - * -* * -* Remarques : - * -* * -******************************************************************************/ - -static void g_armv7_maccess_operand_init(GArmV7MAccessOperand *operand) -{ - -} - - -/****************************************************************************** -* * -* Paramètres : operand = instance d'objet GLib à traiter. * -* * -* Description : Supprime toutes les références externes. * -* * -* Retour : - * -* * -* Remarques : - * -* * -******************************************************************************/ - -static void g_armv7_maccess_operand_dispose(GArmV7MAccessOperand *operand) -{ - g_object_unref(G_OBJECT(operand->base)); - - if (operand->offset != NULL) - g_object_unref(G_OBJECT(operand->offset)); - - if (operand->shift != NULL) - g_object_unref(G_OBJECT(operand->shift)); - - G_OBJECT_CLASS(g_armv7_maccess_operand_parent_class)->dispose(G_OBJECT(operand)); - -} - - -/****************************************************************************** -* * -* Paramètres : operand = instance d'objet GLib à traiter. * -* * -* Description : Procède à la libération totale de la mémoire. * -* * -* Retour : - * -* * -* Remarques : - * -* * -******************************************************************************/ - -static void g_armv7_maccess_operand_finalize(GArmV7MAccessOperand *operand) -{ - G_OBJECT_CLASS(g_armv7_maccess_operand_parent_class)->finalize(G_OBJECT(operand)); - -} - - -/****************************************************************************** -* * -* Paramètres : a = premier opérande à consulter. * -* b = second opérande à consulter. * -* * -* Description : Compare un opérande avec un autre. * -* * -* Retour : Bilan de la comparaison. * -* * -* Remarques : - * -* * -******************************************************************************/ - -static int g_armv7_maccess_operand_compare(const GArmV7MAccessOperand *a, const GArmV7MAccessOperand *b) -{ - int result; /* Bilan à faire remonter */ - - result = g_arch_operand_compare(a->base, b->base); - if (result != 0) goto gamoc_done; - - result = sort_pointer(a->offset, b->offset, (__compar_fn_t)g_arch_operand_compare); - if (result != 0) goto gamoc_done; - - result = sort_pointer(a->shift, b->shift, (__compar_fn_t)g_arch_operand_compare); - if (result != 0) goto gamoc_done; - - result = sort_boolean(a->not_post_indexed, b->not_post_indexed); - if (result != 0) goto gamoc_done; - - result = sort_boolean(a->write_back, b->write_back); - - gamoc_done: - - return result; - -} - - -/****************************************************************************** -* * -* Paramètres : operand = opérande à traiter. * -* line = ligne tampon où imprimer l'opérande donné. * -* syntax = type de représentation demandée. * -* * -* Description : Traduit un opérande en version humainement lisible. * -* * -* Retour : - * -* * -* Remarques : - * -* * -******************************************************************************/ - -static void g_armv7_maccess_operand_print(const GArmV7MAccessOperand *operand, GBufferLine *line, AsmSyntax syntax) -{ - g_buffer_line_append_text(line, BLC_ASSEMBLY, "[", 1, RTT_HOOK, NULL); - - g_arch_operand_print(operand->base, line, syntax); - - if (!operand->not_post_indexed) - g_buffer_line_append_text(line, BLC_ASSEMBLY, "]", 1, RTT_HOOK, NULL); - - if (operand->offset != NULL) - { - g_buffer_line_append_text(line, BLC_ASSEMBLY, ",", 1, RTT_PUNCT, NULL); - g_buffer_line_append_text(line, BLC_ASSEMBLY, " ", 1, RTT_RAW, NULL); - - g_arch_operand_print(operand->offset, line, syntax); - - } - - if (operand->shift != NULL) - { - g_buffer_line_append_text(line, BLC_ASSEMBLY, ",", 1, RTT_PUNCT, NULL); - g_buffer_line_append_text(line, BLC_ASSEMBLY, " ", 1, RTT_RAW, NULL); - - g_arch_operand_print(operand->shift, line, syntax); - - } - - if (operand->not_post_indexed) - g_buffer_line_append_text(line, BLC_ASSEMBLY, "]", 1, RTT_HOOK, NULL); - - if (operand->write_back) - g_buffer_line_append_text(line, BLC_ASSEMBLY, "!", 1, RTT_PUNCT, NULL); - -} - - -/****************************************************************************** -* * -* Paramètres : base = représente le registre de la base d'accès. * -* offset = détermine le décallage entre l'adresse et la base. * -* shift = opération de décallage pour jouer sur le décallage.* -* indexed = précise la forme donnée au décallage à appliquer. * -* wback = indique une mise à jour de la base après usage. * -* * -* Description : Crée un accès à la mémoire depuis une base et un décallage. * -* * -* Retour : Opérande mis en place. * -* * -* Remarques : - * -* * -******************************************************************************/ - -GArchOperand *g_armv7_maccess_operand_new(GArchOperand *base, GArchOperand *offset, GArchOperand *shift, bool indexed, bool wback) -{ - GArmV7MAccessOperand *result; /* Structure à retourner */ - - result = g_object_new(G_TYPE_ARMV7_MACCESS_OPERAND, NULL); - - result->base = base; - result->offset = offset; - result->shift = shift; - - result->not_post_indexed = indexed; - result->write_back = wback; - - return G_ARCH_OPERAND(result); - -} - - -/****************************************************************************** -* * -* Paramètres : operand = opérande à consulter. * -* * -* Description : Founit la base d'un accès à la mémoire. * -* * -* Retour : Opérande en place. * -* * -* Remarques : - * -* * -******************************************************************************/ - -GArchOperand *g_armv7_maccess_operand_get_base(const GArmV7MAccessOperand *operand) -{ - return operand->base; - -} - - -/****************************************************************************** -* * -* Paramètres : operand = opérande à consulter. * -* * -* Description : Founit le décallage d'un accès à la mémoire depuis la base. * -* * -* Retour : Opérande en place. * -* * -* Remarques : - * -* * -******************************************************************************/ - -GArchOperand *g_armv7_maccess_operand_get_offset(const GArmV7MAccessOperand *operand) -{ - return operand->offset; - -} - - -/****************************************************************************** -* * -* Paramètres : operand = opérande à consulter. * -* * -* Description : Founit le décallage d'un décallage pour un accès mémoire. * -* * -* Retour : Opérande en place. * -* * -* Remarques : - * -* * -******************************************************************************/ - -GArchOperand *g_armv7_maccess_operand_get_shift(const GArmV7MAccessOperand *operand) -{ - return operand->shift; - -} - - -/****************************************************************************** -* * -* Paramètres : operand = opérande à consulter. * -* * -* Description : Indique si le décallage est post-indexé. * -* * -* Retour : Statut des opérations menées. * -* * -* Remarques : - * -* * -******************************************************************************/ - -bool g_armv7_maccess_operand_is_post_indexed(const GArmV7MAccessOperand *operand) -{ - return !operand->not_post_indexed; - -} - - -/****************************************************************************** -* * -* Paramètres : operand = opérande à consulter. * -* * -* Description : Indique si la base est mise à jour après usage. * -* * -* Retour : Statut des opérations menées. * -* * -* Remarques : - * -* * -******************************************************************************/ - -bool g_armv7_maccess_operand_has_to_write_back(const GArmV7MAccessOperand *operand) -{ - return operand->write_back; - -} diff --git a/src/arch/arm/v7/operands/maccess.h b/src/arch/arm/v7/operands/maccess.h deleted file mode 100644 index 6e99e0b..0000000 --- a/src/arch/arm/v7/operands/maccess.h +++ /dev/null @@ -1,75 +0,0 @@ - -/* Chrysalide - Outil d'analyse de fichiers binaires - * maccess.h - prototypes pour les accès à la mémorie à partir d'un registre et d'un décallage - * - * Copyright (C) 2014-2017 Cyrille Bagard - * - * This file is part of Chrysalide. - * - * Chrysalide is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Chrysalide is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Foobar. If not, see . - */ - - -#ifndef _ARCH_ARM_V7_OPERANDS_MACCESS_H -#define _ARCH_ARM_V7_OPERANDS_MACCESS_H - - -#include -#include - - -#include "../pseudo.h" -#include "../../../operand.h" - - - -#define G_TYPE_ARMV7_MACCESS_OPERAND g_armv7_maccess_operand_get_type() -#define G_ARMV7_MACCESS_OPERAND(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), g_armv7_maccess_operand_get_type(), GArmV7MAccessOperand)) -#define G_IS_ARMV7_MACCESS_OPERAND(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), g_armv7_maccess_operand_get_type())) -#define G_ARMV7_MACCESS_OPERAND_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), G_TYPE_ARMV7_MACCESS_OPERAND, GArmV7MAccessOperandClass)) -#define G_IS_ARMV7_MACCESS_OPERAND_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), G_TYPE_ARMV7_MACCESS_OPERAND)) -#define G_ARMV7_MACCESS_OPERAND_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), G_TYPE_ARMV7_MACCESS_OPERAND, GArmV7MAccessOperandClass)) - - -/* Définition d'un opérande offrant un accès à la mémoire depuis une base (instance) */ -typedef struct _GArmV7MAccessOperand GArmV7MAccessOperand; - -/* Définition d'un opérande offrant un accès à la mémoire depuis une base (classe) */ -typedef struct _GArmV7MAccessOperandClass GArmV7MAccessOperandClass; - - -/* Indique le type défini par la GLib pour un accès à la mémoire depuis une base. */ -GType g_armv7_maccess_operand_get_type(void); - -/* Crée un accès à la mémoire depuis une base et un décallage. */ -GArchOperand *g_armv7_maccess_operand_new(GArchOperand *, GArchOperand *, GArchOperand *, bool, bool); - -/* Founit la base d'un accès à la mémoire. */ -GArchOperand *g_armv7_maccess_operand_get_base(const GArmV7MAccessOperand *); - -/* Founit le décallage d'un accès à la mémoire depuis la base. */ -GArchOperand *g_armv7_maccess_operand_get_offset(const GArmV7MAccessOperand *); - -/* Founit le décallage d'un décallage pour un accès mémoire. */ -GArchOperand *g_armv7_maccess_operand_get_shift(const GArmV7MAccessOperand *); - -/* Indique si le décallage est post-indexé. */ -bool g_armv7_maccess_operand_is_post_indexed(const GArmV7MAccessOperand *); - -/* Indique si la base est mise à jour après usage. */ -bool g_armv7_maccess_operand_has_to_write_back(const GArmV7MAccessOperand *); - - - -#endif /* _ARCH_ARM_V7_OPERANDS_MACCESS_H */ diff --git a/src/arch/arm/v7/operands/offset.c b/src/arch/arm/v7/operands/offset.c deleted file mode 100644 index b8df640..0000000 --- a/src/arch/arm/v7/operands/offset.c +++ /dev/null @@ -1,283 +0,0 @@ - -/* Chrysalide - Outil d'analyse de fichiers binaires - * offset.c - constitution d'un décallage positif ou négatif - * - * Copyright (C) 2014-2017 Cyrille Bagard - * - * This file is part of Chrysalide. - * - * Chrysalide is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Chrysalide is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Foobar. If not, see . - */ - - -#include "offset.h" - - -#include "../../../operand-int.h" -#include "../../../../common/sort.h" - - - -/* Définition d'un opérande visant à constituer un décallage relatif ARMv7 (instance) */ -struct _GArmV7OffsetOperand -{ - GArchOperand parent; /* Instance parente */ - - bool positive; /* Sens du décallage */ - GArchOperand *value; /* Valeur du décallage */ - -}; - - -/* Définition d'un opérande visant à constituer un décallage relatif ARMv7 (classe) */ -struct _GArmV7OffsetOperandClass -{ - GArchOperandClass parent; /* Classe parente */ - -}; - - -/* Initialise la classe des décallages relatifs ARMv7. */ -static void g_armv7_offset_operand_class_init(GArmV7OffsetOperandClass *); - -/* Initialise une instance de décallage relatif ARMv7. */ -static void g_armv7_offset_operand_init(GArmV7OffsetOperand *); - -/* Supprime toutes les références externes. */ -static void g_armv7_offset_operand_dispose(GArmV7OffsetOperand *); - -/* Procède à la libération totale de la mémoire. */ -static void g_armv7_offset_operand_finalize(GArmV7OffsetOperand *); - -/* Compare un opérande avec un autre. */ -static int g_armv7_offset_operand_compare(const GArmV7OffsetOperand *, const GArmV7OffsetOperand *); - -/* Traduit un opérande en version humainement lisible. */ -static void g_armv7_offset_operand_print(const GArmV7OffsetOperand *, GBufferLine *, AsmSyntax); - - - -/* Indique le type défini par la GLib pour un décallage relatif ARMv7. */ -G_DEFINE_TYPE(GArmV7OffsetOperand, g_armv7_offset_operand, G_TYPE_ARCH_OPERAND); - - -/****************************************************************************** -* * -* Paramètres : klass = classe à initialiser. * -* * -* Description : Initialise la classe des décallages relatifs ARMv7. * -* * -* Retour : - * -* * -* Remarques : - * -* * -******************************************************************************/ - -static void g_armv7_offset_operand_class_init(GArmV7OffsetOperandClass *klass) -{ - GObjectClass *object; /* Autre version de la classe */ - GArchOperandClass *operand; /* Version de classe parente */ - - object = G_OBJECT_CLASS(klass); - operand = G_ARCH_OPERAND_CLASS(klass); - - object->dispose = (GObjectFinalizeFunc/* ! */)g_armv7_offset_operand_dispose; - object->finalize = (GObjectFinalizeFunc)g_armv7_offset_operand_finalize; - - operand->compare = (operand_compare_fc)g_armv7_offset_operand_compare; - operand->print = (operand_print_fc)g_armv7_offset_operand_print; - -} - - -/****************************************************************************** -* * -* Paramètres : operand = instance à initialiser. * -* * -* Description : Initialise une instance de décallage relatif ARMv7. * -* * -* Retour : - * -* * -* Remarques : - * -* * -******************************************************************************/ - -static void g_armv7_offset_operand_init(GArmV7OffsetOperand *operand) -{ - -} - - -/****************************************************************************** -* * -* Paramètres : operand = instance d'objet GLib à traiter. * -* * -* Description : Supprime toutes les références externes. * -* * -* Retour : - * -* * -* Remarques : - * -* * -******************************************************************************/ - -static void g_armv7_offset_operand_dispose(GArmV7OffsetOperand *operand) -{ - g_object_unref(G_OBJECT(operand->value)); - - G_OBJECT_CLASS(g_armv7_offset_operand_parent_class)->dispose(G_OBJECT(operand)); - -} - - -/****************************************************************************** -* * -* Paramètres : operand = instance d'objet GLib à traiter. * -* * -* Description : Procède à la libération totale de la mémoire. * -* * -* Retour : - * -* * -* Remarques : - * -* * -******************************************************************************/ - -static void g_armv7_offset_operand_finalize(GArmV7OffsetOperand *operand) -{ - G_OBJECT_CLASS(g_armv7_offset_operand_parent_class)->finalize(G_OBJECT(operand)); - -} - - -/****************************************************************************** -* * -* Paramètres : a = premier opérande à consulter. * -* b = second opérande à consulter. * -* * -* Description : Compare un opérande avec un autre. * -* * -* Retour : Bilan de la comparaison. * -* * -* Remarques : - * -* * -******************************************************************************/ - -static int g_armv7_offset_operand_compare(const GArmV7OffsetOperand *a, const GArmV7OffsetOperand *b) -{ - int result; /* Bilan à faire remonter */ - - result = sort_boolean(a->positive, b->positive); - if (result != 0) goto gaooc_done; - - result = g_arch_operand_compare(a->value, b->value); - - gaooc_done: - - return result; - -} - - -/****************************************************************************** -* * -* Paramètres : operand = opérande à traiter. * -* line = ligne tampon où imprimer l'opérande donné. * -* syntax = type de représentation demandée. * -* * -* Description : Traduit un opérande en version humainement lisible. * -* * -* Retour : - * -* * -* Remarques : - * -* * -******************************************************************************/ - -static void g_armv7_offset_operand_print(const GArmV7OffsetOperand *operand, GBufferLine *line, AsmSyntax syntax) -{ - if (!operand->positive) - g_buffer_line_append_text(line, BLC_ASSEMBLY, "-", 1, RTT_KEY_WORD, NULL); - - g_arch_operand_print(operand->value, line, syntax); - -} - - -/****************************************************************************** -* * -* Paramètres : positive = indique si la quantité doit être ajoutée ou non. * -* value = valeur du décallage à appliquer. * -* * -* Description : Crée un décallage selon un sens et une valeur donnés. * -* * -* Retour : Opérande mis en place. * -* * -* Remarques : - * -* * -******************************************************************************/ - -GArchOperand *g_armv7_offset_operand_new(bool positive, GArchOperand *value) -{ - GArmV7OffsetOperand *result; /* Structure à retourner */ - - result = g_object_new(G_TYPE_ARMV7_OFFSET_OPERAND, NULL); - - result->positive = positive; - result->value = value; - - return G_ARCH_OPERAND(result); - -} - - -/****************************************************************************** -* * -* Paramètres : operand = opérande à consulter. * -* * -* Description : Indique le sens du décallage représenté. * -* * -* Retour : Indication d'ajout ou de retrait. * -* * -* Remarques : - * -* * -******************************************************************************/ - -bool g_armv7_offset_operand_is_positive(const GArmV7OffsetOperand *operand) -{ - return operand->positive; - -} - - -/****************************************************************************** -* * -* Paramètres : operand = opérande à consulter. * -* * -* Description : Founit la valeur utilisée pour un décallage. * -* * -* Retour : Opérande en place. * -* * -* Remarques : - * -* * -******************************************************************************/ - -GArchOperand *g_armv7_offset_operand_get_value(const GArmV7OffsetOperand *operand) -{ - GArchOperand *result; /* Instance à retourner */ - - result = operand->value; - - g_object_ref(G_OBJECT(result)); - - return result; - -} diff --git a/src/arch/arm/v7/operands/offset.h b/src/arch/arm/v7/operands/offset.h deleted file mode 100644 index 64744df..0000000 --- a/src/arch/arm/v7/operands/offset.h +++ /dev/null @@ -1,66 +0,0 @@ - -/* Chrysalide - Outil d'analyse de fichiers binaires - * offset.h - prototypes pour la constitution d'un décallage positif ou négatif - * - * Copyright (C) 2014-2017 Cyrille Bagard - * - * This file is part of Chrysalide. - * - * Chrysalide is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Chrysalide is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Foobar. If not, see . - */ - - -#ifndef _ARCH_ARM_V7_OPERANDS_OFFSET_H -#define _ARCH_ARM_V7_OPERANDS_OFFSET_H - - -#include -#include - - -#include "../pseudo.h" -#include "../../../operand.h" - - - -#define G_TYPE_ARMV7_OFFSET_OPERAND g_armv7_offset_operand_get_type() -#define G_ARMV7_OFFSET_OPERAND(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), g_armv7_offset_operand_get_type(), GArmV7OffsetOperand)) -#define G_IS_ARMV7_OFFSET_OPERAND(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), g_armv7_offset_operand_get_type())) -#define G_ARMV7_OFFSET_OPERAND_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), G_TYPE_ARMV7_OFFSET_OPERAND, GArmV7OffsetOperandClass)) -#define G_IS_ARMV7_OFFSET_OPERAND_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), G_TYPE_ARMV7_OFFSET_OPERAND)) -#define G_ARMV7_OFFSET_OPERAND_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), G_TYPE_ARMV7_OFFSET_OPERAND, GArmV7OffsetOperandClass)) - - -/* Définition d'un opérande visant à constituer un décallage relatif ARMv7 (instance) */ -typedef struct _GArmV7OffsetOperand GArmV7OffsetOperand; - -/* Définition d'un opérande visant à constituer un décallage relatif ARMv7 (classe) */ -typedef struct _GArmV7OffsetOperandClass GArmV7OffsetOperandClass; - - -/* Indique le type défini par la GLib pour un décallage relatif ARMv7. */ -GType g_armv7_offset_operand_get_type(void); - -/* Crée un décallage selon un sens et une valeur donnés. */ -GArchOperand *g_armv7_offset_operand_new(bool, GArchOperand *); - -/* Indique le sens du décallage représenté. */ -bool g_armv7_offset_operand_is_positive(const GArmV7OffsetOperand *); - -/* Founit la valeur utilisée pour un décallage. */ -GArchOperand *g_armv7_offset_operand_get_value(const GArmV7OffsetOperand *); - - - -#endif /* _ARCH_ARM_V7_OPERANDS_OFFSET_H */ diff --git a/src/arch/arm/v7/operands/reglist.c b/src/arch/arm/v7/operands/reglist.c deleted file mode 100644 index 9f641b8..0000000 --- a/src/arch/arm/v7/operands/reglist.c +++ /dev/null @@ -1,376 +0,0 @@ - -/* Chrysalide - Outil d'analyse de fichiers binaires - * reglist.c - accès à la mémorie à partir d'un registre et d'un décallage - * - * Copyright (C) 2014-2017 Cyrille Bagard - * - * This file is part of Chrysalide. - * - * Chrysalide is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Chrysalide is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Foobar. If not, see . - */ - - -#include "reglist.h" - - -#include -#include - - -#include "../../../operand-int.h" -#include "../../../register.h" -#include "../../../../common/sort.h" - - - -/* Définition d'un opérande listant une série de registres ARM (instance) */ -struct _GArmV7RegListOperand -{ - GArchOperand parent; /* Instance parente */ - - GArmV7Register **registers; /* Liste de registres intégrés */ - size_t count; /* Taille de cette liste */ - -}; - - -/* Définition d'un opérande listant une série de registres ARM (classe) */ -struct _GArmV7RegListOperandClass -{ - GArchOperandClass parent; /* Classe parente */ - -}; - - -/* Initialise la classe des listes de registres ARM. */ -static void g_armv7_reglist_operand_class_init(GArmV7RegListOperandClass *); - -/* Initialise une instance de liste de registres ARM. */ -static void g_armv7_reglist_operand_init(GArmV7RegListOperand *); - -/* Supprime toutes les références externes. */ -static void g_armv7_reglist_operand_dispose(GArmV7RegListOperand *); - -/* Procède à la libération totale de la mémoire. */ -static void g_armv7_reglist_operand_finalize(GArmV7RegListOperand *); - -/* Compare un opérande avec un autre. */ -static int g_armv7_reglist_operand_compare(const GArmV7RegListOperand *, const GArmV7RegListOperand *); - -/* Traduit un opérande en version humainement lisible. */ -static void g_armv7_reglist_operand_print(const GArmV7RegListOperand *, GBufferLine *, AsmSyntax); - - - -/* Indique le type défini par la GLib pour une liste de registres ARM. */ -G_DEFINE_TYPE(GArmV7RegListOperand, g_armv7_reglist_operand, G_TYPE_ARCH_OPERAND); - - -/****************************************************************************** -* * -* Paramètres : klass = classe à initialiser. * -* * -* Description : Initialise la classe des listes de registres ARM. * -* * -* Retour : - * -* * -* Remarques : - * -* * -******************************************************************************/ - -static void g_armv7_reglist_operand_class_init(GArmV7RegListOperandClass *klass) -{ - GObjectClass *object; /* Autre version de la classe */ - GArchOperandClass *operand; /* Version de classe parente */ - - object = G_OBJECT_CLASS(klass); - operand = G_ARCH_OPERAND_CLASS(klass); - - object->dispose = (GObjectFinalizeFunc/* ! */)g_armv7_reglist_operand_dispose; - object->finalize = (GObjectFinalizeFunc)g_armv7_reglist_operand_finalize; - - operand->compare = (operand_compare_fc)g_armv7_reglist_operand_compare; - operand->print = (operand_print_fc)g_armv7_reglist_operand_print; - -} - - -/****************************************************************************** -* * -* Paramètres : operand = instance à initialiser. * -* * -* Description : Initialise une instance de liste de registres ARM. * -* * -* Retour : - * -* * -* Remarques : - * -* * -******************************************************************************/ - -static void g_armv7_reglist_operand_init(GArmV7RegListOperand *operand) -{ - -} - - -/****************************************************************************** -* * -* Paramètres : operand = instance d'objet GLib à traiter. * -* * -* Description : Supprime toutes les références externes. * -* * -* Retour : - * -* * -* Remarques : - * -* * -******************************************************************************/ - -static void g_armv7_reglist_operand_dispose(GArmV7RegListOperand *operand) -{ - size_t i; /* Boucle de parcours */ - - for (i = 0; i < operand->count; i++) - g_object_unref(G_OBJECT(operand->registers[i])); - - G_OBJECT_CLASS(g_armv7_reglist_operand_parent_class)->dispose(G_OBJECT(operand)); - -} - - -/****************************************************************************** -* * -* Paramètres : operand = instance d'objet GLib à traiter. * -* * -* Description : Procède à la libération totale de la mémoire. * -* * -* Retour : - * -* * -* Remarques : - * -* * -******************************************************************************/ - -static void g_armv7_reglist_operand_finalize(GArmV7RegListOperand *operand) -{ - if (operand->registers != NULL) - free(operand->registers); - - G_OBJECT_CLASS(g_armv7_reglist_operand_parent_class)->finalize(G_OBJECT(operand)); - -} - - -/****************************************************************************** -* * -* Paramètres : a = premier opérande à consulter. * -* b = second opérande à consulter. * -* * -* Description : Compare un opérande avec un autre. * -* * -* Retour : Bilan de la comparaison. * -* * -* Remarques : - * -* * -******************************************************************************/ - -static int g_armv7_reglist_operand_compare(const GArmV7RegListOperand *a, const GArmV7RegListOperand *b) -{ - int result; /* Bilan à faire remonter */ - size_t i; /* Boucle de parcours */ - GArchRegister *ra; /* Registre de la liste A */ - GArchRegister *rb; /* Registre de la liste B */ - - /* Création de l'objet... */ - if (b == NULL) - { - result = 1; - goto garoc_done; - } - - result = sort_unsigned_long(a->count, b->count); - if (result != 0) goto garoc_done; - - for (i = 0; i < a->count && result == 0; i++) - { - ra = G_ARCH_REGISTER(a->registers[i]); - rb = G_ARCH_REGISTER(b->registers[i]); - - result = g_arch_register_compare(ra, rb); - - } - - garoc_done: - - return result; - -} - - -/****************************************************************************** -* * -* Paramètres : operand = opérande à traiter. * -* line = ligne tampon où imprimer l'opérande donné. * -* syntax = type de représentation demandée. * -* * -* Description : Traduit un opérande en version humainement lisible. * -* * -* Retour : - * -* * -* Remarques : - * -* * -******************************************************************************/ - -static void g_armv7_reglist_operand_print(const GArmV7RegListOperand *operand, GBufferLine *line, AsmSyntax syntax) -{ - size_t i; /* Boucle de parcours */ - - g_buffer_line_append_text(line, BLC_ASSEMBLY, "{", 1, RTT_HOOK, NULL); - - for (i = 0; i < operand->count; i++) - { - if (i > 0) - { - g_buffer_line_append_text(line, BLC_ASSEMBLY, ",", 1, RTT_PUNCT, NULL); - g_buffer_line_append_text(line, BLC_ASSEMBLY, " ", 1, RTT_RAW, NULL); - } - - g_arch_register_print(G_ARCH_REGISTER(operand->registers[i]), line, syntax); - - } - - g_buffer_line_append_text(line, BLC_ASSEMBLY, "}", 1, RTT_HOOK, NULL); - -} - - -/****************************************************************************** -* * -* Paramètres : - * -* * -* Description : Crée une liste vierge de registres ARM. * -* * -* Retour : Opérande mis en place. * -* * -* Remarques : - * -* * -******************************************************************************/ - -GArchOperand *g_armv7_reglist_operand_new(void) -{ - GArchOperand *result; /* Structure à retourner */ - - result = g_object_new(G_TYPE_ARMV7_REGLIST_OPERAND, NULL); - - return G_ARCH_OPERAND(result); - -} - - -/****************************************************************************** -* * -* Paramètres : operand = liste de registres à compléter. * -* selected = masque de bits pour les registres à intégrer. * -* * -* Description : Remplit une liste de registres de registres ARM. * -* * -* Retour : Bilan de l'opération. * -* * -* Remarques : - * -* * -******************************************************************************/ - -bool g_armv7_reglist_load_registers(GArmV7RegListOperand *operand, uint32_t selected) -{ - uint8_t i; /* Boucle de parcours */ - GArmV7Register *reg; /* Nouveau registre à intégrer */ - - for (i = 18; i < 32; i++) - if (selected & (1 << i)) return false; - - for (i = 0; i < 18; i++) - { - if ((selected & (1 << i)) == 0) continue; - - reg = g_armv7_register_new(i); - g_armv7_reglist_add_register(operand, reg); - - } - - return true; - -} - - -/****************************************************************************** -* * -* Paramètres : operand = liste de registres à compléter. * -* reg = nouveau registre à intégrer. * -* * -* Description : Ajoute un registre à une liste de registres ARM. * -* * -* Retour : - * -* * -* Remarques : - * -* * -******************************************************************************/ - -void g_armv7_reglist_add_register(GArmV7RegListOperand *operand, GArmV7Register *reg) -{ - operand->registers = (GArmV7Register **)realloc(operand->registers, - ++operand->count * sizeof(GArmV7Register *)); - - operand->registers[operand->count - 1] = reg; - -} - - - -/****************************************************************************** -* * -* Paramètres : operand = opérande à consulter. * -* * -* Description : Compte le nombre de registres ARM composant la liste. * -* * -* Retour : Nombre positif ou nul. * -* * -* Remarques : - * -* * -******************************************************************************/ - -size_t g_armv7_reglist_count_registers(const GArmV7RegListOperand *operand) -{ - return operand->count; - -} - - -/****************************************************************************** -* * -* Paramètres : operand = opérande à consulter. * -* index = indice de l'élément à fournier. * -* * -* Description : Founit un élément donné d'une liste de registres ARM. * -* * -* Retour : Registre intégré à la liste manipulée. * -* * -* Remarques : - * -* * -******************************************************************************/ - -GArmV7Register *g_armv7_reglist_operand_get_register(const GArmV7RegListOperand *operand, size_t index) -{ - assert(index < operand->count); - - return operand->registers[index]; - -} diff --git a/src/arch/arm/v7/operands/reglist.h b/src/arch/arm/v7/operands/reglist.h deleted file mode 100644 index 7c60805..0000000 --- a/src/arch/arm/v7/operands/reglist.h +++ /dev/null @@ -1,72 +0,0 @@ - -/* Chrysalide - Outil d'analyse de fichiers binaires - * reglist.h - prototypes pour les accès à la mémorie à partir d'un registre et d'un décallage - * - * Copyright (C) 2014-2017 Cyrille Bagard - * - * This file is part of Chrysalide. - * - * Chrysalide is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Chrysalide is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Foobar. If not, see . - */ - - -#ifndef _ARCH_ARM_V7_OPERANDS_REGLIST_H -#define _ARCH_ARM_V7_OPERANDS_REGLIST_H - - -#include -#include - - -#include "../register.h" -#include "../../../operand.h" - - - -#define G_TYPE_ARMV7_REGLIST_OPERAND g_armv7_reglist_operand_get_type() -#define G_ARMV7_REGLIST_OPERAND(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), g_armv7_reglist_operand_get_type(), GArmV7RegListOperand)) -#define G_IS_ARMV7_REGLIST_OPERAND(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), g_armv7_reglist_operand_get_type())) -#define G_ARMV7_REGLIST_OPERAND_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), G_TYPE_ARMV7_REGLIST_OPERAND, GArmV7RegListOperandClass)) -#define G_IS_ARMV7_REGLIST_OPERAND_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), G_TYPE_ARMV7_REGLIST_OPERAND)) -#define G_ARMV7_REGLIST_OPERAND_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), G_TYPE_ARMV7_REGLIST_OPERAND, GArmV7RegListOperandClass)) - - -/* Définition d'un opérande listant une série de registres ARM (instance) */ -typedef struct _GArmV7RegListOperand GArmV7RegListOperand; - -/* Définition d'un opérande listant une série de registres ARM (classe) */ -typedef struct _GArmV7RegListOperandClass GArmV7RegListOperandClass; - - -/* Indique le type défini par la GLib pour une liste de registres ARM. */ -GType g_armv7_reglist_operand_get_type(void); - -/* Crée une liste vierge de registres ARM. */ -GArchOperand *g_armv7_reglist_operand_new(void); - -/* Remplit une liste de registres de registres ARM. */ -bool g_armv7_reglist_load_registers(GArmV7RegListOperand *, uint32_t); - -/* Ajoute un registre à une liste de registres ARM. */ -void g_armv7_reglist_add_register(GArmV7RegListOperand *, GArmV7Register *); - -/* Compte le nombre de registres ARM composant la liste. */ -size_t g_armv7_reglist_count_registers(const GArmV7RegListOperand *); - -/* Founit un élément donné d'une liste de registres ARM. */ -GArmV7Register *g_armv7_reglist_operand_get_register(const GArmV7RegListOperand *, size_t ); - - - -#endif /* _ARCH_ARM_V7_OPERANDS_REGLIST_H */ diff --git a/src/arch/arm/v7/operands/rotation.c b/src/arch/arm/v7/operands/rotation.c deleted file mode 100644 index ba31441..0000000 --- a/src/arch/arm/v7/operands/rotation.c +++ /dev/null @@ -1,256 +0,0 @@ - -/* Chrysalide - Outil d'analyse de fichiers binaires - * rotation.c - rotations de valeurs - * - * Copyright (C) 2015-2017 Cyrille Bagard - * - * This file is part of Chrysalide. - * - * Chrysalide is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Chrysalide is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Foobar. If not, see . - */ - - -#include "rotation.h" - - -#include "../../../operand-int.h" - - - -/* Définition d'un opérande visant une opérande de rotation ARMv7 (instance) */ -struct _GArmV7RotationOperand -{ - GArchOperand parent; /* Instance parente */ - - GArchOperand *value; /* Valeur du décallage */ - -}; - - -/* Définition d'un opérande visant une opérande de rotation ARMv7 (classe) */ -struct _GArmV7RotationOperandClass -{ - GArchOperandClass parent; /* Classe parente */ - -}; - - -/* Initialise la classe des opérandes de rotation ARMv7. */ -static void g_armv7_rotation_operand_class_init(GArmV7RotationOperandClass *); - -/* Initialise une instance d'opérande de rotation ARMv7. */ -static void g_armv7_rotation_operand_init(GArmV7RotationOperand *); - -/* Supprime toutes les références externes. */ -static void g_armv7_rotation_operand_dispose(GArmV7RotationOperand *); - -/* Procède à la libération totale de la mémoire. */ -static void g_armv7_rotation_operand_finalize(GArmV7RotationOperand *); - -/* Compare un opérande avec un autre. */ -static int g_armv7_rotation_operand_compare(const GArmV7RotationOperand *, const GArmV7RotationOperand *); - -/* Traduit un opérande en version humainement lisible. */ -static void g_armv7_rotation_operand_print(const GArmV7RotationOperand *, GBufferLine *, AsmSyntax); - - - -/* Indique le type défini par la GLib pour une opérande de rotation ARMv7. */ -G_DEFINE_TYPE(GArmV7RotationOperand, g_armv7_rotation_operand, G_TYPE_ARCH_OPERAND); - - -/****************************************************************************** -* * -* Paramètres : klass = classe à initialiser. * -* * -* Description : Initialise la classe des opérandes de rotation ARMv7. * -* * -* Retour : - * -* * -* Remarques : - * -* * -******************************************************************************/ - -static void g_armv7_rotation_operand_class_init(GArmV7RotationOperandClass *klass) -{ - GObjectClass *object; /* Autre version de la classe */ - GArchOperandClass *operand; /* Version de classe parente */ - - object = G_OBJECT_CLASS(klass); - operand = G_ARCH_OPERAND_CLASS(klass); - - object->dispose = (GObjectFinalizeFunc/* ! */)g_armv7_rotation_operand_dispose; - object->finalize = (GObjectFinalizeFunc)g_armv7_rotation_operand_finalize; - - operand->compare = (operand_compare_fc)g_armv7_rotation_operand_compare; - operand->print = (operand_print_fc)g_armv7_rotation_operand_print; - -} - - -/****************************************************************************** -* * -* Paramètres : operand = instance à initialiser. * -* * -* Description : Initialise une instance d'opérande de rotation ARMv7. * -* * -* Retour : - * -* * -* Remarques : - * -* * -******************************************************************************/ - -static void g_armv7_rotation_operand_init(GArmV7RotationOperand *operand) -{ - -} - - -/****************************************************************************** -* * -* Paramètres : operand = instance d'objet GLib à traiter. * -* * -* Description : Supprime toutes les références externes. * -* * -* Retour : - * -* * -* Remarques : - * -* * -******************************************************************************/ - -static void g_armv7_rotation_operand_dispose(GArmV7RotationOperand *operand) -{ - g_object_unref(G_OBJECT(operand->value)); - - G_OBJECT_CLASS(g_armv7_rotation_operand_parent_class)->dispose(G_OBJECT(operand)); - -} - - -/****************************************************************************** -* * -* Paramètres : operand = instance d'objet GLib à traiter. * -* * -* Description : Procède à la libération totale de la mémoire. * -* * -* Retour : - * -* * -* Remarques : - * -* * -******************************************************************************/ - -static void g_armv7_rotation_operand_finalize(GArmV7RotationOperand *operand) -{ - G_OBJECT_CLASS(g_armv7_rotation_operand_parent_class)->finalize(G_OBJECT(operand)); - -} - - -/****************************************************************************** -* * -* Paramètres : a = premier opérande à consulter. * -* b = second opérande à consulter. * -* * -* Description : Compare un opérande avec un autre. * -* * -* Retour : Bilan de la comparaison. * -* * -* Remarques : - * -* * -******************************************************************************/ - -static int g_armv7_rotation_operand_compare(const GArmV7RotationOperand *a, const GArmV7RotationOperand *b) -{ - int result; /* Bilan à faire remonter */ - - result = g_arch_operand_compare(a->value, b->value); - - return result; - -} - - -/****************************************************************************** -* * -* Paramètres : operand = opérande à traiter. * -* line = ligne tampon où imprimer l'opérande donné. * -* syntax = type de représentation demandée. * -* * -* Description : Traduit un opérande en version humainement lisible. * -* * -* Retour : - * -* * -* Remarques : - * -* * -******************************************************************************/ - -static void g_armv7_rotation_operand_print(const GArmV7RotationOperand *operand, GBufferLine *line, AsmSyntax syntax) -{ - g_buffer_line_append_text(line, BLC_ASSEMBLY, "ror", 3, RTT_KEY_WORD, NULL); - - g_buffer_line_append_text(line, BLC_ASSEMBLY, " ", 1, RTT_RAW, NULL); - - g_arch_operand_print(operand->value, line, syntax); - -} - - -/****************************************************************************** -* * -* Paramètres : - * -* * -* Description : Crée un réceptacle pour opérandes de rotation ARMv7. * -* * -* Retour : Opérande mis en place. * -* * -* Remarques : - * -* * -******************************************************************************/ - -GArchOperand *g_armv7_rotation_operand_new(GArchOperand *value) -{ - GArmV7RotationOperand *result; /* Structure à retourner */ - - result = g_object_new(G_TYPE_ARMV7_ROTATION_OPERAND, NULL); - - result->value = value; - - return G_ARCH_OPERAND(result); - -} - - -/****************************************************************************** -* * -* Paramètres : operand = opérande à consulter. * -* * -* Description : Founit la valeur utilisée pour une rotation. * -* * -* Retour : Opérande en place. * -* * -* Remarques : - * -* * -******************************************************************************/ - -GArchOperand *g_armv7_rotation_operand_get_value(const GArmV7RotationOperand *operand) -{ - GArchOperand *result; /* Instance à retourner */ - - result = operand->value; - - g_object_ref(G_OBJECT(result)); - - return result; - -} diff --git a/src/arch/arm/v7/operands/rotation.h b/src/arch/arm/v7/operands/rotation.h deleted file mode 100644 index 7fb6c09..0000000 --- a/src/arch/arm/v7/operands/rotation.h +++ /dev/null @@ -1,61 +0,0 @@ - -/* Chrysalide - Outil d'analyse de fichiers binaires - * rotation.h - prototypes pour les rotations de valeurs - * - * Copyright (C) 2015-2017 Cyrille Bagard - * - * This file is part of Chrysalide. - * - * Chrysalide is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Chrysalide is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Foobar. If not, see . - */ - - -#ifndef _ARCH_ARM_V7_OPERANDS_ROTATION_H -#define _ARCH_ARM_V7_OPERANDS_ROTATION_H - - -#include - - -#include "../../../operand.h" - - - -#define G_TYPE_ARMV7_ROTATION_OPERAND g_armv7_rotation_operand_get_type() -#define G_ARMV7_ROTATION_OPERAND(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), g_armv7_rotation_operand_get_type(), GArmV7RotationOperand)) -#define G_IS_ARMV7_ROTATION_OPERAND(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), g_armv7_rotation_operand_get_type())) -#define G_ARMV7_ROTATION_OPERAND_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), G_TYPE_ARMV7_ROTATION_OPERAND, GArmV7RotationOperandClass)) -#define G_IS_ARMV7_ROTATION_OPERAND_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), G_TYPE_ARMV7_ROTATION_OPERAND)) -#define G_ARMV7_ROTATION_OPERAND_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), G_TYPE_ARMV7_ROTATION_OPERAND, GArmV7RotationOperandClass)) - - -/* Définition d'un opérande visant une opérande de rotation ARMv7 (instance) */ -typedef struct _GArmV7RotationOperand GArmV7RotationOperand; - -/* Définition d'un opérande visant une opérande de rotation ARMv7 (classe) */ -typedef struct _GArmV7RotationOperandClass GArmV7RotationOperandClass; - - -/* Indique le type défini par la GLib pour une opérande de rotation ARMv7. */ -GType g_armv7_rotation_operand_get_type(void); - -/* Crée un réceptacle pour opérandes de rotation ARMv7. */ -GArchOperand *g_armv7_rotation_operand_new(GArchOperand *); - -/* Founit la valeur utilisée pour une rotation. */ -GArchOperand *g_armv7_rotation_operand_get_value(const GArmV7RotationOperand *); - - - -#endif /* _ARCH_ARM_V7_OPERANDS_ROTATION_H */ diff --git a/src/arch/arm/v7/operands/shift.c b/src/arch/arm/v7/operands/shift.c deleted file mode 100644 index 6fbdbcb..0000000 --- a/src/arch/arm/v7/operands/shift.c +++ /dev/null @@ -1,300 +0,0 @@ - -/* Chrysalide - Outil d'analyse de fichiers binaires - * shift.c - décallages de valeurs - * - * Copyright (C) 2014-2017 Cyrille Bagard - * - * This file is part of Chrysalide. - * - * Chrysalide is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Chrysalide is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Foobar. If not, see . - */ - - -#include "shift.h" - - -#include "../../../operand-int.h" -#include "../../../../common/sort.h" - - - -/* Définition d'un opérande visant une opérande de décallage ARMv7 (instance) */ -struct _GArmV7ShiftOperand -{ - GArchOperand parent; /* Instance parente */ - - SRType shift_type; /* Type de décallage */ - GArchOperand *shift_value; /* Valeur du décallage */ - -}; - - -/* Définition d'un opérande visant une opérande de décallage ARMv7 (classe) */ -struct _GArmV7ShiftOperandClass -{ - GArchOperandClass parent; /* Classe parente */ - -}; - - -/* Initialise la classe des opérandes de décallage ARMv7. */ -static void g_armv7_shift_operand_class_init(GArmV7ShiftOperandClass *); - -/* Initialise une instance d'opérande de décallage ARMv7. */ -static void g_armv7_shift_operand_init(GArmV7ShiftOperand *); - -/* Supprime toutes les références externes. */ -static void g_armv7_shift_operand_dispose(GArmV7ShiftOperand *); - -/* Procède à la libération totale de la mémoire. */ -static void g_armv7_shift_operand_finalize(GArmV7ShiftOperand *); - -/* Compare un opérande avec un autre. */ -static int g_armv7_shift_operand_compare(const GArmV7ShiftOperand *, const GArmV7ShiftOperand *); - -/* Traduit un opérande en version humainement lisible. */ -static void g_armv7_shift_operand_print(const GArmV7ShiftOperand *, GBufferLine *, AsmSyntax); - - - -/* Indique le type défini par la GLib pour une opérande de décallage ARMv7. */ -G_DEFINE_TYPE(GArmV7ShiftOperand, g_armv7_shift_operand, G_TYPE_ARCH_OPERAND); - - -/****************************************************************************** -* * -* Paramètres : klass = classe à initialiser. * -* * -* Description : Initialise la classe des opérandes de décallage ARMv7. * -* * -* Retour : - * -* * -* Remarques : - * -* * -******************************************************************************/ - -static void g_armv7_shift_operand_class_init(GArmV7ShiftOperandClass *klass) -{ - GObjectClass *object; /* Autre version de la classe */ - GArchOperandClass *operand; /* Version de classe parente */ - - object = G_OBJECT_CLASS(klass); - operand = G_ARCH_OPERAND_CLASS(klass); - - object->dispose = (GObjectFinalizeFunc/* ! */)g_armv7_shift_operand_dispose; - object->finalize = (GObjectFinalizeFunc)g_armv7_shift_operand_finalize; - - operand->compare = (operand_compare_fc)g_armv7_shift_operand_compare; - operand->print = (operand_print_fc)g_armv7_shift_operand_print; - -} - - -/****************************************************************************** -* * -* Paramètres : operand = instance à initialiser. * -* * -* Description : Initialise une instance d'opérande de décallage ARMv7. * -* * -* Retour : - * -* * -* Remarques : - * -* * -******************************************************************************/ - -static void g_armv7_shift_operand_init(GArmV7ShiftOperand *operand) -{ - -} - - -/****************************************************************************** -* * -* Paramètres : operand = instance d'objet GLib à traiter. * -* * -* Description : Supprime toutes les références externes. * -* * -* Retour : - * -* * -* Remarques : - * -* * -******************************************************************************/ - -static void g_armv7_shift_operand_dispose(GArmV7ShiftOperand *operand) -{ - g_object_unref(G_OBJECT(operand->shift_value)); - - G_OBJECT_CLASS(g_armv7_shift_operand_parent_class)->dispose(G_OBJECT(operand)); - -} - - -/****************************************************************************** -* * -* Paramètres : operand = instance d'objet GLib à traiter. * -* * -* Description : Procède à la libération totale de la mémoire. * -* * -* Retour : - * -* * -* Remarques : - * -* * -******************************************************************************/ - -static void g_armv7_shift_operand_finalize(GArmV7ShiftOperand *operand) -{ - G_OBJECT_CLASS(g_armv7_shift_operand_parent_class)->finalize(G_OBJECT(operand)); - -} - - -/****************************************************************************** -* * -* Paramètres : a = premier opérande à consulter. * -* b = second opérande à consulter. * -* * -* Description : Compare un opérande avec un autre. * -* * -* Retour : Bilan de la comparaison. * -* * -* Remarques : - * -* * -******************************************************************************/ - -static int g_armv7_shift_operand_compare(const GArmV7ShiftOperand *a, const GArmV7ShiftOperand *b) -{ - int result; /* Bilan à faire remonter */ - - result = sort_unsigned_long(a->shift_type, b->shift_type); - if (result != 0) goto gasoc_done; - - result = g_arch_operand_compare(a->shift_value, b->shift_value); - - gasoc_done: - - return result; - -} - - -/****************************************************************************** -* * -* Paramètres : operand = opérande à traiter. * -* line = ligne tampon où imprimer l'opérande donné. * -* syntax = type de représentation demandée. * -* * -* Description : Traduit un opérande en version humainement lisible. * -* * -* Retour : - * -* * -* Remarques : - * -* * -******************************************************************************/ - -static void g_armv7_shift_operand_print(const GArmV7ShiftOperand *operand, GBufferLine *line, AsmSyntax syntax) -{ - switch (operand->shift_type) - { - case SRType_LSL: - g_buffer_line_append_text(line, BLC_ASSEMBLY, "lsl", 3, RTT_KEY_WORD, NULL); - break; - case SRType_LSR: - g_buffer_line_append_text(line, BLC_ASSEMBLY, "lsr", 3, RTT_KEY_WORD, NULL); - break; - case SRType_ASR: - g_buffer_line_append_text(line, BLC_ASSEMBLY, "asr", 3, RTT_KEY_WORD, NULL); - break; - case SRType_ROR: - g_buffer_line_append_text(line, BLC_ASSEMBLY, "ror", 3, RTT_KEY_WORD, NULL); - break; - case SRType_RRX: - g_buffer_line_append_text(line, BLC_ASSEMBLY, "rrx", 3, RTT_KEY_WORD, NULL); - break; - } - - g_buffer_line_append_text(line, BLC_ASSEMBLY, " ", 1, RTT_RAW, NULL); - - g_arch_operand_print(operand->shift_value, line, syntax); - -} - - -/****************************************************************************** -* * -* Paramètres : - * -* * -* Description : Crée un réceptacle pour opérande de décallage ARMv7. * -* * -* Retour : Opérande mis en place. * -* * -* Remarques : - * -* * -******************************************************************************/ - -GArchOperand *g_armv7_shift_operand_new(SRType type, GArchOperand *value) -{ - GArmV7ShiftOperand *result; /* Structure à retourner */ - - result = g_object_new(G_TYPE_ARMV7_SHIFT_OPERAND, NULL); - - result->shift_type = type; - result->shift_value = value; - - return G_ARCH_OPERAND(result); - -} - - -/****************************************************************************** -* * -* Paramètres : operand = opérande à consulter. * -* * -* Description : Indique la forme de décallage représenté. * -* * -* Retour : Type de décallage. * -* * -* Remarques : - * -* * -******************************************************************************/ - -SRType g_armv7_shift_operand_get_shift_type(const GArmV7ShiftOperand *operand) -{ - return operand->shift_type; - -} - - -/****************************************************************************** -* * -* Paramètres : operand = opérande à consulter. * -* * -* Description : Founit la valeur utilisée pour un décallage. * -* * -* Retour : Opérande en place. * -* * -* Remarques : - * -* * -******************************************************************************/ - -GArchOperand *g_armv7_shift_operand_get_shift_value(const GArmV7ShiftOperand *operand) -{ - GArchOperand *result; /* Instance à retourner */ - - result = operand->shift_value; - - g_object_ref(G_OBJECT(result)); - - return result; - -} diff --git a/src/arch/arm/v7/operands/shift.h b/src/arch/arm/v7/operands/shift.h deleted file mode 100644 index 2eac092..0000000 --- a/src/arch/arm/v7/operands/shift.h +++ /dev/null @@ -1,65 +0,0 @@ - -/* Chrysalide - Outil d'analyse de fichiers binaires - * shift.h - prototypes pour les décallages de valeurs - * - * Copyright (C) 2014-2017 Cyrille Bagard - * - * This file is part of Chrysalide. - * - * Chrysalide is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Chrysalide is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Foobar. If not, see . - */ - - -#ifndef _ARCH_ARM_V7_OPERANDS_SHIFT_H -#define _ARCH_ARM_V7_OPERANDS_SHIFT_H - - -#include - - -#include "../pseudo.h" -#include "../../../operand.h" - - - -#define G_TYPE_ARMV7_SHIFT_OPERAND g_armv7_shift_operand_get_type() -#define G_ARMV7_SHIFT_OPERAND(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), g_armv7_shift_operand_get_type(), GArmV7ShiftOperand)) -#define G_IS_ARMV7_SHIFT_OPERAND(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), g_armv7_shift_operand_get_type())) -#define G_ARMV7_SHIFT_OPERAND_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), G_TYPE_ARMV7_SHIFT_OPERAND, GArmV7ShiftOperandClass)) -#define G_IS_ARMV7_SHIFT_OPERAND_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), G_TYPE_ARMV7_SHIFT_OPERAND)) -#define G_ARMV7_SHIFT_OPERAND_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), G_TYPE_ARMV7_SHIFT_OPERAND, GArmV7ShiftOperandClass)) - - -/* Définition d'un opérande visant une opérande de décallage ARMv7 (instance) */ -typedef struct _GArmV7ShiftOperand GArmV7ShiftOperand; - -/* Définition d'un opérande visant une opérande de décallage ARMv7 (classe) */ -typedef struct _GArmV7ShiftOperandClass GArmV7ShiftOperandClass; - - -/* Indique le type défini par la GLib pour une opérande de décallage ARMv7. */ -GType g_armv7_shift_operand_get_type(void); - -/* Crée un réceptacle pour opérande de décallage ARMv7. */ -GArchOperand *g_armv7_shift_operand_new(SRType, GArchOperand *); - -/* Indique la forme de décallage représenté. */ -SRType g_armv7_shift_operand_get_shift_type(const GArmV7ShiftOperand *); - -/* Founit la valeur utilisée pour un décallage. */ -GArchOperand *g_armv7_shift_operand_get_shift_value(const GArmV7ShiftOperand *); - - - -#endif /* _ARCH_ARM_V7_OPERANDS_SHIFT_H */ diff --git a/src/arch/arm/v7/post.c b/src/arch/arm/v7/post.c deleted file mode 100644 index 46a1792..0000000 --- a/src/arch/arm/v7/post.c +++ /dev/null @@ -1,99 +0,0 @@ - -/* Chrysalide - Outil d'analyse de fichiers binaires - * post.c - traitements complémentaires à la phase de désassemblage - * - * Copyright (C) 2014-2017 Cyrille Bagard - * - * This file is part of Chrysalide. - * - * Chrysalide is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Chrysalide is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Foobar. If not, see . - */ - - -#include "post.h" - - -#include "../../target.h" - - - -/****************************************************************************** -* * -* Paramètres : instr = instruction ARMv7 à traiter. * -* proc = représentation de l'architecture utilisée. * -* context = contexte associé à la phase de désassemblage. * -* format = accès aux données du binaire d'origine. * -* * -* Description : Complète un désassemblage accompli pour une instruction. * -* * -* Retour : - * -* * -* Remarques : - * -* * -******************************************************************************/ - -void post_process_ldr_instructions(GArchInstruction *instr, GArchProcessor *proc, GProcContext *context, GExeFormat *format) -{ - GArchOperand *op; /* Opérande numérique en place */ - uint32_t addr; /* Adresse visée par le saut */ - GBinFormat *bfmt; /* Version basique du format */ - GTargetOperand *new; /* Instruction de ciblage */ - vmpa2t target; /* Défination finale précise */ - mrange_t trange; /* Etendue du symbole à créer */ - VMPA_BUFFER(loc); /* Espace pour une conversion */ - char name[5 + VMPA_MAX_LEN]; /* Etiquette à constituer */ - GBinSymbol *symbol; /* Nouveau symbole construit */ - - g_arch_instruction_lock_operands(instr); - - op = _g_arch_instruction_get_operand(instr, 1); - - if (!G_IS_IMM_OPERAND(op)) - goto ppli_release; - - if (g_imm_operand_get_value(G_IMM_OPERAND(op), MDS_32_BITS_UNSIGNED, &addr) - && g_exe_format_translate_address_into_vmpa(format, addr, &target)) - { - bfmt = G_BIN_FORMAT(format); - - new = G_TARGET_OPERAND(g_target_operand_new(MDS_32_BITS_UNSIGNED, &target)); - - if (!g_target_operand_resolve(new, bfmt, true)) - { - addr &= ~0x1; - - init_mrange(&trange, &target, 0); - - vmpa2_virt_to_string(&target, MDS_UNDEFINED, loc, NULL); - snprintf(name, sizeof(name), "loc_%s", loc + 2); - - symbol = g_binary_symbol_new(&trange, STP_CODE_LABEL); - g_binary_symbol_set_alt_label(symbol, name); - g_binary_format_add_symbol(bfmt, symbol); - - g_target_operand_resolve(new, bfmt, true); - - } - - _g_arch_instruction_replace_operand(instr, op, G_ARCH_OPERAND(new)); - - } - - ppli_release: - - g_object_unref(G_OBJECT(op)); - - g_arch_instruction_unlock_operands(instr); - -} diff --git a/src/arch/arm/v7/post.h b/src/arch/arm/v7/post.h deleted file mode 100644 index 89a86a6..0000000 --- a/src/arch/arm/v7/post.h +++ /dev/null @@ -1,57 +0,0 @@ - -/* Chrysalide - Outil d'analyse de fichiers binaires - * post.h - prototypes pour les traitements complémentaires à la phase de désassemblage - * - * Copyright (C) 2014-2017 Cyrille Bagard - * - * This file is part of Chrysalide. - * - * Chrysalide is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Chrysalide is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Foobar. If not, see . - */ - - -#ifndef _ARCH_ARM_V7_POST_H -#define _ARCH_ARM_V7_POST_H - - -#include "../../instruction.h" -#include "../../post.h" - - - -static inline void post_process_branch_instructions(GArchInstruction *ins, GArchProcessor *proc, GProcContext *ctx, GExeFormat *fmt) -{ - post_process_target_resolution(ins, proc, ctx, fmt, 0, STP_CODE_LABEL); - -} - -static inline void post_process_branch_and_link_instructions(GArchInstruction *ins, GArchProcessor *proc, GProcContext *ctx, GExeFormat *fmt) -{ - post_process_target_resolution(ins, proc, ctx, fmt, 0, STP_ROUTINE); - -} - -static inline void post_process_comp_and_branch_instructions(GArchInstruction *ins, GArchProcessor *proc, GProcContext *ctx, GExeFormat *fmt) -{ - post_process_target_resolution(ins, proc, ctx, fmt, 1, STP_CODE_LABEL); - -} - - -/* Complète un désassemblage accompli pour une instruction. */ -void post_process_ldr_instructions(GArchInstruction *, GArchProcessor *, GProcContext *, GExeFormat *); - - - -#endif /* _ARCH_ARM_V7_POST_H */ diff --git a/src/arch/arm/v7/processor.c b/src/arch/arm/v7/processor.c deleted file mode 100644 index b310652..0000000 --- a/src/arch/arm/v7/processor.c +++ /dev/null @@ -1,295 +0,0 @@ - -/* Chrysalide - Outil d'analyse de fichiers binaires - * processor.c - manipulation du processeur ARMv7 - * - * Copyright (C) 2014-2017 Cyrille Bagard - * - * This file is part of Chrysalide. - * - * Chrysalide is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Chrysalide is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Foobar. If not, see . - */ - - -#include "processor.h" - - -#include - - -#include "arm.h" -#include "context.h" -#include "thumb_16.h" -#include "thumb_32.h" -#include "../processor-int.h" -#include "../../raw.h" - - - -/* Définition du processeur ARMv7 (instance) */ -struct _GArmV7Processor -{ - GArmProcessor parent; /* Instance parente */ - -}; - - -/* Définition du processeur ARMv7 (classe) */ -struct _GArmV7ProcessorClass -{ - GArmProcessorClass parent; /* Classe parente */ - -}; - - -/* Initialise la classe des registres ARMv7. */ -static void g_armv7_processor_class_init(GArmV7ProcessorClass *); - -/* Initialise une instance de registre ARMv7. */ -static void g_armv7_processor_init(GArmV7Processor *); - -/* Supprime toutes les références externes. */ -static void g_armv7_processor_dispose(GArmV7Processor *); - -/* Procède à la libération totale de la mémoire. */ -static void g_armv7_processor_finalize(GArmV7Processor *); - -/* Fournit un contexte pour l'exécution du processeur ARM. */ -static GArmV7Context *g_armv7_processor_get_context(const GArmV7Processor *); - -/* Décode une instruction dans un flux de données. */ -static GArchInstruction *g_armv7_processor_disassemble(const GArmV7Processor *, GArmV7Context *, const GBinContent *, vmpa2t *, GExeFormat *); - - - -/* Indique le type défini par la GLib pour le processeur ARMv7. */ -G_DEFINE_TYPE(GArmV7Processor, g_armv7_processor, G_TYPE_ARM_PROCESSOR); - - -/****************************************************************************** -* * -* Paramètres : klass = classe à initialiser. * -* * -* Description : Initialise la classe des processeurs ARMv7. * -* * -* Retour : - * -* * -* Remarques : - * -* * -******************************************************************************/ - -static void g_armv7_processor_class_init(GArmV7ProcessorClass *klass) -{ - GObjectClass *object_class; /* Autre version de la classe */ - GArchProcessorClass *proc; /* Encore une autre vision... */ - - object_class = G_OBJECT_CLASS(klass); - proc = G_ARCH_PROCESSOR_CLASS(klass); - - object_class->dispose = (GObjectFinalizeFunc/* ! */)g_armv7_processor_dispose; - object_class->finalize = (GObjectFinalizeFunc)g_armv7_processor_finalize; - - proc->disassemble = (disass_instr_fc)g_armv7_processor_disassemble; - -} - - -/****************************************************************************** -* * -* Paramètres : proc = instance à initialiser. * -* * -* Description : Initialise une instance de processeur ARMv7. * -* * -* Retour : - * -* * -* Remarques : - * -* * -******************************************************************************/ - -static void g_armv7_processor_init(GArmV7Processor *proc) -{ - - GArchProcessor *parent; /* Instance parente */ - - parent = G_ARCH_PROCESSOR(proc); - - parent->endianness = SRE_LITTLE; - parent->memsize = MDS_32_BITS; - parent->inssize = MDS_32_BITS; - - - - - parent->get_ctx = (get_processor_context_fc)g_armv7_processor_get_context; - - -} - - -/****************************************************************************** -* * -* Paramètres : proc = instance d'objet GLib à traiter. * -* * -* Description : Supprime toutes les références externes. * -* * -* Retour : - * -* * -* Remarques : - * -* * -******************************************************************************/ - -static void g_armv7_processor_dispose(GArmV7Processor *proc) -{ - G_OBJECT_CLASS(g_armv7_processor_parent_class)->dispose(G_OBJECT(proc)); - -} - - -/****************************************************************************** -* * -* Paramètres : proc = instance d'objet GLib à traiter. * -* * -* Description : Procède à la libération totale de la mémoire. * -* * -* Retour : - * -* * -* Remarques : - * -* * -******************************************************************************/ - -static void g_armv7_processor_finalize(GArmV7Processor *proc) -{ - G_OBJECT_CLASS(g_armv7_processor_parent_class)->finalize(G_OBJECT(proc)); - -} - - -/****************************************************************************** -* * -* Paramètres : - * -* * -* Description : Crée le support de l'architecture ARMv7. * -* * -* Retour : Adresse de la structure mise en place. * -* * -* Remarques : - * -* * -******************************************************************************/ - -GArmV7Processor *g_armv7_processor_new(void) -{ - GArmV7Processor *result; /* Structure à retourner */ - - result = g_object_new(G_TYPE_ARMV7_PROCESSOR, NULL); - - return result; - -} - - -/****************************************************************************** -* * -* Paramètres : proc = architecture, spectatrice ici. * -* * -* Description : Fournit un contexte pour l'exécution du processeur Arm. * -* * -* Retour : Contexte mis en place. * -* * -* Remarques : - * -* * -******************************************************************************/ - -static GArmV7Context *g_armv7_processor_get_context(const GArmV7Processor *proc) -{ - return g_armv7_context_new(); - -} - - -/****************************************************************************** -* * -* Paramètres : proc = architecture visée par la procédure. * -* ctx = contexte lié à l'exécution du processeur. * -* content = flux de données à analyser. * -* pos = position courante dans ce flux. [OUT] * -* format = format du fichier contenant le code. * -* * -* Description : Désassemble une instruction dans un flux de données. * -* * -* Retour : Instruction mise en place ou NULL en cas d'échec. * -* * -* Remarques : - * -* * -******************************************************************************/ - -static GArchInstruction *g_armv7_processor_disassemble(const GArmV7Processor *proc, GArmV7Context *ctx, const GBinContent *content, vmpa2t *pos, GExeFormat *format) -{ - GArchInstruction *result; /* Instruction à renvoyer */ - SourceEndian endian; /* Boutisme des données lues */ - uint16_t raw16; /* Donnée 16 bits à analyser */ - uint32_t raw32; /* Donnée 32 bits à analyser */ - ArmV7InstrSet iset; /* Type de jeu d'instructions */ - - endian = G_ARCH_PROCESSOR(proc)->endianness; - - iset = g_armv7_context_find_encoding(ctx, get_virt_addr(pos)); - - switch (iset) - { - case AV7IS_ARM: - - if (!g_binary_content_read_u32(content, pos, endian, &raw32)) - return NULL; - - result = process_armv7_arm_instruction_set_encoding(raw32); - - break; - - case AV7IS_THUMB: - - if (!g_binary_content_read_u16(content, pos, endian, &raw16)) - return NULL; - - switch (raw16 >> 11) - { - case 0b11101: - case 0b11110: - case 0b11111: - - raw32 = raw16 << 16; - - if (!g_binary_content_read_u16(content, pos, endian, &raw16)) - return NULL; - - raw32 |= raw16; - - result = process_armv7_thumb_32_instruction_set_encoding(raw32); - break; - - default: - result = process_armv7_thumb_16_instruction_set_encoding(raw16); - break; - - } - - break; - - default: - assert(0); - break; - - } - - return result; - -} diff --git a/src/arch/arm/v7/processor.h b/src/arch/arm/v7/processor.h deleted file mode 100644 index 2e0805c..0000000 --- a/src/arch/arm/v7/processor.h +++ /dev/null @@ -1,56 +0,0 @@ - -/* Chrysalide - Outil d'analyse de fichiers binaires - * processor.h - prototypes pour la manipulation du processeur ARMv7 - * - * Copyright (C) 2014-2017 Cyrille Bagard - * - * This file is part of Chrysalide. - * - * Chrysalide is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Chrysalide is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Foobar. If not, see . - */ - - -#ifndef _ARCH_ARM_V7_PROCESSOR_H -#define _ARCH_ARM_V7_PROCESSOR_H - - -#include -#include - - - -#define G_TYPE_ARMV7_PROCESSOR g_armv7_processor_get_type() -#define G_ARMV7_PROCESSOR(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), g_armv7_processor_get_type(), GArmV7Processor)) -#define G_IS_ARMV7_PROCESSOR(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), g_armv7_processor_get_type())) -#define G_ARMV7_PROCESSOR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), G_TYPE_ARMV7_PROCESSOR, GArmV7ProcessorClass)) -#define G_IS_ARMV7_PROCESSOR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), G_TYPE_ARMV7_PROCESSOR)) -#define G_ARMV7_PROCESSOR_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), G_TYPE_ARMV7_PROCESSOR, GArmV7ProcessorClass)) - - -/* Définition du processeur ARMv7 (instance) */ -typedef struct _GArmV7Processor GArmV7Processor; - -/* Définition du processeur ARMv7 (classe) */ -typedef struct _GArmV7ProcessorClass GArmV7ProcessorClass; - - -/* Indique le type défini par la GLib pour le processeur ARMv7. */ -GType g_armv7_processor_get_type(void); - -/* Crée le support de l'architecture ARMv7. */ -GArmV7Processor *g_armv7_processor_new(void); - - - -#endif /* _ARCH_ARM_V7_PROCESSOR_H */ diff --git a/src/arch/arm/v7/pseudo.c b/src/arch/arm/v7/pseudo.c deleted file mode 100644 index 8dc4c6e..0000000 --- a/src/arch/arm/v7/pseudo.c +++ /dev/null @@ -1,683 +0,0 @@ - -/* Chrysalide - Outil d'analyse de fichiers binaires - * pseudo.c - implémentation des pseudo-fonctions de spécification - * - * Copyright (C) 2014-2017 Cyrille Bagard - * - * This file is part of Chrysalide. - * - * Chrysalide is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Chrysalide is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Foobar. If not, see . - */ - - -#include "pseudo.h" - - -#include - - -#include "../../../common/bconst.h" - - - -/****************************************************************************** -* * -* Paramètres : x = valeur sur 32 bits maximum à traiter. * -* n = nombre de bits à prendre en compte. * -* shift = nombre de décallages visés. * -* carry = retenue enventuelle à constituer. [OUT] * -* value = nouvelle valeur calculée. [OUT] * -* * -* Description : Traduit la fonction 'LSL_C'. * -* * -* Retour : Bilan de l'opération. * -* * -* Remarques : - * -* * -******************************************************************************/ - -bool armv7_lsl_c(uint32_t x, unsigned int n, unsigned int shift, bool *carry, uint32_t *value) -{ - if (n > 32) return false; - if (shift == 0) return false; - - if (carry != NULL) - *carry = x & (1 << (n - 1)); - - *value = x << shift; - - return true; - -} - - -/****************************************************************************** -* * -* Paramètres : x = valeur sur 32 bits maximum à traiter. * -* n = nombre de bits à prendre en compte. * -* shift = nombre de décallages visés. * -* value = nouvelle valeur calculée. [OUT] * -* * -* Description : Traduit la fonction 'LSL'. * -* * -* Retour : Bilan de l'opération. * -* * -* Remarques : - * -* * -******************************************************************************/ - -bool armv7_lsl(uint32_t x, unsigned int n, unsigned int shift, uint32_t *value) -{ - bool result; /* Bilan final à retourner */ - - if (shift == 0) - result = true; - - else - result = armv7_lsl_c(x, n, shift, NULL, value); - - return result; - -} - - -/****************************************************************************** -* * -* Paramètres : x = valeur sur 32 bits maximum à traiter. * -* n = nombre de bits à prendre en compte. * -* shift = nombre de décallages visés. * -* carry = retenue enventuelle à constituer. [OUT] * -* value = nouvelle valeur calculée. [OUT] * -* * -* Description : Traduit la fonction 'LSR_C'. * -* * -* Retour : Bilan de l'opération. * -* * -* Remarques : - * -* * -******************************************************************************/ - -bool armv7_lsr_c(uint32_t x, unsigned int n, unsigned int shift, bool *carry, uint32_t *value) -{ - if (n > 32) return false; - if (shift == 0) return false; - - if (carry != NULL) - *carry = x & (1 << (shift - 1)); - - *value = x >> shift; - - return true; - -} - - -/****************************************************************************** -* * -* Paramètres : x = valeur sur 32 bits maximum à traiter. * -* n = nombre de bits à prendre en compte. * -* shift = nombre de décallages visés. * -* value = nouvelle valeur calculée. [OUT] * -* * -* Description : Traduit la fonction 'LSR'. * -* * -* Retour : Bilan de l'opération. * -* * -* Remarques : - * -* * -******************************************************************************/ - -bool armv7_lsr(uint32_t x, unsigned int n, unsigned int shift, uint32_t *value) -{ - bool result; /* Bilan final à retourner */ - - if (shift == 0) - result = x; - - else - result = armv7_lsr_c(x, n, shift, NULL, value); - - return result; - -} - - -/****************************************************************************** -* * -* Paramètres : x = valeur sur 32 bits maximum à traiter. * -* n = nombre de bits à prendre en compte. * -* shift = nombre de décallages visés. * -* carry = retenue enventuelle à constituer. [OUT] * -* value = nouvelle valeur calculée. [OUT] * -* * -* Description : Traduit la fonction 'ASR_C'. * -* * -* Retour : Bilan de l'opération. * -* * -* Remarques : - * -* * -******************************************************************************/ - -bool armv7_asr_c(uint32_t x, unsigned int n, unsigned int shift, bool *carry, uint32_t *value) -{ - if (n > 32) return false; - if (shift == 0) return false; - - if (carry != NULL) - *carry = x & (1 << (shift - 1)); - - *value = ((int32_t)x) >> shift; - - return true; - -} - - -/****************************************************************************** -* * -* Paramètres : x = valeur sur 32 bits maximum à traiter. * -* n = nombre de bits à prendre en compte. * -* shift = nombre de décallages visés. * -* value = nouvelle valeur calculée. [OUT] * -* * -* Description : Traduit la fonction 'ASR'. * -* * -* Retour : Bilan de l'opération. * -* * -* Remarques : - * -* * -******************************************************************************/ - -bool armv7_asr(uint32_t x, unsigned int n, unsigned int shift, uint32_t *value) -{ - bool result; /* Bilan final à retourner */ - - if (shift == 0) - result = true; - - else - result = armv7_asr_c(x, n, shift, NULL, value); - - return result; - -} - - -/****************************************************************************** -* * -* Paramètres : x = valeur sur 32 bits maximum à traiter. * -* n = nombre de bits à prendre en compte. * -* shift = nombre de décallages visés. * -* carry = retenue enventuelle à constituer. [OUT] * -* value = nouvelle valeur calculée. [OUT] * -* * -* Description : Traduit la fonction 'ROR_C'. * -* * -* Retour : Bilan de l'opération. * -* * -* Remarques : - * -* * -******************************************************************************/ - -bool armv7_ror_c(uint32_t x, unsigned int n, unsigned int shift, bool *carry, uint32_t *value) -{ - if (n > 32) return false; - if (shift == 0) return false; - - *value = (x >> shift) | (x << (32 - shift)); - - if (carry != NULL) - *carry = *value & (1 << (n - 1)); - - return true; - -} - - -/****************************************************************************** -* * -* Paramètres : x = valeur sur 32 bits maximum à traiter. * -* n = nombre de bits à prendre en compte. * -* shift = nombre de décallages visés. * -* value = nouvelle valeur calculée. [OUT] * -* * -* Description : Traduit la fonction 'ROR'. * -* * -* Retour : Bilan de l'opération. * -* * -* Remarques : - * -* * -******************************************************************************/ - -bool armv7_ror(uint32_t x, unsigned int n, unsigned int shift, uint32_t *value) -{ - bool result; /* Bilan final à retourner */ - - if (shift == 0) - result = true; - - else - result = armv7_ror_c(x, n, shift, NULL, value); - - return result; - -} - - -/****************************************************************************** -* * -* Paramètres : x = valeur sur 32 bits maximum à traiter. * -* n = nombre de bits à prendre en compte. * -* carry = retenue enventuelle à utiliser puis constituer. [OUT]* -* value = nouvelle valeur calculée. [OUT] * -* * -* Description : Traduit la fonction 'RRX_C'. * -* * -* Retour : Bilan de l'opération. * -* * -* Remarques : - * -* * -******************************************************************************/ - -bool armv7_rrx_c(uint32_t x, unsigned int n, bool *carry, uint32_t *value) -{ - bool new_c; /* Nouvelle retenue à retenir */ - - new_c = x & 0x1; - - *value = (*carry ? 1 : 0) << (n - 1) | x >> 1; - - *carry = new_c; - - return true; - -} - - -/****************************************************************************** -* * -* Paramètres : x = valeur sur 32 bits maximum à traiter. * -* n = nombre de bits à prendre en compte. * -* carry = retenue enventuelle à utiliser. * -* value = nouvelle valeur calculée. [OUT] * -* * -* Description : Traduit la fonction 'RRX'. * -* * -* Retour : Bilan de l'opération. * -* * -* Remarques : - * -* * -******************************************************************************/ - -bool armv7_rrx(uint32_t x, unsigned int n, bool carry, uint32_t *value) -{ - return armv7_rrx_c(x, n, &carry, value); - -} - - -/****************************************************************************** -* * -* Paramètres : imm12 = valeur sur 32 bits maximum à traiter. * -* carry = retenue enventuelle à utiliser / constituer. [OUT] * -* value = nouvelle valeur calculée. [OUT] * -* * -* Description : Traduit la fonction 'ARMExpandImm_C'. * -* * -* Retour : Bilan de l'opération. * -* * -* Remarques : - * -* * -******************************************************************************/ - -bool armv7_arm_expand_imm_c(uint32_t imm12, bool *carry, uint32_t *value) -{ - bool result; /* Bilan final à retourner */ - uint32_t unrotated; /* Transformation à décaller */ - - /** - * Selon les spécifications, x contient toujours 12 bits utiles seulement. - */ - - unrotated = armv7_zero_extend(imm12 & 0xff, 8, 32); - - result = armv7_shift(unrotated, 32, SRType_ROR, 2 * ((imm12 >> 8) & 0xf), carry, value); - - return result; - -} - - -/****************************************************************************** -* * -* Paramètres : imm12 = valeur sur 32 bits maximum à traiter. * -* carry = retenue enventuelle à utiliser / constituer. [OUT] * -* value = nouvelle valeur calculée. [OUT] * -* * -* Description : Traduit la fonction 'ARMExpandImm'. * -* * -* Retour : Bilan de l'opération. * -* * -* Remarques : - * -* * -******************************************************************************/ - -bool armv7_arm_expand_imm(uint32_t imm12, uint32_t *value) -{ - return armv7_arm_expand_imm_c(imm12, (bool []) { false /* FIXME : APSR.C */ }, value); - -} - - -/****************************************************************************** -* * -* Paramètres : imm12 = valeur sur 32 bits maximum à traiter. * -* carry = retenue enventuelle à utiliser / constituer. [OUT] * -* value = nouvelle valeur calculée. [OUT] * -* * -* Description : Traduit la fonction 'ThumbExpandImm_C'. * -* * -* Retour : Bilan de l'opération. * -* * -* Remarques : - * -* * -******************************************************************************/ - -bool armv7_thumb_expand_imm_c(uint32_t imm12, bool *carry, uint32_t *value) -{ - bool result; /* Conclusion à faire remonter */ - uint8_t byte; /* Octet à reproduire */ - uint32_t unrotated; /* Transformation à décaller */ - - result = true; - - if (((imm12 >> 10) & b11) == b00) - { - byte = imm12 & 0xff; - - switch ((imm12 >> 8) & b11) - { - case b00: - *value = armv7_zero_extend(byte, 8, 32); - break; - - case b01: - if (byte == 0) - result = false; - else - *value = byte << 16 | byte; - break; - - case b10: - if (byte == 0) - result = false; - else - *value = byte << 24 | byte << 8; - break; - - case b11: - if (byte == 0) - result = false; - else - *value = byte << 24 | byte << 16 | byte << 8 | byte; - break; - - } - - } - else - { - unrotated = 1 << 7 | (imm12 & 0x3f); - result = armv7_ror_c(unrotated, 32, (imm12 >> 7) & 0x1f, carry, value); - } - - return result; - -} - - -/****************************************************************************** -* * -* Paramètres : imm12 = valeur sur 32 bits maximum à traiter. * -* carry = retenue enventuelle à utiliser / constituer. [OUT] * -* value = nouvelle valeur calculée. [OUT] * -* * -* Description : Traduit la fonction 'ThumbExpandImm'. * -* * -* Retour : Bilan de l'opération. * -* * -* Remarques : - * -* * -******************************************************************************/ - -bool armv7_thumb_expand_imm(uint32_t imm12, uint32_t *value) -{ - return armv7_thumb_expand_imm_c(imm12, (bool []) { false /* FIXME : APSR.C */ }, value); - -} - - -/****************************************************************************** -* * -* Paramètres : type2 = type de décallage encodé sur 2 bits. * -* imm5 = valeur de décallage entière sur 5 bits. * -* type = type de décallage à constituer. [OUT] * -* value = valeur pleine et entière à utiliser. [OUT] * -* * -* Description : Traduit la fonction 'DecodeImmShift'. * -* * -* Retour : Bilan de l'opération. * -* * -* Remarques : - * -* * -******************************************************************************/ - -bool armv7_decode_imm_shift(uint8_t type2, uint8_t imm5, SRType *type, uint32_t *value) -{ - bool result; /* Bilan à retourner */ - - result = true; - - switch (type2) - { - case b00: - *type = SRType_LSL; - *value = imm5; - break; - - case b01: - *type = SRType_LSR; - *value = (imm5 == 0 ? 32 : imm5); - break; - - case b10: - *type = SRType_ASR; - *value = (imm5 == 0 ? 32 : imm5); - break; - - case b11: - if (imm5 == 0) - { - *type = SRType_RRX; - *value = 1; - } - else - { - *type = SRType_ROR; - *value = imm5; - } - break; - - default: - result = false; - break; - - } - - return result; - -} - - -/****************************************************************************** -* * -* Paramètres : type2 = type de décallage encodé sur 2 bits. * -* type = type de décallage à constituer. [OUT] * -* * -* Description : Traduit la fonction 'DecodeRegShift'. * -* * -* Retour : Bilan de l'opération. * -* * -* Remarques : - * -* * -******************************************************************************/ - -bool armv7_decode_reg_shift(uint8_t type2, SRType *type) -{ - bool result; /* Bilan à retourner */ - - result = true; - - switch (type2) - { - case b00: - *type = SRType_LSL; - break; - - case b01: - *type = SRType_LSR; - break; - - case b10: - *type = SRType_ASR; - break; - - case b11: - *type = SRType_ROR; - break; - - default: - result = false; - break; - - } - - return result; - -} - - -/****************************************************************************** -* * -* Paramètres : x = valeur sur 32 bits maximum à traiter. * -* n = nombre de bits à prendre en compte. * -* type = type d'opération à mener. * -* amount = quantité liée à l'opération à mener. * -* carry = retenue enventuelle à utiliser / constituer. [OUT] * -* value = nouvelle valeur calculée. [OUT] * -* * -* Description : Traduit la fonction 'Shift_C'. * -* * -* Retour : Bilan de l'opération. * -* * -* Remarques : - * -* * -******************************************************************************/ - -bool armv7_shift_c(uint32_t x, unsigned int n, SRType type, unsigned int amount, bool *carry, uint32_t *value) -{ - bool result; /* Bilan final à retourner */ - - if (type == SRType_RRX && amount != 1) return false; - - if (amount == 0) - { - *value = x; - return true; - } - - result = true; /* Pour GCC... */ - - switch (type) - { - case SRType_LSL: - result = armv7_lsl_c(x, n, amount, carry, value); - break; - - case SRType_LSR: - result = armv7_lsr_c(x, n, amount, carry, value); - break; - - case SRType_ASR: - result = armv7_asr_c(x, n, amount, carry, value); - break; - - case SRType_ROR: - result = armv7_ror_c(x, n, amount, carry, value); - break; - - case SRType_RRX: - result = armv7_rrx_c(x, n, carry, value); - break; - - } - - return result; - -} - - -/****************************************************************************** -* * -* Paramètres : x = valeur sur 32 bits maximum à traiter. * -* n = nombre de bits à prendre en compte. * -* type = type d'opération à mener. * -* amount = quantité liée à l'opération à mener. * -* carry = retenue enventuelle à utiliser. * -* value = nouvelle valeur calculée. [OUT] * -* * -* Description : Traduit la fonction 'Shift'. * -* * -* Retour : Bilan de l'opération. * -* * -* Remarques : - * -* * -******************************************************************************/ - -bool armv7_shift(uint32_t x, unsigned int n, SRType type, unsigned int amount, bool carry, uint32_t *value) -{ - return armv7_shift_c(x, n, type, amount, &carry, value); - -} - - -/****************************************************************************** -* * -* Paramètres : x = valeur sur 32 bits maximum à traiter. * -* n = nombre de bits à prendre en compte. * -* i = taille finale à obtenir. * -* * -* Description : Traduit la fonction 'ZeroExtend'. * -* * -* Retour : Nouvelle valeur calculée. * -* * -* Remarques : - * -* * -******************************************************************************/ - -uint32_t armv7_zero_extend(uint32_t x, unsigned int n, unsigned int i) -{ - return x; - -} diff --git a/src/arch/arm/v7/pseudo.h b/src/arch/arm/v7/pseudo.h deleted file mode 100644 index 48d73b8..0000000 --- a/src/arch/arm/v7/pseudo.h +++ /dev/null @@ -1,136 +0,0 @@ - -/* Chrysalide - Outil d'analyse de fichiers binaires - * pseudo.h - prototypes pour l'implémentation des pseudo-fonctions de spécification - * - * Copyright (C) 2014-2017 Cyrille Bagard - * - * This file is part of Chrysalide. - * - * Chrysalide is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Chrysalide is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Foobar. If not, see . - */ - - -#ifndef _ARCH_ARM_V7_PSEUDO_H -#define _ARCH_ARM_V7_PSEUDO_H - - -#include -#include - - - -/** - * § A2.2.1 - Integer arithmetic - */ - - -/* Traduit la fonction 'LSL_C'. */ -bool armv7_lsl_c(uint32_t, unsigned int, unsigned int, bool *, uint32_t *); - -/* Traduit la fonction 'LSL'. */ -bool armv7_lsl(uint32_t, unsigned int, unsigned int, uint32_t *); - -/* Traduit la fonction 'LSR_C'. */ -bool armv7_lsr_c(uint32_t, unsigned int, unsigned int, bool *, uint32_t *); - -/* Traduit la fonction 'LSR'. */ -bool armv7_lsr(uint32_t, unsigned int, unsigned int, uint32_t *); - -/* Traduit la fonction 'ASR_C'. */ -bool armv7_asr_c(uint32_t, unsigned int, unsigned int, bool *, uint32_t *); - -/* Traduit la fonction 'ASR'. */ -bool armv7_asr(uint32_t, unsigned int, unsigned int, uint32_t *); - -/* Traduit la fonction 'ROR_C'. */ -bool armv7_ror_c(uint32_t, unsigned int, unsigned int, bool *, uint32_t *); - -/* Traduit la fonction 'ROR'. */ -bool armv7_ror(uint32_t, unsigned int, unsigned int, uint32_t *); - -/* Traduit la fonction 'RRX_C'. */ -bool armv7_rrx_c(uint32_t, unsigned int, bool *, uint32_t *); - -/* Traduit la fonction 'RRX'. */ -bool armv7_rrx(uint32_t, unsigned int, bool, uint32_t *); - - - -/** - * § A5.2.4 - Modified immediate constants in ARM instructions - */ - - -/* Traduit la fonction 'ARMExpandImm_C'. */ -bool armv7_arm_expand_imm_c(uint32_t, bool *, uint32_t *); - -/* Traduit la fonction 'ARMExpandImm'. */ -bool armv7_arm_expand_imm(uint32_t, uint32_t *); - - - -/** - * § A6.3.2 - Modified immediate constants in Thumb instructions - */ - - -/* Traduit la fonction 'ThumbExpandImm_C'. */ -bool armv7_thumb_expand_imm_c(uint32_t, bool *, uint32_t *); - -/* Traduit la fonction 'ThumbExpandImm'. */ -bool armv7_thumb_expand_imm(uint32_t, uint32_t *); - - - -/** - * § A8.4.3 - Pseudocode details of instruction-specified shifts and rotates - */ - - -typedef enum _SRType -{ - SRType_LSL, - SRType_LSR, - SRType_ASR, - SRType_ROR, - SRType_RRX - -} SRType; - - -/* Traduit la fonction 'DecodeImmShift'. */ -bool armv7_decode_imm_shift(uint8_t, uint8_t, SRType *, uint32_t *); - -/* Traduit la fonction 'DecodeRegShift'. */ -bool armv7_decode_reg_shift(uint8_t, SRType *); - -/* Traduit la fonction 'Shift_C'. */ -bool armv7_shift_c(uint32_t, unsigned int, SRType, unsigned int, bool *, uint32_t *); - -/* Traduit la fonction 'Shift'. */ -bool armv7_shift(uint32_t, unsigned int, SRType, unsigned int, bool, uint32_t *); - - - -/** - * § P.5.3 - Bitstring manipulation - */ - - -/* Traduit la fonction 'ZeroExtend'. */ -uint32_t armv7_zero_extend(uint32_t, unsigned int, unsigned int); - - - -#endif /* _ARCH_ARM_V7_PSEUDO_H */ diff --git a/src/arch/arm/v7/register.c b/src/arch/arm/v7/register.c deleted file mode 100644 index 3cd9e0f..0000000 --- a/src/arch/arm/v7/register.c +++ /dev/null @@ -1,229 +0,0 @@ - -/* Chrysalide - Outil d'analyse de fichiers binaires - * registers.c - aides auxiliaires relatives aux registres ARMv7 - * - * Copyright (C) 2014-2017 Cyrille Bagard - * - * This file is part of Chrysalide. - * - * Chrysalide is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Chrysalide is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Foobar. If not, see . - */ - - -#include "register.h" - - -#include - - -#include "../register-int.h" - - - -/* Représentation d'un registre ARMv7 (instance) */ -struct _GArmV7Register -{ - GArmRegister parent; /* Instance parente */ - -}; - - -/* Représentation d'un registre ARMv7 (classe) */ -struct _GArmV7RegisterClass -{ - GArmRegisterClass parent; /* Classe parente */ - -}; - - -#define MAX_REGNAME_LEN 8 - - -/* Initialise la classe des registres ARMv7. */ -static void g_armv7_register_class_init(GArmV7RegisterClass *); - -/* Initialise une instance de registre ARMv7. */ -static void g_armv7_register_init(GArmV7Register *); - -/* Supprime toutes les références externes. */ -static void g_armv7_register_dispose(GArmV7Register *); - -/* Procède à la libération totale de la mémoire. */ -static void g_armv7_register_finalize(GArmV7Register *); - -/* Traduit un registre en version humainement lisible. */ -static void g_armv7_register_print(const GArmV7Register *, GBufferLine *, AsmSyntax); - - - -/* Indique le type défini pour une représentation d'un registre ARMv7. */ -G_DEFINE_TYPE(GArmV7Register, g_armv7_register, G_TYPE_ARM_REGISTER); - - -/****************************************************************************** -* * -* Paramètres : klass = classe à initialiser. * -* * -* Description : Initialise la classe des registres ARMv7. * -* * -* Retour : - * -* * -* Remarques : - * -* * -******************************************************************************/ - -static void g_armv7_register_class_init(GArmV7RegisterClass *klass) -{ - GObjectClass *object_class; /* Autre version de la classe */ - GArchRegisterClass *reg_class; /* Classe de haut niveau */ - - object_class = G_OBJECT_CLASS(klass); - reg_class = G_ARCH_REGISTER_CLASS(klass); - - object_class->dispose = (GObjectFinalizeFunc/* ! */)g_armv7_register_dispose; - object_class->finalize = (GObjectFinalizeFunc)g_armv7_register_finalize; - - reg_class->print = (reg_print_fc)g_armv7_register_print; - -} - - -/****************************************************************************** -* * -* Paramètres : reg = instance à initialiser. * -* * -* Description : Initialise une instance de registre ARMv7. * -* * -* Retour : - * -* * -* Remarques : - * -* * -******************************************************************************/ - -static void g_armv7_register_init(GArmV7Register *reg) -{ - -} - - -/****************************************************************************** -* * -* Paramètres : reg = instance d'objet GLib à traiter. * -* * -* Description : Supprime toutes les références externes. * -* * -* Retour : - * -* * -* Remarques : - * -* * -******************************************************************************/ - -static void g_armv7_register_dispose(GArmV7Register *reg) -{ - G_OBJECT_CLASS(g_armv7_register_parent_class)->dispose(G_OBJECT(reg)); - -} - - -/****************************************************************************** -* * -* Paramètres : reg = instance d'objet GLib à traiter. * -* * -* Description : Procède à la libération totale de la mémoire. * -* * -* Retour : - * -* * -* Remarques : - * -* * -******************************************************************************/ - -static void g_armv7_register_finalize(GArmV7Register *reg) -{ - G_OBJECT_CLASS(g_armv7_register_parent_class)->finalize(G_OBJECT(reg)); - -} - - -/****************************************************************************** -* * -* Paramètres : reg = registre à transcrire. * -* line = ligne tampon où imprimer l'opérande donné. * -* syntax = type de représentation demandée. * -* * -* Description : Traduit un registre en version humainement lisible. * -* * -* Retour : - * -* * -* Remarques : - * -* * -******************************************************************************/ - -static void g_armv7_register_print(const GArmV7Register *reg, GBufferLine *line, AsmSyntax syntax) -{ - char key[MAX_REGNAME_LEN]; /* Mot clef principal */ - size_t klen; /* Taille de ce mot clef */ - - switch (G_ARM_REGISTER(reg)->index) - { - case 0 ... 12: - klen = snprintf(key, MAX_REGNAME_LEN, "r%hhu", G_ARM_REGISTER(reg)->index); - break; - case 13: - klen = snprintf(key, MAX_REGNAME_LEN, "sp"); - break; - case 14: - klen = snprintf(key, MAX_REGNAME_LEN, "lr"); - break; - case 15: - klen = snprintf(key, MAX_REGNAME_LEN, "pc"); - break; - case 16: - klen = snprintf(key, MAX_REGNAME_LEN, "cpsr"); - break; - case 17: - klen = snprintf(key, MAX_REGNAME_LEN, "spsr"); - break; - default: - klen = snprintf(key, MAX_REGNAME_LEN, "r??"); - break; - } - - g_buffer_line_append_text(line, BLC_ASSEMBLY, key, klen, RTT_REGISTER, NULL); - -} - - -/****************************************************************************** -* * -* Paramètres : index = indice du registre correspondant. * -* * -* Description : Crée une réprésentation de registre ARMv7. * -* * -* Retour : Adresse de la structure mise en place. * -* * -* Remarques : - * -* * -******************************************************************************/ - -GArmV7Register *g_armv7_register_new(uint8_t index) -{ - GArmV7Register *result; /* Structure à retourner */ - - result = g_object_new(G_TYPE_ARMV7_REGISTER, NULL); - - G_ARM_REGISTER(result)->index = index; - - return result; - -} diff --git a/src/arch/arm/v7/register.h b/src/arch/arm/v7/register.h deleted file mode 100644 index d0a89f2..0000000 --- a/src/arch/arm/v7/register.h +++ /dev/null @@ -1,57 +0,0 @@ - -/* Chrysalide - Outil d'analyse de fichiers binaires - * registers.h - prototypes pour les aides auxiliaires relatives aux registres ARMv7 - * - * Copyright (C) 2014-2017 Cyrille Bagard - * - * This file is part of Chrysalide. - * - * Chrysalide is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Chrysalide is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Foobar. If not, see . - */ - - -#ifndef _ARCH_ARM_V7_REGISTER_H -#define _ARCH_ARM_V7_REGISTER_H - - -#include -#include -#include - - - -#define G_TYPE_ARMV7_REGISTER g_armv7_register_get_type() -#define G_ARMV7_REGISTER(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), g_armv7_register_get_type(), GArmV7Register)) -#define G_IS_ARMV7_REGISTER(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), g_armv7_register_get_type())) -#define G_ARMV7_REGISTER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), G_TYPE_ARMV7_REGISTER, GArmV7RegisterClass)) -#define G_IS_ARMV7_REGISTER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), G_TYPE_ARMV7_REGISTER)) -#define G_ARMV7_REGISTER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), G_TYPE_ARMV7_REGISTER, GArmV7RegisterClass)) - - -/* Représentation d'un registre ARMv7 (instance) */ -typedef struct _GArmV7Register GArmV7Register; - -/* Représentation d'un registre ARMv7 (classe) */ -typedef struct _GArmV7RegisterClass GArmV7RegisterClass; - - -/* Indique le type défini pour une représentation d'un registre ARMv7. */ -GType g_armv7_register_get_type(void); - -/* Crée une réprésentation de registre ARMv7. */ -GArmV7Register *g_armv7_register_new(uint8_t); - - - -#endif /* _ARCH_ARM_V7_REGISTER_H */ diff --git a/src/arch/arm/v7/simd.c b/src/arch/arm/v7/simd.c deleted file mode 100644 index c722757..0000000 --- a/src/arch/arm/v7/simd.c +++ /dev/null @@ -1,1539 +0,0 @@ - -/* Chrysalide - Outil d'analyse de fichiers binaires - * simd.c - désassemblage des instructions ARMv7 SIMD - * - * Copyright (C) 2016-2017 Cyrille Bagard - * - * This file is part of Chrysalide. - * - * Chrysalide is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Chrysalide is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Foobar. If not, see . - */ - - -#include "simd.h" - - -#include - - -//#include "opcodes/simd_opcodes.h" -#include "opcodes/opcodes_tmp_simd.h" -#include "../../undefined.h" -#include "../../../common/bconst.h" - - - -/* Désassemble une instruction ARMv7 liées au chapitre A7.4.1. */ -static GArchInstruction *process_armv7_simd_three_registers_of_the_same_length(uint32_t, bool); - -/* Désassemble une instruction ARMv7 liées au chapitre A7.4.2. */ -static GArchInstruction *process_armv7_simd_three_registers_of_different_lengths(uint32_t, bool); - -/* Désassemble une instruction ARMv7 liées au chapitre A7.4.3. */ -static GArchInstruction *process_armv7_simd_two_registers_and_a_scalar(uint32_t, bool); - -/* Désassemble une instruction ARMv7 liées au chapitre A7.4.4. */ -static GArchInstruction *process_armv7_simd_two_registers_and_a_shift_amount(uint32_t, bool); - -/* Désassemble une instruction ARMv7 liées au chapitre A7.4.5. */ -static GArchInstruction *process_armv7_simd_two_registers_miscellaneous(uint32_t, bool); - -/* Désassemble une instruction ARMv7 liées au chapitre A7.4.6. */ -static GArchInstruction *process_armv7_simd_one_register_and_a_modified_immediate_value(uint32_t, bool); - - - -/****************************************************************************** -* * -* Paramètres : raw = donnée brute de 16 bits à désassembler. * -* arm = précise si l'encodage est en mode ARM ou Thumb. * -* * -* Description : Désassemble une instruction ARMv7 liées au chapitre A7.4. * -* * -* Retour : Instruction mise en place ou NULL en cas d'échec. * -* * -* Remarques : - * -* * -******************************************************************************/ - -GArchInstruction *process_armv7_simd_advanced_simd_data_processing_instructions(uint32_t raw, bool arm) -{ - GArchInstruction *result; /* Instruction à renvoyer */ - uint32_t u; /* Champ 'u' à retrouver */ - uint32_t a; /* Champ 'a' à retrouver */ - uint32_t b; /* Champ 'b' à retrouver */ - uint32_t c; /* Champ 'c' à retrouver */ - - /** - * Suit les directives de : - * § A7.4 Advanced SIMD data-processing instructions - */ - - if (arm) - { - if ((raw & 0xfe000000) != 0xf2000000) return NULL; - } - else - { - if ((raw & 0xef000000) != 0xef000000) return NULL; - } - - result = NULL; - - if (arm) - { - u = (raw >> 24) & b1; - a = (raw >> 19) & b11111; - b = (raw >> 8) & b1111; - c = (raw >> 4) & b1111; - } - else - { - u = (raw >> 28) & b1; - a = (raw >> 19) & b11111; - b = (raw >> 8) & b1111; - c = (raw >> 4) & b1111; - } - - if ((a & b10000) == b00000) - result = process_armv7_simd_three_registers_of_the_same_length(raw, arm); - - else if ((a & b10111) == b10000 && (c & b1001) == b0001) - result = process_armv7_simd_one_register_and_a_modified_immediate_value(raw, arm); - - else if ((a & b10111) == b10001 && (c & b1001) == b0001) - result = process_armv7_simd_two_registers_and_a_shift_amount(raw, arm); - - else if ((a & b10110) == b10010 && (c & b1001) == b0001) - result = process_armv7_simd_two_registers_and_a_shift_amount(raw, arm); - - else if ((a & b10100) == b10100 && (c & b1001) == b0001) - result = process_armv7_simd_two_registers_and_a_shift_amount(raw, arm); - - else if ((a & b10000) == b10000 && (c & b1001) == b1001) - result = process_armv7_simd_two_registers_and_a_shift_amount(raw, arm); - - else if ((a & b10100) == b10000 && (c & b0101) == b0000) - result = process_armv7_simd_three_registers_of_different_lengths(raw, arm); - - else if ((a & b10110) == b10100 && (c & b0101) == b0000) - result = process_armv7_simd_three_registers_of_different_lengths(raw, arm); - - else if ((a & b10100) == b10000 && (c & b0101) == b0100) - result = process_armv7_simd_two_registers_and_a_scalar(raw, arm); - - else if ((a & b10110) == b10100 && (c & b0101) == b0100) - result = process_armv7_simd_two_registers_and_a_scalar(raw, arm); - - else if (u == b0 && (a & b10110) == b10110 && (c & b0001) == b0000) - result = armv7_read_simd_instr_vext(raw, arm); - - else if (u == b1 && (a & b10110) == b10110) - { - if ((b & b1000) == b0000 && (c & b0001) == b0000) - result = process_armv7_simd_two_registers_miscellaneous(raw, arm); - - else if ((b & b1100) == b1000 && (c & b0001) == b0000) - result = armv7_read_simd_instr_vtbl_vtbx(raw, arm); - - else if (b == b1100 && (c & b1001) == b0000) - result = armv7_read_simd_instr_vdup_scalar(raw, arm); - - } - - return result; - -} - - -/****************************************************************************** -* * -* Paramètres : raw = donnée brute de 16 bits à désassembler. * -* arm = précise si l'encodage est en mode ARM ou Thumb. * -* * -* Description : Désassemble une instruction ARMv7 liées au chapitre A7.4.1. * -* * -* Retour : Instruction mise en place ou NULL en cas d'échec. * -* * -* Remarques : - * -* * -******************************************************************************/ - -static GArchInstruction *process_armv7_simd_three_registers_of_the_same_length(uint32_t raw, bool arm) -{ - GArchInstruction *result; /* Instruction à renvoyer */ - uint32_t u; /* Champ 'u' à retrouver */ - uint32_t c; /* Champ 'c' à retrouver */ - uint32_t a; /* Champ 'a' à retrouver */ - uint32_t b; /* Champ 'b' à retrouver */ - - /** - * Suit les directives de : - * § A7.4.1 Three registers of the same length - */ - - if (arm) - { - if ((raw & 0xfe800000) != 0xf2000000) return NULL; - } - else - { - if ((raw & 0xef800000) != 0xef000000) return NULL; - } - - result = NULL; - - if (arm) - { - u = (raw >> 24) & b1; - c = (raw >> 20) & b11; - a = (raw >> 8) & b1111; - b = (raw >> 4) & b1; - } - else - { - u = (raw >> 28) & b1; - c = (raw >> 20) & b11; - a = (raw >> 8) & b1111; - b = (raw >> 4) & b1; - } - - if (a == b0000) - { - if (b == b0) - result = armv7_read_simd_instr_vhadd_vhsub(raw, arm); - - else/* if (b == b1)*/ - result = armv7_read_simd_instr_vqadd(raw, arm); - - } - - else if (a == b0001) - { - if (b == b0) - result = armv7_read_simd_instr_vrhadd(raw, arm); - - else/* if (b == b1)*/ - { - if (u == b0) - switch (c) - { - case b00: - result = armv7_read_simd_instr_vand_register(raw, arm); - break; - - case b01: - result = armv7_read_simd_instr_vbic_register(raw, arm); - break; - - case b10: - /* Cf. vmov_register aussi */ - result = armv7_read_simd_instr_vorr_register(raw, arm); - break; - - case b11: - result = armv7_read_simd_instr_vorn_register(raw, arm); - break; - - } - - else/* if (u == b1)*/ - switch (c) - { - case b00: - result = armv7_read_simd_instr_veor(raw, arm); - break; - - case b01: - result = armv7_read_simd_instr_vbif_vbit_vbsl(raw, arm); - break; - - case b10: - result = armv7_read_simd_instr_vbif_vbit_vbsl(raw, arm); - break; - - case b11: - result = armv7_read_simd_instr_vbif_vbit_vbsl(raw, arm); - break; - - } - - } - - } - - else if (a == b0010) - { - if (b == b0) - result = armv7_read_simd_instr_vhadd_vhsub(raw, arm); - - else/* if (b == b1)*/ - result = armv7_read_simd_instr_vqsub(raw, arm); - - } - - else if (a == b0011) - { - if (b == b0) - result = armv7_read_simd_instr_vcgt_register(raw, arm); - - else/* if (b == b1)*/ - result = armv7_read_simd_instr_vcge_register(raw, arm); - - } - - else if (a == b0100) - { - if (b == b0) - result = armv7_read_simd_instr_vshl_register(raw, arm); - - else/* if (b == b1)*/ - result = armv7_read_simd_instr_vqshl_register(raw, arm); - - } - - else if (a == b0101) - { - if (b == b0) - result = armv7_read_simd_instr_vrshl(raw, arm); - - else/* if (b == b1)*/ - result = armv7_read_simd_instr_vqrshl(raw, arm); - - } - - else if (a == b0110) - result = armv7_read_simd_instr_vmax_vmin_integer(raw, arm); - - else if (a == b0111) - { - if (b == b0) - result = armv7_read_simd_instr_vabd_vabdl_integer(raw, arm); - - else/* if (b == b1)*/ - result = armv7_read_simd_instr_vaba_vabal(raw, arm); - - } - - else if (a == b1000) - { - if (b == b0) - { - if (u == b0) - result = armv7_read_simd_instr_vadd_integer(raw, arm); - - else/* if (u == b1)*/ - result = armv7_read_simd_instr_vsub_integer(raw, arm); - - } - - else/* if (b == b1)*/ - { - if (u == b0) - result = armv7_read_simd_instr_vtst(raw, arm); - - else/* if (u == b1)*/ - result = armv7_read_simd_instr_vceq_register(raw, arm); - - } - - } - - else if (a == b1001) - { - if (b == b0) - result = armv7_read_simd_instr_vmla_vmlal_vmls_vmlsl_integer(raw, arm); - - else/* if (b == b1)*/ - result = armv7_read_simd_instr_vmul_vmull_integer_and_polynomial(raw, arm); - - } - - else if (a == b1010) - result = armv7_read_simd_instr_vpmax_vpmin_integer(raw, arm); - - else if (a == b1011) - { - if (b == b0) - { - if (u == b0) - result = armv7_read_simd_instr_vqdmulh(raw, arm); - - else/* if (u == b1)*/ - result = armv7_read_simd_instr_vqrdmulh(raw, arm); - - } - - else/* if (b == b1)*/ - { - if (u == b0) - result = armv7_read_simd_instr_vpadd_integer(raw, arm); - - } - - } - - else if (a == b1100) - { - if (b == b1 && u == b0) - result = armv7_read_simd_instr_vfma_vfms(raw, arm); - - } - - else if (a == b1101) - { - if (b == b0) - { - if (u == b0) - { - if ((c & b10) == b00) - result = armv7_read_simd_instr_vadd_floating_point(raw, arm); - - else/* if ((c & b10) == b10)*/ - result = armv7_read_simd_instr_vsub_floating_point(raw, arm); - - } - - else/* if (u == b1)*/ - { - if ((c & b10) == b00) - result = armv7_read_simd_instr_vpadd_floating_point(raw, arm); - - else/* if ((c & b10) == b10)*/ - result = armv7_read_simd_instr_vabd_floating_point(raw, arm); - - } - - } - - else/* if (b == b1)*/ - { - if (u == b0) - result = armv7_read_simd_instr_vmla_vmls_floating_point(raw, arm); - - else/* if (u == b1)*/ - { - if ((c & b10) == b00) - result = armv7_read_simd_instr_vmul_floating_point(raw, arm); - - } - - } - - } - - else if (a == b1110) - { - if (b == b0) - { - if (u == b0) - { - if ((c & b10) == b00) - result = armv7_read_simd_instr_vceq_register(raw, arm); - - } - - else/* if (u == b1)*/ - { - if ((c & b10) == b00) - result = armv7_read_simd_instr_vcge_register(raw, arm); - - else/* if ((c & b10) == b10)*/ - result = armv7_read_simd_instr_vcgt_register(raw, arm); - - } - - } - - else/* if (b == b1)*/ - { - if (u == b1) - result = armv7_read_simd_instr_vacge_vacgt_vacle_vaclt(raw, arm); - - } - - } - - else if (a == b1111) - { - if (b == b0) - { - if (u == b0) - result = armv7_read_simd_instr_vmax_vmin_floating_point(raw, arm); - - else/* if (u == b1)*/ - result = armv7_read_simd_instr_vpmax_vpmin_floating_point(raw, arm); - - } - - else/* if (b == b1)*/ - { - if (u == b0) - { - if ((c & b10) == b00) - result = armv7_read_simd_instr_vrecps(raw, arm); - - else/* if ((c & b10) == b10)*/ - result = armv7_read_simd_instr_vrsqrts(raw, arm); - - } - - } - - } - - return result; - -} - - -/****************************************************************************** -* * -* Paramètres : raw = donnée brute de 16 bits à désassembler. * -* arm = précise si l'encodage est en mode ARM ou Thumb. * -* * -* Description : Désassemble une instruction ARMv7 liées au chapitre A7.4.2. * -* * -* Retour : Instruction mise en place ou NULL en cas d'échec. * -* * -* Remarques : - * -* * -******************************************************************************/ - -static GArchInstruction *process_armv7_simd_three_registers_of_different_lengths(uint32_t raw, bool arm) -{ - GArchInstruction *result; /* Instruction à renvoyer */ - uint32_t u; /* Champ 'u' à retrouver */ - uint32_t a; /* Champ 'a' à retrouver */ - - /** - * Suit les directives de : - * § A7.4.2 Three registers of different lengths - */ - - if (arm) - { - if ((raw & 0xfe800050) != 0xf2800000) return NULL; - } - else - { - if ((raw & 0xef800050) != 0xef800000) return NULL; - } - - result = NULL; - - if (arm) - { - u = (raw >> 24) & b1; - a = (raw >> 8) & b1111; - } - else - { - u = (raw >> 28) & b1; - a = (raw >> 8) & b1111; - } - - if ((a & b1110) == b0000) - result = armv7_read_simd_instr_vaddl_vaddw(raw, arm); - - else if ((a & b1110) == b0010) - result = armv7_read_simd_instr_vsubl_vsubw(raw, arm); - - else if (a == b0100) - { - if (u == b0) - result = armv7_read_simd_instr_vaddhn(raw, arm); - - else/* if (u == b1)*/ - result = armv7_read_simd_instr_vraddhn(raw, arm); - - } - - else if (a == b0101) - result = armv7_read_simd_instr_vaba_vabal(raw, arm); - - else if (a == b0110) - { - if (u == b0) - result = armv7_read_simd_instr_vsubhn(raw, arm); - - else/* if (u == b1)*/ - result = armv7_read_simd_instr_vrsubhn(raw, arm); - - } - - else if (a == b0111) - result = armv7_read_simd_instr_vabd_vabdl_integer(raw, arm); - - else if ((a & b1101) == b1000) - result = armv7_read_simd_instr_vmla_vmlal_vmls_vmlsl_integer(raw, arm); - - else if ((a & b1101) == b1001) - { - if (u == b0) - result = armv7_read_simd_instr_vqdmlal_vqdmlsl(raw, arm); - - } - - else if (a == b1100) - result = armv7_read_simd_instr_vmul_vmull_integer_and_polynomial(raw, arm); - - else if (a == b1101) - { - if (u == b0) - result = armv7_read_simd_instr_vqdmull(raw, arm); - - } - - else if (a == b1110) - result = armv7_read_simd_instr_vmul_vmull_integer_and_polynomial(raw, arm); - - return result; - -} - - -/****************************************************************************** -* * -* Paramètres : raw = donnée brute de 16 bits à désassembler. * -* arm = précise si l'encodage est en mode ARM ou Thumb. * -* * -* Description : Désassemble une instruction ARMv7 liées au chapitre A7.4.3. * -* * -* Retour : Instruction mise en place ou NULL en cas d'échec. * -* * -* Remarques : - * -* * -******************************************************************************/ - -static GArchInstruction *process_armv7_simd_two_registers_and_a_scalar(uint32_t raw, bool arm) -{ - GArchInstruction *result; /* Instruction à renvoyer */ - uint32_t u; /* Champ 'u' à retrouver */ - uint32_t a; /* Champ 'a' à retrouver */ - - /** - * Suit les directives de : - * § A7.4.3 Two registers and a scalar - */ - - if (arm) - { - if ((raw & 0xfe800050) != 0xf2800040) return NULL; - } - else - { - if ((raw & 0xef800050) != 0xef800040) return NULL; - } - - result = NULL; - - if (arm) - { - u = (raw >> 24) & b1; - a = (raw >> 8) & b1111; - } - else - { - u = (raw >> 28) & b1; - a = (raw >> 8) & b1111; - } - - if ((a & b1010) == b0000) - result = armv7_read_simd_instr_vmla_vmlal_vmls_vmlsl_by_scalar(raw, arm); - - else if ((a & b1010) == b0010) - result = armv7_read_simd_instr_vmla_vmlal_vmls_vmlsl_by_scalar(raw, arm); - - else if ((a & b1011) == b0011 && u == b0) - result = armv7_read_simd_instr_vqdmlal_vqdmlsl(raw, arm); - - else if ((a & b1110) == b1000) - result = armv7_read_simd_instr_vmul_vmull_by_scalar(raw, arm); - - else if (a == b1010) - result = armv7_read_simd_instr_vmul_vmull_by_scalar(raw, arm); - - else if (a == b1011 && u == b0) - result = armv7_read_simd_instr_vqdmull(raw, arm); - - else if (a == b1100) - result = armv7_read_simd_instr_vqdmulh(raw, arm); - - else if (a == b1101) - result = armv7_read_simd_instr_vqrdmulh(raw, arm); - - return result; - -} - - -/****************************************************************************** -* * -* Paramètres : raw = donnée brute de 16 bits à désassembler. * -* arm = précise si l'encodage est en mode ARM ou Thumb. * -* * -* Description : Désassemble une instruction ARMv7 liées au chapitre A7.4.4. * -* * -* Retour : Instruction mise en place ou NULL en cas d'échec. * -* * -* Remarques : - * -* * -******************************************************************************/ - -static GArchInstruction *process_armv7_simd_two_registers_and_a_shift_amount(uint32_t raw, bool arm) -{ - GArchInstruction *result; /* Instruction à renvoyer */ - uint32_t u; /* Champ 'u' à retrouver */ - uint32_t a; /* Champ 'a' à retrouver */ - uint32_t l; /* Champ 'l' à retrouver */ - uint32_t b; /* Champ 'b' à retrouver */ - - /** - * Suit les directives de : - * § A7.4.4 Two registers and a shift amount - */ - - if (arm) - { - if ((raw & 0xfe800010) != 0xf2800010) return NULL; - } - else - { - if ((raw & 0xef800010) != 0xef800010) return NULL; - } - - result = NULL; - - if (arm) - { - u = (raw >> 24) & b1; - a = (raw >> 8) & b1111; - l = (raw >> 7) & b1; - b = (raw >> 6) & b1; - } - else - { - u = (raw >> 28) & b1; - a = (raw >> 8) & b1111; - l = (raw >> 7) & b1; - b = (raw >> 6) & b1; - } - - if (a == b0000) - result = armv7_read_simd_instr_vshr(raw, arm); - - else if (a == b0001) - result = armv7_read_simd_instr_vsra(raw, arm); - - else if (a == b0010) - result = armv7_read_simd_instr_vrshr(raw, arm); - - else if (a == b0011) - result = armv7_read_simd_instr_vrsra(raw, arm); - - else if (a == b0100 && u == b1) - result = armv7_read_simd_instr_vsri(raw, arm); - - else if (a == b0101) - { - if (u == b0) - result = armv7_read_simd_instr_vshl_immediate(raw, arm); - - else/* if (u == b1)*/ - result = armv7_read_simd_instr_vsli(raw, arm); - - } - - else if ((a & b1110) == b0110) - result = armv7_read_simd_instr_vqshl_vqshlu_immediate(raw, arm); - - else if (a == b1000) - { - if (u == b0) - { - if (b == b0 && l == b0) - result = armv7_read_simd_instr_vshrn(raw, arm); - - else if (b == b1 && l == b0) - result = armv7_read_simd_instr_vrshrn(raw, arm); - - } - else/* if (u == b1)*/ - { - if (b == b0 && l == b0) - result = armv7_read_simd_instr_vqshrn_vqshrun(raw, arm); - - else if (b == b1 && l == b0) - result = armv7_read_simd_instr_vqrshrn_vqrshrun(raw, arm); - - } - - } - - else if (a == b1001) - { - if (b == b0 && l == b0) - result = armv7_read_simd_instr_vqshrn_vqshrun(raw, arm); - - else if (b == b1 && l == b0) - result = armv7_read_simd_instr_vqrshrn_vqrshrun(raw, arm); - - } - - else if (a == b1010 && b == b0 && l == b0) - { - result = armv7_read_simd_instr_vshll(raw, arm); - - /* ??? */ - if (result == NULL) - result = armv7_read_simd_instr_vmovl(raw, arm); - - } - - else if ((a & b1110) == b1110 && l == b0) - result = armv7_read_simd_instr_vcvt_between_floating_point_and_fixed_point_advanced_simd(raw, arm); - - return result; - -} - - -/****************************************************************************** -* * -* Paramètres : raw = donnée brute de 16 bits à désassembler. * -* arm = précise si l'encodage est en mode ARM ou Thumb. * -* * -* Description : Désassemble une instruction ARMv7 liées au chapitre A7.4.5. * -* * -* Retour : Instruction mise en place ou NULL en cas d'échec. * -* * -* Remarques : - * -* * -******************************************************************************/ - -static GArchInstruction *process_armv7_simd_two_registers_miscellaneous(uint32_t raw, bool arm) -{ - GArchInstruction *result; /* Instruction à renvoyer */ - uint32_t a; /* Champ 'a' à retrouver */ - uint32_t b; /* Champ 'b' à retrouver */ - - /** - * Suit les directives de : - * § A7.4.5 Two registers, miscellaneous - */ - - if (arm) - { - if ((raw & 0xffb00810) != 0xf3b00000) return NULL; - } - else - { - if ((raw & 0xffb00810) != 0xffb00000) return NULL; - } - - result = NULL; - - a = (raw >> 16) & b11; - b = (raw >> 6) & b11111; - - if (a == b00) - { - if ((b & b11110) == b00000) - result = armv7_read_simd_instr_vrev16_vrev32_vrev64(raw, arm); - - else if ((b & b11110) == b00010) - result = armv7_read_simd_instr_vrev16_vrev32_vrev64(raw, arm); - - else if ((b & b11110) == b00100) - result = armv7_read_simd_instr_vrev16_vrev32_vrev64(raw, arm); - - else if ((b & b11100) == b01000) - result = armv7_read_simd_instr_vpaddl(raw, arm); - - else if ((b & b11110) == b10000) - result = armv7_read_simd_instr_vcls(raw, arm); - - else if ((b & b11110) == b10010) - result = armv7_read_simd_instr_vclz(raw, arm); - - else if ((b & b11110) == b10100) - result = armv7_read_simd_instr_vcnt(raw, arm); - - else if ((b & b11110) == b10110) - result = armv7_read_simd_instr_vmvn_register(raw, arm); - - else if ((b & b11100) == b11000) - result = armv7_read_simd_instr_vpadal(raw, arm); - - else if ((b & b11110) == b11100) - result = armv7_read_simd_instr_vqabs(raw, arm); - - else if ((b & b11110) == b11110) - result = armv7_read_simd_instr_vqneg(raw, arm); - - } - - else if (a == b01) - { - if ((b & b01110) == b00000) - result = armv7_read_simd_instr_vcgt_immediate_0(raw, arm); - - else if ((b & b01110) == b00010) - result = armv7_read_simd_instr_vcge_immediate_0(raw, arm); - - else if ((b & b01110) == b00100) - result = armv7_read_simd_instr_vceq_immediate_0(raw, arm); - - else if ((b & b01110) == b00110) - result = armv7_read_simd_instr_vcle_immediate_0(raw, arm); - - else if ((b & b01110) == b01000) - result = armv7_read_simd_instr_vclt_immediate_0(raw, arm); - - else if ((b & b01110) == b01100) - result = armv7_read_simd_instr_vabs(raw, arm); - - else if ((b & b01110) == b01110) - result = armv7_read_simd_instr_vneg(raw, arm); - - } - - return result; - -} - - -/****************************************************************************** -* * -* Paramètres : raw = donnée brute de 16 bits à désassembler. * -* arm = précise si l'encodage est en mode ARM ou Thumb. * -* * -* Description : Désassemble une instruction ARMv7 liées au chapitre A7.4.6. * -* * -* Retour : Instruction mise en place ou NULL en cas d'échec. * -* * -* Remarques : - * -* * -******************************************************************************/ - -static GArchInstruction *process_armv7_simd_one_register_and_a_modified_immediate_value(uint32_t raw, bool arm) -{ - GArchInstruction *result; /* Instruction à renvoyer */ - uint32_t cmode; /* Champ 'cmode' à retrouver */ - uint32_t op; /* Champ 'op' à retrouver */ - - /** - * Suit les directives de : - * § A7.4.6 One register and a modified immediate value - */ - - if (arm) - { - if ((raw & 0xfeb80090) != 0xf2800010) return NULL; - } - else - { - if ((raw & 0xefb80090) != 0xef800010) return NULL; - } - - result = NULL; - - cmode = (raw >> 8) & b1111; - op = (raw >> 5) & b1; - - if (op == b0) - { - if ((cmode & b1001) == b0000) - result = armv7_read_simd_instr_vmov_immediate(raw, arm); - - else if ((cmode & b1001) == b0001) - result = armv7_read_simd_instr_vorr_immediate(raw, arm); - - else if ((cmode & b1101) == b1000) - result = armv7_read_simd_instr_vmov_immediate(raw, arm); - - else if ((cmode & b1101) == b1001) - result = armv7_read_simd_instr_vorr_immediate(raw, arm); - - else if ((cmode & b1100) == b1100) - result = armv7_read_simd_instr_vmov_immediate(raw, arm); - - } - - else/* if (op == b1)*/ - { - if ((cmode & b1001) == b0000) - result = armv7_read_simd_instr_vmvn_immediate(raw, arm); - - else if ((cmode & b1001) == b0001) - result = armv7_read_simd_instr_vbic_immediate(raw, arm); - - else if ((cmode & b1101) == b1000) - result = armv7_read_simd_instr_vmvn_immediate(raw, arm); - - else if ((cmode & b1101) == b1001) - result = armv7_read_simd_instr_vbic_immediate(raw, arm); - - else if ((cmode & b1110) == b1100) - result = armv7_read_simd_instr_vmvn_immediate(raw, arm); - - else if (cmode == b1110) - result = armv7_read_simd_instr_vmov_immediate(raw, arm); - - else if (cmode == b1111) - result = g_undef_instruction_new(IBS_UNDEFINED); - - } - - return result; - -} - - -/****************************************************************************** -* * -* Paramètres : raw = donnée brute de 16 bits à désassembler. * -* arm = précise si l'encodage est en mode ARM ou Thumb. * -* * -* Description : Désassemble une instruction ARMv7 liées au chapitre A7.5. * -* * -* Retour : Instruction mise en place ou NULL en cas d'échec. * -* * -* Remarques : - * -* * -******************************************************************************/ - -GArchInstruction *process_armv7_simd_floating_point_data_processing_instructions(uint32_t raw, bool arm) -{ - GArchInstruction *result; /* Instruction à renvoyer */ - uint32_t opc1; /* Champ 'opc1' à retrouver */ - uint32_t opc2; /* Champ 'opc2' à retrouver */ - uint32_t opc3; /* Champ 'opc3' à retrouver */ - - /** - * Suit les directives de : - * § A7.5 Floating-point data-processing instructions - */ - - if (arm) - { - if ((raw & 0x0f000e10) != 0xee000a00) return NULL; - } - else - { - if ((raw & 0xef000e10) != 0x0e000a00) return NULL; - } - - result = NULL; - - opc1 = (raw >> 20) & b1111; - opc2 = (raw >> 16) & b1111; - opc3 = (raw >> 6) & b11; - - - if ((opc1 & b1011) == b0000) - result = armv7_read_simd_instr_vmla_vmls_floating_point(raw, arm); - - else if ((opc1 & b1011) == b0001) - result = armv7_read_simd_instr_vnmla_vnmls_vnmul(raw, arm); - - else if ((opc1 & b1011) == b0010) - { - if ((opc3 & b01) == b01) - result = armv7_read_simd_instr_vnmla_vnmls_vnmul(raw, arm); - - else/* if ((opc3 & b01) == b00)*/ - result = armv7_read_simd_instr_vmul_floating_point(raw, arm); - - } - - else if ((opc1 & b1011) == b0011) - { - if ((opc3 & b01) == b00) - result = armv7_read_simd_instr_vadd_floating_point(raw, arm); - - else/* if ((opc3 & b01) == b01)*/ - result = armv7_read_simd_instr_vsub_floating_point(raw, arm); - - } - - else if ((opc1 & b1011) == b1000) - { - if ((opc3 & b01) == b00) - result = armv7_read_simd_instr_vdiv(raw, arm); - - } - - else if ((opc1 & b1011) == b1001) - result = armv7_read_simd_instr_vfnma_vfnms(raw, arm); - - else if ((opc1 & b1011) == b1010) - result = armv7_read_simd_instr_vfma_vfms(raw, arm); - - else if ((opc1 & b1011) == b1011) - { - if ((opc3 & b01) == b00) - result = armv7_read_simd_instr_vmov_immediate(raw, arm); - - else if (opc2 == b0000) - { - if (opc3 == b01) - result = armv7_read_simd_instr_vmov_register(raw, arm); - - else if (opc3 == b11) - result = armv7_read_simd_instr_vabs(raw, arm); - - } - - else if (opc2 == b0001) - { - if (opc3 == b01) - result = armv7_read_simd_instr_vneg(raw, arm); - - else if (opc3 == b11) - result = armv7_read_simd_instr_vsqrt(raw, arm); - - } - - else if ((opc2 & b1110) == b0010 && (opc3 & b01) == b01) - result = armv7_read_simd_instr_vcvtb_vcvtt(raw, arm); - - else if ((opc2 & b1110) == b0100 && (opc3 & b01) == b01) - result = armv7_read_simd_instr_vcmp_vcmpe(raw, arm); - - else if (opc2 == b0111 && opc3 == b11) - result = armv7_read_simd_instr_vcvt_between_double_precision_and_single_precision(raw, arm); - - else if (opc2 == b1000 && (opc3 & b01) == b01) - result = armv7_read_simd_instr_vcvt_vcvtr_between_floating_point_and_integer_floating_point(raw, arm); - - else if ((opc2 & b1110) == b1010 && (opc3 & b01) == b01) - result = armv7_read_simd_instr_vcvt_between_floating_point_and_fixed_point_floating_point(raw, arm); - - else if ((opc2 & b1110) == b1100 && (opc3 & b01) == b01) - result = armv7_read_simd_instr_vcvt_vcvtr_between_floating_point_and_integer_floating_point(raw, arm); - - else if ((opc2 & b1110) == b1110 && (opc3 & b01) == b01) - result = armv7_read_simd_instr_vcvt_between_floating_point_and_fixed_point_floating_point(raw, arm); - - } - - return result; - -} - - -/****************************************************************************** -* * -* Paramètres : raw = donnée brute de 16 bits à désassembler. * -* arm = précise si l'encodage est en mode ARM ou Thumb. * -* * -* Description : Désassemble une instruction ARMv7 liées au chapitre A7.6. * -* * -* Retour : Instruction mise en place ou NULL en cas d'échec. * -* * -* Remarques : - * -* * -******************************************************************************/ - -GArchInstruction *process_armv7_simd_extension_register_load_store_instructions(uint32_t raw, bool arm) -{ - GArchInstruction *result; /* Instruction à renvoyer */ - uint32_t opcode; /* Champ 'opcode' à retrouver */ - uint32_t rn; /* Champ 'rn' à retrouver */ - - /** - * Suit les directives de : - * § A7.6 Extension register load/store instructions - */ - - if (arm) - { - if ((raw & 0x0e000e00) != 0x0c000a00) return NULL; - } - else - { - if ((raw & 0xee000e00) != 0xec000a00) return NULL; - } - - result = NULL; - - opcode = (raw >> 20) & b11111; - rn = (raw >> 16) & b1111; - - if ((opcode & b11110) == b00100) - result = process_armv7_simd_64_bit_transfers_between_arm_core_and_extension_registers(raw, arm); - - else if ((opcode & b11011) == b01000) - result = armv7_read_simd_instr_vstm(raw, arm); - - else if ((opcode & b11011) == b01010) - result = armv7_read_simd_instr_vstm(raw, arm); - - else if ((opcode & b10011) == b10000) - result = armv7_read_simd_instr_vstr(raw, arm); - - else if ((opcode & b11011) == b10010) - { - if (rn != b1101) - result = armv7_read_simd_instr_vstm(raw, arm); - - else/* if (rn == b1101)*/ - result = armv7_read_simd_instr_vpush(raw, arm); - - } - - else if ((opcode & b11011) == b01001) - result = armv7_read_simd_instr_vldm(raw, arm); - - else if ((opcode & b11011) == b01011) - { - if (rn != 1101) - result = armv7_read_simd_instr_vldm(raw, arm); - - else/* if (rn == 1101)*/ - result = armv7_read_simd_instr_vpop(raw, arm); - - } - - else if ((opcode & b10011) == b10001) - result = armv7_read_simd_instr_vldr(raw, arm); - - else if ((opcode & b11011) == b10011) - result = armv7_read_simd_instr_vldm(raw, arm); - - return result; - -} - - -/****************************************************************************** -* * -* Paramètres : raw = donnée brute de 16 bits à désassembler. * -* arm = précise si l'encodage est en mode ARM ou Thumb. * -* * -* Description : Désassemble une instruction ARMv7 liées au chapitre A7.7. * -* * -* Retour : Instruction mise en place ou NULL en cas d'échec. * -* * -* Remarques : - * -* * -******************************************************************************/ - -GArchInstruction *process_armv7_simd_advanced_simd_element_or_structure_load_store_instructions(uint32_t raw, bool arm) -{ - GArchInstruction *result; /* Instruction à renvoyer */ - uint32_t a; /* Champ 'a' à retrouver */ - uint32_t l; /* Champ 'l' à retrouver */ - uint32_t b; /* Champ 'b' à retrouver */ - - /** - * Suit les directives de : - * § A7.7 Advanced SIMD element or structure load/store instructions - */ - - if (arm) - { - if ((raw & 0xff100000) != 0xf4000000) return NULL; - } - else - { - if ((raw & 0xff100000) != 0xf9000000) return NULL; - } - - result = NULL; - - a = (raw >> 23) & b1; - l = (raw >> 21) & b1; - b = (raw >> 8) & b1111; - - if (l == b0) - { - if (a == b0) - { - if (b == b0010) - result = armv7_read_simd_instr_vst1_multiple_single_elements(raw, arm); - - else if ((b & b1110) == b0110) - result = armv7_read_simd_instr_vst1_multiple_single_elements(raw, arm); - - else if (b == b1010) - result = armv7_read_simd_instr_vst1_multiple_single_elements(raw, arm); - - else if (b == b0011) - result = armv7_read_simd_instr_vst2_multiple_2_element_structures(raw, arm); - - else if ((b & b1110) == b1000) - result = armv7_read_simd_instr_vst2_multiple_2_element_structures(raw, arm); - - else if ((b & b1110) == b0100) - result = armv7_read_simd_instr_vst3_multiple_3_element_structures(raw, arm); - - else if ((b & b1110) == b0000) - result = armv7_read_simd_instr_vst4_multiple_4_element_structures(raw, arm); - - } - - else/* if (a == b1)*/ - { - if ((b & b1011) == b0000) - result = armv7_read_simd_instr_vst1_single_element_from_one_lane(raw, arm); - - else if (b == b1000) - result = armv7_read_simd_instr_vst1_single_element_from_one_lane(raw, arm); - - else if ((b & b1011) == b0001) - result = armv7_read_simd_instr_vst2_single_2_element_structure_from_one_lane(raw, arm); - - else if (b == b1001) - result = armv7_read_simd_instr_vst2_single_2_element_structure_from_one_lane(raw, arm); - - else if ((b & b1011) == b0010) - result = armv7_read_simd_instr_vst3_single_3_element_structure_from_one_lane(raw, arm); - - else if (b == b1010) - result = armv7_read_simd_instr_vst3_single_3_element_structure_from_one_lane(raw, arm); - - else if ((b & b1011) == b0011) - result = armv7_read_simd_instr_vst4_single_4_element_structure_from_one_lane(raw, arm); - - else if (b == b1011) - result = armv7_read_simd_instr_vst4_single_4_element_structure_from_one_lane(raw, arm); - - } - - } - - else/* if (l == b1)*/ - { - if (a == b0) - { - if (b == b0010) - result = armv7_read_simd_instr_vld1_multiple_single_elements(raw, arm); - - else if ((b & b1110) == b0110) - result = armv7_read_simd_instr_vld1_multiple_single_elements(raw, arm); - - else if (b == b1010) - result = armv7_read_simd_instr_vld1_multiple_single_elements(raw, arm); - - else if (b == b0011) - result = armv7_read_simd_instr_vld2_multiple_2_element_structures(raw, arm); - - else if ((b & b1110) == b1000) - result = armv7_read_simd_instr_vld2_multiple_2_element_structures(raw, arm); - - else if ((b & b1110) == b0100) - result = armv7_read_simd_instr_vld3_multiple_3_element_structures(raw, arm); - - else if ((b & b1110) == b0000) - result = armv7_read_simd_instr_vld4_multiple_4_element_structures(raw, arm); - - } - - else/* if (a == b1)*/ - { - if ((b & b1011) == b0000) - result = armv7_read_simd_instr_vld1_single_element_to_one_lane(raw, arm); - - else if (b == b1000) - result = armv7_read_simd_instr_vld1_single_element_to_one_lane(raw, arm); - - else if (b == b1100) - result = armv7_read_simd_instr_vld1_single_element_to_all_lanes(raw, arm); - - else if ((b & b1011) == b0001) - result = armv7_read_simd_instr_vld2_single_2_element_structure_to_one_lane(raw, arm); - - else if (b == b1001) - result = armv7_read_simd_instr_vld2_single_2_element_structure_to_one_lane(raw, arm); - - else if (b == b1101) - result = armv7_read_simd_instr_vld2_single_2_element_structure_to_all_lanes(raw, arm); - - else if ((b & b1011) == b0010) - result = armv7_read_simd_instr_vld3_single_3_element_structure_to_one_lane(raw, arm); - - else if (b == b1010) - result = armv7_read_simd_instr_vld3_single_3_element_structure_to_one_lane(raw, arm); - - else if (b == b1110) - result = armv7_read_simd_instr_vld3_single_3_element_structure_to_all_lanes(raw, arm); - - else if ((b & b1011) == b0011) - result = armv7_read_simd_instr_vld4_single_4_element_structure_to_one_lane(raw, arm); - - else if (b == b1011) - result = armv7_read_simd_instr_vld4_single_4_element_structure_to_one_lane(raw, arm); - - else if (b == b1111) - result = armv7_read_simd_instr_vld4_single_4_element_structure_to_all_lanes(raw, arm); - - } - - } - - return result; - -} - - -/****************************************************************************** -* * -* Paramètres : raw = donnée brute de 16 bits à désassembler. * -* arm = précise si l'encodage est en mode ARM ou Thumb. * -* * -* Description : Désassemble une instruction ARMv7 liées au chapitre A7.8. * -* * -* Retour : Instruction mise en place ou NULL en cas d'échec. * -* * -* Remarques : - * -* * -******************************************************************************/ - -GArchInstruction *process_armv7_simd_8_16_and_32_bit_transfer_between_arm_core_and_extension_registers(uint32_t raw, bool arm) -{ - GArchInstruction *result; /* Instruction à renvoyer */ - uint32_t a; /* Champ 'a' à retrouver */ - uint32_t l; /* Champ 'l' à retrouver */ - uint32_t c; /* Champ 'c' à retrouver */ - uint32_t b; /* Champ 'b' à retrouver */ - - /** - * Suit les directives de : - * § A7.8 8, 16, and 32-bit transfer between ARM core and extension registers - */ - - if (arm) - { - if ((raw & 0x0f000e10) != 0x0e000a10) return NULL; - } - else - { - if ((raw & 0xef000e10) != 0xee000a10) return NULL; - } - - result = NULL; - - a = (raw >> 21) & b111; - l = (raw >> 20) & b1; - c = (raw >> 8) & b1; - b = (raw >> 5) & b11; - - if (l == b0) - { - if (c == b0) - { - if (a == b000) - result = armv7_read_simd_instr_vmov_between_arm_core_register_and_single_precision_register(raw, arm); - - else if (a == b111) - { - result = armv7_read_simd_instr_vmsr(raw, arm); - - if (result == NULL /* ! */) - result = armv7_read_simd_instr_vmsr_b9(raw, arm); - - } - - } - - else/* if (c == b1)*/ - { - if ((a & b100) == b000) - result = armv7_read_simd_instr_vmov_arm_core_register_to_scalar(raw, arm); - - else if (/*(a & b100) == b000) && */(b & b10) == b00) - result = armv7_read_simd_instr_vdup_arm_core_register(raw, arm); - - } - - } - - else/* if (l == b1)*/ - { - if (c == b0) - { - if (a == b000) - result = armv7_read_simd_instr_vmov_between_arm_core_register_and_single_precision_register(raw, arm); - - else if (a == b111) - { - result = armv7_read_simd_instr_vmrs(raw, arm); - - if (result == NULL /* ! */) - result = armv7_read_simd_instr_vmrs_b9(raw, arm); - - } - - } - - else/* if (c == b1)*/ - result = armv7_read_simd_instr_vmov_scalar_to_arm_core_register(raw, arm); - - } - - return result; - -} - - -/****************************************************************************** -* * -* Paramètres : raw = donnée brute de 16 bits à désassembler. * -* arm = précise si l'encodage est en mode ARM ou Thumb. * -* * -* Description : Désassemble une instruction ARMv7 liées au chapitre A7.9. * -* * -* Retour : Instruction mise en place ou NULL en cas d'échec. * -* * -* Remarques : - * -* * -******************************************************************************/ - -GArchInstruction *process_armv7_simd_64_bit_transfers_between_arm_core_and_extension_registers(uint32_t raw, bool arm) -{ - GArchInstruction *result; /* Instruction à renvoyer */ - uint32_t c; /* Champ 'c' à retrouver */ - uint32_t op; /* Champ 'op' à retrouver */ - - /** - * Suit les directives de : - * § A7.9 64-bit transfers between ARM core and extension registers - */ - - if (arm) - { - if ((raw & 0x0fe00e00) != 0x0c400a00) return NULL; - } - else - { - if ((raw & 0xefe00e00) != 0xec400a00) return NULL; - } - - result = NULL; - - c = (raw >> 8) & b1; - op = (raw >> 4) & b1111; - - if (c == b0 && (op & b1101) == 0001) - result = armv7_read_simd_instr_vmov_between_two_arm_core_registers_and_two_single_precision_registers(raw, arm); - - else if (c == b1 && (op & b1101) == 0001) - result = armv7_read_simd_instr_vmov_between_two_arm_core_registers_and_a_doubleword_extension_register(raw, arm); - - return result; - -} diff --git a/src/arch/arm/v7/simd.h b/src/arch/arm/v7/simd.h deleted file mode 100644 index f4fe556..0000000 --- a/src/arch/arm/v7/simd.h +++ /dev/null @@ -1,55 +0,0 @@ - -/* Chrysalide - Outil d'analyse de fichiers binaires - * simd.h - prototypes pour le désassemblage des instructions ARMv7 SIMD - * - * Copyright (C) 2016-2017 Cyrille Bagard - * - * This file is part of Chrysalide. - * - * Chrysalide is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Chrysalide is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Foobar. If not, see . - */ - - -#ifndef _ARCH_ARM_V7_SIMD_H -#define _ARCH_ARM_V7_SIMD_H - - -#include - - -#include "../../instruction.h" - - - -/* Désassemble une instruction ARMv7 liées au chapitre A7.4. */ -GArchInstruction *process_armv7_simd_advanced_simd_data_processing_instructions(uint32_t, bool); - -/* Désassemble une instruction ARMv7 liées au chapitre A7.5. */ -GArchInstruction *process_armv7_simd_floating_point_data_processing_instructions(uint32_t, bool); - -/* Désassemble une instruction ARMv7 liées au chapitre A7.6. */ -GArchInstruction *process_armv7_simd_extension_register_load_store_instructions(uint32_t, bool); - -/* Désassemble une instruction ARMv7 liées au chapitre A7.7. */ -GArchInstruction *process_armv7_simd_advanced_simd_element_or_structure_load_store_instructions(uint32_t, bool); - -/* Désassemble une instruction ARMv7 liées au chapitre A7.8. */ -GArchInstruction *process_armv7_simd_8_16_and_32_bit_transfer_between_arm_core_and_extension_registers(uint32_t, bool); - -/* Désassemble une instruction ARMv7 liées au chapitre A7.9. */ -GArchInstruction *process_armv7_simd_64_bit_transfers_between_arm_core_and_extension_registers(uint32_t, bool); - - - -#endif /* _ARCH_ARM_V7_SIMD_H */ diff --git a/src/arch/arm/v7/thumb_16.c b/src/arch/arm/v7/thumb_16.c deleted file mode 100644 index 7f59481..0000000 --- a/src/arch/arm/v7/thumb_16.c +++ /dev/null @@ -1,670 +0,0 @@ - -/* Chrysalide - Outil d'analyse de fichiers binaires - * thumb_16.c - désassemblage des instructions ARMv7 Thumb 16 bits - * - * Copyright (C) 2014-2017 Cyrille Bagard - * - * This file is part of Chrysalide. - * - * Chrysalide is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Chrysalide is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Foobar. If not, see . - */ - - -#include "thumb_16.h" - - -#include - - -#include "opcodes/thumb_16_opcodes.h" -#include "opcodes/opcodes_tmp_thumb_16.h" -#include "../../../common/bconst.h" - - - -/* Désassemble une instruction ARMv7 liées au chapitre A6.2.1 */ -static GArchInstruction *process_armv7_thumb_16_shift_immediate_add_subtract_move_and_compare(uint16_t); - -/* Désassemble une instruction ARMv7 liées au chapitre A6.2.2. */ -static GArchInstruction *process_armv7_thumb_16_data_processing(uint16_t); - -/* Désassemble une instruction ARMv7 liées au chapitre A6.2.3. */ -static GArchInstruction *process_armv7_thumb_16_special_data_instructions_and_branch_and_exchange(uint16_t); - -/* Désassemble une instruction ARMv7 liées au chapitre A6.2.4. */ -static GArchInstruction *process_armv7_thumb_16_load_store_single_data_item(uint16_t); - -/* Désassemble une instruction ARMv7 liées au chapitre A6.2.5. */ -static GArchInstruction *process_armv7_thumb_16_miscellaneous_16_bit_instructions(uint16_t); - -/* Désassemble une instruction ARMv7 liées au chapitre A6.2.5.b. */ -static GArchInstruction *process_armv7_thumb_16_miscellaneous_16_bit_instructions_if_then_and_hints(uint16_t); - -/* Désassemble une instruction ARMv7 liées au chapitre A6.2.6. */ -static GArchInstruction *process_armv7_thumb_16_conditional_branch_and_supervisor_call(uint16_t); - - - -/****************************************************************************** -* * -* Paramètres : raw = donnée brute de 16 bits à désassembler. * -* * -* Description : Désassemble une instruction ARMv7 liées au chapitre A6.2. * -* * -* Retour : Instruction mise en place ou NULL en cas d'échec. * -* * -* Remarques : - * -* * -******************************************************************************/ - -GArchInstruction *process_armv7_thumb_16_instruction_set_encoding(uint16_t raw) -{ - GArchInstruction *result; /* Instruction à renvoyer */ - uint16_t opcode; /* Champ 'opcode' à retrouver */ - - /** - * Suit les directives de : - * § A6.2 16-bit Thumb instruction encoding - */ - - result = NULL; - - opcode = (raw >> 10) & b111111; - - if ((opcode & b110000) == b000000) - result = process_armv7_thumb_16_shift_immediate_add_subtract_move_and_compare(raw); - - else if (opcode == b010000) - result = process_armv7_thumb_16_data_processing(raw); - - else if (opcode == b010001) - result = process_armv7_thumb_16_special_data_instructions_and_branch_and_exchange(raw); - - else if ((opcode & b111110) == b010010) - result = armv7_read_thumb_16_instr_ldr_literal(raw); - - else if ((opcode & b111100) == b010100) - result = process_armv7_thumb_16_load_store_single_data_item(raw); - - else if ((opcode & b111000) == b011000) - result = process_armv7_thumb_16_load_store_single_data_item(raw); - - else if ((opcode & b111000) == b100000) - result = process_armv7_thumb_16_load_store_single_data_item(raw); - - else if ((opcode & b111110) == b101000) - result = armv7_read_thumb_16_instr_adr(raw); - - else if ((opcode & b111110) == b101010) - result = armv7_read_thumb_16_instr_add_sp_plus_immediate(raw); - - else if ((opcode & b111100) == b101100) - result = process_armv7_thumb_16_miscellaneous_16_bit_instructions(raw); - - else if ((opcode & b111110) == b110000) - result = armv7_read_thumb_16_instr_stm_stmia_stmea(raw); - - else if ((opcode & b111110) == b110010) - result = armv7_read_thumb_16_instr_ldm_ldmia_ldmfd_thumb(raw); - - else if ((opcode & b111100) == b110100) - result = process_armv7_thumb_16_conditional_branch_and_supervisor_call(raw); - - else if ((opcode & b111110) == b111000) - result = armv7_read_thumb_16_instr_b(raw); - - return result; - -} - - -/****************************************************************************** -* * -* Paramètres : raw = donnée brute de 16 bits à désassembler. * -* * -* Description : Désassemble une instruction ARMv7 liées au chapitre A6.2.1. * -* * -* Retour : Instruction mise en place ou NULL en cas d'échec. * -* * -* Remarques : - * -* * -******************************************************************************/ - -static GArchInstruction *process_armv7_thumb_16_shift_immediate_add_subtract_move_and_compare(uint16_t raw) -{ - GArchInstruction *result; /* Instruction à renvoyer */ - uint16_t opcode; /* Champ 'opcode' à retrouver */ - - /** - * Suit les directives de : - * § A6.2.1 Shift (immediate), add, subtract, move, and compare - */ - - if ((raw & 0xc000) != 0x0000) return NULL; - - result = NULL; - - opcode = (raw >> 9) & b11111; - - if ((opcode & b11100) == b00000) - result = armv7_read_thumb_16_instr_lsl_immediate(raw); - - else if ((opcode & b11100) == b00100) - result = armv7_read_thumb_16_instr_lsr_immediate(raw); - - else if ((opcode & b11100) == b01000) - result = armv7_read_thumb_16_instr_asr_immediate(raw); - - else if (opcode == b01100) - result = armv7_read_thumb_16_instr_add_register_thumb(raw); - - else if (opcode == b01101) - result = armv7_read_thumb_16_instr_sub_register(raw); - - else if (opcode == b01110) - result = armv7_read_thumb_16_instr_add_immediate_thumb(raw); - - else if (opcode == b01111) - result = armv7_read_thumb_16_instr_sub_immediate_thumb(raw); - - else if ((opcode & b11100) == b10000) - result = armv7_read_thumb_16_instr_mov_immediate(raw); - - else if ((opcode & b11100) == b10100) - result = armv7_read_thumb_16_instr_cmp_immediate(raw); - - else if ((opcode & b11100) == b11000) - result = armv7_read_thumb_16_instr_add_immediate_thumb(raw); - - else if ((opcode & b11100) == b11100) - result = armv7_read_thumb_16_instr_sub_immediate_thumb(raw); - - return result; - -} - - -/****************************************************************************** -* * -* Paramètres : raw = donnée brute de 16 bits à désassembler. * -* * -* Description : Désassemble une instruction ARMv7 liées au chapitre A6.2.2. * -* * -* Retour : Instruction mise en place ou NULL en cas d'échec. * -* * -* Remarques : - * -* * -******************************************************************************/ - -static GArchInstruction *process_armv7_thumb_16_data_processing(uint16_t raw) -{ - GArchInstruction *result; /* Instruction à renvoyer */ - uint16_t opcode; /* Champ 'opcode' à retrouver */ - - /** - * Suit les directives de : - * § A6.2.2 Data-processing - */ - - if ((raw & 0xfc00) != 0x4000) return NULL; - - result = NULL; - - opcode = (raw >> 6) & b1111; - - switch (opcode) - { - case b0000: - result = armv7_read_thumb_16_instr_and_register(raw); - break; - - case b0001: - result = armv7_read_thumb_16_instr_eor_register(raw); - break; - - case b0010: - result = armv7_read_thumb_16_instr_lsl_register(raw); - break; - - case b0011: - result = armv7_read_thumb_16_instr_lsr_register(raw); - break; - - case b0100: - result = armv7_read_thumb_16_instr_asr_register(raw); - break; - - case b0101: - result = armv7_read_thumb_16_instr_adc_register(raw); - break; - - case b0110: - result = armv7_read_thumb_16_instr_sbc_register(raw); - break; - - case b0111: - result = armv7_read_thumb_16_instr_ror_register(raw); - break; - - case b1000: - result = armv7_read_thumb_16_instr_tst_register(raw); - break; - - case b1001: - result = armv7_read_thumb_16_instr_rsb_immediate(raw); - break; - - case b1010: - result = armv7_read_thumb_16_instr_cmp_register(raw); - break; - - case b1011: - result = armv7_read_thumb_16_instr_cmn_register(raw); - break; - - case b1100: - result = armv7_read_thumb_16_instr_orr_register(raw); - break; - - case b1101: - result = armv7_read_thumb_16_instr_mul(raw); - break; - - case b1110: - result = armv7_read_thumb_16_instr_bic_register(raw); - break; - - case b1111: - result = armv7_read_thumb_16_instr_mvn_register(raw); - break; - - } - - return result; - -} - - -/****************************************************************************** -* * -* Paramètres : raw = donnée brute de 16 bits à désassembler. * -* * -* Description : Désassemble une instruction ARMv7 liées au chapitre A6.2.3. * -* * -* Retour : Instruction mise en place ou NULL en cas d'échec. * -* * -* Remarques : - * -* * -******************************************************************************/ - -static GArchInstruction *process_armv7_thumb_16_special_data_instructions_and_branch_and_exchange(uint16_t raw) -{ - GArchInstruction *result; /* Instruction à renvoyer */ - uint16_t opcode; /* Champ 'opcode' à retrouver */ - - /** - * Suit les directives de : - * § A6.2.3 Special data instructions and branch and exchange - */ - - if ((raw & 0xfc00) != 0x4400) return NULL; - - result = NULL; - - opcode = (raw >> 6) & b1111; - - if (opcode == b0000) - result = armv7_read_thumb_16_instr_add_register_thumb(raw); - - else if (opcode == b0001) - result = armv7_read_thumb_16_instr_add_register_thumb(raw); - - else if ((opcode & b1110) == b0010) - result = armv7_read_thumb_16_instr_add_register_thumb(raw); - - else if ((opcode & b1100) == b0100) - result = armv7_read_thumb_16_instr_cmp_register(raw); - - else if (opcode == b1000) - result = armv7_read_thumb_16_instr_mov_register_thumb(raw); - - else if (opcode == b1001) - result = armv7_read_thumb_16_instr_mov_register_thumb(raw); - - else if ((opcode & b1110) == b1010) - result = armv7_read_thumb_16_instr_mov_register_thumb(raw); - - else if ((opcode & b1110) == b1100) - result = armv7_read_thumb_16_instr_bx(raw); - - else if ((opcode & b1110) == b1110) - result = armv7_read_thumb_16_instr_blx_register(raw); - - return result; - -} - - -/****************************************************************************** -* * -* Paramètres : raw = donnée brute de 16 bits à désassembler. * -* * -* Description : Désassemble une instruction ARMv7 liées au chapitre A6.2.4. * -* * -* Retour : Instruction mise en place ou NULL en cas d'échec. * -* * -* Remarques : - * -* * -******************************************************************************/ - -static GArchInstruction *process_armv7_thumb_16_load_store_single_data_item(uint16_t raw) -{ - GArchInstruction *result; /* Instruction à renvoyer */ - uint16_t opa; /* Champ 'opa' à retrouver */ - uint16_t opb; /* Champ 'opb' à retrouver */ - - /** - * Suit les directives de : - * § A6.2.4 Load/store single data item - */ - - result = NULL; - - opa = (raw >> 12) & b1111; - opb = (raw >> 9) & b111; - - switch (opa) - { - case b0101: - switch (opb) - { - case b000: - result = armv7_read_thumb_16_instr_str_register(raw); - break; - - case b001: - result = armv7_read_thumb_16_instr_strh_register(raw); - break; - - case b010: - result = armv7_read_thumb_16_instr_strb_register(raw); - break; - - case b011: - result = armv7_read_thumb_16_instr_ldrsb_register(raw); - break; - - case b100: - result = armv7_read_thumb_16_instr_ldr_register_thumb(raw); - break; - - case b101: - result = armv7_read_thumb_16_instr_ldrh_register(raw); - break; - - case b110: - result = armv7_read_thumb_16_instr_ldrb_register(raw); - break; - - case b111: - result = armv7_read_thumb_16_instr_ldrsh_register(raw); - break; - - } - break; - - case b0110: - - if ((opb & b100) == b000) - result = armv7_read_thumb_16_instr_str_immediate_thumb(raw); - else /*if ((opb & b100) == b100)*/ - result = armv7_read_thumb_16_instr_ldr_immediate_thumb(raw); - - break; - - case b0111: - - if ((opb & b100) == b000) - result = armv7_read_thumb_16_instr_strb_immediate_thumb(raw); - else /*if ((opb & b100) == b100)*/ - result = armv7_read_thumb_16_instr_ldrb_immediate_thumb(raw); - - break; - - case b1000: - - if ((opb & b100) == b000) - result = armv7_read_thumb_16_instr_strh_immediate_thumb(raw); - else /*if ((opb & b100) == b100)*/ - result = armv7_read_thumb_16_instr_ldrh_immediate_thumb(raw); - - break; - - case b1001: - - if ((opb & b100) == b000) - result = armv7_read_thumb_16_instr_str_immediate_thumb(raw); - else /*if ((opb & b100) == b100)*/ - result = armv7_read_thumb_16_instr_ldr_immediate_thumb(raw); - - break; - - } - - return result; - -} - - -/****************************************************************************** -* * -* Paramètres : raw = donnée brute de 16 bits à désassembler. * -* * -* Description : Désassemble une instruction ARMv7 liées au chapitre A6.2.5. * -* * -* Retour : Instruction mise en place ou NULL en cas d'échec. * -* * -* Remarques : - * -* * -******************************************************************************/ - -static GArchInstruction *process_armv7_thumb_16_miscellaneous_16_bit_instructions(uint16_t raw) -{ - GArchInstruction *result; /* Instruction à renvoyer */ - uint16_t opcode; /* Champ 'opcode' à retrouver */ - - /** - * Suit les directives de : - * § A6.2.5 Miscellaneous 16-bit instructions - */ - - if ((raw & 0xf000) != 0xb000) return NULL; - - result = NULL; - - opcode = (raw >> 5) & b1111111; - - if ((opcode & b1111100) == b0000000) - result = armv7_read_thumb_16_instr_add_sp_plus_immediate(raw); - - else if ((opcode & b1111100) == b0000100) - result = armv7_read_thumb_16_instr_sub_sp_minus_immediate(raw); - - else if ((opcode & b1111000) == b0001000) - result = armv7_read_thumb_16_instr_cbnz_cbz(raw); - - else if ((opcode & b1111110) == b0010000) - result = armv7_read_thumb_16_instr_sxth(raw); - - else if ((opcode & b1111110) == b0010010) - result = armv7_read_thumb_16_instr_sxtb(raw); - - else if ((opcode & b1111110) == b0010100) - result = armv7_read_thumb_16_instr_uxth(raw); - - else if ((opcode & b1111110) == b0010110) - result = armv7_read_thumb_16_instr_uxtb(raw); - - else if ((opcode & b1111000) == b0011000) - result = armv7_read_thumb_16_instr_cbnz_cbz(raw); - - else if ((opcode & b1110000) == b0100000) - result = armv7_read_thumb_16_instr_push(raw); - - else if (opcode == b0110010) - result = armv7_read_thumb_16_instr_setend(raw); - - else if (opcode == b0110011) - result = armv7_read_thumb_16_instr_cps_thumb(raw); - - else if ((opcode & b1111000) == b1001000) - result = armv7_read_thumb_16_instr_cbnz_cbz(raw); - - else if ((opcode & b1111110) == b1010000) - result = armv7_read_thumb_16_instr_rev(raw); - - else if ((opcode & b1111110) == b1010010) - result = armv7_read_thumb_16_instr_rev16(raw); - - else if ((opcode & b1111110) == b1010110) - result = armv7_read_thumb_16_instr_revsh(raw); - - else if ((opcode & b1111000) == b1011000) - result = armv7_read_thumb_16_instr_cbnz_cbz(raw); - - else if ((opcode & b1110000) == b1100000) - result = armv7_read_thumb_16_instr_pop_thumb(raw); - - else if ((opcode & b1111000) == b1110000) - result = armv7_read_thumb_16_instr_bkpt(raw); - - else if ((opcode & b1111000) == b1111000) - result = process_armv7_thumb_16_miscellaneous_16_bit_instructions_if_then_and_hints(raw); - - return result; - -} - - -/****************************************************************************** -* * -* Paramètres : raw = donnée brute de 16 bits à désassembler. * -* * -* Description : Désassemble une instruction ARMv7 liées au chapitre A6.2.5.b.* -* * -* Retour : Instruction mise en place ou NULL en cas d'échec. * -* * -* Remarques : - * -* * -******************************************************************************/ - -static GArchInstruction *process_armv7_thumb_16_miscellaneous_16_bit_instructions_if_then_and_hints(uint16_t raw) -{ - GArchInstruction *result; /* Instruction à renvoyer */ - uint16_t opa; /* Champ 'opa' à retrouver */ - uint16_t opb; /* Champ 'opb' à retrouver */ - - /** - * Suit les directives de : - * § A6.2.5 Miscellaneous 16-bit instructions - * |-> If-Then, and hints - */ - - if ((raw & 0xff00) != 0xbf00) return NULL; - - result = NULL; - - opa = (raw >> 4) & b1111; - opb = (raw >> 0) & b1111; - - if (opb != b0000) - result = armv7_read_thumb_16_instr_it(raw); - - else - switch (opa) - { - case b0000: - result = armv7_read_thumb_16_instr_nop(raw); - break; - - case b0001: - result = armv7_read_thumb_16_instr_yield(raw); - break; - - case b0010: - result = armv7_read_thumb_16_instr_wfe(raw); - break; - - case b0011: - result = armv7_read_thumb_16_instr_wfi(raw); - break; - - case b0100: - result = armv7_read_thumb_16_instr_sev(raw); - break; - - } - - return result; - -} - - -/****************************************************************************** -* * -* Paramètres : raw = donnée brute de 16 bits à désassembler. * -* * -* Description : Désassemble une instruction ARMv7 liées au chapitre A6.2.6. * -* * -* Retour : Instruction mise en place ou NULL en cas d'échec. * -* * -* Remarques : - * -* * -******************************************************************************/ - -static GArchInstruction *process_armv7_thumb_16_conditional_branch_and_supervisor_call(uint16_t raw) -{ - GArchInstruction *result; /* Instruction à renvoyer */ - uint16_t opcode; /* Champ 'opcode' à retrouver */ - - /** - * Suit les directives de : - * § A6.2.6 Conditional branch, and Supervisor Call - */ - - if ((raw & 0xf000) != 0xd000) return NULL; - - result = NULL; - - opcode = (raw >> 8) & b1111; - - switch (opcode) - { - case b1110: - result = armv7_read_thumb_16_instr_udf(raw); - break; - - case b1111: - result = armv7_read_thumb_16_instr_svc_previously_swi(raw); - break; - - default: - result = armv7_read_thumb_16_instr_b(raw); - break; - - } - - return result; - -} diff --git a/src/arch/arm/v7/thumb_16.h b/src/arch/arm/v7/thumb_16.h deleted file mode 100644 index d75f490..0000000 --- a/src/arch/arm/v7/thumb_16.h +++ /dev/null @@ -1,37 +0,0 @@ - -/* Chrysalide - Outil d'analyse de fichiers binaires - * thumb_16.h - prototypes pour le désassemblage des instructions ARMv7 Thumb 16 bits - * - * Copyright (C) 2014-2017 Cyrille Bagard - * - * This file is part of Chrysalide. - * - * Chrysalide is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Chrysalide is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Foobar. If not, see . - */ - - -#ifndef _ARCH_ARM_V7_THUMB_16_H -#define _ARCH_ARM_V7_THUMB_16_H - - -#include "../../instruction.h" - - - -/* Désassemble une instruction ARMv7 liées au chapitre A6.2. */ -GArchInstruction *process_armv7_thumb_16_instruction_set_encoding(uint16_t); - - - -#endif /* _ARCH_ARM_V7_THUMB_16_H */ diff --git a/src/arch/arm/v7/thumb_32.c b/src/arch/arm/v7/thumb_32.c deleted file mode 100644 index f9de2e6..0000000 --- a/src/arch/arm/v7/thumb_32.c +++ /dev/null @@ -1,2268 +0,0 @@ - -/* Chrysalide - Outil d'analyse de fichiers binaires - * thumb_32.c - désassemblage des instructions ARMv7 Thumb 32 bits - * - * Copyright (C) 2014-2017 Cyrille Bagard - * - * This file is part of Chrysalide. - * - * Chrysalide is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Chrysalide is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Foobar. If not, see . - */ - - -#include "thumb_32.h" - - -#include - - -#include "simd.h" -#include "opcodes/thumb_32_opcodes.h" -#include "opcodes/opcodes_tmp_thumb_32.h" -#include "../../undefined.h" -#include "../../../common/bconst.h" - - - -/* Désassemble une instruction ARMv7 liées au chapitre A6.3.1. */ -static GArchInstruction *process_armv7_thumb_32_data_processing_modified_immediate(uint32_t); - -/* Désassemble une instruction ARMv7 liées au chapitre A6.3.3. */ -static GArchInstruction *process_armv7_thumb_32_data_processing_plain_binary_immediate(uint32_t); - -/* Désassemble une instruction ARMv7 liées au chapitre A6.3.4. */ -static GArchInstruction *process_armv7_thumb_32_branches_and_miscellaneous_control(uint32_t); - -/* Désassemble une instruction ARMv7 liées au chapitre A6.3.4b. */ -static GArchInstruction *process_armv7_thumb_32_change_processor_state_and_hints(uint32_t); - -/* Désassemble une instruction ARMv7 liées au chapitre A6.3.4t. */ -static GArchInstruction *process_armv7_thumb_32_miscellaneous_control_instructions(uint32_t); - -/* Désassemble une instruction ARMv7 liées au chapitre A6.3.5. */ -static GArchInstruction *process_armv7_thumb_32_load_store_multiple(uint32_t); - -/* Désassemble une instruction ARMv7 liées au chapitre A6.3.6. */ -static GArchInstruction *process_armv7_thumb_32_load_store_dual_load_store_exclusive_table_branch(uint32_t); - -/* Désassemble une instruction ARMv7 liées au chapitre A6.3.7. */ -static GArchInstruction *process_armv7_thumb_32_load_word(uint32_t); - -/* Désassemble une instruction ARMv7 liées au chapitre A6.3.8. */ -static GArchInstruction *process_armv7_thumb_32_load_halfword_memory_hints(uint32_t); - -/* Désassemble une instruction ARMv7 liées au chapitre A6.3.9. */ -static GArchInstruction *process_armv7_thumb_32_load_byte_memory_hints(uint32_t); - -/* Désassemble une instruction ARMv7 liées au chapitre A6.3.10. */ -static GArchInstruction *process_armv7_thumb_32_store_single_data_item(uint32_t); - -/* Désassemble une instruction ARMv7 liées au chapitre A6.3.11. */ -static GArchInstruction *process_armv7_thumb_32_data_processing_shifted_register(uint32_t); - -/* Désassemble une instruction ARMv7 liées au chapitre A6.3.11b. */ -static GArchInstruction *process_armv7_thumb_32_move_register_and_immediate_shifts(uint32_t); - -/* Désassemble une instruction ARMv7 liées au chapitre A6.3.12. */ -static GArchInstruction *process_armv7_thumb_32_data_processing_register(uint32_t); - -/* Désassemble une instruction ARMv7 liées au chapitre A6.3.13. */ -static GArchInstruction *process_armv7_thumb_32_parallel_addition_and_subtraction_signed(uint32_t); - -/* Désassemble une instruction ARMv7 liées au chapitre A6.3.14. */ -static GArchInstruction *process_armv7_thumb_32_parallel_addition_and_subtraction_unsigned(uint32_t); - -/* Désassemble une instruction ARMv7 liées au chapitre A6.3.15. */ -static GArchInstruction *process_armv7_thumb_32_miscellaneous_operations(uint32_t); - -/* Désassemble une instruction ARMv7 liées au chapitre A6.3.16. */ -static GArchInstruction *process_armv7_thumb_32_multiply_multiply_accumulate_and_absolute_difference(uint32_t); - -/* Désassemble une instruction ARMv7 liées au chapitre A6.3.17. */ -static GArchInstruction *process_armv7_thumb_32_long_multiply_long_multiply_accumulate_and_divide(uint32_t); - -/* Désassemble une instruction ARMv7 liées au chapitre A6.3.18. */ -static GArchInstruction *process_armv7_thumb_32_coprocessor_advanced_simd_and_floating_point_instructions(uint32_t); - - - -/****************************************************************************** -* * -* Paramètres : raw = donnée brute de 32 bits à désassembler. * -* * -* Description : Désassemble une instruction ARMv7 liées au chapitre A6.3. * -* * -* Retour : Instruction mise en place ou NULL en cas d'échec. * -* * -* Remarques : - * -* * -******************************************************************************/ - -GArchInstruction *process_armv7_thumb_32_instruction_set_encoding(uint32_t raw) -{ - GArchInstruction *result; /* Instruction à renvoyer */ - uint32_t op1; /* Champ 'op1' à retrouver */ - uint32_t op2; /* Champ 'op2' à retrouver */ - uint32_t op; /* Champ 'op' à retrouver */ - - /** - * Suit les directives de : - * § A6.3 32-bit Thumb instruction encoding - */ - - if (((raw >> 29) & b111) != b111) return NULL; - - result = NULL; - - op1 = (raw >> 27) & b11; - op2 = (raw >> 20) & b1111111; - op = (raw >> 15) & b1; - - switch (op1) - { - case b01: - - if ((op2 & b1100100) == b0000000) - result = process_armv7_thumb_32_load_store_multiple(raw); - - else if ((op2 & b1100100) == b0000100) - result = process_armv7_thumb_32_load_store_dual_load_store_exclusive_table_branch(raw); - - else if ((op2 & b1100000) == b0100000) - result = process_armv7_thumb_32_data_processing_shifted_register(raw); - - else if ((op2 & b1000000) == b1000000) - result = process_armv7_thumb_32_coprocessor_advanced_simd_and_floating_point_instructions(raw); - - break; - - case b10: - - if (op == 1) - result = process_armv7_thumb_32_branches_and_miscellaneous_control(raw); - - else - { - if ((op2 & b0100000) == b0000000) - result = process_armv7_thumb_32_data_processing_modified_immediate(raw); - - else if ((op2 & b0100000) == b0100000) - result = process_armv7_thumb_32_data_processing_plain_binary_immediate(raw); - - } - - break; - - case b11: - - if ((op2 & b1110001) == b0000000) - result = process_armv7_thumb_32_store_single_data_item(raw); - - else if ((op2 & b1100111) == b0000001) - result = process_armv7_thumb_32_load_byte_memory_hints(raw); - - else if ((op2 & b1100111) == b0000011) - result = process_armv7_thumb_32_load_halfword_memory_hints(raw); - - else if ((op2 & b1100111) == b0000101) - result = process_armv7_thumb_32_load_word(raw); - - else if ((op2 & b1100111) == b0000111) - result = g_undef_instruction_new(IBS_UNDEFINED); - - else if ((op2 & b1110001) == b0010000) - result = process_armv7_simd_advanced_simd_element_or_structure_load_store_instructions(raw, false); - - else if ((op2 & b1110000) == b0100000) - result = process_armv7_thumb_32_data_processing_register(raw); - - else if ((op2 & b1111000) == b0110000) - result = process_armv7_thumb_32_multiply_multiply_accumulate_and_absolute_difference(raw); - - else if ((op2 & b1111000) == b0111000) - result = process_armv7_thumb_32_long_multiply_long_multiply_accumulate_and_divide(raw); - - else if ((op2 & b1000000) == b1000000) - result = process_armv7_thumb_32_coprocessor_advanced_simd_and_floating_point_instructions(raw); - - break; - - } - - return result; - -} - - -/****************************************************************************** -* * -* Paramètres : raw = donnée brute de 32 bits à désassembler. * -* * -* Description : Désassemble une instruction ARMv7 liées au chapitre A6.3.1. * -* * -* Retour : Instruction mise en place ou NULL en cas d'échec. * -* * -* Remarques : - * -* * -******************************************************************************/ - -static GArchInstruction *process_armv7_thumb_32_data_processing_modified_immediate(uint32_t raw) -{ - GArchInstruction *result; /* Instruction à renvoyer */ - uint32_t op; /* Champ 'op' à retrouver */ - uint32_t rn; /* Champ 'rn' à retrouver */ - uint32_t rds; /* Champ 'rds' à retrouver */ - - /** - * Suit les directives de : - * § A6.3.1 Data-processing (modified immediate) - */ - - if ((raw & 0xfa008000) != 0xf0000000) return NULL; - - result = NULL; - - op = (raw >> 21) & b1111; - rn = (raw >> 16) & b1111; - rds = (((raw >> 8) & b1111) << 1) | ((raw >> 20) & b1); - - switch (op) - { - case b0000: - - if (rds == b11111) - result = armv7_read_thumb_32_instr_tst_immediate(raw); - - else - result = armv7_read_thumb_32_instr_and_immediate(raw); - - break; - - case b0001: - result = armv7_read_thumb_32_instr_bic_immediate(raw); - break; - - case b0010: - - if (rn == b1111) - result = armv7_read_thumb_32_instr_mov_immediate(raw); - - else - result = armv7_read_thumb_32_instr_orr_immediate(raw); - - break; - - case b0011: - - if (rn == b1111) - result = armv7_read_thumb_32_instr_mvn_immediate(raw); - - else - result = armv7_read_thumb_32_instr_orn_immediate(raw); - - break; - - case b0100: - - if (rds == b11111) - result = armv7_read_thumb_32_instr_teq_immediate(raw); - - else - result = armv7_read_thumb_32_instr_eor_immediate(raw); - - break; - - case b1000: - - if (rds == b11111) - result = armv7_read_thumb_32_instr_cmn_immediate(raw); - - else - result = armv7_read_thumb_32_instr_add_immediate_thumb(raw); - - break; - - case b1010: - result = armv7_read_thumb_32_instr_adc_immediate(raw); - break; - - case b1011: - result = armv7_read_thumb_32_instr_sbc_immediate(raw); - break; - - case b1101: - - if (rds == b11111) - result = armv7_read_thumb_32_instr_cmp_immediate(raw); - - else - result = armv7_read_thumb_32_instr_sub_immediate_thumb(raw); - - break; - - case b1110: - result = armv7_read_thumb_32_instr_rsb_immediate(raw); - break; - - } - - return result; - -} - - -/****************************************************************************** -* * -* Paramètres : raw = donnée brute de 32 bits à désassembler. * -* * -* Description : Désassemble une instruction ARMv7 liées au chapitre A6.3.3. * -* * -* Retour : Instruction mise en place ou NULL en cas d'échec. * -* * -* Remarques : - * -* * -******************************************************************************/ - -static GArchInstruction *process_armv7_thumb_32_data_processing_plain_binary_immediate(uint32_t raw) -{ - GArchInstruction *result; /* Instruction à renvoyer */ - uint32_t op; /* Champ 'op' à retrouver */ - uint32_t rn; /* Champ 'rn' à retrouver */ - - /** - * Suit les directives de : - * § A6.3.3 Data-processing (plain binary immediate) - */ - - if ((raw & 0xfa008000) != 0xf2000000) return NULL; - - result = NULL; - - op = (raw >> 20) & b11111; - rn = (raw >> 16) & b1111; - - switch (op) - { - case b00000: - - if (rn == b1111) - result = armv7_read_thumb_32_instr_adr(raw); - - else - result = armv7_read_thumb_32_instr_add_immediate_thumb(raw); - - break; - - case b00100: - result = armv7_read_thumb_32_instr_mov_immediate(raw); - break; - - case b01010: - - if (rn == b11111) - result = armv7_read_thumb_32_instr_adr(raw); - - else - result = armv7_read_thumb_32_instr_sub_immediate_thumb(raw); - - break; - - case b01100: - result = armv7_read_thumb_32_instr_movt(raw); - break; - - case b10000: - result = armv7_read_thumb_32_instr_ssat(raw); - break; - - case b10010: - - if ((raw & 0x000070c0) != 0) - result = armv7_read_thumb_32_instr_ssat(raw); - - else - result = armv7_read_thumb_32_instr_ssat16(raw); - - break; - - case b10100: - result = armv7_read_thumb_32_instr_sbfx(raw); - break; - - case b10110: - - if (rn == b11111) - result = armv7_read_thumb_32_instr_bfc(raw); - - else - result = armv7_read_thumb_32_instr_bfi(raw); - - break; - - case b11000: - result = armv7_read_thumb_32_instr_usat(raw); - break; - - case b11010: - - if ((raw & 0x000070c0) != 0) - result = armv7_read_thumb_32_instr_usat(raw); - - else - result = armv7_read_thumb_32_instr_usat16(raw); - - break; - - case b11100: - result = armv7_read_thumb_32_instr_ubfx(raw); - break; - - } - - return result; - -} - - -/****************************************************************************** -* * -* Paramètres : raw = donnée brute de 32 bits à désassembler. * -* * -* Description : Désassemble une instruction ARMv7 liées au chapitre A6.3.4. * -* * -* Retour : Instruction mise en place ou NULL en cas d'échec. * -* * -* Remarques : - * -* * -******************************************************************************/ - -static GArchInstruction *process_armv7_thumb_32_branches_and_miscellaneous_control(uint32_t raw) -{ - GArchInstruction *result; /* Instruction à renvoyer */ - uint32_t op; /* Champ 'op' à retrouver */ - uint32_t op1; /* Champ 'op1' à retrouver */ - uint32_t op2; /* Champ 'op2' à retrouver */ - uint32_t imm8; /* Champ 'imm8' à retrouver */ - - /** - * Suit les directives de : - * § A6.3.4 Branches and miscellaneous control - */ - - if ((raw & 0xf8000000) != 0xf0000000) return NULL; - - result = NULL; - - op = (raw >> 20) & b1111111; - op1 = (raw >> 12) & b111; - op2 = (raw >> 8) & b1111; - imm8 = (raw >> 0) & b11111111; - - if (op1 == b000 && op == b1111110) - result = armv7_read_thumb_32_instr_hvc(raw); - - else if (op1 == b000 && op == b1111111) - result = armv7_read_thumb_32_instr_smc_previously_smi(raw); - - else if ((op1 & b101) == b000) - { - if ((op & b0111000) != b0111000) - result = armv7_read_thumb_32_instr_b(raw); - - else if ((imm8 & b00100000) == b00100000 && (op & b1111110) == b0111000) - result = armv7_read_thumb_32_instr_msr_banked_register(raw); - - else if ((imm8 & b00100000) == b00000000 && op == b0111000 && (op2 & b0011) == b0000) - result = armv7_read_thumb_32_instr_msr_register(raw); - - else if ((imm8 & b00100000) == b00000000 && op == b0111000 && (op2 & b0011) == b0001) - result = armv7_read_thumb_32_instr_b_msr_register(raw); - - else if ((imm8 & b00100000) == b00000000 && op == b0111000 && (op2 & b0010) == b0010) - result = armv7_read_thumb_32_instr_b_msr_register(raw); - - else if ((imm8 & b00100000) == b00000000 && op == b0111001) - result = armv7_read_thumb_32_instr_b_msr_register(raw); - - else if (op == b0111010) - result = process_armv7_thumb_32_change_processor_state_and_hints(raw); - - else if (op == b0111011) - result = process_armv7_thumb_32_miscellaneous_control_instructions(raw); - - else if (op == b0111100) - result = armv7_read_thumb_32_instr_bxj(raw); - - else if (imm8 == b00000000 && op == b0111101) - result = armv7_read_thumb_32_instr_eret(raw); - - else if (imm8 != b00000000 && op == b0111101) - result = armv7_read_thumb_32_instr_subs_pc_lr_thumb(raw); - - else if ((imm8 & b00100000) == b00100000 && (op & b1111110) == b0111110) - result = armv7_read_thumb_32_instr_mrs_banked_register(raw); - - else if ((imm8 & b00100000) == b00000000 && op == b0111110) - result = armv7_read_thumb_32_instr_mrs(raw); - - else if ((imm8 & b00100000) == b00000000 && op == b0111111) - result = armv7_read_thumb_32_instr_b_mrs(raw); - - } - - else if ((op1 & b101) == b001) - result = armv7_read_thumb_32_instr_b(raw); - - else if (op1 == b010 && op == b1111111) - result = armv7_read_thumb_32_instr_udf(raw); - - else if ((op1 & b101) == b100) - result = armv7_read_thumb_32_instr_bl_blx_immediate(raw); - - else if ((op1 & b101) == b101) - result = armv7_read_thumb_32_instr_bl_blx_immediate(raw); - - return result; - -} - - -/****************************************************************************** -* * -* Paramètres : raw = donnée brute de 32 bits à désassembler. * -* * -* Description : Désassemble une instruction ARMv7 classique. * -* * -* Retour : Désassemble une instruction ARMv7 liées au chapitre A6.3.4b. * -* * -* Remarques : - * -* * -******************************************************************************/ - -static GArchInstruction *process_armv7_thumb_32_change_processor_state_and_hints(uint32_t raw) -{ - GArchInstruction *result; /* Instruction à renvoyer */ - uint32_t op1; /* Champ 'op1' à retrouver */ - uint32_t op2; /* Champ 'op2' à retrouver */ - - /** - * Suit les directives de : - * § A6.3.4 Branches and miscellaneous control - * |-> Change Processor State, and hints - */ - - if ((raw & 0xfff0d000) != 0xf3a08000) return NULL; - - result = NULL; - - op1 = (raw >> 8) & b111; - op2 = (raw >> 0) & b11111111; - - if (op1 != b000) - result = armv7_read_thumb_32_instr_cps_thumb(raw); - - else - { - if (op2 == b00000000) - result = armv7_read_thumb_32_instr_nop(raw); - - else if (op2 == b00000001) - result = armv7_read_thumb_32_instr_yield(raw); - - else if (op2 == b00000010) - result = armv7_read_thumb_32_instr_wfe(raw); - - else if (op2 == b00000011) - result = armv7_read_thumb_32_instr_wfi(raw); - - else if (op2 == b00000100) - result = armv7_read_thumb_32_instr_sev(raw); - - else if ((op2 & b11110000) == b11110000) - result = armv7_read_thumb_32_instr_dbg(raw); - - } - - return result; - -} - - -/****************************************************************************** -* * -* Paramètres : raw = donnée brute de 32 bits à désassembler. * -* * -* Description : Désassemble une instruction ARMv7 liées au chapitre A6.3.4t. * -* * -* Retour : Instruction mise en place ou NULL en cas d'échec. * -* * -* Remarques : - * -* * -******************************************************************************/ - -static GArchInstruction *process_armv7_thumb_32_miscellaneous_control_instructions(uint32_t raw) -{ - GArchInstruction *result; /* Instruction à renvoyer */ - uint32_t op; /* Champ 'op' à retrouver */ - - /** - * Suit les directives de : - * § A6.3.4 Branches and miscellaneous control - * |-> Miscellaneous control instructions - */ - - if ((raw & 0xfff0d000) != 0xf3b08000) return NULL; - - result = NULL; - - op = (raw >> 4) & b1111; - - switch (op) - { - case b0000: - result = armv7_read_thumb_32_instr_enterx_leavex(raw); - break; - - case b0001: - result = armv7_read_thumb_32_instr_enterx_leavex(raw); - break; - - case b0010: - result = armv7_read_thumb_32_instr_clrex(raw); - break; - - case b0100: - result = armv7_read_thumb_32_instr_dsb(raw); - break; - - case b0101: - result = armv7_read_thumb_32_instr_dmb(raw); - break; - - case b0110: - result = armv7_read_thumb_32_instr_isb(raw); - break; - - } - - return result; - -} - - -/****************************************************************************** -* * -* Paramètres : raw = donnée brute de 32 bits à désassembler. * -* * -* Description : Désassemble une instruction ARMv7 liées au chapitre A6.3.5. * -* * -* Retour : Instruction mise en place ou NULL en cas d'échec. * -* * -* Remarques : - * -* * -******************************************************************************/ - -static GArchInstruction *process_armv7_thumb_32_load_store_multiple(uint32_t raw) -{ - GArchInstruction *result; /* Instruction à renvoyer */ - uint32_t op; /* Champ 'op' à retrouver */ - uint32_t l; /* Champ 'l' à retrouver */ - uint32_t wrn; /* Champ 'wrn' à retrouver */ - - /** - * Suit les directives de : - * § A6.3.5 Load/store multiple - */ - - if ((raw & 0xfe400000) != 0xe8000000) return NULL; - - result = NULL; - - op = (raw >> 23) & b11; - l = (raw >> 20) & b1; - wrn = (((raw >> 21) & b1) << 4) | ((raw >> 16) & b1111); - - switch (op) - { - case b00: - - if (l == b0) - result = armv7_read_thumb_32_instr_srs_thumb(raw); - - else - result = armv7_read_thumb_32_instr_rfe(raw); - - break; - - case b01: - - if (l == b0) - result = armv7_read_thumb_32_instr_stm_stmia_stmea(raw); - - else - { - if (wrn == b11101) - result = armv7_read_thumb_32_instr_pop_thumb(raw); - - else - result = armv7_read_thumb_32_instr_ldm_ldmia_ldmfd_thumb(raw); - - } - - break; - - case b10: - - if (l == b0) - { - if (wrn == b11101) - result = armv7_read_thumb_32_instr_push(raw); - - else - result = armv7_read_thumb_32_instr_stmdb_stmfd(raw); - - } - - else - result = armv7_read_thumb_32_instr_ldmdb_ldmea(raw); - - break; - - case b11: - - if (l == b0) - result = armv7_read_thumb_32_instr_srs_thumb(raw); - - else - result = armv7_read_thumb_32_instr_rfe(raw); - - break; - - } - - return result; - -} - - -/****************************************************************************** -* * -* Paramètres : raw = donnée brute de 32 bits à désassembler. * -* * -* Description : Désassemble une instruction ARMv7 liées au chapitre A6.3.6. * -* * -* Retour : Instruction mise en place ou NULL en cas d'échec. * -* * -* Remarques : - * -* * -******************************************************************************/ - -static GArchInstruction *process_armv7_thumb_32_load_store_dual_load_store_exclusive_table_branch(uint32_t raw) -{ - GArchInstruction *result; /* Instruction à renvoyer */ - uint32_t op1; /* Champ 'op1' à retrouver */ - uint32_t op2; /* Champ 'op2' à retrouver */ - uint32_t rn; /* Champ 'rn' à retrouver */ - uint32_t op3; /* Champ 'op3' à retrouver */ - - /** - * Suit les directives de : - * § A6.3.6 Load/store dual, load/store exclusive, table branch - */ - - if ((raw & 0xfe400000) != 0xe8400000) return NULL; - - result = NULL; - - op1 = (raw >> 23) & 0x3; - op2 = (raw >> 20) & 0x3; - rn = (raw >> 16) & 0xf; - op3 = (raw >> 4) & 0xf; - - if (op1 == b00 && op2 == b00) - result = armv7_read_thumb_32_instr_strex(raw); - - else if (op1 == b00 && op2 == b01) - result = armv7_read_thumb_32_instr_ldrex(raw); - - else if ((op1 & b10) == b00 && op2 == b10) - result = armv7_read_thumb_32_instr_strd_immediate(raw); - - else if ((op1 & b10) == b10 && (op2 & b01) == b00) - result = armv7_read_thumb_32_instr_strd_immediate(raw); - - else if ((op1 & b10) == b00 && op2 == b11) - { - if (rn != b1111) - result = armv7_read_thumb_32_instr_ldrd_immediate(raw); - - else/* if (rn == b1111)*/ - result = armv7_read_thumb_32_instr_ldrd_literal(raw); - - } - - else if ((op1 & b10) == b10 && (op2 & b01) == b01) - { - if (rn != b1111) - result = armv7_read_thumb_32_instr_ldrd_immediate(raw); - - else/* if (rn == b1111)*/ - result = armv7_read_thumb_32_instr_ldrd_literal(raw); - - } - - else if (op1 == b01 && op2 == b00) - switch (op3) - { - case b0100: - result = armv7_read_thumb_32_instr_strexb(raw); - break; - - case b0101: - result = armv7_read_thumb_32_instr_strexh(raw); - break; - - case b0111: - result = armv7_read_thumb_32_instr_strexd(raw); - break; - - } - - else if (op1 == b01 && op2 == b01) - switch (op3) - { - case b0000: - result = armv7_read_thumb_32_instr_tbb_tbh(raw); - break; - - case b0001: - result = armv7_read_thumb_32_instr_tbb_tbh(raw); - break; - - case b0100: - result = armv7_read_thumb_32_instr_ldrexb(raw); - break; - - case b0101: - result = armv7_read_thumb_32_instr_ldrexh(raw); - break; - - case b0111: - result = armv7_read_thumb_32_instr_ldrexd(raw); - break; - - } - - return result; - -} - - -/****************************************************************************** -* * -* Paramètres : raw = donnée brute de 32 bits à désassembler. * -* * -* Description : Désassemble une instruction ARMv7 liées au chapitre A6.3.7. * -* * -* Retour : Instruction mise en place ou NULL en cas d'échec. * -* * -* Remarques : - * -* * -******************************************************************************/ - -static GArchInstruction *process_armv7_thumb_32_load_word(uint32_t raw) -{ - GArchInstruction *result; /* Instruction à renvoyer */ - uint32_t op1; /* Champ 'op1' à retrouver */ - uint32_t rn; /* Champ 'rn' à retrouver */ - uint32_t op2; /* Champ 'op2' à retrouver */ - - /** - * Suit les directives de : - * § A6.3.7 Load word - */ - - if ((raw & 0xfe700000) != 0xf8500000) return NULL; - - result = NULL; - - op1 = (raw >> 23) & b11; - rn = (raw >> 16) & b1111; - op2 = (raw >> 6) & b111111; - - switch (op1) - { - case b00: - - if (op2 == b000000 && rn != b1111) - result = armv7_read_thumb_32_instr_ldr_register_thumb(raw); - - else if ((op2 & b100100) == b100100 && rn != b1111) - result = armv7_read_thumb_32_instr_ldr_immediate_thumb(raw); - - else if ((op2 & b111100) == b110000 && rn != b1111) - result = armv7_read_thumb_32_instr_ldr_immediate_thumb(raw); - - else if ((op2 & b111100) == b111000 && rn != b1111) - result = armv7_read_thumb_32_instr_ldrt(raw); - - break; - - case b01: - if (rn != b1111) - result = armv7_read_thumb_32_instr_ldr_immediate_thumb(raw); - break; - - } - - if (result == NULL && (op1 & b10) == b00 && rn == b1111) - result = armv7_read_thumb_32_instr_ldr_literal(raw); - - return result; - -} - - -/****************************************************************************** -* * -* Paramètres : raw = donnée brute de 32 bits à désassembler. * -* * -* Description : Désassemble une instruction ARMv7 liées au chapitre A6.3.8. * -* * -* Retour : Instruction mise en place ou NULL en cas d'échec. * -* * -* Remarques : - * -* * -******************************************************************************/ - -static GArchInstruction *process_armv7_thumb_32_load_halfword_memory_hints(uint32_t raw) -{ - GArchInstruction *result; /* Instruction à renvoyer */ - uint32_t op1; /* Champ 'op1' à retrouver */ - uint32_t rn; /* Champ 'rn' à retrouver */ - uint32_t rt; /* Champ 'rt' à retrouver */ - uint32_t op2; /* Champ 'op2' à retrouver */ - - /** - * Suit les directives de : - * § A6.3.8 Load halfword, memory hints - */ - - if ((raw & 0xfe700000) != 0xf8300000) return NULL; - - result = NULL; - - op1 = (raw >> 23) & 0x3; - rn = (raw >> 16) & 0xf; - rt = (raw >> 12) & 0xf; - op2 = (raw >> 6) & 0x3f; - - if (rn == b1111) - { - if ((op1 & b10) == b00) - { - if (rt != b1111) - result = armv7_read_thumb_32_instr_ldrh_literal(raw); - - else/* if (rt == b1111)*/ - result = armv7_read_thumb_32_instr_pld_literal(raw); - - } - - else/* if ((op1 & b10) == b10)*/ - { - if (rt != b1111) - result = armv7_read_thumb_32_instr_ldrsh_literal(raw); - - else/* if (rt == b1111)*/ - result = g_undef_instruction_new(IBS_NOP); - - } - - } - - else/* if (rn != b1111)*/ - { - if (op1 == b00) - { - if ((op2 & b100100) == b100100) - result = armv7_read_thumb_32_instr_ldrh_immediate_thumb(raw); - - else if ((op2 & b111100) == b110000 && rt != b1111) - result = armv7_read_thumb_32_instr_ldrh_immediate_thumb(raw); - - else if (op2 == b000000 && rt != b1111) - result = armv7_read_thumb_32_instr_ldrh_register(raw); - - else if ((op2 & b111100) == b111000) - result = armv7_read_thumb_32_instr_ldrht(raw); - - else if (op2 == b000000 && rt == b1111) - result = armv7_read_thumb_32_instr_pld_pldw_register(raw); - - else if ((op2 & b111100) == b110000 && rt == b1111) - result = armv7_read_thumb_32_instr_pld_pldw_immediate(raw); - - } - - else if (op1 == b01) - { - if (rt != b1111) - result = armv7_read_thumb_32_instr_ldrh_immediate_thumb(raw); - - else/* if (rt == b1111)*/ - result = armv7_read_thumb_32_instr_pld_pldw_immediate(raw); - - } - - else if (op1 == b10) - { - if ((op2 & b100100) == b100100) - result = armv7_read_thumb_32_instr_ldrsh_immediate(raw); - - else if ((op2 & b111100) == b110000 && rt != b1111) - result = armv7_read_thumb_32_instr_ldrsh_immediate(raw); - - else if (op2 == b000000 && rt != b1111) - result = armv7_read_thumb_32_instr_ldrsh_register(raw); - - else if ((op2 & b111100) == b111000) - result = armv7_read_thumb_32_instr_ldrsht(raw); - - else if (op2 == b000000 && rt == b1111) - result = g_undef_instruction_new(IBS_NOP); - - else if ((op2 & b111100) == b110000 && rt == b1111) - result = g_undef_instruction_new(IBS_NOP); - - } - - else if (op1 == b11) - { - if (rt != b1111) - result = armv7_read_thumb_32_instr_ldrsh_immediate(raw); - - else/* if (rt == b1111)*/ - result = g_undef_instruction_new(IBS_NOP); - - } - - } - - return result; - -} - - -/****************************************************************************** -* * -* Paramètres : raw = donnée brute de 32 bits à désassembler. * -* * -* Description : Désassemble une instruction ARMv7 liées au chapitre A6.3.9. * -* * -* Retour : Instruction mise en place ou NULL en cas d'échec. * -* * -* Remarques : - * -* * -******************************************************************************/ - -static GArchInstruction *process_armv7_thumb_32_load_byte_memory_hints(uint32_t raw) -{ - GArchInstruction *result; /* Instruction à renvoyer */ - uint32_t op1; /* Champ 'op1' à retrouver */ - uint32_t rn; /* Champ 'rn' à retrouver */ - uint32_t rt; /* Champ 'rt' à retrouver */ - uint32_t op2; /* Champ 'op2' à retrouver */ - - /** - * Suit les directives de : - * § A6.3.9 Load byte, memory hints - */ - - if ((raw & 0xfe700000) != 0xf8100000) return NULL; - - result = NULL; - - op1 = (raw >> 23) & b11; - rn = (raw >> 16) & b1111; - rt = (raw >> 12) & b1111; - op2 = (raw >> 6) & b111111; - - if (op1 == b00 && op2 == b000000 && rn != b1111) - { - if (rt != b1111) - result = armv7_read_thumb_32_instr_ldrb_register(raw); - - else /*if (rt == b1111) */ - result = armv7_read_thumb_32_instr_pld_register(raw); - - } - - else if ((op1 & b10) == b00 && rn == b1111) - { - if (rt != b1111) - result = armv7_read_thumb_32_instr_ldrb_literal(raw); - - else /*if (rt == b1111) */ - result = armv7_read_thumb_32_instr_pld_literal(raw); - - } - - else if (op1 == b00 && (op2 & b100100) == b100100 && rn != b1111) - result = armv7_read_thumb_32_instr_ldrb_immediate_thumb(raw); - - else if (op1 == b00 && (op2 & b111100) == b110000 && rn != b1111) - { - if (rt != b1111) - result = armv7_read_thumb_32_instr_ldrb_immediate_thumb(raw); - - else /*if (rt == b1111) */ - result = armv7_read_thumb_32_instr_pld_immediate(raw); - - } - - else if (op1 == b00 && (op2 & b111100) == b111000 && rn != b1111) - result = armv7_read_thumb_32_instr_ldrbt(raw); - - else if (op1 == b01 && rn != b1111) - { - if (rt != b1111) - result = armv7_read_thumb_32_instr_ldrb_immediate_thumb(raw); - - else /*if (rt == b1111) */ - result = armv7_read_thumb_32_instr_pld_immediate(raw); - - } - - if (op1 == b10 && op2 == b000000 && rn != b1111) - { - if (rt != b1111) - result = armv7_read_thumb_32_instr_ldrsb_register(raw); - else /*if (rt == b1111) */ - result = armv7_read_thumb_32_instr_pli_register(raw); - } - - else if ((op1 & b10) == b10 && rn == b1111) - { - if (rt != b1111) - result = armv7_read_thumb_32_instr_ldrsb_literal(raw); - - else /*if (rt == b1111) */ - result = armv7_read_thumb_32_instr_pli_immediate_literal(raw); - - } - - else if (op1 == b10 && (op2 & b100100) == b100100 && rn != b1111) - result = armv7_read_thumb_32_instr_ldrsb_immediate(raw); - - else if (op1 == b10 && (op2 & b111100) == b110000 && rn != b1111) - { - if (rt != b1111) - result = armv7_read_thumb_32_instr_ldrsb_immediate(raw); - - else /*if (rt == b1111) */ - result = armv7_read_thumb_32_instr_pli_immediate_literal(raw); - - } - - else if (op1 == b10 && (op2 & b111100) == b111000 && rn != b1111) - result = armv7_read_thumb_32_instr_ldrsbt(raw); - - else if (op1 == b11 && rn != b1111) - { - if (rt != b1111) - result = armv7_read_thumb_32_instr_ldrsb_immediate(raw); - - else /*if (rt == b1111) */ - result = armv7_read_thumb_32_instr_pli_immediate_literal(raw); - - } - - return result; - -} - - -/****************************************************************************** -* * -* Paramètres : raw = donnée brute de 32 bits à désassembler. * -* * -* Description : Désassemble une instruction ARMv7 liées au chapitre A6.3.10. * -* * -* Retour : Instruction mise en place ou NULL en cas d'échec. * -* * -* Remarques : - * -* * -******************************************************************************/ - -static GArchInstruction *process_armv7_thumb_32_store_single_data_item(uint32_t raw) -{ - GArchInstruction *result; /* Instruction à renvoyer */ - uint32_t op1; /* Champ 'op1' à retrouver */ - uint32_t op2; /* Champ 'op2' à retrouver */ - - /** - * Suit les directives de : - * § A6.3.10 Store single data item - */ - - if ((raw & 0xff100000) != 0xf8000000) return NULL; - - result = NULL; - - op1 = (raw >> 21) & b111; - op2 = (raw >> 6) & b111111; - - switch (op1) - { - case b000: - - if (op2 == b000000) - result = armv7_read_thumb_32_instr_strb_register(raw); - - else if ((op2 & b100100) == b100100) - result = armv7_read_thumb_32_instr_strb_immediate_thumb(raw); - - else if ((op2 & b111100) == b110000) - result = armv7_read_thumb_32_instr_strb_immediate_thumb(raw); - - else if ((op2 & b111100) == b111000) - result = armv7_read_thumb_32_instr_strbt(raw); - - break; - - case b001: - - if (op2 == b000000) - result = armv7_read_thumb_32_instr_strh_register(raw); - - else if ((op2 & b100100) == b100100) - result = armv7_read_thumb_32_instr_strh_immediate_thumb(raw); - - else if ((op2 & b111100) == b110000) - result = armv7_read_thumb_32_instr_strh_immediate_thumb(raw); - - else if ((op2 & b111100) == b111000) - result = armv7_read_thumb_32_instr_strht(raw); - - break; - - case b010: - - if (op2 == b000000) - result = armv7_read_thumb_32_instr_str_register(raw); - - else if ((op2 & b100100) == b100100) - result = armv7_read_thumb_32_instr_str_immediate_thumb(raw); - - else if ((op2 & b111100) == b110000) - result = armv7_read_thumb_32_instr_str_immediate_thumb(raw); - - else if ((op2 & b111100) == b111000) - result = armv7_read_thumb_32_instr_strt(raw); - - break; - - case b100: - result = armv7_read_thumb_32_instr_strb_immediate_thumb(raw); - break; - - case b101: - result = armv7_read_thumb_32_instr_strh_immediate_thumb(raw); - break; - - case b110: - result = armv7_read_thumb_32_instr_str_immediate_thumb(raw); - break; - - } - - return result; - -} - - -/****************************************************************************** -* * -* Paramètres : raw = donnée brute de 32 bits à désassembler. * -* * -* Description : Désassemble une instruction ARMv7 liées au chapitre A6.3.11. * -* * -* Retour : Instruction mise en place ou NULL en cas d'échec. * -* * -* Remarques : - * -* * -******************************************************************************/ - -static GArchInstruction *process_armv7_thumb_32_data_processing_shifted_register(uint32_t raw) -{ - GArchInstruction *result; /* Instruction à renvoyer */ - uint32_t op; /* Champ 'op' à retrouver */ - uint32_t rn; /* Champ 'rn' à retrouver */ - uint32_t rds; /* Champ 'rds' à retrouver */ - - /** - * Suit les directives de : - * § A6.3.11 Data-processing (shifted register) - */ - - if ((raw & 0xfe000000) != 0xea000000) return NULL; - - result = NULL; - - op = (raw >> 21) & b1111; - rn = (raw >> 16) & b1111; - rds = (((raw >> 8) & b1111) << 1) | ((raw >> 20) & b1); - - switch (op) - { - case b0000: - - if (rds == b11111) - result = armv7_read_thumb_32_instr_tst_register(raw); - - else - result = armv7_read_thumb_32_instr_and_register(raw); - - break; - - case b0001: - result = armv7_read_thumb_32_instr_bic_register(raw); - break; - - case b0010: - - if (rn == b11111) - result = process_armv7_thumb_32_move_register_and_immediate_shifts(raw); - - else - result = armv7_read_thumb_32_instr_orr_register(raw); - - break; - - case b0011: - - if (rn == b11111) - result = armv7_read_thumb_32_instr_mvn_register(raw); - - else - result = armv7_read_thumb_32_instr_orn_register(raw); - - break; - - case b0100: - - if (rds == b11111) - result = armv7_read_thumb_32_instr_teq_register(raw); - - else - result = armv7_read_thumb_32_instr_eor_register(raw); - - break; - - case b0110: - result = armv7_read_thumb_32_instr_pkh(raw); - break; - - case b1000: - - if (rds == b11111) - result = armv7_read_thumb_32_instr_cmn_register(raw); - - else - result = armv7_read_thumb_32_instr_add_register_thumb(raw); - - break; - - case b1010: - result = armv7_read_thumb_32_instr_adc_register(raw); - break; - - case b1011: - result = armv7_read_thumb_32_instr_sbc_register(raw); - break; - - case b1101: - - if (rds == b11111) - result = armv7_read_thumb_32_instr_cmp_register(raw); - - else - result = armv7_read_thumb_32_instr_sub_register_thumb(raw); - - break; - - case b1110: - result = armv7_read_thumb_32_instr_rsb_register(raw); - break; - - } - - return result; - -} - - -/****************************************************************************** -* * -* Paramètres : raw = donnée brute de 32 bits à désassembler. * -* * -* Description : Désassemble une instruction ARMv7 liées au chapitre A6.3.11b.* -* * -* Retour : Instruction mise en place ou NULL en cas d'échec. * -* * -* Remarques : - * -* * -******************************************************************************/ - -static GArchInstruction *process_armv7_thumb_32_move_register_and_immediate_shifts(uint32_t raw) -{ - GArchInstruction *result; /* Instruction à renvoyer */ - uint32_t imm5; /* Champs 'imm[32]' à retrouver*/ - uint32_t type; /* Champ 'type' à retrouver */ - - /** - * Suit les directives de : - * § A6.3.11 Data-processing (shifted register) - * |-> Move register and immediate shifts - */ - - if ((raw & 0xffef0000) != 0xea4f0000) return NULL; - - result = NULL; - - imm5 = (((raw >> 12) & 0x7) << 2) | ((raw >> 6) & 0x3); - type = (raw >> 4) & 0x3; - - switch (type) - { - case b00: - - if (imm5 == b00000) - result = armv7_read_thumb_32_instr_mov_register_thumb(raw); - - else/* if (imm5 != b00000)*/ - result = armv7_read_thumb_32_instr_lsl_immediate(raw); - - break; - - case b01: - result = armv7_read_thumb_32_instr_lsr_immediate(raw); - break; - - case b10: - result = armv7_read_thumb_32_instr_asr_immediate(raw); - break; - - case b11: - - if (imm5 == b00000) - result = armv7_read_thumb_32_instr_rrx(raw); - - else/* if (imm5 != b00000)*/ - result = armv7_read_thumb_32_instr_ror_immediate(raw); - - break; - - } - - return result; - -} - - -/****************************************************************************** -* * -* Paramètres : raw = donnée brute de 32 bits à désassembler. * -* * -* Description : Désassemble une instruction ARMv7 liées au chapitre A6.3.12. * -* * -* Retour : Instruction mise en place ou NULL en cas d'échec. * -* * -* Remarques : - * -* * -******************************************************************************/ - -static GArchInstruction *process_armv7_thumb_32_data_processing_register(uint32_t raw) -{ - GArchInstruction *result; /* Instruction à renvoyer */ - uint32_t op1; /* Champ 'op1' à retrouver */ - uint32_t rn; /* Champ 'rn' à retrouver */ - uint32_t op2; /* Champ 'op2' à retrouver */ - - /** - * Suit les directives de : - * § A6.3.12 Data-processing (register) - */ - - if ((raw & 0xff00f000) != 0xfa00f000) return NULL; - - result = NULL; - - op1 = (raw >> 20) & b1111; - rn = (raw >> 16) & b1111; - op2 = (raw >> 4) & b1111; - - if ((op1 & b1110) == b0000 && op2 == b0000) - result = armv7_read_thumb_32_instr_lsl_register(raw); - - else if ((op1 & b1110) == b0010 && op2 == b0000) - result = armv7_read_thumb_32_instr_lsr_register(raw); - - else if ((op1 & b1110) == b0100 && op2 == b0000) - result = armv7_read_thumb_32_instr_asr_register(raw); - - else if ((op1 & b1110) == b0110 && op2 == b0000) - result = armv7_read_thumb_32_instr_ror_register(raw); - - else if (op1 == b0000 && (op2 & b1000) == b1000) - { - if (rn == b1111) - result = armv7_read_thumb_32_instr_sxth(raw); - - else - result = armv7_read_thumb_32_instr_sxtah(raw); - - } - - else if (op1 == b0001 && (op2 & b1000) == b1000) - { - if (rn == b1111) - result = armv7_read_thumb_32_instr_uxth(raw); - - else - result = armv7_read_thumb_32_instr_uxtah(raw); - - } - - else if (op1 == b0010 && (op2 & b1000) == b1000) - { - if (rn == b1111) - result = armv7_read_thumb_32_instr_sxtb16(raw); - - else - result = armv7_read_thumb_32_instr_sxtab16(raw); - - } - - else if (op1 == b0011 && (op2 & b1000) == b1000) - { - if (rn == b1111) - result = armv7_read_thumb_32_instr_uxtb16(raw); - - else - result = armv7_read_thumb_32_instr_uxtab16(raw); - - } - - else if (op1 == b0100 && (op2 & b1000) == b1000) - { - if (rn == b1111) - result = armv7_read_thumb_32_instr_sxtb(raw); - - else - result = armv7_read_thumb_32_instr_sxtab(raw); - - } - - else if (op1 == b0101 && (op2 & b1000) == b1000) - { - if (rn == b1111) - result = armv7_read_thumb_32_instr_uxtb(raw); - - else - result = armv7_read_thumb_32_instr_uxtab(raw); - - } - - else if ((op1 & b1000) == b1000 && (op2 & b1100) == b0000) - result = process_armv7_thumb_32_parallel_addition_and_subtraction_signed(raw); - - else if ((op1 & b1000) == b1000 && (op2 & b1100) == b0100) - result = process_armv7_thumb_32_parallel_addition_and_subtraction_unsigned(raw); - - else if ((op1 & b1100) == b1000 && (op2 & b1100) == b1000) - result = process_armv7_thumb_32_miscellaneous_operations(raw); - - return result; - -} - - -/****************************************************************************** -* * -* Paramètres : raw = donnée brute de 32 bits à désassembler. * -* * -* Description : Désassemble une instruction ARMv7 liées au chapitre A6.3.13. * -* * -* Retour : Instruction mise en place ou NULL en cas d'échec. * -* * -* Remarques : - * -* * -******************************************************************************/ - -static GArchInstruction *process_armv7_thumb_32_parallel_addition_and_subtraction_signed(uint32_t raw) -{ - GArchInstruction *result; /* Instruction à renvoyer */ - uint32_t op1; /* Champ 'op1' à retrouver */ - uint32_t op2; /* Champ 'op2' à retrouver */ - - /** - * Suit les directives de : - * § A6.3.13 Parallel addition and subtraction, signed - */ - - if ((raw & 0xff80f000) != 0xfa80f000) return NULL; - - result = NULL; - - op1 = (raw >> 20) & b111; - op2 = (raw >> 4) & b11; - - switch (op2) - { - case b00: - switch (op1) - { - case b001: - result = armv7_read_thumb_32_instr_sadd16(raw); - break; - - case b010: - result = armv7_read_thumb_32_instr_sasx(raw); - break; - - case b110: - result = armv7_read_thumb_32_instr_ssax(raw); - break; - - case b101: - result = armv7_read_thumb_32_instr_ssub16(raw); - break; - - case b000: - result = armv7_read_thumb_32_instr_sadd8(raw); - break; - - case b100: - result = armv7_read_thumb_32_instr_ssub8(raw); - break; - - } - break; - - case b01: - switch (op1) - { - case b001: - result = armv7_read_thumb_32_instr_sqadd16(raw); - break; - - case b010: - result = armv7_read_thumb_32_instr_sqasx(raw); - break; - - case b110: - result = armv7_read_thumb_32_instr_sqsax(raw); - break; - - case b101: - result = armv7_read_thumb_32_instr_sqsub16(raw); - break; - - case b000: - result = armv7_read_thumb_32_instr_sqadd8(raw); - break; - - case b100: - result = armv7_read_thumb_32_instr_sqsub8(raw); - break; - - } - break; - - case b10: - switch (op1) - { - case b001: - result = armv7_read_thumb_32_instr_shadd16(raw); - break; - - case b010: - result = armv7_read_thumb_32_instr_shasx(raw); - break; - - case b110: - result = armv7_read_thumb_32_instr_shsax(raw); - break; - - case b101: - result = armv7_read_thumb_32_instr_shsub16(raw); - break; - - case b000: - result = armv7_read_thumb_32_instr_shadd8(raw); - break; - - case b100: - result = armv7_read_thumb_32_instr_shsub8(raw); - break; - - } - break; - - } - - return result; - -} - - -/****************************************************************************** -* * -* Paramètres : raw = donnée brute de 32 bits à désassembler. * -* * -* Description : Désassemble une instruction ARMv7 liées au chapitre A6.3.14. * -* * -* Retour : Instruction mise en place ou NULL en cas d'échec. * -* * -* Remarques : - * -* * -******************************************************************************/ - -static GArchInstruction *process_armv7_thumb_32_parallel_addition_and_subtraction_unsigned(uint32_t raw) -{ - GArchInstruction *result; /* Instruction à renvoyer */ - uint32_t op1; /* Champ 'op1' à retrouver */ - uint32_t op2; /* Champ 'op2' à retrouver */ - - /** - * Suit les directives de : - * § A6.3.14 Parallel addition and subtraction, unsigned - */ - - if ((raw & 0xff80f0c0) != 0xfa80f040) return NULL; - - result = NULL; - - op1 = (raw >> 20) & b111; - op2 = (raw >> 4) & b11; - - switch (op2) - { - case b00: - switch (op1) - { - case b001: - result = armv7_read_thumb_32_instr_uadd16(raw); - break; - - case b010: - result = armv7_read_thumb_32_instr_uasx(raw); - break; - - case b110: - result = armv7_read_thumb_32_instr_usax(raw); - break; - - case b101: - result = armv7_read_thumb_32_instr_usub16(raw); - break; - - case b000: - result = armv7_read_thumb_32_instr_uadd8(raw); - break; - - case b100: - result = armv7_read_thumb_32_instr_usub8(raw); - break; - - } - break; - - case b01: - switch (op1) - { - case b001: - result = armv7_read_thumb_32_instr_uqadd16(raw); - break; - - case b010: - result = armv7_read_thumb_32_instr_uqasx(raw); - break; - - case b110: - result = armv7_read_thumb_32_instr_uqsax(raw); - break; - - case b101: - result = armv7_read_thumb_32_instr_uqsub16(raw); - break; - - case b000: - result = armv7_read_thumb_32_instr_uqadd8(raw); - break; - - case b100: - result = armv7_read_thumb_32_instr_uqsub8(raw); - break; - - } - break; - - case b10: - switch (op1) - { - case b001: - result = armv7_read_thumb_32_instr_uhadd16(raw); - break; - - case b010: - result = armv7_read_thumb_32_instr_uhasx(raw); - break; - - case b110: - result = armv7_read_thumb_32_instr_uhsax(raw); - break; - - case b101: - result = armv7_read_thumb_32_instr_uhsub16(raw); - break; - - case b000: - result = armv7_read_thumb_32_instr_uhadd8(raw); - break; - - case b100: - result = armv7_read_thumb_32_instr_uhsub8(raw); - break; - - } - break; - - } - - return result; - -} - - -/****************************************************************************** -* * -* Paramètres : raw = donnée brute de 32 bits à désassembler. * -* * -* Description : Désassemble une instruction ARMv7 liées au chapitre A6.3.15. * -* * -* Retour : Instruction mise en place ou NULL en cas d'échec. * -* * -* Remarques : - * -* * -******************************************************************************/ - -static GArchInstruction *process_armv7_thumb_32_miscellaneous_operations(uint32_t raw) -{ - GArchInstruction *result; /* Instruction à renvoyer */ - uint32_t op1; /* Champ 'op1' à retrouver */ - uint32_t op2; /* Champ 'op2' à retrouver */ - - /** - * Suit les directives de : - * § A6.3.15 Miscellaneous operations - */ - - if ((raw & 0xffc0f0c0) != 0xfa80f080) return NULL; - - result = NULL; - - op1 = (raw >> 20) & b11; - op2 = (raw >> 4) & b11; - - switch (op1) - { - case b00: - switch (op2) - { - case b00: - result = armv7_read_thumb_32_instr_qadd(raw); - break; - - case b01: - result = armv7_read_thumb_32_instr_qdadd(raw); - break; - - case b10: - result = armv7_read_thumb_32_instr_qsub(raw); - break; - - case b11: - result = armv7_read_thumb_32_instr_qdsub(raw); - break; - - } - break; - - case b01: - switch (op2) - { - case b00: - result = armv7_read_thumb_32_instr_rev(raw); - break; - - case b01: - result = armv7_read_thumb_32_instr_rev16(raw); - break; - - case b10: - result = armv7_read_thumb_32_instr_rbit(raw); - break; - - case b11: - result = armv7_read_thumb_32_instr_revsh(raw); - break; - - } - break; - - case b10: - if (op2 == b00) - result = armv7_read_thumb_32_instr_sel(raw); - break; - - case b11: - if (op2 == b00) - result = armv7_read_thumb_32_instr_clz(raw); - break; - - } - - return result; - -} - - -/****************************************************************************** -* * -* Paramètres : raw = donnée brute de 32 bits à désassembler. * -* * -* Description : Désassemble une instruction ARMv7 liées au chapitre A6.3.16. * -* * -* Retour : Instruction mise en place ou NULL en cas d'échec. * -* * -* Remarques : - * -* * -******************************************************************************/ - -static GArchInstruction *process_armv7_thumb_32_multiply_multiply_accumulate_and_absolute_difference(uint32_t raw) -{ - GArchInstruction *result; /* Instruction à renvoyer */ - uint32_t op1; /* Champ 'op1' à retrouver */ - uint32_t ra; /* Champ 'ra' à retrouver */ - uint32_t op2; /* Champ 'op2' à retrouver */ - - /** - * Suit les directives de : - * § A6.3.16 Multiply, multiply accumulate, and absolute difference - */ - - if ((raw & 0xff8000c0) != 0xfb000000) return NULL; - - result = NULL; - - op1 = (raw >> 20) & b111; - ra = (raw >> 12) & b1111; - op2 = (raw >> 4) & b11; - - switch (op1) - { - case b000: - - if (op2 == b00) - { - if (ra == b1111) - result = armv7_read_thumb_32_instr_mul(raw); - - else - result = armv7_read_thumb_32_instr_mla(raw); - - } - - else if (op2 == b01) - result = armv7_read_thumb_32_instr_mls(raw); - - break; - - case b001: - - if (ra == b1111) - result = armv7_read_thumb_32_instr_smulbb_smulbt_smultb_smultt(raw); - - else - result = armv7_read_thumb_32_instr_smlabb_smlabt_smlatb_smlatt(raw); - - break; - - case b010: - if ((op2 & b10) == b00) - { - if (ra == b1111) - result = armv7_read_thumb_32_instr_smuad(raw); - - else - result = armv7_read_thumb_32_instr_smlad(raw); - - } - break; - - case b011: - if ((op2 & b10) == b00) - { - if (ra == b1111) - result = armv7_read_thumb_32_instr_smulwb_smulwt(raw); - - else - result = armv7_read_thumb_32_instr_smlawb_smlawt(raw); - - } - break; - - case b100: - if ((op2 & b10) == b00) - { - if (ra == b1111) - result = armv7_read_thumb_32_instr_smusd(raw); - - else - result = armv7_read_thumb_32_instr_smlsd(raw); - - } - break; - - case b101: - if ((op2 & b10) == b00) - { - if (ra == b1111) - result = armv7_read_thumb_32_instr_smmul(raw); - - else - result = armv7_read_thumb_32_instr_smmla(raw); - - } - break; - - case b110: - if ((op2 & b10) == b00) - result = armv7_read_thumb_32_instr_smmls(raw); - break; - - case b111: - if (op2 == b00) - { - if (ra == b1111) - result = armv7_read_thumb_32_instr_usad8(raw); - - else - result = armv7_read_thumb_32_instr_usada8(raw); - - } - break; - - } - - return result; - -} - - -/****************************************************************************** -* * -* Paramètres : raw = donnée brute de 32 bits à désassembler. * -* * -* Description : Désassemble une instruction ARMv7 liées au chapitre A6.3.17. * -* * -* Retour : Instruction mise en place ou NULL en cas d'échec. * -* * -* Remarques : - * -* * -******************************************************************************/ - -static GArchInstruction *process_armv7_thumb_32_long_multiply_long_multiply_accumulate_and_divide(uint32_t raw) -{ - GArchInstruction *result; /* Instruction à renvoyer */ - uint32_t op1; /* Champ 'op1' à retrouver */ - uint32_t op2; /* Champ 'op2' à retrouver */ - - /** - * Suit les directives de : - * § A6.3.17 Long multiply, long multiply accumulate, and divide - */ - - if ((raw & 0xff800000) != 0xfb800000) return NULL; - - result = NULL; - - op1 = (raw >> 20) & b111; - op2 = (raw >> 4) & b1111; - - switch (op1) - { - case b000: - if (op2 == b0000) - result = armv7_read_thumb_32_instr_smull(raw); - break; - - case b001: - if (op2 == b1111) - result = armv7_read_thumb_32_instr_sdiv(raw); - break; - - case b010: - if (op2 == b0000) - result = armv7_read_thumb_32_instr_umull(raw); - break; - - case b011: - if (op2 == b1111) - result = armv7_read_thumb_32_instr_udiv(raw); - break; - - case b100: - - if (op2 == b0000) - result = armv7_read_thumb_32_instr_smlal(raw); - - else if ((op2 & b1100) == b1000) - result = armv7_read_thumb_32_instr_smlalbb_smlalbt_smlaltb_smlaltt(raw); - - else if ((op2 & b1110) == b1100) - result = armv7_read_thumb_32_instr_smlald(raw); - - break; - - case b101: - if ((op2 & b1110) == b1100) - result = armv7_read_thumb_32_instr_smlsld(raw); - break; - - case b110: - - if (op2 == b0000) - result = armv7_read_thumb_32_instr_umlal(raw); - - else if (op2 == b0110) - result = armv7_read_thumb_32_instr_umaal(raw); - - break; - - } - - return result; - -} - - -/****************************************************************************** -* * -* Paramètres : raw = donnée brute de 32 bits à désassembler. * -* * -* Description : Désassemble une instruction ARMv7 liées au chapitre A6.3.18. * -* * -* Retour : Instruction mise en place ou NULL en cas d'échec. * -* * -* Remarques : - * -* * -******************************************************************************/ - -static GArchInstruction *process_armv7_thumb_32_coprocessor_advanced_simd_and_floating_point_instructions(uint32_t raw) -{ - GArchInstruction *result; /* Instruction à renvoyer */ - uint32_t op1; /* Champ 'op1' à retrouver */ - uint32_t rn; /* Champ 'rn' à retrouver */ - uint32_t coproc; /* Champ 'coproc' à retrouver */ - uint32_t op; /* Champ 'op' à retrouver */ - - /** - * Suit les directives de : - * § A6.3.18 Coprocessor, Advanced SIMD, and Floating-point instructions - */ - - if ((raw & 0xec000000) != 0xec000000) return NULL; - - result = NULL; - - op1 = (raw >> 20) & 0x3f; - rn = (raw >> 16) & 0xf; - coproc = (raw >> 8) & 0xf; - op = (raw >> 4) & 0x1; - - if ((op1 & b111110) == b000000) - result = g_undef_instruction_new(IBS_UNDEFINED); - - else if ((op1 & b110000) == b110000) - result = process_armv7_simd_advanced_simd_data_processing_instructions(raw, false); - - else if ((coproc & b1110) != b1010) - { - if ((op1 & b100001) == b000000 && (op1 & b111010) != b000000) - result = armv7_read_thumb_32_instr_stc_stc2(raw); - - else if ((op1 & b100001) == b000001 && (op1 & b111010) != b000000) - { - if (rn != b1111) - result = armv7_read_thumb_32_instr_ldc_ldc2_immediate(raw); - - else/* if (rn == b1111)*/ - result = armv7_read_thumb_32_instr_ldc_ldc2_literal(raw); - - } - - else if (op1 == b000100) - result = armv7_read_thumb_32_instr_mcrr_mcrr2(raw); - - else if (op1 == b000101) - result = armv7_read_thumb_32_instr_mrrc_mrrc2(raw); - - else if ((op1 & b110000) == b100000 && op == b0) - result = armv7_read_thumb_32_instr_cdp_cdp2(raw); - - else if ((op1 & b110001) == b100000 && op == b1) - result = armv7_read_thumb_32_instr_mcr_mcr2(raw); - - else if ((op1 & b110001) == b100001 && op == b1) - result = armv7_read_thumb_32_instr_mrc_mrc2(raw); - - } - - else if ((coproc & b1110) == b1010) - { - if ((op1 & b100000) == b000000 && (op1 & b111010) != b000000) - result = process_armv7_simd_extension_register_load_store_instructions(raw, false); - - else if ((op1 & b111110) == b000100) - result = process_armv7_simd_64_bit_transfers_between_arm_core_and_extension_registers(raw, false); - - else if ((op1 & b110000) == b100000) - { - if (op == b0) - result = process_armv7_simd_floating_point_data_processing_instructions(raw, false); - - else/* if (op == b1)*/ - result = process_armv7_simd_8_16_and_32_bit_transfer_between_arm_core_and_extension_registers(raw, false); - - } - - } - - return result; - -} diff --git a/src/arch/arm/v7/thumb_32.h b/src/arch/arm/v7/thumb_32.h deleted file mode 100644 index 9d09650..0000000 --- a/src/arch/arm/v7/thumb_32.h +++ /dev/null @@ -1,37 +0,0 @@ - -/* Chrysalide - Outil d'analyse de fichiers binaires - * thumb_32.h - prototypes pour le désassemblage des instructions ARMv7 Thumb 32 bits - * - * Copyright (C) 2014-2017 Cyrille Bagard - * - * This file is part of Chrysalide. - * - * Chrysalide is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * Chrysalide is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Foobar. If not, see . - */ - - -#ifndef _ARCH_ARM_V7_THUMB_32_H -#define _ARCH_ARM_V7_THUMB_32_H - - -#include "../../instruction.h" - - - -/* Désassemble une instruction ARMv7 liées au chapitre A6.3. */ -GArchInstruction *process_armv7_thumb_32_instruction_set_encoding(uint32_t); - - - -#endif /* _ARCH_ARM_V7_THUMB_32_H */ diff --git a/src/core/processors.c b/src/core/processors.c index 661374e..f798641 100644 --- a/src/core/processors.c +++ b/src/core/processors.c @@ -29,8 +29,6 @@ #include -#include "../arch/arm/v7/core.h" -#include "../arch/arm/v7/processor.h" //#include "../arch/jvm/processor.h" @@ -132,10 +130,6 @@ bool load_hard_coded_processors_definitions(void) result = true; - if (result) - result = register_processor_type("armv7", "ARM v7", G_TYPE_ARMV7_PROCESSOR, - init_armv7_core, exit_armv7_core); - //result &= register_processor_type("jvm", "Java Virtual Machine", G_TYPE_JVM_PROCESSOR); return result; diff --git a/src/plugins/plugin.c b/src/plugins/plugin.c index 2cfb3de..d9072d7 100644 --- a/src/plugins/plugin.c +++ b/src/plugins/plugin.c @@ -459,6 +459,9 @@ bool g_plugin_module_resolve_dependencies(GPluginModule *plugin, GPluginModule * else { + if (dependency->dependencies == NULL) + dependency->dependencies = create_bit_field(count, false); + set_in_bit_field(new, index, 1); or_bit_field(new, dependency->dependencies); -- cgit v0.11.2-87-g4458