Rizin
unix-like reverse engineering framework and cli tools
analysis_nios2.c
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: 2014 pancake <pancake@nopcode.org>
2 // SPDX-License-Identifier: LGPL-3.0-only
3 
4 #include <string.h>
5 #include <rz_types.h>
6 #include <rz_lib.h>
7 #include <rz_asm.h>
8 #include <rz_analysis.h>
9 
10 static int nios2_op(RzAnalysis *analysis, RzAnalysisOp *op, ut64 addr, const ut8 *b, int len, RzAnalysisOpMask mask) {
11  if (!op) {
12  return 1;
13  }
14  op->size = 4;
15 
16  if ((b[0] & 0xff) == 0x3a) {
17  // XXX
19  } else if ((b[0] & 0xf) == 0xa) {
21  } else if ((b[0] & 0xf) == 4) {
23  } else if ((b[0] & 0xf) == 5) {
25  } else if ((b[0] & 0xf) == 6) {
26  // blt, r19, r5, 0x8023480
28  // TODO: address
29  } else if ((b[0] & 0xf) == 7) {
30  // blt, r19, r5, 0x8023480
32  // TODO: address
33  } else {
34  switch (b[0]) {
35  case 0x3a:
36  if (b[1] >= 0xa0 && b[1] <= 0xaf && b[3] == 0x3d) {
38  } else if ((b[1] >= 0xe0 && b[1] <= 0xe7) && b[2] == 0x3e && !b[3]) {
39  // nextpc ra
41  }
42  break;
43  case 0x01:
44  // jmpi
46  break;
47  case 0x00:
48  case 0x20:
49  case 0x40:
50  case 0x80:
51  case 0xc0:
52  //
54  break;
55  case 0x26:
56  // beq
57  break;
58  case 0x07:
59  case 0x47:
60  case 0x87:
61  case 0xc7:
62  // ldb
64  break;
65  case 0x0d:
66  case 0x2d:
67  case 0x4d:
68  case 0x8d:
69  case 0xcd:
70  // sth && sthio
72  break;
73  case 0x06:
74  case 0x46:
75  case 0x86:
76  case 0xc6:
77  // br
79  break;
80  }
81  }
82  return op->size;
83 }
84 
86  .name = "nios2",
87  .desc = "NIOS II code analysis plugin",
88  .license = "LGPL3",
89  .arch = "nios2",
90  .esil = false,
91  .bits = 32,
92  .op = &nios2_op,
93 };
94 
95 #ifndef RZ_PLUGIN_INCORE
98  .data = &rz_analysis_plugin_nios2,
100 };
101 #endif
size_t len
Definition: 6502dis.c:15
#define mask()
static int nios2_op(RzAnalysis *analysis, RzAnalysisOp *op, ut64 addr, const ut8 *b, int len, RzAnalysisOpMask mask)
RZ_API RzLibStruct rizin_plugin
RzAnalysisPlugin rz_analysis_plugin_nios2
#define RZ_API
uint8_t ut8
Definition: lh5801.h:11
RzAnalysisOpMask
Definition: rz_analysis.h:439
@ RZ_ANALYSIS_OP_TYPE_LOAD
Definition: rz_analysis.h:416
@ RZ_ANALYSIS_OP_TYPE_JMP
Definition: rz_analysis.h:368
@ RZ_ANALYSIS_OP_TYPE_TRAP
Definition: rz_analysis.h:392
@ RZ_ANALYSIS_OP_TYPE_CALL
Definition: rz_analysis.h:378
@ RZ_ANALYSIS_OP_TYPE_ADD
Definition: rz_analysis.h:401
@ RZ_ANALYSIS_OP_TYPE_STORE
Definition: rz_analysis.h:415
@ RZ_ANALYSIS_OP_TYPE_CJMP
Definition: rz_analysis.h:373
@ RZ_ANALYSIS_OP_TYPE_RET
Definition: rz_analysis.h:385
@ RZ_LIB_TYPE_ANALYSIS
Definition: rz_lib.h:73
#define RZ_VERSION
Definition: rz_version.h:8
#define b(i)
Definition: sha256.c:42
const char * version
Definition: rz_analysis.h:1239
Definition: dis.c:32
ut64(WINAPI *w32_GetEnabledXStateFeatures)()
static int addr
Definition: z80asm.c:58