crabstone 4.0.4 → 5.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGES.md +6 -0
- data/README.md +24 -8
- data/lib/crabstone/arch/3/constants.rb +86 -0
- data/lib/crabstone/arch/4/constants.rb +116 -0
- data/lib/crabstone/arch/5/arm.rb +111 -0
- data/lib/crabstone/arch/5/arm64.rb +131 -0
- data/lib/crabstone/arch/5/arm64_const.rb +3015 -0
- data/lib/crabstone/arch/5/arm_const.rb +840 -0
- data/lib/crabstone/arch/5/bpf.rb +81 -0
- data/lib/crabstone/arch/5/bpf_const.rb +124 -0
- data/lib/crabstone/arch/5/constants.rb +155 -0
- data/lib/crabstone/arch/5/evm.rb +20 -0
- data/lib/crabstone/arch/5/evm_const.rb +161 -0
- data/lib/crabstone/arch/5/m680x.rb +106 -0
- data/lib/crabstone/arch/5/m680x_const.rb +426 -0
- data/lib/crabstone/arch/5/m68k.rb +129 -0
- data/lib/crabstone/arch/5/m68k_const.rb +496 -0
- data/lib/crabstone/arch/5/mips.rb +57 -0
- data/lib/crabstone/arch/5/mips_const.rb +869 -0
- data/lib/crabstone/arch/5/mos65xx.rb +52 -0
- data/lib/crabstone/arch/5/mos65xx_const.rb +162 -0
- data/lib/crabstone/arch/5/ppc.rb +69 -0
- data/lib/crabstone/arch/5/ppc_const.rb +2024 -0
- data/lib/crabstone/arch/5/riscv.rb +58 -0
- data/lib/crabstone/arch/5/riscv_const.rb +455 -0
- data/lib/crabstone/arch/5/sh.rb +72 -0
- data/lib/crabstone/arch/5/sh_const.rb +376 -0
- data/lib/crabstone/arch/5/sparc.rb +60 -0
- data/lib/crabstone/arch/5/sparc_const.rb +439 -0
- data/lib/crabstone/arch/5/sysz.rb +60 -0
- data/lib/crabstone/arch/5/sysz_const.rb +2532 -0
- data/lib/crabstone/arch/5/tms320c64x.rb +87 -0
- data/lib/crabstone/arch/5/tms320c64x_const.rb +287 -0
- data/lib/crabstone/arch/5/tricore.rb +59 -0
- data/lib/crabstone/arch/5/tricore_const.rb +488 -0
- data/lib/crabstone/arch/5/wasm.rb +81 -0
- data/lib/crabstone/arch/5/wasm_const.rb +201 -0
- data/lib/crabstone/arch/5/x86.rb +98 -0
- data/lib/crabstone/arch/5/x86_const.rb +1999 -0
- data/lib/crabstone/arch/5/xcore.rb +59 -0
- data/lib/crabstone/arch/5/xcore_const.rb +171 -0
- data/lib/crabstone/arch/extension.rb +2 -1
- data/lib/crabstone/arch/register.rb +1 -1
- data/lib/crabstone/arch.rb +6 -0
- data/lib/crabstone/binding/5/detail.rb +47 -0
- data/lib/crabstone/binding/5/instruction.rb +23 -0
- data/lib/crabstone/binding.rb +2 -2
- data/lib/crabstone/constants.rb +2 -107
- data/lib/crabstone/cs_version.rb +2 -3
- data/lib/crabstone/disassembler.rb +2 -3
- data/lib/crabstone/instruction.rb +0 -1
- data/lib/crabstone/version.rb +1 -1
- metadata +45 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 61a5d2f9b0883060f78093231c7679e9d31fff9d30e90eb624f3dd08b2b3b046
|
4
|
+
data.tar.gz: 781b06af4e9ef704e2e076c5ebd66e679cd6e2a7e4bf9af9d1f98dd30b130b5a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3cbdd4aebed09844010ed984f2ec2013bac24c99966bd405f9448bf9043bdaec5ab29ffcd24fa287a3f2a02037825990f1f34da6c7a944e81cb618fd236b3f2c
|
7
|
+
data.tar.gz: c2fd2bac156c6156285bf144aa16a243499e3630de3b7eda720cf0abd2e9788d704e6dc70037b040f59651fdfc3d6ff6cc68356c77beba1cc0788454e37bcf7d
|
data/CHANGES.md
CHANGED
@@ -1,3 +1,9 @@
|
|
1
|
+
## 5.0.0
|
2
|
+
* Support Capstone 5!
|
3
|
+
* New architectures: BPF, MOS65XX, RISC-V, TriCore, SuperH, and WASM
|
4
|
+
* Ensured Ruby version support 3.1 ~ 3.3
|
5
|
+
* [Diff from previous release](https://github.com/david942j/crabstone/compare/v4.0.4...v5.0.0)
|
6
|
+
|
1
7
|
## 4.0.4
|
2
8
|
* Ensured Ruby version support 2.6 ~ 3.1
|
3
9
|
* [Diff from previous release](https://github.com/david942j/crabstone/compare/v4.0.3...v4.0.4)
|
data/README.md
CHANGED
@@ -7,7 +7,7 @@
|
|
7
7
|
crabstone
|
8
8
|
====
|
9
9
|
|
10
|
-
Current library support: Capstone 3 \& 4
|
10
|
+
Current library support: Capstone 3 \& 4 \& 5
|
11
11
|
----
|
12
12
|
|
13
13
|
( FROM THE CAPSTONE README )
|
@@ -48,7 +48,7 @@ Capstone offers some unparalleled features:
|
|
48
48
|
To install:
|
49
49
|
----
|
50
50
|
|
51
|
-
First install the capstone library from either https://github.com/
|
51
|
+
First install the capstone library from either https://github.com/capstone-engine/capstone
|
52
52
|
or http://www.capstone-engine.org
|
53
53
|
|
54
54
|
Then:
|
@@ -60,17 +60,17 @@ gem install crabstone
|
|
60
60
|
To write code:
|
61
61
|
----
|
62
62
|
|
63
|
-
Check the tests in [Capstone](https://github.com/
|
63
|
+
Check the tests in [Capstone](https://github.com/capstone-engine/capstone) for
|
64
|
+
more examples. Here is "Hello World":
|
64
65
|
```ruby
|
65
|
-
|
66
66
|
require 'crabstone'
|
67
|
-
|
67
|
+
|
68
68
|
arm =
|
69
69
|
"\xED\xFF\xFF\xEB\x04\xe0\x2d\xe5\x00\x00\x00\x00\xe0\x83\x22" \
|
70
70
|
"\xe5\xf1\x02\x03\x0e\x00\x00\xa0\xe3\x02\x30\xc1\xe7\x00\x00\x53\xe3"
|
71
71
|
|
72
72
|
begin
|
73
|
-
cs = Disassembler.new(ARCH_ARM, MODE_ARM)
|
73
|
+
cs = Crabstone::Disassembler.new(Crabstone::ARCH_ARM, Crabstone::MODE_ARM)
|
74
74
|
puts "Hello from Capstone v#{cs.version.join('.')}!"
|
75
75
|
puts 'Disasm:'
|
76
76
|
|
@@ -78,16 +78,32 @@ begin
|
|
78
78
|
cs.disasm(arm, 0x1000).each do |i|
|
79
79
|
printf("0x%x:\t%s\t\t%s\n", i.address, i.mnemonic, i.op_str)
|
80
80
|
end
|
81
|
-
rescue
|
81
|
+
rescue Crabstone::Error => e
|
82
82
|
raise "Disassembly error: #{e.message}"
|
83
83
|
ensure
|
84
84
|
cs.close
|
85
85
|
end
|
86
|
-
rescue
|
86
|
+
rescue Crabstone::Error => e
|
87
87
|
raise "Unable to open engine: #{e.message}"
|
88
88
|
end
|
89
89
|
```
|
90
90
|
|
91
|
+
Sample output (exact content may differ according to the Capstone engine version
|
92
|
+
you are using):
|
93
|
+
|
94
|
+
```
|
95
|
+
Hello from Capstone v3.0!
|
96
|
+
Disasm:
|
97
|
+
0x1000: bl #0xfbc
|
98
|
+
0x1004: str lr, [sp, #-4]!
|
99
|
+
0x1008: andeq r0, r0, r0
|
100
|
+
0x100c: str r8, [r2, #-0x3e0]!
|
101
|
+
0x1010: mcreq p2, #0, r0, c3, c1, #7
|
102
|
+
0x1014: mov r0, #0
|
103
|
+
0x1018: strb r3, [r1, r2]
|
104
|
+
0x101c: cmp r3, #0
|
105
|
+
```
|
106
|
+
|
91
107
|
Contributing:
|
92
108
|
----
|
93
109
|
|
@@ -0,0 +1,86 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# THIS FILE WAS AUTO-GENERATED -- DO NOT EDIT!
|
4
|
+
|
5
|
+
module Crabstone
|
6
|
+
API_MAJOR = 3
|
7
|
+
API_MINOR = 0
|
8
|
+
|
9
|
+
VERSION_MAJOR = API_MAJOR
|
10
|
+
VERSION_MINOR = API_MINOR
|
11
|
+
VERSION_EXTRA = 5
|
12
|
+
|
13
|
+
ARCH_ARM = 0
|
14
|
+
ARCH_ARM64 = 1
|
15
|
+
ARCH_MIPS = 2
|
16
|
+
ARCH_X86 = 3
|
17
|
+
ARCH_PPC = 4
|
18
|
+
ARCH_SPARC = 5
|
19
|
+
ARCH_SYSZ = 6
|
20
|
+
ARCH_XCORE = 7
|
21
|
+
ARCH_MAX = 8
|
22
|
+
ARCH_ALL = 0xFFFF
|
23
|
+
|
24
|
+
MODE_LITTLE_ENDIAN = 0 # little-endian mode (default mode)
|
25
|
+
MODE_ARM = 0 # ARM mode
|
26
|
+
MODE_16 = (1 << 1) # 16-bit mode (for X86)
|
27
|
+
MODE_32 = (1 << 2) # 32-bit mode (for X86)
|
28
|
+
MODE_64 = (1 << 3) # 64-bit mode (for X86, PPC)
|
29
|
+
MODE_THUMB = (1 << 4) # ARM's Thumb mode, including Thumb-2
|
30
|
+
MODE_MCLASS = (1 << 5) # ARM's Cortex-M series
|
31
|
+
MODE_V8 = (1 << 6) # ARMv8 A32 encodings for ARM
|
32
|
+
MODE_MICRO = (1 << 4) # MicroMips mode (MIPS architecture)
|
33
|
+
MODE_MIPS3 = (1 << 5) # Mips III ISA
|
34
|
+
MODE_MIPS32R6 = (1 << 6) # Mips32r6 ISA
|
35
|
+
MODE_MIPSGP64 = (1 << 7) # General Purpose Registers are 64-bit wide (MIPS arch)
|
36
|
+
MODE_V9 = (1 << 4) # Sparc V9 mode (for Sparc)
|
37
|
+
MODE_BIG_ENDIAN = (1 << 31) # big-endian mode
|
38
|
+
MODE_MIPS32 = MODE_32 # Mips32 ISA
|
39
|
+
MODE_MIPS64 = MODE_64 # Mips64 ISA
|
40
|
+
|
41
|
+
OPT_SYNTAX = 1 # Intel X86 asm syntax (ARCH_X86 arch)
|
42
|
+
OPT_DETAIL = 2 # Break down instruction structure into details
|
43
|
+
OPT_MODE = 3 # Change engine's mode at run-time
|
44
|
+
OPT_MEM = 4 # Change engine's mode at run-time
|
45
|
+
OPT_SKIPDATA = 5 # Skip data when disassembling
|
46
|
+
OPT_SKIPDATA_SETUP = 6 # Setup user-defined function for SKIPDATA option
|
47
|
+
|
48
|
+
OPT_OFF = 0 # Turn OFF an option - default option of OPT_DETAIL
|
49
|
+
OPT_ON = 3 # Turn ON an option (OPT_DETAIL)
|
50
|
+
|
51
|
+
OP_INVALID = 0
|
52
|
+
OP_REG = 1
|
53
|
+
OP_IMM = 2
|
54
|
+
OP_MEM = 3
|
55
|
+
OP_FP = 4
|
56
|
+
|
57
|
+
GRP_INVALID = 0 # uninitialized/invalid group.
|
58
|
+
GRP_JUMP = 1 # all jump instructions (conditional+direct+indirect jumps)
|
59
|
+
GRP_CALL = 2 # all call instructions
|
60
|
+
GRP_RET = 3 # all return instructions
|
61
|
+
GRP_INT = 4 # all interrupt instructions (int+syscall)
|
62
|
+
GRP_IRET = 5 # all interrupt return instructions
|
63
|
+
|
64
|
+
OPT_SYNTAX_DEFAULT = 0 # Default assembly syntax of all platforms (OPT_SYNTAX)
|
65
|
+
OPT_SYNTAX_INTEL = 1 # Intel X86 asm syntax - default syntax on X86 (OPT_SYNTAX, ARCH_X86)
|
66
|
+
OPT_SYNTAX_ATT = 2 # ATT asm syntax (OPT_SYNTAX, ARCH_X86)
|
67
|
+
OPT_SYNTAX_NOREGNAME = 3 # Asm syntax prints register name with only number - (OPT_SYNTAX, ARCH_PPC, ARCH_ARM)
|
68
|
+
|
69
|
+
ERR_OK = 0 # No error: everything was fine
|
70
|
+
ERR_MEM = 1 # Out-Of-Memory error: cs_open(), cs_disasm()
|
71
|
+
ERR_ARCH = 2 # Unsupported architecture: cs_open()
|
72
|
+
ERR_HANDLE = 3 # Invalid handle: cs_op_count(), cs_op_index()
|
73
|
+
ERR_CSH = 4 # Invalid csh argument: cs_close(), cs_errno(), cs_option()
|
74
|
+
ERR_MODE = 5 # Invalid/unsupported mode: cs_open()
|
75
|
+
ERR_OPTION = 6 # Invalid/unsupported option: cs_option()
|
76
|
+
ERR_DETAIL = 7 # Invalid/unsupported option: cs_option()
|
77
|
+
ERR_MEMSETUP = 8
|
78
|
+
ERR_VERSION = 9 # Unsupported version (bindings)
|
79
|
+
ERR_DIET = 10 # Information irrelevant in diet engine
|
80
|
+
ERR_SKIPDATA = 11 # Access irrelevant data for "data" instruction in SKIPDATA mode
|
81
|
+
ERR_X86_ATT = 12 # X86 AT&T syntax is unsupported (opt-out at compile time)
|
82
|
+
ERR_X86_INTEL = 13 # X86 Intel syntax is unsupported (opt-out at compile time)
|
83
|
+
|
84
|
+
SUPPORT_DIET = ARCH_ALL + 1
|
85
|
+
SUPPORT_X86_REDUCE = ARCH_ALL + 2
|
86
|
+
end
|
@@ -0,0 +1,116 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# THIS FILE WAS AUTO-GENERATED -- DO NOT EDIT!
|
4
|
+
|
5
|
+
module Crabstone
|
6
|
+
API_MAJOR = 4
|
7
|
+
API_MINOR = 0
|
8
|
+
|
9
|
+
VERSION_MAJOR = API_MAJOR
|
10
|
+
VERSION_MINOR = API_MINOR
|
11
|
+
VERSION_EXTRA = 2
|
12
|
+
|
13
|
+
ARCH_ARM = 0
|
14
|
+
ARCH_ARM64 = 1
|
15
|
+
ARCH_MIPS = 2
|
16
|
+
ARCH_X86 = 3
|
17
|
+
ARCH_PPC = 4
|
18
|
+
ARCH_SPARC = 5
|
19
|
+
ARCH_SYSZ = 6
|
20
|
+
ARCH_XCORE = 7
|
21
|
+
ARCH_M68K = 8
|
22
|
+
ARCH_TMS320C64X = 9
|
23
|
+
ARCH_M680X = 10
|
24
|
+
ARCH_EVM = 11
|
25
|
+
ARCH_MAX = 12
|
26
|
+
ARCH_ALL = 0xFFFF
|
27
|
+
|
28
|
+
MODE_LITTLE_ENDIAN = 0 # little-endian mode (default mode)
|
29
|
+
MODE_ARM = 0 # ARM mode
|
30
|
+
MODE_16 = (1 << 1) # 16-bit mode (for X86)
|
31
|
+
MODE_32 = (1 << 2) # 32-bit mode (for X86)
|
32
|
+
MODE_64 = (1 << 3) # 64-bit mode (for X86, PPC)
|
33
|
+
MODE_THUMB = (1 << 4) # ARM's Thumb mode, including Thumb-2
|
34
|
+
MODE_MCLASS = (1 << 5) # ARM's Cortex-M series
|
35
|
+
MODE_V8 = (1 << 6) # ARMv8 A32 encodings for ARM
|
36
|
+
MODE_MICRO = (1 << 4) # MicroMips mode (MIPS architecture)
|
37
|
+
MODE_MIPS3 = (1 << 5) # Mips III ISA
|
38
|
+
MODE_MIPS32R6 = (1 << 6) # Mips32r6 ISA
|
39
|
+
MODE_MIPS2 = (1 << 7) # Mips II ISA
|
40
|
+
MODE_V9 = (1 << 4) # Sparc V9 mode (for Sparc)
|
41
|
+
MODE_QPX = (1 << 4) # Quad Processing eXtensions mode (PPC)
|
42
|
+
MODE_M68K_000 = (1 << 1) # M68K 68000 mode
|
43
|
+
MODE_M68K_010 = (1 << 2) # M68K 68010 mode
|
44
|
+
MODE_M68K_020 = (1 << 3) # M68K 68020 mode
|
45
|
+
MODE_M68K_030 = (1 << 4) # M68K 68030 mode
|
46
|
+
MODE_M68K_040 = (1 << 5) # M68K 68040 mode
|
47
|
+
MODE_M68K_060 = (1 << 6) # M68K 68060 mode
|
48
|
+
MODE_BIG_ENDIAN = (1 << 31) # big-endian mode
|
49
|
+
MODE_MIPS32 = MODE_32 # Mips32 ISA
|
50
|
+
MODE_MIPS64 = MODE_64 # Mips64 ISA
|
51
|
+
MODE_M680X_6301 = (1 << 1) # M680X HD6301/3 mode
|
52
|
+
MODE_M680X_6309 = (1 << 2) # M680X HD6309 mode
|
53
|
+
MODE_M680X_6800 = (1 << 3) # M680X M6800/2 mode
|
54
|
+
MODE_M680X_6801 = (1 << 4) # M680X M6801/3 mode
|
55
|
+
MODE_M680X_6805 = (1 << 5) # M680X M6805 mode
|
56
|
+
MODE_M680X_6808 = (1 << 6) # M680X M68HC08 mode
|
57
|
+
MODE_M680X_6809 = (1 << 7) # M680X M6809 mode
|
58
|
+
MODE_M680X_6811 = (1 << 8) # M680X M68HC11 mode
|
59
|
+
MODE_M680X_CPU12 = (1 << 9) # M680X CPU12 mode
|
60
|
+
MODE_M680X_HCS08 = (1 << 10) # M680X HCS08 mode
|
61
|
+
|
62
|
+
OPT_SYNTAX = 1 # Intel X86 asm syntax (ARCH_X86 arch)
|
63
|
+
OPT_DETAIL = 2 # Break down instruction structure into details
|
64
|
+
OPT_MODE = 3 # Change engine's mode at run-time
|
65
|
+
OPT_MEM = 4 # Change engine's mode at run-time
|
66
|
+
OPT_SKIPDATA = 5 # Skip data when disassembling
|
67
|
+
OPT_SKIPDATA_SETUP = 6 # Setup user-defined function for SKIPDATA option
|
68
|
+
OPT_MNEMONIC = 7 # Customize instruction mnemonic
|
69
|
+
OPT_UNSIGNED = 8 # Print immediate in unsigned form
|
70
|
+
|
71
|
+
OPT_OFF = 0 # Turn OFF an option - default option of OPT_DETAIL
|
72
|
+
OPT_ON = 3 # Turn ON an option (OPT_DETAIL)
|
73
|
+
|
74
|
+
OP_INVALID = 0
|
75
|
+
OP_REG = 1
|
76
|
+
OP_IMM = 2
|
77
|
+
OP_MEM = 3
|
78
|
+
OP_FP = 4
|
79
|
+
|
80
|
+
GRP_INVALID = 0 # uninitialized/invalid group.
|
81
|
+
GRP_JUMP = 1 # all jump instructions (conditional+direct+indirect jumps)
|
82
|
+
GRP_CALL = 2 # all call instructions
|
83
|
+
GRP_RET = 3 # all return instructions
|
84
|
+
GRP_INT = 4 # all interrupt instructions (int+syscall)
|
85
|
+
GRP_IRET = 5 # all interrupt return instructions
|
86
|
+
GRP_PRIVILEGE = 6 # all privileged instructions
|
87
|
+
|
88
|
+
AC_INVALID = 0 # Invalid/unitialized access type.
|
89
|
+
AC_READ = (1 << 0) # Operand that is read from.
|
90
|
+
AC_WRITE = (1 << 1) # Operand that is written to.
|
91
|
+
|
92
|
+
OPT_SYNTAX_DEFAULT = 0 # Default assembly syntax of all platforms (OPT_SYNTAX)
|
93
|
+
OPT_SYNTAX_INTEL = 1 # Intel X86 asm syntax - default syntax on X86 (OPT_SYNTAX, ARCH_X86)
|
94
|
+
OPT_SYNTAX_ATT = 2 # ATT asm syntax (OPT_SYNTAX, ARCH_X86)
|
95
|
+
OPT_SYNTAX_NOREGNAME = 3 # Asm syntax prints register name with only number - (OPT_SYNTAX, ARCH_PPC, ARCH_ARM)
|
96
|
+
OPT_SYNTAX_MASM = 4 # MASM syntax (OPT_SYNTAX, ARCH_X86)
|
97
|
+
|
98
|
+
ERR_OK = 0 # No error: everything was fine
|
99
|
+
ERR_MEM = 1 # Out-Of-Memory error: cs_open(), cs_disasm()
|
100
|
+
ERR_ARCH = 2 # Unsupported architecture: cs_open()
|
101
|
+
ERR_HANDLE = 3 # Invalid handle: cs_op_count(), cs_op_index()
|
102
|
+
ERR_CSH = 4 # Invalid csh argument: cs_close(), cs_errno(), cs_option()
|
103
|
+
ERR_MODE = 5 # Invalid/unsupported mode: cs_open()
|
104
|
+
ERR_OPTION = 6 # Invalid/unsupported option: cs_option()
|
105
|
+
ERR_DETAIL = 7 # Invalid/unsupported option: cs_option()
|
106
|
+
ERR_MEMSETUP = 8
|
107
|
+
ERR_VERSION = 9 # Unsupported version (bindings)
|
108
|
+
ERR_DIET = 10 # Information irrelevant in diet engine
|
109
|
+
ERR_SKIPDATA = 11 # Access irrelevant data for "data" instruction in SKIPDATA mode
|
110
|
+
ERR_X86_ATT = 12 # X86 AT&T syntax is unsupported (opt-out at compile time)
|
111
|
+
ERR_X86_INTEL = 13 # X86 Intel syntax is unsupported (opt-out at compile time)
|
112
|
+
ERR_X86_MASM = 14 # X86 Intel syntax is unsupported (opt-out at compile time)
|
113
|
+
|
114
|
+
SUPPORT_DIET = ARCH_ALL + 1
|
115
|
+
SUPPORT_X86_REDUCE = ARCH_ALL + 2
|
116
|
+
end
|
@@ -0,0 +1,111 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# THIS FILE WAS AUTO-GENERATED -- DO NOT EDIT!
|
4
|
+
|
5
|
+
require 'ffi'
|
6
|
+
|
7
|
+
require 'crabstone/arch/extension'
|
8
|
+
require_relative 'arm_const'
|
9
|
+
|
10
|
+
module Crabstone
|
11
|
+
module ARM
|
12
|
+
class OperandShift < FFI::Struct
|
13
|
+
layout(
|
14
|
+
:type, :uint,
|
15
|
+
:value, :uint
|
16
|
+
)
|
17
|
+
end
|
18
|
+
|
19
|
+
class OperandMemory < FFI::Struct
|
20
|
+
layout(
|
21
|
+
:base, :uint,
|
22
|
+
:index, :uint,
|
23
|
+
:scale, :int,
|
24
|
+
:disp, :int,
|
25
|
+
:lshift, :int
|
26
|
+
)
|
27
|
+
end
|
28
|
+
|
29
|
+
class OperandValue < FFI::Union
|
30
|
+
layout(
|
31
|
+
:reg, :uint,
|
32
|
+
:imm, :int,
|
33
|
+
:fp, :double,
|
34
|
+
:mem, OperandMemory,
|
35
|
+
:setend, :int
|
36
|
+
)
|
37
|
+
end
|
38
|
+
|
39
|
+
class Operand < FFI::Struct
|
40
|
+
layout(
|
41
|
+
:vector_index, :int,
|
42
|
+
:shift, OperandShift,
|
43
|
+
:type, :uint,
|
44
|
+
:value, OperandValue,
|
45
|
+
:subtracted, :bool,
|
46
|
+
:access, :uint8,
|
47
|
+
:neon_lane, :int8
|
48
|
+
)
|
49
|
+
|
50
|
+
include Crabstone::Extension::Operand
|
51
|
+
|
52
|
+
def reg?
|
53
|
+
[
|
54
|
+
OP_REG,
|
55
|
+
OP_SYSREG
|
56
|
+
].include?(self[:type])
|
57
|
+
end
|
58
|
+
|
59
|
+
def imm?
|
60
|
+
[
|
61
|
+
OP_IMM,
|
62
|
+
OP_CIMM,
|
63
|
+
OP_PIMM
|
64
|
+
].include?(self[:type])
|
65
|
+
end
|
66
|
+
|
67
|
+
def mem?
|
68
|
+
self[:type] == OP_MEM
|
69
|
+
end
|
70
|
+
|
71
|
+
def fp?
|
72
|
+
self[:type] == OP_FP
|
73
|
+
end
|
74
|
+
|
75
|
+
def cimm?
|
76
|
+
self[:type] == OP_CIMM
|
77
|
+
end
|
78
|
+
|
79
|
+
def pimm?
|
80
|
+
self[:type] == OP_PIMM
|
81
|
+
end
|
82
|
+
|
83
|
+
def setend?
|
84
|
+
self[:type] == OP_SETEND
|
85
|
+
end
|
86
|
+
|
87
|
+
def sysreg?
|
88
|
+
self[:type] == OP_SYSREG
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
class Instruction < FFI::Struct
|
93
|
+
layout(
|
94
|
+
:usermode, :bool,
|
95
|
+
:vector_size, :int,
|
96
|
+
:vector_data, :int,
|
97
|
+
:cps_mode, :int,
|
98
|
+
:cps_flag, :int,
|
99
|
+
:cc, :uint,
|
100
|
+
:update_flags, :bool,
|
101
|
+
:writeback, :bool,
|
102
|
+
:post_index, :bool,
|
103
|
+
:mem_barrier, :int,
|
104
|
+
:op_count, :uint8,
|
105
|
+
:operands, [Operand, 36]
|
106
|
+
)
|
107
|
+
|
108
|
+
include Crabstone::Extension::Instruction
|
109
|
+
end
|
110
|
+
end
|
111
|
+
end
|
@@ -0,0 +1,131 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# THIS FILE WAS AUTO-GENERATED -- DO NOT EDIT!
|
4
|
+
|
5
|
+
require 'ffi'
|
6
|
+
|
7
|
+
require 'crabstone/arch/extension'
|
8
|
+
require_relative 'arm64_const'
|
9
|
+
|
10
|
+
module Crabstone
|
11
|
+
module ARM64
|
12
|
+
class OperandShift < FFI::Struct
|
13
|
+
layout(
|
14
|
+
:type, :uint,
|
15
|
+
:value, :uint
|
16
|
+
)
|
17
|
+
end
|
18
|
+
|
19
|
+
class OperandMemory < FFI::Struct
|
20
|
+
layout(
|
21
|
+
:base, :uint,
|
22
|
+
:index, :uint,
|
23
|
+
:disp, :int
|
24
|
+
)
|
25
|
+
end
|
26
|
+
|
27
|
+
class OperandSmeIndex < FFI::Struct
|
28
|
+
layout(
|
29
|
+
:reg, :uint,
|
30
|
+
:base, :uint,
|
31
|
+
:disp, :int
|
32
|
+
)
|
33
|
+
end
|
34
|
+
|
35
|
+
class OperandValue < FFI::Union
|
36
|
+
layout(
|
37
|
+
:reg, :uint,
|
38
|
+
:imm, :long,
|
39
|
+
:fp, :double,
|
40
|
+
:mem, OperandMemory,
|
41
|
+
:pstate, :int,
|
42
|
+
:sys, :uint,
|
43
|
+
:prefetch, :int,
|
44
|
+
:barrier, :int,
|
45
|
+
:sme_index, OperandSmeIndex
|
46
|
+
)
|
47
|
+
end
|
48
|
+
|
49
|
+
class Operand < FFI::Struct
|
50
|
+
layout(
|
51
|
+
:vector_index, :int,
|
52
|
+
:vas, :int,
|
53
|
+
:shift, OperandShift,
|
54
|
+
:ext, :uint,
|
55
|
+
:type, :uint,
|
56
|
+
:svcr, :uint,
|
57
|
+
:value, OperandValue,
|
58
|
+
:access, :uint8
|
59
|
+
)
|
60
|
+
def shift?
|
61
|
+
self[:shift][:type] != SFT_INVALID
|
62
|
+
end
|
63
|
+
|
64
|
+
def ext?
|
65
|
+
self[:ext] != EXT_INVALID
|
66
|
+
end
|
67
|
+
|
68
|
+
include Crabstone::Extension::Operand
|
69
|
+
|
70
|
+
def reg?
|
71
|
+
self[:type] == OP_REG
|
72
|
+
end
|
73
|
+
|
74
|
+
def imm?
|
75
|
+
[
|
76
|
+
OP_IMM,
|
77
|
+
OP_CIMM
|
78
|
+
].include?(self[:type])
|
79
|
+
end
|
80
|
+
|
81
|
+
def mem?
|
82
|
+
self[:type] == OP_MEM
|
83
|
+
end
|
84
|
+
|
85
|
+
def fp?
|
86
|
+
self[:type] == OP_FP
|
87
|
+
end
|
88
|
+
|
89
|
+
def cimm?
|
90
|
+
self[:type] == OP_CIMM
|
91
|
+
end
|
92
|
+
|
93
|
+
def pstate?
|
94
|
+
self[:type] == OP_PSTATE
|
95
|
+
end
|
96
|
+
|
97
|
+
def sys?
|
98
|
+
self[:type] == OP_SYS
|
99
|
+
end
|
100
|
+
|
101
|
+
def svcr?
|
102
|
+
self[:type] == OP_SVCR
|
103
|
+
end
|
104
|
+
|
105
|
+
def prefetch?
|
106
|
+
self[:type] == OP_PREFETCH
|
107
|
+
end
|
108
|
+
|
109
|
+
def barrier?
|
110
|
+
self[:type] == OP_BARRIER
|
111
|
+
end
|
112
|
+
|
113
|
+
def sme_index?
|
114
|
+
self[:type] == OP_SME_INDEX
|
115
|
+
end
|
116
|
+
end
|
117
|
+
|
118
|
+
class Instruction < FFI::Struct
|
119
|
+
layout(
|
120
|
+
:cc, :uint,
|
121
|
+
:update_flags, :bool,
|
122
|
+
:writeback, :bool,
|
123
|
+
:post_index, :bool,
|
124
|
+
:op_count, :uint8,
|
125
|
+
:operands, [Operand, 8]
|
126
|
+
)
|
127
|
+
|
128
|
+
include Crabstone::Extension::Instruction
|
129
|
+
end
|
130
|
+
end
|
131
|
+
end
|