Rizin
unix-like reverse engineering framework and cli tools
analysis_mcore.c File Reference
#include <rz_analysis.h>
#include <rz_types.h>
#include <rz_lib.h>
#include "../../asm/arch/mcore/mcore.h"

Go to the source code of this file.

Functions

static int mcore_analysis (RzAnalysis *analysis, RzAnalysisOp *op, ut64 addr, const ut8 *buf, int len, RzAnalysisOpMask mask)
 
static char * get_reg_profile (RzAnalysis *analysis)
 
static int archinfo (RzAnalysis *analysis, int q)
 

Variables

RzAnalysisPlugin rz_analysis_plugin_mcore
 
RZ_API RzLibStruct rizin_plugin
 

Function Documentation

◆ archinfo()

static int archinfo ( RzAnalysis analysis,
int  q 
)
static

Definition at line 113 of file analysis_mcore.c.

113  {
114  return 2;
115 }

◆ get_reg_profile()

static char* get_reg_profile ( RzAnalysis analysis)
static

Definition at line 47 of file analysis_mcore.c.

47  {
48  const char *p =
49  "=PC pc\n"
50  "=SP r1\n"
51  "=SR sr\n"
52  "=A0 r3\n"
53  "=A1 r4\n"
54  "=A2 r5\n"
55  "=A3 r6\n"
56  "=A4 r7\n"
57  "=A5 r8\n"
58  "=A6 r6\n"
59  "gpr r0 .32 0 0\n"
60  "gpr r1 .32 4 0\n"
61  "gpr r2 .32 8 0\n"
62  "gpr r3 .32 12 0\n"
63  "gpr r4 .32 16 0\n"
64  "gpr r5 .32 20 0\n"
65  "gpr r6 .32 24 0\n"
66  "gpr r7 .32 28 0\n"
67  "gpr r8 .32 32 0\n"
68  "gpr r9 .32 36 0\n"
69  "gpr r10 .32 40 0\n"
70  "gpr r11 .32 44 0\n"
71  "gpr r12 .32 48 0\n"
72  "gpr r13 .32 52 0\n"
73  "gpr r14 .32 56 0\n"
74  "gpr r15 .32 60 0\n"
75 
76  "gpr psr .32 64 0\n"
77  "gpr vbr .32 68 0\n"
78  "gpr epsr .32 72 0\n"
79  "gpr fpsr .32 76 0\n"
80  "gpr epc .32 80 0\n"
81  "gpr fpc .32 84 0\n"
82  "gpr ss0 .32 88 0\n"
83  "gpr ss1 .32 92 0\n"
84  "gpr ss2 .32 96 0\n"
85  "gpr ss3 .32 100 0\n"
86  "gpr ss4 .32 104 0\n"
87  "gpr gcr .32 108 0\n"
88  "gpr gsr .32 112 0\n"
89  "gpr cpidr .32 116 0\n"
90  "gpr dcsr .32 120 0\n"
91  "gpr cwr .32 124 0\n"
92  "gpr cr16 .32 128 0\n"
93  "gpr cfr .32 132 0\n"
94  "gpr ccr .32 136 0\n"
95  "gpr capr .32 140 0\n"
96  "gpr pacr .32 144 0\n"
97  "gpr prsr .32 148 0\n"
98 
99  "gpr cr22 .32 152 0\n"
100  "gpr cr23 .32 156 0\n"
101  "gpr cr24 .32 160 0\n"
102  "gpr cr25 .32 164 0\n"
103  "gpr cr26 .32 168 0\n"
104  "gpr cr27 .32 172 0\n"
105  "gpr cr28 .32 176 0\n"
106  "gpr cr29 .32 180 0\n"
107  "gpr cr30 .32 184 0\n"
108  "gpr cr31 .32 188 0\n"
109  "gpr pc .32 192 0\n";
110  return strdup(p);
111 }
void * p
Definition: libc.cpp:67
return strdup("=SP r13\n" "=LR r14\n" "=PC r15\n" "=A0 r0\n" "=A1 r1\n" "=A2 r2\n" "=A3 r3\n" "=ZF zf\n" "=SF nf\n" "=OF vf\n" "=CF cf\n" "=SN or0\n" "gpr lr .32 56 0\n" "gpr pc .32 60 0\n" "gpr cpsr .32 64 0 ____tfiae_________________qvczn\n" "gpr or0 .32 68 0\n" "gpr tf .1 64.5 0 thumb\n" "gpr ef .1 64.9 0 endian\n" "gpr jf .1 64.24 0 java\n" "gpr qf .1 64.27 0 sticky_overflow\n" "gpr vf .1 64.28 0 overflow\n" "gpr cf .1 64.29 0 carry\n" "gpr zf .1 64.30 0 zero\n" "gpr nf .1 64.31 0 negative\n" "gpr itc .4 64.10 0 if_then_count\n" "gpr gef .4 64.16 0 great_or_equal\n" "gpr r0 .32 0 0\n" "gpr r1 .32 4 0\n" "gpr r2 .32 8 0\n" "gpr r3 .32 12 0\n" "gpr r4 .32 16 0\n" "gpr r5 .32 20 0\n" "gpr r6 .32 24 0\n" "gpr r7 .32 28 0\n" "gpr r8 .32 32 0\n" "gpr r9 .32 36 0\n" "gpr r10 .32 40 0\n" "gpr r11 .32 44 0\n" "gpr r12 .32 48 0\n" "gpr r13 .32 52 0\n" "gpr r14 .32 56 0\n" "gpr r15 .32 60 0\n" "gpr r16 .32 64 0\n" "gpr r17 .32 68 0\n")

