crabstone 3.0.3 → 4.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +5 -5
- data/CHANGES.md +59 -42
- data/README.md +37 -39
- data/lib/{arch → crabstone/arch/3}/arm.rb +28 -49
- data/lib/crabstone/arch/3/arm64.rb +124 -0
- data/lib/{arch → crabstone/arch/3}/arm64_const.rb +45 -86
- data/lib/{arch → crabstone/arch/3}/arm_const.rb +19 -47
- data/lib/crabstone/arch/3/mips.rb +57 -0
- data/lib/{arch → crabstone/arch/3}/mips_const.rb +18 -38
- data/lib/crabstone/arch/3/ppc.rb +73 -0
- data/lib/{arch → crabstone/arch/3}/ppc_const.rb +27 -43
- data/lib/crabstone/arch/3/sparc.rb +60 -0
- data/lib/{arch → crabstone/arch/3}/sparc_const.rb +49 -67
- data/lib/crabstone/arch/3/sysz.rb +67 -0
- data/lib/{arch → crabstone/arch/3}/sysz_const.rb +11 -25
- data/lib/crabstone/arch/3/x86.rb +82 -0
- data/lib/{arch → crabstone/arch/3}/x86_const.rb +15 -36
- data/lib/crabstone/arch/3/xcore.rb +59 -0
- data/lib/{arch → crabstone/arch/3}/xcore_const.rb +10 -22
- data/lib/crabstone/arch/4/arm.rb +110 -0
- data/lib/crabstone/arch/4/arm64.rb +125 -0
- data/lib/crabstone/arch/4/arm64_const.rb +1016 -0
- data/lib/crabstone/arch/4/arm_const.rb +785 -0
- data/lib/crabstone/arch/4/evm.rb +20 -0
- data/lib/crabstone/arch/4/evm_const.rb +161 -0
- data/lib/crabstone/arch/4/m680x.rb +106 -0
- data/lib/crabstone/arch/4/m680x_const.rb +426 -0
- data/lib/crabstone/arch/4/m68k.rb +129 -0
- data/lib/crabstone/arch/4/m68k_const.rb +496 -0
- data/lib/crabstone/arch/4/mips.rb +57 -0
- data/lib/crabstone/arch/4/mips_const.rb +869 -0
- data/lib/crabstone/arch/4/ppc.rb +73 -0
- data/lib/crabstone/arch/4/ppc_const.rb +1375 -0
- data/lib/crabstone/arch/4/sparc.rb +60 -0
- data/lib/crabstone/arch/4/sparc_const.rb +439 -0
- data/lib/crabstone/arch/4/sysz.rb +67 -0
- data/lib/crabstone/arch/4/sysz_const.rb +763 -0
- data/lib/crabstone/arch/4/tms320c64x.rb +87 -0
- data/lib/crabstone/arch/4/tms320c64x_const.rb +287 -0
- data/lib/crabstone/arch/4/x86.rb +91 -0
- data/lib/crabstone/arch/4/x86_const.rb +1972 -0
- data/lib/crabstone/arch/4/xcore.rb +59 -0
- data/lib/crabstone/arch/4/xcore_const.rb +171 -0
- data/lib/crabstone/arch/extension.rb +27 -0
- data/lib/crabstone/arch/register.rb +34 -0
- data/lib/crabstone/arch.rb +37 -0
- data/lib/crabstone/binding/3/detail.rb +36 -0
- data/lib/crabstone/binding/3/instruction.rb +23 -0
- data/lib/crabstone/binding/4/detail.rb +40 -0
- data/lib/crabstone/binding/4/instruction.rb +23 -0
- data/lib/crabstone/binding/structs.rb +32 -0
- data/lib/crabstone/binding.rb +59 -0
- data/lib/crabstone/constants.rb +110 -0
- data/lib/crabstone/cs_version.rb +57 -0
- data/lib/crabstone/disassembler.rb +147 -0
- data/lib/crabstone/error.rb +74 -0
- data/lib/crabstone/instruction.rb +178 -0
- data/lib/crabstone/version.rb +5 -0
- data/lib/crabstone.rb +5 -557
- metadata +142 -331
- data/MANIFEST +0 -312
- data/Rakefile +0 -27
- data/bin/genconst +0 -66
- data/bin/genreg +0 -99
- data/crabstone.gemspec +0 -27
- data/examples/hello_world.rb +0 -43
- data/lib/arch/arm64.rb +0 -167
- data/lib/arch/arm64_registers.rb +0 -295
- data/lib/arch/arm_registers.rb +0 -149
- data/lib/arch/mips.rb +0 -78
- data/lib/arch/mips_registers.rb +0 -208
- data/lib/arch/ppc.rb +0 -90
- data/lib/arch/ppc_registers.rb +0 -209
- data/lib/arch/sparc.rb +0 -79
- data/lib/arch/sparc_registers.rb +0 -121
- data/lib/arch/systemz.rb +0 -79
- data/lib/arch/sysz_registers.rb +0 -66
- data/lib/arch/x86.rb +0 -107
- data/lib/arch/x86_registers.rb +0 -265
- data/lib/arch/xcore.rb +0 -78
- data/lib/arch/xcore_registers.rb +0 -57
- data/test/MC/AArch64/basic-a64-instructions.s.cs +0 -2014
- data/test/MC/AArch64/gicv3-regs.s.cs +0 -111
- data/test/MC/AArch64/neon-2velem.s.cs +0 -113
- data/test/MC/AArch64/neon-3vdiff.s.cs +0 -143
- data/test/MC/AArch64/neon-aba-abd.s.cs +0 -28
- data/test/MC/AArch64/neon-across.s.cs +0 -40
- data/test/MC/AArch64/neon-add-pairwise.s.cs +0 -11
- data/test/MC/AArch64/neon-add-sub-instructions.s.cs +0 -21
- data/test/MC/AArch64/neon-bitwise-instructions.s.cs +0 -17
- data/test/MC/AArch64/neon-compare-instructions.s.cs +0 -136
- data/test/MC/AArch64/neon-crypto.s.cs +0 -15
- data/test/MC/AArch64/neon-extract.s.cs +0 -3
- data/test/MC/AArch64/neon-facge-facgt.s.cs +0 -13
- data/test/MC/AArch64/neon-frsqrt-frecp.s.cs +0 -7
- data/test/MC/AArch64/neon-halving-add-sub.s.cs +0 -25
- data/test/MC/AArch64/neon-max-min-pairwise.s.cs +0 -37
- data/test/MC/AArch64/neon-max-min.s.cs +0 -37
- data/test/MC/AArch64/neon-mla-mls-instructions.s.cs +0 -19
- data/test/MC/AArch64/neon-mov.s.cs +0 -74
- data/test/MC/AArch64/neon-mul-div-instructions.s.cs +0 -24
- data/test/MC/AArch64/neon-perm.s.cs +0 -43
- data/test/MC/AArch64/neon-rounding-halving-add.s.cs +0 -13
- data/test/MC/AArch64/neon-rounding-shift.s.cs +0 -15
- data/test/MC/AArch64/neon-saturating-add-sub.s.cs +0 -29
- data/test/MC/AArch64/neon-saturating-rounding-shift.s.cs +0 -15
- data/test/MC/AArch64/neon-saturating-shift.s.cs +0 -15
- data/test/MC/AArch64/neon-scalar-abs.s.cs +0 -8
- data/test/MC/AArch64/neon-scalar-add-sub.s.cs +0 -3
- data/test/MC/AArch64/neon-scalar-by-elem-mla.s.cs +0 -13
- data/test/MC/AArch64/neon-scalar-by-elem-mul.s.cs +0 -13
- data/test/MC/AArch64/neon-scalar-by-elem-saturating-mla.s.cs +0 -15
- data/test/MC/AArch64/neon-scalar-by-elem-saturating-mul.s.cs +0 -18
- data/test/MC/AArch64/neon-scalar-compare.s.cs +0 -12
- data/test/MC/AArch64/neon-scalar-cvt.s.cs +0 -34
- data/test/MC/AArch64/neon-scalar-dup.s.cs +0 -23
- data/test/MC/AArch64/neon-scalar-extract-narrow.s.cs +0 -10
- data/test/MC/AArch64/neon-scalar-fp-compare.s.cs +0 -21
- data/test/MC/AArch64/neon-scalar-mul.s.cs +0 -13
- data/test/MC/AArch64/neon-scalar-neg.s.cs +0 -6
- data/test/MC/AArch64/neon-scalar-recip.s.cs +0 -11
- data/test/MC/AArch64/neon-scalar-reduce-pairwise.s.cs +0 -3
- data/test/MC/AArch64/neon-scalar-rounding-shift.s.cs +0 -3
- data/test/MC/AArch64/neon-scalar-saturating-add-sub.s.cs +0 -25
- data/test/MC/AArch64/neon-scalar-saturating-rounding-shift.s.cs +0 -9
- data/test/MC/AArch64/neon-scalar-saturating-shift.s.cs +0 -9
- data/test/MC/AArch64/neon-scalar-shift-imm.s.cs +0 -42
- data/test/MC/AArch64/neon-scalar-shift.s.cs +0 -3
- data/test/MC/AArch64/neon-shift-left-long.s.cs +0 -13
- data/test/MC/AArch64/neon-shift.s.cs +0 -22
- data/test/MC/AArch64/neon-simd-copy.s.cs +0 -42
- data/test/MC/AArch64/neon-simd-ldst-multi-elem.s.cs +0 -197
- data/test/MC/AArch64/neon-simd-ldst-one-elem.s.cs +0 -129
- data/test/MC/AArch64/neon-simd-misc.s.cs +0 -213
- data/test/MC/AArch64/neon-simd-post-ldst-multi-elem.s.cs +0 -107
- data/test/MC/AArch64/neon-simd-shift.s.cs +0 -151
- data/test/MC/AArch64/neon-tbl.s.cs +0 -21
- data/test/MC/AArch64/trace-regs.s.cs +0 -383
- data/test/MC/ARM/arm-aliases.s.cs +0 -7
- data/test/MC/ARM/arm-arithmetic-aliases.s.cs +0 -50
- data/test/MC/ARM/arm-it-block.s.cs +0 -2
- data/test/MC/ARM/arm-memory-instructions.s.cs +0 -138
- data/test/MC/ARM/arm-shift-encoding.s.cs +0 -50
- data/test/MC/ARM/arm-thumb-trustzone.s.cs +0 -3
- data/test/MC/ARM/arm-trustzone.s.cs +0 -3
- data/test/MC/ARM/arm_addrmode2.s.cs +0 -15
- data/test/MC/ARM/arm_addrmode3.s.cs +0 -9
- data/test/MC/ARM/arm_instructions.s.cs +0 -25
- data/test/MC/ARM/basic-arm-instructions-v8.s.cs +0 -10
- data/test/MC/ARM/basic-arm-instructions.s.cs +0 -997
- data/test/MC/ARM/basic-thumb-instructions.s.cs +0 -130
- data/test/MC/ARM/basic-thumb2-instructions-v8.s.cs +0 -1
- data/test/MC/ARM/basic-thumb2-instructions.s.cs +0 -1242
- data/test/MC/ARM/crc32-thumb.s.cs +0 -7
- data/test/MC/ARM/crc32.s.cs +0 -7
- data/test/MC/ARM/dot-req.s.cs +0 -3
- data/test/MC/ARM/fp-armv8.s.cs +0 -52
- data/test/MC/ARM/idiv-thumb.s.cs +0 -3
- data/test/MC/ARM/idiv.s.cs +0 -3
- data/test/MC/ARM/load-store-acquire-release-v8-thumb.s.cs +0 -15
- data/test/MC/ARM/load-store-acquire-release-v8.s.cs +0 -15
- data/test/MC/ARM/mode-switch.s.cs +0 -7
- data/test/MC/ARM/neon-abs-encoding.s.cs +0 -15
- data/test/MC/ARM/neon-absdiff-encoding.s.cs +0 -39
- data/test/MC/ARM/neon-add-encoding.s.cs +0 -119
- data/test/MC/ARM/neon-bitcount-encoding.s.cs +0 -15
- data/test/MC/ARM/neon-bitwise-encoding.s.cs +0 -126
- data/test/MC/ARM/neon-cmp-encoding.s.cs +0 -88
- data/test/MC/ARM/neon-convert-encoding.s.cs +0 -27
- data/test/MC/ARM/neon-crypto.s.cs +0 -16
- data/test/MC/ARM/neon-dup-encoding.s.cs +0 -13
- data/test/MC/ARM/neon-minmax-encoding.s.cs +0 -57
- data/test/MC/ARM/neon-mov-encoding.s.cs +0 -76
- data/test/MC/ARM/neon-mul-accum-encoding.s.cs +0 -39
- data/test/MC/ARM/neon-mul-encoding.s.cs +0 -72
- data/test/MC/ARM/neon-neg-encoding.s.cs +0 -15
- data/test/MC/ARM/neon-pairwise-encoding.s.cs +0 -47
- data/test/MC/ARM/neon-reciprocal-encoding.s.cs +0 -13
- data/test/MC/ARM/neon-reverse-encoding.s.cs +0 -13
- data/test/MC/ARM/neon-satshift-encoding.s.cs +0 -75
- data/test/MC/ARM/neon-shift-encoding.s.cs +0 -238
- data/test/MC/ARM/neon-shiftaccum-encoding.s.cs +0 -97
- data/test/MC/ARM/neon-shuffle-encoding.s.cs +0 -59
- data/test/MC/ARM/neon-sub-encoding.s.cs +0 -82
- data/test/MC/ARM/neon-table-encoding.s.cs +0 -9
- data/test/MC/ARM/neon-v8.s.cs +0 -38
- data/test/MC/ARM/neon-vld-encoding.s.cs +0 -213
- data/test/MC/ARM/neon-vst-encoding.s.cs +0 -120
- data/test/MC/ARM/neon-vswp.s.cs +0 -3
- data/test/MC/ARM/neont2-abs-encoding.s.cs +0 -15
- data/test/MC/ARM/neont2-absdiff-encoding.s.cs +0 -39
- data/test/MC/ARM/neont2-add-encoding.s.cs +0 -65
- data/test/MC/ARM/neont2-bitcount-encoding.s.cs +0 -15
- data/test/MC/ARM/neont2-bitwise-encoding.s.cs +0 -15
- data/test/MC/ARM/neont2-cmp-encoding.s.cs +0 -17
- data/test/MC/ARM/neont2-convert-encoding.s.cs +0 -19
- data/test/MC/ARM/neont2-dup-encoding.s.cs +0 -19
- data/test/MC/ARM/neont2-minmax-encoding.s.cs +0 -57
- data/test/MC/ARM/neont2-mov-encoding.s.cs +0 -58
- data/test/MC/ARM/neont2-mul-accum-encoding.s.cs +0 -41
- data/test/MC/ARM/neont2-mul-encoding.s.cs +0 -31
- data/test/MC/ARM/neont2-neg-encoding.s.cs +0 -15
- data/test/MC/ARM/neont2-pairwise-encoding.s.cs +0 -43
- data/test/MC/ARM/neont2-reciprocal-encoding.s.cs +0 -13
- data/test/MC/ARM/neont2-reverse-encoding.s.cs +0 -13
- data/test/MC/ARM/neont2-satshift-encoding.s.cs +0 -75
- data/test/MC/ARM/neont2-shift-encoding.s.cs +0 -80
- data/test/MC/ARM/neont2-shiftaccum-encoding.s.cs +0 -97
- data/test/MC/ARM/neont2-shuffle-encoding.s.cs +0 -23
- data/test/MC/ARM/neont2-sub-encoding.s.cs +0 -23
- data/test/MC/ARM/neont2-table-encoding.s.cs +0 -9
- data/test/MC/ARM/neont2-vld-encoding.s.cs +0 -51
- data/test/MC/ARM/neont2-vst-encoding.s.cs +0 -48
- data/test/MC/ARM/simple-fp-encoding.s.cs +0 -157
- data/test/MC/ARM/thumb-fp-armv8.s.cs +0 -51
- data/test/MC/ARM/thumb-hints.s.cs +0 -12
- data/test/MC/ARM/thumb-neon-crypto.s.cs +0 -16
- data/test/MC/ARM/thumb-neon-v8.s.cs +0 -38
- data/test/MC/ARM/thumb-shift-encoding.s.cs +0 -19
- data/test/MC/ARM/thumb.s.cs +0 -19
- data/test/MC/ARM/thumb2-b.w-encodingT4.s.cs +0 -2
- data/test/MC/ARM/thumb2-branches.s.cs +0 -85
- data/test/MC/ARM/thumb2-mclass.s.cs +0 -41
- data/test/MC/ARM/thumb2-narrow-dp.ll.cs +0 -379
- data/test/MC/ARM/thumb2-pldw.s.cs +0 -2
- data/test/MC/ARM/vfp4-thumb.s.cs +0 -13
- data/test/MC/ARM/vfp4.s.cs +0 -13
- data/test/MC/ARM/vpush-vpop-thumb.s.cs +0 -9
- data/test/MC/ARM/vpush-vpop.s.cs +0 -9
- data/test/MC/Mips/hilo-addressing.s.cs +0 -4
- data/test/MC/Mips/micromips-alu-instructions-EB.s.cs +0 -33
- data/test/MC/Mips/micromips-alu-instructions.s.cs +0 -33
- data/test/MC/Mips/micromips-branch-instructions-EB.s.cs +0 -11
- data/test/MC/Mips/micromips-branch-instructions.s.cs +0 -11
- data/test/MC/Mips/micromips-expansions.s.cs +0 -20
- data/test/MC/Mips/micromips-jump-instructions-EB.s.cs +0 -5
- data/test/MC/Mips/micromips-jump-instructions.s.cs +0 -6
- data/test/MC/Mips/micromips-loadstore-instructions-EB.s.cs +0 -9
- data/test/MC/Mips/micromips-loadstore-instructions.s.cs +0 -9
- data/test/MC/Mips/micromips-loadstore-unaligned-EB.s.cs +0 -5
- data/test/MC/Mips/micromips-loadstore-unaligned.s.cs +0 -5
- data/test/MC/Mips/micromips-movcond-instructions-EB.s.cs +0 -5
- data/test/MC/Mips/micromips-movcond-instructions.s.cs +0 -5
- data/test/MC/Mips/micromips-multiply-instructions-EB.s.cs +0 -5
- data/test/MC/Mips/micromips-multiply-instructions.s.cs +0 -5
- data/test/MC/Mips/micromips-shift-instructions-EB.s.cs +0 -9
- data/test/MC/Mips/micromips-shift-instructions.s.cs +0 -9
- data/test/MC/Mips/micromips-trap-instructions-EB.s.cs +0 -13
- data/test/MC/Mips/micromips-trap-instructions.s.cs +0 -13
- data/test/MC/Mips/mips-alu-instructions.s.cs +0 -53
- data/test/MC/Mips/mips-control-instructions-64.s.cs +0 -33
- data/test/MC/Mips/mips-control-instructions.s.cs +0 -33
- data/test/MC/Mips/mips-coprocessor-encodings.s.cs +0 -17
- data/test/MC/Mips/mips-dsp-instructions.s.cs +0 -43
- data/test/MC/Mips/mips-expansions.s.cs +0 -20
- data/test/MC/Mips/mips-fpu-instructions.s.cs +0 -93
- data/test/MC/Mips/mips-jump-instructions.s.cs +0 -1
- data/test/MC/Mips/mips-memory-instructions.s.cs +0 -17
- data/test/MC/Mips/mips-register-names.s.cs +0 -33
- data/test/MC/Mips/mips64-alu-instructions.s.cs +0 -47
- data/test/MC/Mips/mips64-instructions.s.cs +0 -3
- data/test/MC/Mips/mips64-register-names.s.cs +0 -33
- data/test/MC/Mips/mips_directives.s.cs +0 -12
- data/test/MC/Mips/nabi-regs.s.cs +0 -12
- data/test/MC/Mips/set-at-directive.s.cs +0 -6
- data/test/MC/Mips/test_2r.s.cs +0 -16
- data/test/MC/Mips/test_2rf.s.cs +0 -33
- data/test/MC/Mips/test_3r.s.cs +0 -243
- data/test/MC/Mips/test_3rf.s.cs +0 -83
- data/test/MC/Mips/test_bit.s.cs +0 -49
- data/test/MC/Mips/test_cbranch.s.cs +0 -11
- data/test/MC/Mips/test_ctrlregs.s.cs +0 -33
- data/test/MC/Mips/test_elm.s.cs +0 -16
- data/test/MC/Mips/test_elm_insert.s.cs +0 -4
- data/test/MC/Mips/test_elm_insve.s.cs +0 -5
- data/test/MC/Mips/test_i10.s.cs +0 -5
- data/test/MC/Mips/test_i5.s.cs +0 -45
- data/test/MC/Mips/test_i8.s.cs +0 -11
- data/test/MC/Mips/test_lsa.s.cs +0 -5
- data/test/MC/Mips/test_mi10.s.cs +0 -24
- data/test/MC/Mips/test_vec.s.cs +0 -8
- data/test/MC/PowerPC/ppc64-encoding-bookII.s.cs +0 -25
- data/test/MC/PowerPC/ppc64-encoding-bookIII.s.cs +0 -35
- data/test/MC/PowerPC/ppc64-encoding-ext.s.cs +0 -535
- data/test/MC/PowerPC/ppc64-encoding-fp.s.cs +0 -110
- data/test/MC/PowerPC/ppc64-encoding-vmx.s.cs +0 -170
- data/test/MC/PowerPC/ppc64-encoding.s.cs +0 -202
- data/test/MC/PowerPC/ppc64-operands.s.cs +0 -32
- data/test/MC/README +0 -6
- data/test/MC/Sparc/sparc-alu-instructions.s.cs +0 -47
- data/test/MC/Sparc/sparc-atomic-instructions.s.cs +0 -7
- data/test/MC/Sparc/sparc-ctrl-instructions.s.cs +0 -11
- data/test/MC/Sparc/sparc-fp-instructions.s.cs +0 -59
- data/test/MC/Sparc/sparc-mem-instructions.s.cs +0 -25
- data/test/MC/Sparc/sparc-vis.s.cs +0 -2
- data/test/MC/Sparc/sparc64-alu-instructions.s.cs +0 -13
- data/test/MC/Sparc/sparc64-ctrl-instructions.s.cs +0 -102
- data/test/MC/Sparc/sparcv8-instructions.s.cs +0 -7
- data/test/MC/Sparc/sparcv9-instructions.s.cs +0 -1
- data/test/MC/SystemZ/insn-good-z196.s.cs +0 -589
- data/test/MC/SystemZ/insn-good.s.cs +0 -2265
- data/test/MC/SystemZ/regs-good.s.cs +0 -45
- data/test/MC/X86/3DNow.s.cs +0 -29
- data/test/MC/X86/address-size.s.cs +0 -5
- data/test/MC/X86/avx512-encodings.s.cs +0 -12
- data/test/MC/X86/intel-syntax-encoding.s.cs +0 -30
- data/test/MC/X86/x86-32-avx.s.cs +0 -833
- data/test/MC/X86/x86-32-fma3.s.cs +0 -169
- data/test/MC/X86/x86-32-ms-inline-asm.s.cs +0 -27
- data/test/MC/X86/x86_64-avx-clmul-encoding.s.cs +0 -11
- data/test/MC/X86/x86_64-avx-encoding.s.cs +0 -1058
- data/test/MC/X86/x86_64-bmi-encoding.s.cs +0 -51
- data/test/MC/X86/x86_64-encoding.s.cs +0 -59
- data/test/MC/X86/x86_64-fma3-encoding.s.cs +0 -169
- data/test/MC/X86/x86_64-fma4-encoding.s.cs +0 -98
- data/test/MC/X86/x86_64-hle-encoding.s.cs +0 -3
- data/test/MC/X86/x86_64-imm-widths.s.cs +0 -27
- data/test/MC/X86/x86_64-rand-encoding.s.cs +0 -13
- data/test/MC/X86/x86_64-rtm-encoding.s.cs +0 -4
- data/test/MC/X86/x86_64-sse4a.s.cs +0 -1
- data/test/MC/X86/x86_64-tbm-encoding.s.cs +0 -40
- data/test/MC/X86/x86_64-xop-encoding.s.cs +0 -152
- data/test/README +0 -6
- data/test/test.rb +0 -205
- data/test/test.rb.SPEC +0 -235
- data/test/test_arm.rb +0 -202
- data/test/test_arm.rb.SPEC +0 -275
- data/test/test_arm64.rb +0 -150
- data/test/test_arm64.rb.SPEC +0 -116
- data/test/test_detail.rb +0 -228
- data/test/test_detail.rb.SPEC +0 -322
- data/test/test_exhaustive.rb +0 -80
- data/test/test_mips.rb +0 -118
- data/test/test_mips.rb.SPEC +0 -91
- data/test/test_ppc.rb +0 -137
- data/test/test_ppc.rb.SPEC +0 -84
- data/test/test_sanity.rb +0 -83
- data/test/test_skipdata.rb +0 -111
- data/test/test_skipdata.rb.SPEC +0 -58
- data/test/test_sparc.rb +0 -113
- data/test/test_sparc.rb.SPEC +0 -116
- data/test/test_sysz.rb +0 -111
- data/test/test_sysz.rb.SPEC +0 -61
- data/test/test_x86.rb +0 -189
- data/test/test_x86.rb.SPEC +0 -579
- data/test/test_xcore.rb +0 -100
- data/test/test_xcore.rb.SPEC +0 -75
@@ -0,0 +1,57 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'ffi'
|
4
|
+
|
5
|
+
require 'crabstone/constants'
|
6
|
+
require 'crabstone/version'
|
7
|
+
|
8
|
+
module Crabstone
|
9
|
+
module_function
|
10
|
+
|
11
|
+
# Since some constants/structures are different in different Capstone versions,
|
12
|
+
# some scripts in Crabstone use this method to require the version-sensitive Ruby scripts.
|
13
|
+
# @param [String] path_tpl
|
14
|
+
# @return [Boolean]
|
15
|
+
# @example
|
16
|
+
# version_require 'crabstone/binding/%v/structs'
|
17
|
+
# # equivalent to "require 'crabstone/binding/4/structs'" if Capstone is version 4.
|
18
|
+
def version_require(path_tpl)
|
19
|
+
version_compatitable!
|
20
|
+
path = path_tpl.gsub('%v', cs_major_version.to_s)
|
21
|
+
require path
|
22
|
+
end
|
23
|
+
|
24
|
+
# Get the major version of capstone library.
|
25
|
+
#
|
26
|
+
# @return [Integer]
|
27
|
+
# Returns the major version of Capstone.
|
28
|
+
def cs_major_version
|
29
|
+
cs_version.first
|
30
|
+
end
|
31
|
+
|
32
|
+
# @return [(Integer, Integer)]
|
33
|
+
def cs_version
|
34
|
+
return @cs_version if defined?(@cs_version)
|
35
|
+
|
36
|
+
maj = FFI::MemoryPointer.new(:int)
|
37
|
+
min = FFI::MemoryPointer.new(:int)
|
38
|
+
Binding.cs_version(maj, min)
|
39
|
+
@cs_version = [maj.read_int, min.read_int]
|
40
|
+
end
|
41
|
+
|
42
|
+
# Checks the cs_major is less or equal to Crabstone::VERSION.
|
43
|
+
def version_compatitable!
|
44
|
+
@version_compatitable ||=
|
45
|
+
cs_major_version <= Crabstone::BINDING_MAJ && cs_major_version >= 3
|
46
|
+
maj, min = cs_version
|
47
|
+
raise "FATAL: Crabstone v#{VERSION} doesn't support binding Capstone v#{maj}.#{min}" unless @version_compatitable
|
48
|
+
end
|
49
|
+
|
50
|
+
# @private
|
51
|
+
module Binding
|
52
|
+
extend FFI::Library
|
53
|
+
ffi_lib ['capstone', 'libcapstone.so.4', 'libcapstone.so.3']
|
54
|
+
|
55
|
+
attach_function :cs_version, %i[pointer pointer], :uint
|
56
|
+
end
|
57
|
+
end
|
@@ -0,0 +1,147 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'ffi'
|
4
|
+
|
5
|
+
require 'crabstone/binding'
|
6
|
+
require 'crabstone/cs_version'
|
7
|
+
require 'crabstone/error'
|
8
|
+
require 'crabstone/instruction'
|
9
|
+
|
10
|
+
module Crabstone
|
11
|
+
class Disassembler
|
12
|
+
SYNTAX = {
|
13
|
+
intel: 1,
|
14
|
+
att: 2,
|
15
|
+
no_regname: 3 # for PPC only
|
16
|
+
}.freeze
|
17
|
+
|
18
|
+
DETAIL = {
|
19
|
+
true => 3, # trololol
|
20
|
+
false => 0
|
21
|
+
}.freeze
|
22
|
+
|
23
|
+
SKIPDATA = {
|
24
|
+
true => 3, # trololol
|
25
|
+
false => 0
|
26
|
+
}.freeze
|
27
|
+
|
28
|
+
attr_reader :arch, :mode, :csh, :syntax, :decomposer
|
29
|
+
|
30
|
+
def initialize(arch, mode)
|
31
|
+
@arch = arch
|
32
|
+
@mode = mode
|
33
|
+
@p_csh = FFI::MemoryPointer.new(:ulong_long)
|
34
|
+
safe { Binding.cs_open(arch, mode, @p_csh) }
|
35
|
+
|
36
|
+
@csh = @p_csh.read_ulong_long
|
37
|
+
end
|
38
|
+
|
39
|
+
# After you close the engine, don't use it anymore. Can't believe I even
|
40
|
+
# have to write this.
|
41
|
+
#
|
42
|
+
# @return [void]
|
43
|
+
def close
|
44
|
+
safe { Binding.cs_close(@p_csh) }
|
45
|
+
end
|
46
|
+
|
47
|
+
def syntax=(new_stx)
|
48
|
+
Crabstone::Error.raise!(ErrOption) unless SYNTAX[new_stx]
|
49
|
+
set_raw_option(OPT_SYNTAX, SYNTAX[new_stx])
|
50
|
+
@syntax = new_stx
|
51
|
+
end
|
52
|
+
|
53
|
+
# @param [Boolean] new_val
|
54
|
+
def decomposer=(new_val)
|
55
|
+
Crabstone::Error.raise!(ErrOption) unless DETAIL[new_val]
|
56
|
+
set_raw_option(OPT_DETAIL, DETAIL[new_val])
|
57
|
+
@decomposer = new_val
|
58
|
+
end
|
59
|
+
|
60
|
+
def version
|
61
|
+
Crabstone.cs_version
|
62
|
+
end
|
63
|
+
|
64
|
+
def diet?
|
65
|
+
DIET_MODE
|
66
|
+
end
|
67
|
+
|
68
|
+
def errno
|
69
|
+
Binding.cs_errno(@csh)
|
70
|
+
end
|
71
|
+
|
72
|
+
def skipdata(mnemonic = '.byte')
|
73
|
+
cfg = Binding::SkipdataConfig.new
|
74
|
+
cfg[:mnemonic] = FFI::MemoryPointer.from_string(mnemonic.to_s)
|
75
|
+
|
76
|
+
if block_given?
|
77
|
+
cfg[:callback] = FFI::Function.new(
|
78
|
+
:size_t,
|
79
|
+
%i[pointer size_t size_t pointer]
|
80
|
+
) do |code, sz, offset, _|
|
81
|
+
code = code.read_array_of_uchar(sz).pack('c*')
|
82
|
+
begin
|
83
|
+
Integer(yield(code, offset))
|
84
|
+
rescue StandardError
|
85
|
+
warn "Error in skipdata callback: #{$ERROR_INFO}"
|
86
|
+
# It will go on to crash, but now at least there's more info :)
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
set_raw_option(OPT_SKIPDATA_SETUP, cfg.pointer.address)
|
92
|
+
set_raw_option(OPT_SKIPDATA, SKIPDATA[true])
|
93
|
+
end
|
94
|
+
|
95
|
+
def skipdata_off
|
96
|
+
set_raw_option(OPT_SKIPDATA, SKIPDATA[false])
|
97
|
+
end
|
98
|
+
|
99
|
+
def reg_name(regid)
|
100
|
+
Crabstone::Error.raise!(ErrDiet) if DIET_MODE
|
101
|
+
name = Binding.cs_reg_name(csh, regid)
|
102
|
+
Crabstone::Error.raise!(ErrCsh) unless name
|
103
|
+
name
|
104
|
+
end
|
105
|
+
|
106
|
+
# @return [Array<Crabstone::Instruction>]
|
107
|
+
def disasm(code, offset, count = 0)
|
108
|
+
return [] if code.empty?
|
109
|
+
|
110
|
+
insn_ptr = FFI::MemoryPointer.new(:pointer)
|
111
|
+
insn_count = Binding.cs_disasm(
|
112
|
+
@csh,
|
113
|
+
code,
|
114
|
+
code.bytesize,
|
115
|
+
offset,
|
116
|
+
count,
|
117
|
+
insn_ptr
|
118
|
+
)
|
119
|
+
Crabstone::Error.raise_errno!(errno) if insn_count.zero?
|
120
|
+
|
121
|
+
convert_disasm_result(insn_ptr, insn_count).tap { Binding.free(insn_ptr.read_pointer) }
|
122
|
+
end
|
123
|
+
|
124
|
+
def set_raw_option(opt, val)
|
125
|
+
safe { Binding.cs_option(csh, opt, val) }
|
126
|
+
end
|
127
|
+
|
128
|
+
private
|
129
|
+
|
130
|
+
# Convert the insn_ptr from cs_disasm into Ruby instruction objects.
|
131
|
+
# @param [FFI::MemoryPointer] insn_ptr
|
132
|
+
# @param [Integer] insn_count
|
133
|
+
# @return [Array<Crabstone::Instruction>]
|
134
|
+
def convert_disasm_result(insn_ptr, insn_count)
|
135
|
+
insn_sz = Binding::Instruction.size
|
136
|
+
Array.new(insn_count) do |i|
|
137
|
+
cs_insn_ptr = Binding.malloc(insn_sz)
|
138
|
+
Binding.memcpy(cs_insn_ptr, insn_ptr.read_pointer + i * insn_sz, insn_sz)
|
139
|
+
Crabstone::Instruction.new(@csh, Binding::Instruction.new(cs_insn_ptr), @arch)
|
140
|
+
end
|
141
|
+
end
|
142
|
+
|
143
|
+
def safe
|
144
|
+
yield.tap { |res| Crabstone::Error.raise_errno!(res) unless res.zero? }
|
145
|
+
end
|
146
|
+
end
|
147
|
+
end
|
@@ -0,0 +1,74 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# XXX: Auto-gerneate this file?
|
4
|
+
# Error classes might be added in a newer Capstone version,
|
5
|
+
# but this should not be frequent, currently this file is updated manually.
|
6
|
+
|
7
|
+
module Crabstone
|
8
|
+
# @private
|
9
|
+
class Error < StandardError; end
|
10
|
+
|
11
|
+
class ErrArch < Error; end
|
12
|
+
|
13
|
+
class ErrCsh < Error; end
|
14
|
+
|
15
|
+
class ErrHandle < Error; end
|
16
|
+
|
17
|
+
class ErrMem < Error; end
|
18
|
+
|
19
|
+
class ErrMode < Error; end
|
20
|
+
|
21
|
+
class ErrOK < Error; end
|
22
|
+
|
23
|
+
class ErrOption < Error; end
|
24
|
+
|
25
|
+
class ErrDetail < Error; end
|
26
|
+
|
27
|
+
class ErrMemSetup < Error; end
|
28
|
+
|
29
|
+
class ErrVersion < Error; end
|
30
|
+
|
31
|
+
class ErrDiet < Error; end
|
32
|
+
|
33
|
+
class ErrSkipData < Error; end
|
34
|
+
|
35
|
+
class ErrX86ATT < Error; end
|
36
|
+
|
37
|
+
class ErrX86Intel < Error; end
|
38
|
+
|
39
|
+
class ErrX86MASM < Error; end
|
40
|
+
|
41
|
+
class Error
|
42
|
+
ERRNO = {
|
43
|
+
0 => ErrOK,
|
44
|
+
1 => ErrMem,
|
45
|
+
2 => ErrArch,
|
46
|
+
3 => ErrHandle,
|
47
|
+
4 => ErrCsh,
|
48
|
+
5 => ErrMode,
|
49
|
+
6 => ErrOption,
|
50
|
+
7 => ErrDetail,
|
51
|
+
8 => ErrMemSetup,
|
52
|
+
9 => ErrVersion,
|
53
|
+
10 => ErrDiet,
|
54
|
+
11 => ErrSkipData,
|
55
|
+
12 => ErrX86ATT,
|
56
|
+
13 => ErrX86Intel,
|
57
|
+
14 => ErrX86MASM
|
58
|
+
}.freeze
|
59
|
+
|
60
|
+
def self.raise_errno!(errno)
|
61
|
+
err_klass = ERRNO[errno]
|
62
|
+
raise 'Internal Error: Tried to raise unknown errno' unless err_klass
|
63
|
+
|
64
|
+
err_str = Binding.cs_strerror(errno)
|
65
|
+
raise err_klass, err_str
|
66
|
+
end
|
67
|
+
|
68
|
+
def self.raise!(klass)
|
69
|
+
raise "Invalid error class: #{klass}" unless klass.superclass == self
|
70
|
+
|
71
|
+
raise_errno!(ERRNO.invert[klass])
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
@@ -0,0 +1,178 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'crabstone/arch'
|
4
|
+
require 'crabstone/binding'
|
5
|
+
require 'crabstone/constants'
|
6
|
+
require 'crabstone/error'
|
7
|
+
|
8
|
+
module Crabstone
|
9
|
+
class Instruction
|
10
|
+
attr_reader :csh, :raw_insn
|
11
|
+
|
12
|
+
def initialize(csh, insn, arch)
|
13
|
+
@arch_module = Arch.module_of(arch)
|
14
|
+
@csh = csh
|
15
|
+
@raw_insn = insn
|
16
|
+
init_detail(insn[:detail]) if detailed?
|
17
|
+
end
|
18
|
+
|
19
|
+
def name
|
20
|
+
raise_if_diet
|
21
|
+
name = Binding.cs_insn_name(csh, id)
|
22
|
+
Crabstone::Error.raise!(ErrCsh) unless name
|
23
|
+
name
|
24
|
+
end
|
25
|
+
|
26
|
+
def group_name(grp)
|
27
|
+
raise_if_diet
|
28
|
+
name = Binding.cs_group_name(csh, Integer(grp))
|
29
|
+
Crabstone::Error.raise!(ErrCsh) unless name
|
30
|
+
name
|
31
|
+
end
|
32
|
+
|
33
|
+
# It's more informative to raise if CS_DETAIL is off than just return nil
|
34
|
+
def detailed?
|
35
|
+
!@raw_insn[:detail].pointer.null?
|
36
|
+
end
|
37
|
+
|
38
|
+
def detail
|
39
|
+
raise_unless_detailed
|
40
|
+
@detail
|
41
|
+
end
|
42
|
+
|
43
|
+
def regs_read
|
44
|
+
raise_unless_detailed
|
45
|
+
raise_if_diet
|
46
|
+
@regs_read
|
47
|
+
end
|
48
|
+
|
49
|
+
def regs_write
|
50
|
+
raise_unless_detailed
|
51
|
+
raise_if_diet
|
52
|
+
@regs_write
|
53
|
+
end
|
54
|
+
|
55
|
+
def groups
|
56
|
+
raise_unless_detailed
|
57
|
+
raise_if_diet
|
58
|
+
@groups
|
59
|
+
end
|
60
|
+
|
61
|
+
def group?(group_id)
|
62
|
+
raise_unless_detailed
|
63
|
+
raise_if_diet
|
64
|
+
Binding.cs_insn_group(csh, raw_insn, group_id)
|
65
|
+
end
|
66
|
+
|
67
|
+
def reads_reg?(reg)
|
68
|
+
raise_unless_detailed
|
69
|
+
raise_if_diet
|
70
|
+
Binding.cs_reg_read(csh, raw_insn, @arch_module.register(reg))
|
71
|
+
end
|
72
|
+
|
73
|
+
def writes_reg?(reg)
|
74
|
+
raise_unless_detailed
|
75
|
+
raise_if_diet
|
76
|
+
Binding.cs_reg_write(csh, raw_insn, @arch_module.register(reg))
|
77
|
+
end
|
78
|
+
|
79
|
+
# @return [{:regs_read => Array<Integer>, :regs_write => Array<Integer>}]
|
80
|
+
def regs_access
|
81
|
+
raise_unless_detailed
|
82
|
+
raise_if_diet
|
83
|
+
|
84
|
+
# XXX: Becare of if `typedef uint16_t cs_regs[64];` changes
|
85
|
+
regs_read = FFI::MemoryPointer.new(:uint16, 64)
|
86
|
+
regs_read_count = FFI::MemoryPointer.new(:uint8)
|
87
|
+
regs_write = FFI::MemoryPointer.new(:uint16, 64)
|
88
|
+
regs_write_count = FFI::MemoryPointer.new(:uint8)
|
89
|
+
err = Binding.cs_regs_access(csh, raw_insn, regs_read, regs_read_count, regs_write, regs_write_count)
|
90
|
+
Crabstone::Error.raise_errno(err) if err.nonzero?
|
91
|
+
{
|
92
|
+
regs_read: regs_read.read_array_of_short(regs_read_count.read_int8),
|
93
|
+
regs_write: regs_write.read_array_of_short(regs_write_count.read_int8)
|
94
|
+
}
|
95
|
+
end
|
96
|
+
|
97
|
+
def mnemonic
|
98
|
+
raise_if_diet
|
99
|
+
raw_insn[:mnemonic]
|
100
|
+
end
|
101
|
+
|
102
|
+
def op_str
|
103
|
+
raise_if_diet
|
104
|
+
raw_insn[:op_str]
|
105
|
+
end
|
106
|
+
|
107
|
+
def op_count(op_type = nil)
|
108
|
+
raise_unless_detailed
|
109
|
+
if op_type
|
110
|
+
Binding.cs_op_count(csh, raw_insn, op_type)
|
111
|
+
else
|
112
|
+
operands.size
|
113
|
+
end
|
114
|
+
end
|
115
|
+
|
116
|
+
def bytes
|
117
|
+
raw_insn[:bytes].first(raw_insn[:size])
|
118
|
+
end
|
119
|
+
|
120
|
+
# So an Instruction should respond to all the methods in Instruction, and
|
121
|
+
# all the methods in the Arch specific Instruction class. The methods /
|
122
|
+
# members that have special handling for detail mode or diet mode are
|
123
|
+
# handled above. The rest is dynamically dispatched below.
|
124
|
+
def method_missing(meth, *args)
|
125
|
+
# Dispatch to toplevel Instruction class ( this file )
|
126
|
+
return raw_insn[meth] if raw_insn.members.include?(meth)
|
127
|
+
|
128
|
+
# Nothing else is available without details.
|
129
|
+
unless detailed?
|
130
|
+
raise(
|
131
|
+
NoMethodError,
|
132
|
+
"Either CS_DETAIL is off, or #{self.class} doesn't implement #{meth}"
|
133
|
+
)
|
134
|
+
end
|
135
|
+
# Dispatch to the architecture specific Instruction ( in arch/ )
|
136
|
+
return @arch_insn.__send__(meth, *args) if @arch_insn.respond_to?(meth)
|
137
|
+
return @arch_insn[meth] if @arch_insn.members.include?(meth)
|
138
|
+
|
139
|
+
super
|
140
|
+
end
|
141
|
+
|
142
|
+
def respond_to_missing?(meth, include_private = true)
|
143
|
+
return true if raw_insn.members.include?(meth)
|
144
|
+
return super unless detailed?
|
145
|
+
return true if @arch_insn.respond_to?(meth)
|
146
|
+
return true if @arch_insn.members.include?(meth)
|
147
|
+
|
148
|
+
super
|
149
|
+
end
|
150
|
+
|
151
|
+
private
|
152
|
+
|
153
|
+
def raise_unless_detailed
|
154
|
+
Crabstone::Error.raise!(ErrDetail) unless detailed?
|
155
|
+
end
|
156
|
+
|
157
|
+
def raise_if_diet
|
158
|
+
Crabstone::Error.raise!(ErrDiet) if DIET_MODE
|
159
|
+
end
|
160
|
+
|
161
|
+
def init_detail(detail)
|
162
|
+
@detail = detail
|
163
|
+
@arch_insn = @detail[:arch][arch_field]
|
164
|
+
@regs_read = @detail[:regs_read].first(@detail[:regs_read_count])
|
165
|
+
@regs_write = @detail[:regs_write].first(@detail[:regs_write_count])
|
166
|
+
@groups = @detail[:groups].first(@detail[:groups_count])
|
167
|
+
end
|
168
|
+
|
169
|
+
# Find the field name of Architecture.
|
170
|
+
def arch_field
|
171
|
+
klass = @arch_module.const_get(:Instruction)
|
172
|
+
obj = Binding::Architecture.new
|
173
|
+
Binding::Architecture.members.find do |sym|
|
174
|
+
obj[sym].instance_of?(klass)
|
175
|
+
end
|
176
|
+
end
|
177
|
+
end
|
178
|
+
end
|