Remove mips.gnu (#4802)

This commit is contained in:
Giovanni 2024-12-28 17:29:34 +08:00 committed by GitHub
parent 8427ea95fe
commit f623f70c01
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
8 changed files with 14 additions and 2076 deletions

View file

@ -349,7 +349,6 @@ if get_option('use_gpl')
'cris_gnu',
'hppa_gnu',
'lanai_gnu',
'mips_gnu',
'riscv_gnu',
'sparc_gnu',
'vax_gnu',
@ -362,7 +361,6 @@ if get_option('use_gpl')
'p_gnu/arch_cris.c',
'p_gnu/arch_hppa.c',
'p_gnu/arch_lanai.c',
'p_gnu/arch_mips.c',
'p_gnu/arch_riscv.c',
'p_gnu/arch_sparc.c',
'p_gnu/arch_vax.c',
@ -380,9 +378,6 @@ if get_option('use_gpl')
'isa_gnu/hppa/hppa-dis.c',
'isa_gnu/lanai/lanai-dis.c',
'isa_gnu/lanai/lanai-opc.c',
'isa_gnu/mips/mips-dis.c',
'isa_gnu/mips/mips-opc.c',
'isa_gnu/mips/mips16-opc.c',
# 'isa_gnu/riscv/riscv-opc.c',
# 'isa_gnu/riscv/riscv.c',
'isa_gnu/sparc/sparc-dis.c',

File diff suppressed because it is too large Load diff

View file

@ -1,10 +0,0 @@
// SPDX-FileCopyrightText: 2024 RizinOrg <info@rizin.re>
// SPDX-FileCopyrightText: 2024 deroad <wargio@libero.it>
// SPDX-License-Identifier: LGPL-3.0-only
#include <deprecated_arch_helper.h>
#include "analysis/analysis_mips_gnu.c"
#include "asm/asm_mips_gnu.c"
RZ_ARCH_PLUGIN_DEFINE_DEPRECATED(mips_gnu);

View file

@ -1,158 +0,0 @@
// SPDX-FileCopyrightText: 2009-2018 pancake <pancake@nopcode.org>
// SPDX-FileCopyrightText: 2009-2018 nibble <nibble.ds@gmail.com>
// SPDX-License-Identifier: LGPL-3.0-only
#include <stdio.h>
#include <stdarg.h>
#include <string.h>
#include <rz_types.h>
#include <rz_lib.h>
#include <rz_util.h>
#include <rz_asm.h>
#include <common_gnu/disas-asm.h>
#include <common_gnu/opcode/mips.h>
#include <mips/mips_assembler.h>
static int mips_mode = 0;
static unsigned long Offset = 0;
static RzStrBuf *buf_global = NULL;
static unsigned char bytes[4];
static char *pre_cpu = NULL;
static char *pre_features = NULL;
static int mips_buffer_read_memory(bfd_vma memaddr, bfd_byte *myaddr, unsigned int length, struct disassemble_info *info) {
int delta = (memaddr - Offset);
if (delta < 0) {
return -1; // disable backward reads
}
if ((delta + length) > 4) {
return -1;
}
memcpy(myaddr, bytes + delta, length);
return 0;
}
static int symbol_at_address(bfd_vma addr, struct disassemble_info *info) {
return 0;
}
static void memory_error_func(int status, bfd_vma memaddr, struct disassemble_info *info) {
//--
}
DECLARE_GENERIC_PRINT_ADDRESS_FUNC()
DECLARE_GENERIC_FPRINTF_FUNC()
typedef struct {
struct disassemble_info disasm_obj;
} MIPSGnuContext;
static int mips_gnu_disassemble(struct rz_asm_t *a, struct rz_asm_op_t *op, const ut8 *buf, int len) {
MIPSGnuContext *ctx = (MIPSGnuContext *)a->plugin_data;
if (len < 4) {
return -1;
}
buf_global = &op->buf_asm;
Offset = a->pc;
memcpy(bytes, buf, 4); // TODO handle thumb
if ((a->cpu != pre_cpu) && (a->features != pre_features)) {
free(ctx->disasm_obj.disassembler_options);
memset(&ctx->disasm_obj, '\0', sizeof(struct disassemble_info));
}
/* prepare disassembler */
if (a->cpu && (!pre_cpu || !strcmp(a->cpu, pre_cpu))) {
if (!rz_str_casecmp(a->cpu, "mips64r2")) {
ctx->disasm_obj.mach = bfd_mach_mipsisa64r2;
} else if (!rz_str_casecmp(a->cpu, "mips32r2")) {
ctx->disasm_obj.mach = bfd_mach_mipsisa32r2;
} else if (!rz_str_casecmp(a->cpu, "mips64")) {
ctx->disasm_obj.mach = bfd_mach_mipsisa64;
} else if (!rz_str_casecmp(a->cpu, "mips32")) {
ctx->disasm_obj.mach = bfd_mach_mipsisa32;
}
char *tmp = rz_str_dup(a->cpu);
free(pre_cpu);
pre_cpu = tmp;
}
if (a->features && (!pre_features || !strcmp(a->features, pre_features))) {
free(ctx->disasm_obj.disassembler_options);
if (strstr(a->features, "n64")) {
ctx->disasm_obj.disassembler_options = rz_str_dup("abi=n64");
} else if (strstr(a->features, "n32")) {
ctx->disasm_obj.disassembler_options = rz_str_dup("abi=n32");
} else if (strstr(a->features, "o32")) {
ctx->disasm_obj.disassembler_options = rz_str_dup("abi=o32");
}
char *tmp = rz_str_dup(a->features);
free(pre_features);
pre_features = tmp;
}
mips_mode = a->bits;
ctx->disasm_obj.arch = CPU_LOONGSON_2F;
ctx->disasm_obj.buffer = bytes;
ctx->disasm_obj.read_memory_func = &mips_buffer_read_memory;
ctx->disasm_obj.symbol_at_address_func = &symbol_at_address;
ctx->disasm_obj.memory_error_func = &memory_error_func;
ctx->disasm_obj.print_address_func = &generic_print_address_func;
ctx->disasm_obj.buffer_vma = Offset;
ctx->disasm_obj.buffer_length = 4;
ctx->disasm_obj.endian = !a->big_endian;
ctx->disasm_obj.fprintf_func = &generic_fprintf_func;
ctx->disasm_obj.stream = stdout;
op->size = (ctx->disasm_obj.endian == BFD_ENDIAN_LITTLE)
? print_insn_little_mips((bfd_vma)Offset, &ctx->disasm_obj)
: print_insn_big_mips((bfd_vma)Offset, &ctx->disasm_obj);
if (op->size == -1) {
rz_strbuf_set(&op->buf_asm, "(data)");
}
return op->size;
}
static int mips_gnu_assemble(RzAsm *a, RzAsmOp *op, const char *str) {
ut8 *opbuf = (ut8 *)rz_strbuf_get(&op->buf);
int ret = mips_assemble_opcode(str, a->pc, opbuf);
if (a->big_endian) {
ut8 tmp = opbuf[0];
opbuf[0] = opbuf[3];
opbuf[3] = tmp;
tmp = opbuf[1];
opbuf[1] = opbuf[2];
opbuf[2] = tmp;
}
return ret;
}
static bool mips_gnu_init(void **user) {
MIPSGnuContext *ctx = RZ_NEW0(MIPSGnuContext);
rz_return_val_if_fail(ctx, false);
*user = ctx;
return true;
}
static bool mips_gnu_fini(void *user) {
MIPSGnuContext *ctx = (MIPSGnuContext *)user;
if (ctx) {
RZ_FREE(ctx);
}
return true;
}
RzAsmPlugin rz_asm_plugin_mips_gnu = {
.name = "mips.gnu",
.arch = "mips",
.license = "GPL3",
.bits = 32 | 64,
.endian = RZ_SYS_ENDIAN_LITTLE | RZ_SYS_ENDIAN_BIG,
.desc = "MIPS CPU",
.init = mips_gnu_init,
.fini = mips_gnu_fini,
.disassemble = &mips_gnu_disassemble,
.assemble = &mips_gnu_assemble
};

View file

@ -100,7 +100,7 @@ RUN
NAME=assembler
FILE==
CMDS=<<EOF
e asm.arch=mips.gnu
e asm.arch=mips
e asm.bits=32
e cfg.bigendian=0
pa lui t9, 0x41
@ -122,7 +122,7 @@ RUN
NAME=with-spaces
FILE==
CMDS=<<EOF
e asm.arch=mips.gnu
e asm.arch=mips
e asm.bits=32
e cfg.bigendian=0
pa addiu v0, v1, 33
@ -524,7 +524,7 @@ BROKEN=1
CMDS=<<EOF
e io.va=true
e asm.bits=32
e asm.arch=mips.gnu
e asm.arch=mips
e asm.comments=0
e analysis.hasnext=1
e analysis.nopskip=1
@ -745,11 +745,11 @@ EXPECT=<<EOF
EOF
RUN
NAME=mips.gnu regs
NAME=mips regs
FILE==
BROKEN=1
CMDS=<<EOF
e asm.arch=mips.gnu
e asm.arch=mips
ar
EOF
EXPECT=<<EOF

View file

@ -1,85 +0,0 @@
d "add.s $f0, $f0, $f0" 00000046 0x4
d "addi zero, zero, 0" 00000020 0x4
d "addiu zero, t0, -25" e7ff0025 0x4
d "addiu zero, t0, 0" 00000025 0x4
d "andi zero, zero, 0x0" 00000030 0x4
d "b 0x00000008" 00000010 0x4
d "bc0f 0x00000008" 00000041 0x4
d "bc1f 0x00000008" 00000045 0x4
d "bc2f 0x00000008" 00000049 0x4
d "bc3f 0x00000008" 0000004d 0x4
d "beq t0, s0, 0x0000444c" 11111011 0x4
d "beql sp, t8, 0x00014008" 0050b853 0x4
d "beqz t0, 0x00000008" 00000011 0x4
d "beqzl zero, 0x00000008" 00000050 0x4
d "bgez v0, 0x00000010" 02004104 0x4
d "bgezal s1, 0x00000108" 40003106 0x4
d "bgezall t3, 0x00000128" 48007305 0x4
d "bgezl t6, 0x00000128" 4800c305 0x4
d "bgtz zero, 0x00000008" 0000001c 0x4
d "bgtzl zero, 0x00000008" 0000005c 0x4
d "blez zero, 0x00000008" 00000018 0x4
d "blezl zero, 0x00000008" 00000058 0x4
d "bltz zero, 0x00000008" 00000004 0x4
d "bltzl s6, 0x00000118" 4400c206 0x4
d "bne t0, s0, 0x0000440c" 01111015 0x4
d "bnel s0, s0, 0xffffffffffff4008" 00d01056 0x4
d "bnez zero, 0x00000008" 00000014 0x4
d "bnezl t0, 0x00000008" 00000055 0x4
d "c0 0x0" 00000042 0x4
d "c1 0x1000000" 00000047 0x4
d "c2 0x0" 0000004a 0x4
d "c3 0x0" 0000004e 0x4
d "cache 0x0, 0(zero)" 000000bc 0x4
d "daddi zero, zero, 0" 00000060 0x4
d "daddiu zero, zero, 0" 00000064 0x4
d "j 0x00000000" 00000008 0x4
d "jal 0x00000000" 0000000c 0x4
d "jalx 0x00000000" 00000074 0x4
d "jalx 0x00000004" 01000074 0x4
d "lb zero, 0(zero)" 00000080 0x4
d "lbu zero, 0(zero)" 00000090 0x4
d "ld zero, 0(zero)" 000000dc 0x4
d "ldc1 $f0, 0(zero)" 000000d4 0x4
d "ldc2 $0, 0(zero)" 000000d8 0x4
d "ldl zero, 0(zero)" 00000068 0x4
d "ldr zero, 0(zero)" 0000006c 0x4
d "lh zero, 0(zero)" 00000084 0x4
d "lhu zero, 0(zero)" 00000094 0x4
d "li zero, 0" 00000024 0x4
d "li zero, 0x0" 00000034 0x4
d "ll zero, 0(zero)" 000000c0 0x4
d "lld zero, 0(zero)" 000000d0 0x4
d "lui zero, 0x0" 0000003c 0x4
d "lw zero, 0(zero)" 0000008c 0x4
d "lwc1 $f0, 0(zero)" 000000c4 0x4
d "lwc2 $0, 0(zero)" 000000c8 0x4
d "lwc3 $0, 0(zero)" 000000cc 0x4
d "lwl zero, 0(zero)" 00000088 0x4
d "lwr zero, 0(zero)" 00000098 0x4
d "lwu zero, 0(zero)" 0000009c 0x4
d "mfc0 zero, $0" 00000040 0x4
d "mfc1 zero, $f0" 00000044 0x4
d "mfc2 zero, $0" 00000048 0x4
d "mfc3 zero, $0" 0000004c 0x4
d "nop" 00000000 0x4
d "ori zero, t0, 0x0" 00000035 0x4
d "paddsh $f0, $f0, $f0" 0000004b 0x4
d "sb zero, 0(zero)" 000000a0 0x4
d "sc zero, 0(zero)" 000000e0 0x4
d "scd zero, 0(zero)" 000000f0 0x4
d "sd zero, 0(zero)" 000000fc 0x4
d "sdc1 $f0, 0(zero)" 000000f4 0x4
d "sdc2 $0, 0(zero)" 000000f8 0x4
d "sdl zero, 0(zero)" 000000b0 0x4
d "sdr zero, 0(zero)" 000000b4 0x4
d "sh zero, 0(zero)" 000000a4 0x4
d "slti zero, zero, 0" 00000028 0x4
d "sltiu zero, zero, 0" 0000002c 0x4
d "sw zero, 0(zero)" 000000ac 0x4
d "swc1 $f0, 0(zero)" 000000e4 0x4
d "swc2 $0, 0(zero)" 000000e8 0x4
d "swc3 $0, 0(zero)" 000000ec 0x4
d "swl zero, 0(zero)" 000000a8 0x4
d "swr zero, 0(zero)" 000000b8 0x4
d "xori zero, zero, 0x0" 00000038 0x4

File diff suppressed because one or more lines are too long

View file

@ -76,19 +76,19 @@ RUN
NAME=MIPS new abi
FILE=bins/elf/analysis/mips64r2-busybox-loongson
CMDS=<<EOF
e asm.arch=mips.gnu
e asm.arch=mips
e asm.bytes=true
e cfg.bigendian=false
s 0x120005978
pd 6
EOF
EXPECT=<<EOF
0x120005978 1800bfff sd ra, 24(sp)
0x12000597c 3800a7ff sd a3, 56(sp)
0x120005980 4000a8ff sd a4, 64(sp)
0x120005984 4800a9ff sd a5, 72(sp)
0x120005988 5000aaff sd a6, 80(sp)
0x12000598c 5800abff sd a7, 88(sp)
0x120005978 1800bfff sd ra, 0x18(sp)
0x12000597c 3800a7ff sd a3, 0x38(sp)
0x120005980 4000a8ff sd t0, 0x40(sp)
0x120005984 4800a9ff sd t1, 0x48(sp)
0x120005988 5000aaff sd t2, 0x50(sp)
0x12000598c 5800abff sd t3, 0x58(sp)
EOF
RUN