References p, and strdup().

◆ mcore_analysis()

static int mcore_analysis ( RzAnalysis analysis,
RzAnalysisOp op,
ut64  addr,
const ut8 buf,
int  len,
RzAnalysisOpMask  mask 
)
static

Definition at line 9 of file analysis_mcore.c.

9  {
10  mcore_handle handle = { 0 };
11  mcore_t *instr = NULL;
12 
13  if (mcore_init(&handle, buf, len)) {
14  RZ_LOG_ERROR("mcore: bad or invalid data.\n");
15  return -1;
16  }
17 
18  op->size = 2;
19  if ((instr = mcore_next(&handle))) {
20  op->type = instr->type;
21  switch (instr->type) {
24  op->fail = addr + 2;
25  op->jump = addr + instr->args[0].value + 1;
26  break;
28  op->jump = addr + instr->args[0].value + 1;
29  break;
31  // the loading address depends on the word
32  // that this pointer points to.
33  // op->jump = addr + ((instr->args[i].value << 2) & 0xfffffffc);
34  break;
37  op->eob = true;
38  break;
39  default:
40  break;
41  }
42  mcore_free(instr);
43  }
44  return op->size;
45 }
size_t len
Definition: 6502dis.c:15
static mcore_handle handle
Definition: asm_mcore.c:8
#define NULL
Definition: cris-opc.c:27
voidpf void * buf
Definition: ioapi.h:138
int mcore_init(mcore_handle *handle, const ut8 *buffer, const ut32 size)
Definition: mcore.c:409
mcore_t * mcore_next(mcore_handle *handle)
Definition: mcore.c:418
void mcore_free(mcore_t *instr)
Definition: mcore.c:432
@ RZ_ANALYSIS_OP_TYPE_ICALL
Definition: rz_analysis.h:381
@ RZ_ANALYSIS_OP_TYPE_JMP
Definition: rz_analysis.h:368
@ RZ_ANALYSIS_OP_TYPE_CALL
Definition: rz_analysis.h:378
@ RZ_ANALYSIS_OP_TYPE_CJMP
Definition: rz_analysis.h:373
@ RZ_ANALYSIS_OP_TYPE_ILL
Definition: rz_analysis.h:387
@ RZ_ANALYSIS_OP_TYPE_RET
Definition: rz_analysis.h:385
#define RZ_LOG_ERROR(fmtstr,...)
Definition: rz_log.h:58
ut32 value
Definition: mcore.h:36
Definition: mcore.h:40
ut64 type
Definition: mcore.h:43
mcore_field_t args[ARGS_SIZE]
Definition: mcore.h:42
Definition: dis.c:32
static int addr
Definition: z80asm.c:58

References addr, mcore_t::args, handle, len, mcore_free(), mcore_init(), mcore_next(), NULL, RZ_ANALYSIS_OP_TYPE_CALL, RZ_ANALYSIS_OP_TYPE_CJMP, RZ_ANALYSIS_OP_TYPE_ICALL, RZ_ANALYSIS_OP_TYPE_ILL, RZ_ANALYSIS_OP_TYPE_JMP, RZ_ANALYSIS_OP_TYPE_RET, RZ_LOG_ERROR, mcore_t::type, and mcore_field_t::value.

Variable Documentation

◆ rizin_plugin

RZ_API RzLibStruct rizin_plugin
Initial value:
= {
}
RzAnalysisPlugin rz_analysis_plugin_mcore
@ RZ_LIB_TYPE_ANALYSIS
Definition: rz_lib.h:73
#define RZ_VERSION
Definition: rz_version.h:8
const char * version
Definition: rz_analysis.h:1239

Definition at line 129 of file analysis_mcore.c.

◆ rz_analysis_plugin_mcore

RzAnalysisPlugin rz_analysis_plugin_mcore
Initial value:
= {
.name = "mcore",
.desc = "MCore analysis plugin",
.arch = "mcore",
.license = "LGPL3",
.bits = 32,
.archinfo = archinfo,
.get_reg_profile = &get_reg_profile,
}
static char * get_reg_profile(RzAnalysis *analysis)
static int mcore_analysis(RzAnalysis *analysis, RzAnalysisOp *op, ut64 addr, const ut8 *buf, int len, RzAnalysisOpMask mask)
Definition: analysis_mcore.c:9
static int archinfo(RzAnalysis *analysis, int q)

Definition at line 117 of file analysis_mcore.c.