mirror of
https://github.com/radareorg/radare2.git
synced 2024-11-23 13:19:54 +00:00
Migrate m68k_gnu plugin ##arch
This commit is contained in:
parent
fb4a0bdfdc
commit
06b6f85581
2
dist/plugins-cfg/plugins.def.cfg
vendored
2
dist/plugins-cfg/plugins.def.cfg
vendored
@ -30,7 +30,7 @@ arch.lm32
|
||||
anal.loongarch_gnu
|
||||
anal.m680x_cs
|
||||
anal.m68k_cs
|
||||
anal.m68k_gnu
|
||||
arch.m68k_gnu
|
||||
arch.mcore
|
||||
arch.mcs96
|
||||
anal.mips_cs
|
||||
|
2
dist/plugins-cfg/plugins.mingw.cfg
vendored
2
dist/plugins-cfg/plugins.mingw.cfg
vendored
@ -43,7 +43,7 @@ arch.v850
|
||||
arch.ws
|
||||
arch.xap
|
||||
anal.x86_cs
|
||||
anal.m68k_gnu
|
||||
arch.m68k_gnu
|
||||
anal.xcore_cs
|
||||
arch.z80
|
||||
arch.v810
|
||||
|
2
dist/plugins-cfg/plugins.nocs.cfg
vendored
2
dist/plugins-cfg/plugins.nocs.cfg
vendored
@ -46,7 +46,7 @@ arch.pyc
|
||||
arch.propeller
|
||||
esil.dummy
|
||||
asm.null
|
||||
anal.m68k_gnu
|
||||
arch.m68k_gnu
|
||||
arch.any_as
|
||||
arch.x86_nasm
|
||||
arch.x86_nz
|
||||
|
2
dist/plugins-cfg/plugins.termux.cfg
vendored
2
dist/plugins-cfg/plugins.termux.cfg
vendored
@ -39,7 +39,7 @@ arch.v810
|
||||
esil.dummy
|
||||
arch.arm
|
||||
asm.null
|
||||
anal.m68k_gnu
|
||||
arch.m68k_gnu
|
||||
arch.x86_nasm
|
||||
arch.any_as
|
||||
arch.x86_nz
|
||||
|
@ -57,9 +57,9 @@ r_anal_sources = [
|
||||
'../arch/p/lh5801/plugin.c',
|
||||
'p/anal_m680x_cs.c',
|
||||
'p/anal_m68k_cs.c',
|
||||
'p/anal_m68k_gnu.c',
|
||||
'../asm/arch/m68k/gnu/m68k-dis.c',
|
||||
'../asm/arch/m68k/gnu/m68k-opc.c',
|
||||
'../arch/p/m68k_gnu/plugin.c',
|
||||
'../arch/p/m68k_gnu/m68k-dis.c',
|
||||
'../arch/p/m68k_gnu/m68k-opc.c',
|
||||
'p/anal_mips_cs.c',
|
||||
'../asm/arch/mips/mipsasm.c',
|
||||
'../asm/arch/mips/gnu/mips-dis.c',
|
||||
|
@ -1,14 +0,0 @@
|
||||
OBJ_M68K_GNU=anal_m68k_gnu.o
|
||||
OBJ_M68K_GNU+=../../asm/arch/m68k/gnu/m68k-dis.o
|
||||
OBJ_M68K_GNU+=../../asm/arch/m68k/gnu/m68k-opc.o
|
||||
|
||||
STATIC_OBJ+=${OBJ_M68K_GNU}
|
||||
TARGET_M68K_GNU=anal_m68k_gnu.${EXT_SO}
|
||||
|
||||
ifeq ($(WITHPIC),1)
|
||||
ALL_TARGETS+=${TARGET_M68K_GNU}
|
||||
|
||||
${TARGET_M68K_GNU}: ${OBJ_M68K_GNU}
|
||||
${CC} $(call libname,anal_m68k) ${LDFLAGS} ${CFLAGS} \
|
||||
-o anal_m68k_gnu.${EXT_SO} ${OBJ_M68K_GNU}
|
||||
endif
|
@ -29,6 +29,10 @@ r_arch_sources = [
|
||||
'p/s390_gnu/plugin.c',
|
||||
'p/s390_gnu/s390-dis.c',
|
||||
'p/s390_gnu/s390-opc.c',
|
||||
'p/m68k_gnu/plugin.c',
|
||||
'p/m68k_gnu/m68k-dis.c',
|
||||
'p/m68k_gnu/m68k-opc.c',
|
||||
'p/arm/gnu/floatformat.c',
|
||||
# fails on windows
|
||||
# error LNK2005: SocketNotificationRetrieveEvents already defined in p_hppa_gnu_hppa-dis.c.obj
|
||||
'p/hppa/plugin_gnu.c',
|
||||
|
15
libr/arch/p/m68k_gnu.mk
Normal file
15
libr/arch/p/m68k_gnu.mk
Normal file
@ -0,0 +1,15 @@
|
||||
OBJ_M68K_GNU=p/m68k_gnu/plugin.o
|
||||
OBJ_M68K_GNU+=p/m68k_gnu/m68k-dis.o
|
||||
OBJ_M68K_GNU+=p/m68k_gnu/m68k-opc.o
|
||||
OBJ_M68K_GNU+=p/arm/gnu/floatformat.o
|
||||
|
||||
STATIC_OBJ+=${OBJ_M68K_GNU}
|
||||
TARGET_M68K_GNU=m68k_gnu.${EXT_SO}
|
||||
|
||||
ifeq ($(WITHPIC),1)
|
||||
ALL_TARGETS+=${TARGET_M68K_GNU}
|
||||
|
||||
${TARGET_M68K_GNU}: ${OBJ_M68K_GNU}
|
||||
${CC} $(call libname,arch_m68k) ${LDFLAGS} ${CFLAGS} \
|
||||
-o m68k_gnu.${EXT_SO} ${OBJ_M68K_GNU}
|
||||
endif
|
@ -22,7 +22,7 @@
|
||||
#include "mybfd.h"
|
||||
#include "disas-asm.h"
|
||||
// #include "disassemble.h"
|
||||
#include "../../../arch/p/arm/gnu/floatformat.h"
|
||||
#include "../arm/gnu/floatformat.h"
|
||||
#include "libiberty.h"
|
||||
#include "opintl.h"
|
||||
// #include "cpu-m68k.h"
|
@ -3,11 +3,8 @@
|
||||
#include <stdio.h>
|
||||
#include <stdarg.h>
|
||||
#include <string.h>
|
||||
#include <r_types.h>
|
||||
#include <r_lib.h>
|
||||
#include <r_util.h>
|
||||
#include "../../asm/arch/include/opcode/m68k.h"
|
||||
#include <r_asm.h>
|
||||
#include "../../../asm/arch/include/opcode/m68k.h"
|
||||
#include <r_arch.h>
|
||||
#include "disas-asm.h"
|
||||
|
||||
typedef struct {
|
||||
@ -70,7 +67,10 @@ static void memory_error_func(int status, bfd_vma memaddr, struct disassemble_in
|
||||
DECLARE_GENERIC_PRINT_ADDRESS_FUNC_NOGLOBALS()
|
||||
DECLARE_GENERIC_FPRINTF_FUNC_NOGLOBALS()
|
||||
|
||||
static int m68k_op(RAnal *a, RAnalOp *op, ut64 addr, const ut8 *buf, int len, RAnalOpMask mask) {
|
||||
static bool decode(RArchSession *as, RAnalOp *op, RAnalOpMask mask) {
|
||||
const ut64 addr = op->addr;
|
||||
const int len = op->size;
|
||||
const ut8 *buf = op->bytes;
|
||||
ut8 bytes[8] = {0};
|
||||
struct disassemble_info disasm_obj = {0};
|
||||
RStrBuf *sb = NULL;
|
||||
@ -85,10 +85,10 @@ static int m68k_op(RAnal *a, RAnalOp *op, ut64 addr, const ut8 *buf, int len, RA
|
||||
disasm_obj.symbol_at_address_func = &symbol_at_address;
|
||||
disasm_obj.memory_error_func = &memory_error_func;
|
||||
disasm_obj.print_address_func = &generic_print_address_func;
|
||||
disasm_obj.endian = !R_ARCH_CONFIG_IS_BIG_ENDIAN (a->config);
|
||||
disasm_obj.endian = !R_ARCH_CONFIG_IS_BIG_ENDIAN (as->config);
|
||||
disasm_obj.fprintf_func = &generic_fprintf_func;
|
||||
disasm_obj.stream = sb;
|
||||
disasm_obj.mach = detect_cpu (a->config->cpu);
|
||||
disasm_obj.mach = detect_cpu (as->config->cpu);
|
||||
op->size = print_insn_m68k ((bfd_vma)addr, &disasm_obj);
|
||||
|
||||
if (mask & R_ARCH_OP_MASK_DISASM) {
|
||||
@ -99,29 +99,41 @@ static int m68k_op(RAnal *a, RAnalOp *op, ut64 addr, const ut8 *buf, int len, RA
|
||||
int left = R_MIN (len, op->size);
|
||||
if (left < 1 || (left > 0 && !memcmp (buf, "\xff\xff\xff\xff\xff\xff\xff\xff", left))) {
|
||||
op->mnemonic = strdup ("breakpoint");
|
||||
return 4;
|
||||
r_strbuf_free (sb);
|
||||
return true;
|
||||
}
|
||||
r_strbuf_free (sb);
|
||||
return op->size;
|
||||
return op->size > 0;
|
||||
}
|
||||
|
||||
RAnalPlugin r_anal_plugin_m68k_gnu = {
|
||||
static int info(RArchSession *as, ut32 q) {
|
||||
switch (q) {
|
||||
case R_ANAL_ARCHINFO_MAX_OP_SIZE:
|
||||
return 6;
|
||||
case R_ANAL_ARCHINFO_MIN_OP_SIZE:
|
||||
return 2;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
RArchPlugin r_arch_plugin_m68k_gnu = {
|
||||
.name = "m68k.gnu",
|
||||
.author = "pancake",
|
||||
.arch = "m68k",
|
||||
.license = "GPL3",
|
||||
.cpus = "m68000,m68010,m68020,m68030,m68040,m68060,m68881,m68851"
|
||||
"m68000up,m68010up,m68020up,m68030up,m68040up",
|
||||
.bits = 32,
|
||||
.bits = R_SYS_BITS_PACK1 (32),
|
||||
.endian = R_SYS_ENDIAN_BIG,
|
||||
.desc = "Binutils 2.36 based m68k disassembler",
|
||||
.op = &m68k_op
|
||||
.decode = &decode,
|
||||
.info = &info,
|
||||
};
|
||||
|
||||
#ifndef R2_PLUGIN_INCORE
|
||||
R_API RLibStruct radare_plugin = {
|
||||
.type = R_LIB_TYPE_ANAL,
|
||||
.data = &r_anal_plugin_m68k_gnu,
|
||||
.type = R_LIB_TYPE_ARCH,
|
||||
.data = &r_arch_plugin_m68k_gnu,
|
||||
.version = R2_VERSION
|
||||
};
|
||||
#endif
|
@ -1593,7 +1593,6 @@ extern RAnalPlugin r_anal_plugin_x86_udis;
|
||||
extern RAnalPlugin r_anal_plugin_xcore_cs;
|
||||
extern RAnalPlugin r_anal_plugin_pickle;
|
||||
extern RAnalPlugin r_anal_plugin_evm_cs;
|
||||
extern RAnalPlugin r_anal_plugin_m68k_gnu;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
@ -331,6 +331,7 @@ extern RArchPlugin r_arch_plugin_bf;
|
||||
extern RArchPlugin r_arch_plugin_sparc_gnu;
|
||||
extern RArchPlugin r_arch_plugin_hppa_gnu;
|
||||
extern RArchPlugin r_arch_plugin_s390_gnu;
|
||||
extern RArchPlugin r_arch_plugin_m68k_gnu;
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
@ -167,7 +167,6 @@ anal_plugins += [
|
||||
'java',
|
||||
'loongarch_gnu',
|
||||
'm68k_cs',
|
||||
'm68k_gnu',
|
||||
'm680x_cs',
|
||||
'mips_cs',
|
||||
'ppc_cs',
|
||||
@ -178,6 +177,10 @@ anal_plugins += [
|
||||
'xcore_cs'
|
||||
]
|
||||
|
||||
arch_plugins += [
|
||||
'm68k_gnu',
|
||||
]
|
||||
|
||||
if no_user_plugins
|
||||
if use_gpl
|
||||
anal_plugins += [
|
||||
@ -185,7 +188,6 @@ if no_user_plugins
|
||||
'mips_gnu',
|
||||
'loongarch_gnu',
|
||||
'ppc_gnu',
|
||||
'm68k_gnu',
|
||||
]
|
||||
arch_plugins += [
|
||||
'z80',
|
||||
@ -194,6 +196,7 @@ if no_user_plugins
|
||||
'sparc_gnu',
|
||||
'lanai',
|
||||
's390_gnu',
|
||||
'm68k_gnu',
|
||||
]
|
||||
endif
|
||||
endif
|
||||
|
Loading…
Reference in New Issue
Block a user