Rizin
unix-like reverse engineering framework and cli tools
opcode.h
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: 2009-2012 earada <pkedurat@gmail.com>
2 // SPDX-License-Identifier: LGPL-3.0-only
3 
4 #ifndef DALVIK_OPCODE_H
5 #define DALVIK_OPCODE_H
6 
7 enum fmt_inst {
8  fmt00 = 0, // None
9  fmtop, // op
10  fmtopvAvB, // op vA, vB
11  fmtopvAcB, // op vA, #+B
12  fmtopvAA, // op vAA
13  fmtoppAA, // op +AA
14  fmtopAAtBBBB, // op AA, thing@BBBB
15  fmtoppAAAA, // op +AAAA
16  fmtopvAAvBBBB, // op vAA, vBBBB
17  fmtopvAApBBBB, // op vAA, +BBBB
18  fmtopvAAcBBBB, // op vAA, #+BBBB
19  fmtopvAAcBBBB0000, // op vAA, #+BBBB00000[00000000]
20  fmtopvAAtBBBB, // op vAA, thing@BBBB
21  fmtopvAAvBBvCC, // op vAA, vBB, vCC
22  fmtopvAAvBBcCC, // op vAA, vBB, #+CC
23  fmtopvAvBpCCCC, // op vA, vB, +CCCC
24  fmtopvAvBcCCCC, // op vA, vB, #+CCCC
25  fmtopvAvBtCCCC, // op vA, vB, thing@CCCC
26  fmtoptopvAvBoCCCC, // [opt] op vA, vB, field offset CCCC
27  fmtopvAAAAvBBBB, // op vAAAA, vBBBB
28  fmtoppAAAAAAAA, // op +AAAAAAAA
29  fmtopvAApBBBBBBBB, // op vAA, +BBBBBBBB
30  fmtopvAAcBBBBBBBB, // op vAA, #+BBBBBBBB
31  fmtopvAAtBBBBBBBB, // op vAA, thing@BBBBBBBB
32  fmtopvXtBBBB, // op {vC, vD, vE, vF, vG}, thing@BBBB (B: count, A: vG)
33  fmtoptinvokeVS, // [opt] invoke-virtual+super
34  fmtoptinvokeI, // [opt] invoke-interface
35  fmtopvCCCCmBBBB, // op {vCCCC .. v(CCCC+AA-1)}, meth@BBBB
36  fmtoptinvokeVSR, // [opt] invoke-virtual+super/range
37  fmtoptinvokeIR, // [opt] invoke-interface/range
38  fmtoptinlineI, // [opt] inline invoke
39  fmtoptinlineIR, // [opt] inline invoke/range
40  fmtopvAAcBBBBBBBBBBBBBBBB, // op vAA, #+BBBBBBBBBBBBBBBB
44 };
45 
47  char *name;
48  int len;
49  int fmt;
50 };
51 
52 static const struct dalvik_opcodes_t dalvik_opcodes[256] = {
53  { "nop", 2, fmtop }, /* 0x00 */
54  { "move", 2, fmtopvAvB },
55  { "move/from16", 4, fmtopvAAvBBBB },
56  { "move/16", 6, fmtopvAAAAvBBBB },
57  { "move-wide", 2, fmtopvAvB },
58  { "move-wide/from16", 4, fmtopvAAvBBBB },
59  { "move-wide/16", 6, fmtopvAAAAvBBBB },
60  { "move-object", 2, fmtopvAvB },
61  { "move-object/from16", 4, fmtopvAAvBBBB },
62  { "move-object/16", 6, fmtopvAAAAvBBBB },
63  { "move-result", 2, fmtopvAA },
64  { "move-result-wide", 2, fmtopvAA },
65  { "move-result-object", 2, fmtopvAA },
66  { "move-exception", 2, fmtopvAA },
67  { "return-void", 2, fmtop },
68  { "return", 2, fmtopvAA },
69  { "return-wide", 2, fmtopvAA }, /* 0x10 */
70  { "return-object", 2, fmtopvAA },
71  { "const/4", 2, fmtopvAcB },
72  { "const/16", 4, fmtopvAAcBBBB },
73  { "const", 6, fmtopvAAcBBBBBBBB },
74  { "const/high16", 4, fmtopvAAcBBBB0000 },
75  { "const-wide/16", 4, fmtopvAAcBBBB },
76  { "const-wide/32", 6, fmtopvAAcBBBBBBBB },
77  { "const-wide", 10, fmtopvAAcBBBBBBBBBBBBBBBB },
78  { "const-wide/high16", 4, fmtopvAAcBBBB0000 },
79  { "const-string", 4, fmtopvAAtBBBB },
80  { "const-string/jumbo", 6, fmtopvAAtBBBBBBBB },
81  { "const-class", 4, fmtopvAAtBBBB },
82  { "monitor-enter", 2, fmtopvAA },
83  { "monitor-exit", 2, fmtopvAA },
84  { "check-cast", 4, fmtopvAAtBBBB },
85  { "instance-of", 4, fmtopvAvBtCCCC }, /* 0x20 */
86  { "array-length", 2, fmtopvAvB },
87  { "new-instance", 4, fmtopvAAtBBBB },
88  { "new-array", 4, fmtopvAvBtCCCC },
89  { "filled-new-array", 6, fmtopvXtBBBB },
90  { "filled-new-array/range", 6, fmtopvCCCCmBBBB },
91  { "fill-array-data", 6, fmtopvAApBBBBBBBB },
92  { "throw", 2, fmtopvAA },
93  { "goto", 2, fmtoppAA },
94  { "goto/16", 4, fmtoppAAAA },
95  { "goto/32", 6, fmtoppAAAAAAAA },
96  { "packed-switch", 6, fmtopvAApBBBBBBBB },
97  { "sparse-switch", 6, fmtopvAApBBBBBBBB },
98  { "cmpl-float", 4, fmtopvAAvBBvCC },
99  { "cmpg-float", 4, fmtopvAAvBBvCC },
100  { "cmpl-double", 4, fmtopvAAvBBvCC },
101  { "cmpg-double", 4, fmtopvAAvBBvCC }, /* 0x30 */
102  { "cmp-long", 4, fmtopvAAvBBvCC },
103  { "if-eq", 4, fmtopvAvBpCCCC },
104  { "if-ne", 4, fmtopvAvBpCCCC },
105  { "if-lt", 4, fmtopvAvBpCCCC },
106  { "if-ge", 4, fmtopvAvBpCCCC },
107  { "if-gt", 4, fmtopvAvBpCCCC },
108  { "if-le", 4, fmtopvAvBpCCCC },
109  { "if-eqz", 4, fmtopvAApBBBB },
110  { "if-nez", 4, fmtopvAApBBBB },
111  { "if-ltz", 4, fmtopvAApBBBB },
112  { "if-gez", 4, fmtopvAApBBBB },
113  { "if-gtz", 4, fmtopvAApBBBB },
114  { "if-lez", 4, fmtopvAApBBBB },
115  { "UNUSED", 2, fmt00 },
116  { "UNUSED", 2, fmt00 },
117  { "UNUSED", 2, fmt00 }, /* 0x40 */
118  { "UNUSED", 2, fmt00 },
119  { "UNUSED", 2, fmt00 },
120  { "UNUSED", 2, fmt00 },
121  { "aget", 4, fmtopvAAvBBvCC },
122  { "aget-wide", 4, fmtopvAAvBBvCC },
123  { "aget-object", 4, fmtopvAAvBBvCC },
124  { "aget-boolean", 4, fmtopvAAvBBvCC },
125  { "aget-byte", 4, fmtopvAAvBBvCC },
126  { "aget-char", 4, fmtopvAAvBBvCC },
127  { "aget-short", 4, fmtopvAAvBBvCC },
128  { "aput", 4, fmtopvAAvBBvCC },
129  { "aput-wide", 4, fmtopvAAvBBvCC },
130  { "aput-object", 4, fmtopvAAvBBvCC },
131  { "aput-boolean", 4, fmtopvAAvBBvCC },
132  { "aput-byte", 4, fmtopvAAvBBvCC },
133  { "aput-char", 4, fmtopvAAvBBvCC }, /* 0x50 */
134  { "aput-short", 4, fmtopvAAvBBvCC },
135  { "iget", 4, fmtopvAvBtCCCC },
136  { "iget-wide", 4, fmtopvAvBtCCCC },
137  { "iget-object", 4, fmtopvAvBtCCCC },
138  { "iget-boolean", 4, fmtopvAvBtCCCC },
139  { "iget-byte", 4, fmtopvAvBtCCCC },
140  { "iget-char", 4, fmtopvAvBtCCCC },
141  { "iget-short", 4, fmtopvAvBtCCCC },
142  { "iput", 4, fmtopvAvBtCCCC },
143  { "iput-wide", 4, fmtopvAvBtCCCC },
144  { "iput-object", 4, fmtopvAvBtCCCC },
145  { "iput-boolean", 4, fmtopvAvBtCCCC },
146  { "iput-byte", 4, fmtopvAvBtCCCC },
147  { "iput-char", 4, fmtopvAvBtCCCC },
148  { "iput-short", 4, fmtopvAvBtCCCC },
149  { "sget", 4, fmtopvAAtBBBB }, /* 0x60 */
150  { "sget-wide", 4, fmtopvAAtBBBB },
151  { "sget-object", 4, fmtopvAAtBBBB },
152  { "sget-boolean", 4, fmtopvAAtBBBB },
153  { "sget-byte", 4, fmtopvAAtBBBB },
154  { "sget-char", 4, fmtopvAAtBBBB },
155  { "sget-short", 4, fmtopvAAtBBBB },
156  { "sput", 4, fmtopvAAtBBBB },
157  { "sput-wide", 4, fmtopvAAtBBBB },
158  { "sput-object", 4, fmtopvAAtBBBB },
159  { "sput-boolean", 4, fmtopvAAtBBBB },
160  { "sput-byte", 4, fmtopvAAtBBBB },
161  { "sput-char", 4, fmtopvAAtBBBB },
162  { "sput-short", 4, fmtopvAAtBBBB },
163  { "invoke-virtual", 6, fmtopvXtBBBB },
164  { "invoke-super", 6, fmtopvXtBBBB },
165  { "invoke-direct", 6, fmtopvXtBBBB }, /* 0x70 */
166  { "invoke-static", 6, fmtopvXtBBBB },
167  { "invoke-interface", 6, fmtopvXtBBBB }, // XXX: Maybe use opt invoke-interface ??
168  { "UNUSED", 2, fmt00 },
169  { "invoke-virtual/range", 6, fmtopvCCCCmBBBB },
170  { "invoke-super/range", 6, fmtopvCCCCmBBBB },
171  { "invoke-direct/range", 6, fmtopvCCCCmBBBB },
172  { "invoke-static/range", 6, fmtopvCCCCmBBBB },
173  { "invoke-interface/range", 6, fmtopvCCCCmBBBB },
174  { "UNUSED", 2, fmt00 },
175  { "UNUSED", 2, fmt00 },
176  { "neg-int", 2, fmtopvAvB },
177  { "not-int", 2, fmtopvAvB },
178  { "neg-long", 2, fmtopvAvB },
179  { "not-long", 2, fmtopvAvB },
180  { "neg-float", 2, fmtopvAvB },
181  { "neg-double", 2, fmtopvAvB }, /* 0x80 */
182  { "int-to-long", 2, fmtopvAvB },
183  { "int-to-float", 2, fmtopvAvB },
184  { "int-to-double", 2, fmtopvAvB },
185  { "long-to-int", 2, fmtopvAvB },
186  { "long-to-float", 2, fmtopvAvB },
187  { "long-to-double", 2, fmtopvAvB },
188  { "float-to-int", 2, fmtopvAvB },
189  { "float-to-long", 2, fmtopvAvB },
190  { "float-to-double", 2, fmtopvAvB },
191  { "double-to-int", 2, fmtopvAvB },
192  { "double-to-long", 2, fmtopvAvB },
193  { "double-to-float", 2, fmtopvAvB },
194  { "int-to-byte", 2, fmtopvAvB },
195  { "int-to-char", 2, fmtopvAvB },
196  { "int-to-short", 2, fmtopvAvB },
197  { "add-int", 4, fmtopvAAvBBvCC }, /* 0x90 */
198  { "sub-int", 4, fmtopvAAvBBvCC },
199  { "mul-int", 4, fmtopvAAvBBvCC },
200  { "div-int", 4, fmtopvAAvBBvCC },
201  { "rem-int", 4, fmtopvAAvBBvCC },
202  { "and-int", 4, fmtopvAAvBBvCC },
203  { "or-int", 4, fmtopvAAvBBvCC },
204  { "xor-int", 4, fmtopvAAvBBvCC },
205  { "shl-int", 4, fmtopvAAvBBvCC },
206  { "shr-int", 4, fmtopvAAvBBvCC },
207  { "ushr-int", 4, fmtopvAAvBBvCC },
208  { "add-long", 4, fmtopvAAvBBvCC },
209  { "sub-long", 4, fmtopvAAvBBvCC },
210  { "mul-long", 4, fmtopvAAvBBvCC },
211  { "div-long", 4, fmtopvAAvBBvCC },
212  { "rem-long", 4, fmtopvAAvBBvCC },
213  { "and-long", 4, fmtopvAAvBBvCC }, /* 0xa0 */
214  { "or-long", 4, fmtopvAAvBBvCC },
215  { "xor-long", 4, fmtopvAAvBBvCC },
216  { "shl-long", 4, fmtopvAAvBBvCC },
217  { "shr-long", 4, fmtopvAAvBBvCC },
218  { "ushr-long", 4, fmtopvAAvBBvCC },
219  { "add-float", 4, fmtopvAAvBBvCC },
220  { "sub-float", 4, fmtopvAAvBBvCC },
221  { "mul-float", 4, fmtopvAAvBBvCC },
222  { "div-float", 4, fmtopvAAvBBvCC },
223  { "rem-float", 4, fmtopvAAvBBvCC },
224  { "add-double", 4, fmtopvAAvBBvCC },
225  { "sub-double", 4, fmtopvAAvBBvCC },
226  { "mul-double", 4, fmtopvAAvBBvCC },
227  { "div-double", 4, fmtopvAAvBBvCC },
228  { "rem-double", 4, fmtopvAAvBBvCC },
229  { "add-int/2addr", 2, fmtopvAvB }, /* 0xb0 */
230  { "sub-int/2addr", 2, fmtopvAvB },
231  { "mul-int/2addr", 2, fmtopvAvB },
232  { "div-int/2addr", 2, fmtopvAvB },
233  { "rem-int/2addr", 2, fmtopvAvB },
234  { "and-int/2addr", 2, fmtopvAvB },
235  { "or-int/2addr", 2, fmtopvAvB },
236  { "xor-int/2addr", 2, fmtopvAvB },
237  { "shl-int/2addr", 2, fmtopvAvB },
238  { "shr-int/2addr", 2, fmtopvAvB },
239  { "ushr-int/2addr", 2, fmtopvAvB },
240  { "add-long/2addr", 2, fmtopvAvB },
241  { "sub-long/2addr", 2, fmtopvAvB },
242  { "mul-long/2addr", 2, fmtopvAvB },
243  { "div-long/2addr", 2, fmtopvAvB },
244  { "rem-long/2addr", 2, fmtopvAvB },
245  { "and-long/2addr", 2, fmtopvAvB }, /* 0xc0 */
246  { "or-long/2addr", 2, fmtopvAvB },
247  { "xor-long/2addr", 2, fmtopvAvB },
248  { "shl-long/2addr", 2, fmtopvAvB },
249  { "shr-long/2addr", 2, fmtopvAvB },
250  { "ushr-long/2addr", 2, fmtopvAvB },
251  { "add-float/2addr", 2, fmtopvAvB },
252  { "sub-float/2addr", 2, fmtopvAvB },
253  { "mul-float/2addr", 2, fmtopvAvB },
254  { "div-float/2addr", 2, fmtopvAvB },
255  { "rem-float/2addr", 2, fmtopvAvB },
256  { "add-double/2addr", 2, fmtopvAvB },
257  { "sub-double/2addr", 2, fmtopvAvB },
258  { "mul-double/2addr", 2, fmtopvAvB },
259  { "div-double/2addr", 2, fmtopvAvB },
260  { "rem-double/2addr", 2, fmtopvAvB },
261  { "add-int/lit16", 4, fmtopvAvBcCCCC }, /* 0xd0 */
262  { "rsub-int", 4, fmtopvAvBcCCCC },
263  { "mul-int/lit16", 4, fmtopvAvBcCCCC },
264  { "div-int/lit16", 4, fmtopvAvBcCCCC },
265  { "rem-int/lit16", 4, fmtopvAvBcCCCC },
266  { "and-int/lit16", 4, fmtopvAvBcCCCC },
267  { "or-int/lit16", 4, fmtopvAvBcCCCC },
268  { "xor-int/lit16", 4, fmtopvAvBcCCCC },
269  { "add-int/lit8", 4, fmtopvAAvBBcCC },
270  { "rsub-int/lit8", 4, fmtopvAAvBBcCC },
271  { "mul-int/lit8", 4, fmtopvAAvBBcCC },
272  { "div-int/lit8", 4, fmtopvAAvBBcCC },
273  { "rem-int/lit8", 4, fmtopvAAvBBcCC },
274  { "and-int/lit8", 4, fmtopvAAvBBcCC },
275  { "or-int/lit8", 4, fmtopvAAvBBcCC },
276  { "xor-int/lit8", 4, fmtopvAAvBBcCC },
277  { "shl-int/lit8", 4, fmtopvAAvBBcCC }, /* 0xe0 */
278  { "shr-int/lit8", 4, fmtopvAAvBBcCC },
279  { "ushr-int/lit8", 4, fmtopvAAvBBcCC },
280  { "+iget-volatile", 4, fmtopvAvBtCCCC },
281  { "+iput-volatile", 4, fmtopvAvBtCCCC },
282  { "+sget-volatile", 4, fmtopvAvBtCCCC },
283  { "+sput-volatile", 4, fmtopvAvBtCCCC },
284  { "+iget-object-volatile", 4, fmtopvAvBtCCCC },
285  { "+iget-wide-volatile", 4, fmtopvAvBtCCCC },
286  { "+iput-wide-volatile", 4, fmtopvAvBtCCCC },
287  { "+sget-wide-volatile", 4, fmtopvAvBtCCCC },
288  { "+sput-wide-volatile", 4, fmtopvAvBtCCCC },
289  { "^breakpoint", 4, fmtopvAvBtCCCC },
290  { "^throw-verification-error", 4, fmtopAAtBBBB },
291  { "+execute-inline", 6, fmtoptinlineI },
292  { "+execute-inline/range", 6, fmtoptinlineIR },
293  //{"+invoke-direct-empty", 6, fmtopvXtBBBB}, /* 0xf0 */ // invoke-object-init-range
294  { "+invoke-object-init-range", 6, fmtopvXtBBBB }, /* 0xf0 */ // invoke-object-init-range
295  { "return-void-barrier", 2, fmtop },
296  { "+iget-quick", 4, fmtoptopvAvBoCCCC },
297  { "+iget-wide-quick", 4, fmtoptopvAvBoCCCC },
298  { "+iget-object-quick", 4, fmtoptopvAvBoCCCC },
299  { "+iput-quick", 4, fmtoptopvAvBoCCCC },
300  { "+iput-wide-quick", 4, fmtoptopvAvBoCCCC },
301  { "+iput-object-quick", 4, fmtoptopvAvBoCCCC },
302  { "+invoke-virtual-quick", 6, fmtoptinvokeVS },
303  { "+invoke-virtual-quick/range", 6, fmtoptinvokeVSR },
304  { "invoke-polymorphic", 8, fmtop45CC },
305  { "invoke-polymorphic/range", 8, fmtop4RCC },
306  { "invoke-custom", 6, fmtopvXtBBBB },
307  { "invoke-custom/range", 6, fmtopvCCCCmBBBB },
308  { "+sput-object-volatile", 4, fmtopvAAtBBBB },
309  { "invalid", 2, fmtop }
310 };
311 
312 #endif
fmt_inst
Definition: opcode.h:7
@ fmtopvAAtBBBBBBBB
Definition: opcode.h:31
@ fmtopvAAcBBBB
Definition: opcode.h:18
@ fmtopvAAvBBBB
Definition: opcode.h:16
@ fmtoptinvokeIR
Definition: opcode.h:37
@ fmtopvAvBpCCCC
Definition: opcode.h:23
@ fmtoptinvokeVS
Definition: opcode.h:33
@ fmtop4RCC
Definition: opcode.h:42
@ fmtopvAAvBBvCC
Definition: opcode.h:21
@ fmtopAAtBBBB
Definition: opcode.h:14
@ fmtoptinvokcustom
Definition: opcode.h:43
@ fmtopvXtBBBB
Definition: opcode.h:32
@ fmt00
Definition: opcode.h:8
@ fmtopvAAtBBBB
Definition: opcode.h:20
@ fmtopvCCCCmBBBB
Definition: opcode.h:35
@ fmtopvAAcBBBBBBBB
Definition: opcode.h:30
@ fmtopvAApBBBB
Definition: opcode.h:17
@ fmtoptinvokeVSR
Definition: opcode.h:36
@ fmtopvAvBcCCCC
Definition: opcode.h:24
@ fmtopvAAAAvBBBB
Definition: opcode.h:27
@ fmtoppAA
Definition: opcode.h:13
@ fmtoppAAAA
Definition: opcode.h:15
@ fmtoptinlineI
Definition: opcode.h:38
@ fmtopvAApBBBBBBBB
Definition: opcode.h:29
@ fmtoptinlineIR
Definition: opcode.h:39
@ fmtopvAA
Definition: opcode.h:12
@ fmtopvAvB
Definition: opcode.h:10
@ fmtopvAvBtCCCC
Definition: opcode.h:25
@ fmtoptinvokeI
Definition: opcode.h:34
@ fmtopvAAvBBcCC
Definition: opcode.h:22
@ fmtop
Definition: opcode.h:9
@ fmtopvAAcBBBB0000
Definition: opcode.h:19
@ fmtopvAcB
Definition: opcode.h:11
@ fmtopvAAcBBBBBBBBBBBBBBBB
Definition: opcode.h:40
@ fmtop45CC
Definition: opcode.h:41
@ fmtoptopvAvBoCCCC
Definition: opcode.h:26
@ fmtoppAAAAAAAA
Definition: opcode.h:28
static const struct dalvik_opcodes_t dalvik_opcodes[256]
Definition: opcode.h:52
char * name
Definition: opcode.h:47