arch/vax: remove the GPL binutils-derived VAX plugin
Drop the old GPL-licensed VAX disassembler (vax_gnu), which was derived from GNU binutils and gated behind the use_gpl build option. It is being replaced by a new, clean-room LGPL implementation in a following commit. Removed: - librz/arch/isa_gnu/vax/vax-dis.c - librz/arch/isa_gnu/vax/vax.h - librz/arch/p_gnu/arch_vax.c - librz/arch/p_gnu/asm/asm_vax_gnu.c - librz/arch/p_gnu/analysis/analysis_vax_gnu.c and their entries from the use_gpl plugin/source lists in librz/arch/meson.build.
This commit is contained in:
parent
8abb4ca4d3
commit
423104df4a
6 changed files with 0 additions and 966 deletions
|
|
@ -1,355 +0,0 @@
|
|||
// SPDX-FileCopyrightText: 1995, 1998, 2000, 2001, 2002, 2005, 2007, 2009, 2012 Free Software Foundation, Inc.
|
||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
/* Print VAX instructions.
|
||||
Copyright 1995, 1998, 2000, 2001, 2002, 2005, 2007, 2009, 2012
|
||||
Free Software Foundation, Inc.
|
||||
Contributed by Pauline Middelink <middelin@polyware.iaf.nl>
|
||||
|
||||
This file is part of the GNU opcodes library.
|
||||
|
||||
This library is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 3, or (at your option)
|
||||
any later version.
|
||||
|
||||
It is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
|
||||
License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
|
||||
MA 02110-1301, USA. */
|
||||
|
||||
#include <common_gnu/sysdep.h>
|
||||
#include <setjmp.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include "vax.h"
|
||||
#include <common_gnu/disas-asm.h>
|
||||
|
||||
static char *reg_names[] = {
|
||||
"r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7",
|
||||
"r8", "r9", "r10", "r11", "ap", "fp", "sp", "pc"
|
||||
};
|
||||
|
||||
#if 0
|
||||
/* Definitions for the function entry mask bits. */
|
||||
static char *entry_mask_bit[] =
|
||||
{
|
||||
/* Registers 0 and 1 shall not be saved, since they're used to pass back
|
||||
a function's result to its caller... */
|
||||
"~r0~", "~r1~",
|
||||
/* Registers 2 .. 11 are normal registers. */
|
||||
"r2", "r3", "r4", "r5", "r6", "r7", "r8", "r9", "r10", "r11",
|
||||
/* Registers 12 and 13 are argument and frame pointer and must not
|
||||
be saved by using the entry mask. */
|
||||
"~ap~", "~fp~",
|
||||
/* Bits 14 and 15 control integer and decimal overflow. */
|
||||
"IntOvfl", "DecOvfl",
|
||||
};
|
||||
|
||||
#endif
|
||||
/* Sign-extend an (unsigned char). */
|
||||
#define COERCE_SIGNED_CHAR(ch) ((signed char)(ch))
|
||||
|
||||
/* Get a 1 byte signed integer. */
|
||||
#define NEXTBYTE(p, data) \
|
||||
((p) += 1, FETCH_DATA(info, p, data), \
|
||||
COERCE_SIGNED_CHAR((p)[-1]))
|
||||
|
||||
/* Get a 2 byte signed integer. */
|
||||
#define COERCE16(x) ((int)(((x) ^ 0x8000) - 0x8000))
|
||||
#define NEXTWORD(p, data) \
|
||||
((p) += 2, FETCH_DATA(info, p, data), \
|
||||
COERCE16(((p)[-1] << 8) + (p)[-2]))
|
||||
|
||||
/* Get a 4 byte signed integer. */
|
||||
#define COERCE32(x) ((int)(((x) ^ 0x80000000) - 0x80000000))
|
||||
#define NEXTLONG(p, data) \
|
||||
((p) += 4, FETCH_DATA(info, p, data), \
|
||||
(COERCE32(((((((p)[-1] << 8) + (p)[-2]) << 8) + (p)[-3]) << 8) + (p)[-4])))
|
||||
|
||||
/* Maximum length of an instruction. */
|
||||
#define MAXLEN 25
|
||||
|
||||
struct private {
|
||||
/* Points to first byte not fetched. */
|
||||
bfd_byte *max_fetched;
|
||||
bfd_byte the_buffer[MAXLEN];
|
||||
bfd_vma insn_start;
|
||||
jmp_buf bailout;
|
||||
};
|
||||
|
||||
/* Make sure that bytes from INFO->PRIVATE_DATA->BUFFER (inclusive)
|
||||
to ADDR (exclusive) are valid. Returns 1 for success, longjmps
|
||||
on error. */
|
||||
#define FETCH_DATA(info, addr, data) \
|
||||
((addr) <= ((struct private *)((info)->private_data))->max_fetched \
|
||||
? 1 \
|
||||
: fetch_data((info), (addr), (data)))
|
||||
|
||||
static int
|
||||
fetch_data(struct disassemble_info *info, bfd_byte *addr, void *data) {
|
||||
int status;
|
||||
struct private *priv = (struct private *)info->private_data;
|
||||
bfd_vma start = priv->insn_start + (priv->max_fetched - priv->the_buffer);
|
||||
|
||||
status = (*info->read_memory_func)(start,
|
||||
priv->max_fetched,
|
||||
addr - priv->max_fetched,
|
||||
info, data);
|
||||
if (status != 0) {
|
||||
(*info->memory_error_func)(status, start, info);
|
||||
longjmp(priv->bailout, 1);
|
||||
} else {
|
||||
priv->max_fetched = addr;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* Entry mask handling. */
|
||||
#if 0
|
||||
static unsigned int entry_addr_occupied_slots = 0;
|
||||
static unsigned int entry_addr_total_slots = 0;
|
||||
static bfd_vma * entry_addr = NULL;
|
||||
#endif
|
||||
|
||||
/* Parse the VAX specific disassembler options. These contain function
|
||||
entry addresses, which can be useful to disassemble ROM images, since
|
||||
there's no symbol table. Returns TRUE upon success, FALSE otherwise. */
|
||||
|
||||
/* Check if the given address is a known function entry point. This is
|
||||
the case if there is a symbol of the function type at this address.
|
||||
We also check for synthetic symbols as these are used for PLT entries
|
||||
(weak undefined symbols may not have the function type set). Finally
|
||||
the address may have been forced to be treated as an entry point. The
|
||||
latter helps in disassembling ROM images, because there's no symbol
|
||||
table at all. Forced entry points can be given by supplying several
|
||||
-M options to objdump: -M entry:0xffbb7730. */
|
||||
|
||||
static int
|
||||
print_insn_mode(const char *d,
|
||||
int size,
|
||||
unsigned char *p0,
|
||||
bfd_vma addr, /* PC for this arg to be relative to. */
|
||||
disassemble_info *info, void *data) {
|
||||
unsigned char *p = p0;
|
||||
unsigned char mode, reg;
|
||||
|
||||
/* Fetch and interpret mode byte. */
|
||||
mode = (unsigned char)NEXTBYTE(p, data);
|
||||
reg = mode & 0xF;
|
||||
switch (mode & 0xF0) {
|
||||
case 0x00:
|
||||
case 0x10:
|
||||
case 0x20:
|
||||
case 0x30: /* Literal mode $number. */
|
||||
if (d[1] == 'd' || d[1] == 'f' || d[1] == 'g' || d[1] == 'h') {
|
||||
(*info->fprintf_func)(info->stream, data, "$0x%x [%c-float]", mode, d[1]);
|
||||
} else {
|
||||
(*info->fprintf_func)(info->stream, data, "$0x%x", mode);
|
||||
}
|
||||
break;
|
||||
case 0x40: /* Index: base-addr[Rn] */
|
||||
p += print_insn_mode(d, size, p0 + 1, addr + 1, info, data);
|
||||
(*info->fprintf_func)(info->stream, data, "[%s]", reg_names[reg]);
|
||||
break;
|
||||
case 0x50: /* Register: Rn */
|
||||
(*info->fprintf_func)(info->stream, data, "%s", reg_names[reg]);
|
||||
break;
|
||||
case 0x60: /* Register deferred: (Rn) */
|
||||
(*info->fprintf_func)(info->stream, data, "(%s)", reg_names[reg]);
|
||||
break;
|
||||
case 0x70: /* Autodecrement: -(Rn) */
|
||||
(*info->fprintf_func)(info->stream, data, "-(%s)", reg_names[reg]);
|
||||
break;
|
||||
case 0x80: /* Autoincrement: (Rn)+ */
|
||||
if (reg == 0xF) { /* Immediate? */
|
||||
int i;
|
||||
|
||||
FETCH_DATA(info, p + size, data);
|
||||
(*info->fprintf_func)(info->stream, data, "$0x");
|
||||
if (d[1] == 'd' || d[1] == 'f' || d[1] == 'g' || d[1] == 'h') {
|
||||
int float_word;
|
||||
|
||||
float_word = p[0] | (p[1] << 8);
|
||||
if ((d[1] == 'd' || d[1] == 'f') && (float_word & 0xff80) == 0x8000) {
|
||||
(*info->fprintf_func)(info->stream, data, "[invalid %c-float]",
|
||||
d[1]);
|
||||
} else {
|
||||
for (i = 0; i < size; i++) {
|
||||
(*info->fprintf_func)(info->stream, data, "%02x",
|
||||
p[size - i - 1]);
|
||||
}
|
||||
(*info->fprintf_func)(info->stream, data, " [%c-float]", d[1]);
|
||||
}
|
||||
} else {
|
||||
for (i = 0; i < size; i++) {
|
||||
(*info->fprintf_func)(info->stream, data, "%02x", p[size - i - 1]);
|
||||
}
|
||||
}
|
||||
p += size;
|
||||
} else {
|
||||
(*info->fprintf_func)(info->stream, data, "(%s)+", reg_names[reg]);
|
||||
}
|
||||
break;
|
||||
case 0x90: /* Autoincrement deferred: @(Rn)+ */
|
||||
if (reg == 0xF) {
|
||||
(*info->fprintf_func)(info->stream, data, "*0x%x", NEXTLONG(p, data));
|
||||
} else {
|
||||
(*info->fprintf_func)(info->stream, data, "@(%s)+", reg_names[reg]);
|
||||
}
|
||||
break;
|
||||
case 0xB0: /* Displacement byte deferred: *displ(Rn). */
|
||||
(*info->fprintf_func)(info->stream, data, "*");
|
||||
// fallthrough
|
||||
case 0xA0: /* Displacement byte: displ(Rn). */
|
||||
if (reg == 0xF) {
|
||||
(*info->print_address_func)(addr + 2 + NEXTBYTE(p, data), data, info);
|
||||
} else {
|
||||
(*info->fprintf_func)(info->stream, data, "0x%x(%s)", NEXTBYTE(p, data),
|
||||
reg_names[reg]);
|
||||
}
|
||||
break;
|
||||
case 0xD0: /* Displacement word deferred: *displ(Rn). */
|
||||
(*info->fprintf_func)(info->stream, data, "*");
|
||||
// fallthrough
|
||||
case 0xC0: /* Displacement word: displ(Rn). */
|
||||
if (reg == 0xF) {
|
||||
(*info->print_address_func)(addr + 3 + NEXTWORD(p, data), data, info);
|
||||
} else {
|
||||
(*info->fprintf_func)(info->stream, data, "0x%x(%s)", NEXTWORD(p, data),
|
||||
reg_names[reg]);
|
||||
}
|
||||
break;
|
||||
case 0xF0: /* Displacement long deferred: *displ(Rn). */
|
||||
(*info->fprintf_func)(info->stream, data, "*");
|
||||
// fallthrough
|
||||
case 0xE0: /* Displacement long: displ(Rn). */
|
||||
if (reg == 0xF) {
|
||||
(*info->print_address_func)(addr + 5 + NEXTLONG(p, data), data, info);
|
||||
} else {
|
||||
(*info->fprintf_func)(info->stream, data, "0x%x(%s)", NEXTLONG(p, data),
|
||||
reg_names[reg]);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
return p - p0;
|
||||
}
|
||||
|
||||
/* Returns number of bytes "eaten" by the operand, or return -1 if an
|
||||
invalid operand was found, or -2 if an opcode tabel error was
|
||||
found. */
|
||||
|
||||
static int
|
||||
print_insn_arg(const char *d,
|
||||
unsigned char *p0,
|
||||
bfd_vma addr, /* PC for this arg to be relative to. */
|
||||
disassemble_info *info,
|
||||
void *data) {
|
||||
int arg_len;
|
||||
|
||||
/* Check validity of addressing length. */
|
||||
switch (d[1]) {
|
||||
case 'b': arg_len = 1; break;
|
||||
case 'd': arg_len = 8; break;
|
||||
case 'f': arg_len = 4; break;
|
||||
case 'g': arg_len = 8; break;
|
||||
case 'h': arg_len = 16; break;
|
||||
case 'l': arg_len = 4; break;
|
||||
case 'o': arg_len = 16; break;
|
||||
case 'w': arg_len = 2; break;
|
||||
case 'q': arg_len = 8; break;
|
||||
default: abort();
|
||||
}
|
||||
|
||||
/* Branches have no mode byte. */
|
||||
if (d[0] == 'b') {
|
||||
unsigned char *p = p0;
|
||||
|
||||
if (arg_len == 1) {
|
||||
(*info->print_address_func)(addr + 1 + NEXTBYTE(p, data), data, info);
|
||||
} else {
|
||||
(*info->print_address_func)(addr + 2 + NEXTWORD(p, data), data, info);
|
||||
}
|
||||
|
||||
return p - p0;
|
||||
}
|
||||
|
||||
return print_insn_mode(d, arg_len, p0, addr, info, data);
|
||||
}
|
||||
|
||||
/* Print the vax instruction at address MEMADDR in debugged memory,
|
||||
on INFO->STREAM. Returns length of the instruction, in bytes. */
|
||||
|
||||
int print_insn_vax(bfd_vma memaddr, disassemble_info *info, void *data) {
|
||||
// static bfd_boolean parsed_disassembler_options = FALSE;
|
||||
const struct vot *votp;
|
||||
const char *argp;
|
||||
unsigned char *arg;
|
||||
struct private priv;
|
||||
bfd_byte *buffer = priv.the_buffer;
|
||||
|
||||
info->private_data = &priv;
|
||||
priv.max_fetched = priv.the_buffer;
|
||||
priv.insn_start = memaddr;
|
||||
|
||||
if (setjmp(priv.bailout) != 0) {
|
||||
/* Error return. */
|
||||
return -1;
|
||||
}
|
||||
|
||||
argp = NULL;
|
||||
/* Check if the info buffer has more than one byte left since
|
||||
the last opcode might be a single byte with no argument data. */
|
||||
if (info->buffer_length - (memaddr - info->buffer_vma) > 1) {
|
||||
FETCH_DATA(info, buffer + 2, data);
|
||||
} else {
|
||||
FETCH_DATA(info, buffer + 1, data);
|
||||
buffer[1] = 0;
|
||||
}
|
||||
|
||||
for (votp = &votstrs[0]; votp->name[0]; votp++) {
|
||||
vax_opcodeT opcode = votp->detail.code;
|
||||
|
||||
/* 2 byte codes match 2 buffer pos. */
|
||||
if ((bfd_byte)opcode == buffer[0] && (opcode >> 8 == 0 || opcode >> 8 == buffer[1])) {
|
||||
argp = votp->detail.args;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!argp) {
|
||||
/* Handle undefined instructions. */
|
||||
(*info->fprintf_func)(info->stream, data, ".word 0x%x",
|
||||
(buffer[0] << 8) + buffer[1]);
|
||||
return 2;
|
||||
}
|
||||
|
||||
/* Point at first byte of argument data, and at descriptor for first
|
||||
argument. */
|
||||
arg = buffer + ((votp->detail.code >> 8) ? 2 : 1);
|
||||
|
||||
/* Make sure we have it in mem */
|
||||
FETCH_DATA(info, arg, data);
|
||||
|
||||
(*info->fprintf_func)(info->stream, data, "%s", votp->name);
|
||||
if (*argp) {
|
||||
(*info->fprintf_func)(info->stream, data, " ");
|
||||
}
|
||||
|
||||
while (*argp) {
|
||||
arg += print_insn_arg(argp, arg, memaddr + arg - buffer, info, data);
|
||||
argp += 2;
|
||||
if (*argp) {
|
||||
(*info->fprintf_func)(info->stream, data, ", ");
|
||||
}
|
||||
}
|
||||
|
||||
return arg - buffer;
|
||||
}
|
||||
|
|
@ -1,386 +0,0 @@
|
|||
// SPDX-FileCopyrightText: 1989, 1991, 1992, 1995, 2010 Free Software Foundation, Inc.
|
||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
/* Vax opcde list.
|
||||
Copyright 1989, 1991, 1992, 1995, 2010 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GDB and GAS.
|
||||
|
||||
GDB and GAS are free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 3, or (at your option)
|
||||
any later version.
|
||||
|
||||
GDB and GAS are distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with GDB or GAS; see the file COPYING3. If not, write to
|
||||
the Free Software Foundation, 51 Franklin Street - Fifth Floor,
|
||||
Boston, MA 02110-1301, USA. */
|
||||
|
||||
#ifndef vax_opcodeT
|
||||
#define vax_opcodeT int
|
||||
#endif /* no vax_opcodeT */
|
||||
|
||||
struct vot_wot /* vax opcode table: wot to do with this */
|
||||
/* particular opcode */
|
||||
{
|
||||
const char *args; /* how to compile said opcode */
|
||||
vax_opcodeT code; /* op-code (may be > 8 bits!) */
|
||||
};
|
||||
|
||||
struct vot /* vax opcode text */
|
||||
{
|
||||
const char *name; /* opcode name: lowercase string [key] */
|
||||
struct vot_wot detail; /* rest of opcode table [datum] */
|
||||
};
|
||||
|
||||
#define vot_how args
|
||||
#define vot_code code
|
||||
#define vot_detail detail
|
||||
#define vot_name name
|
||||
|
||||
static const struct vot
|
||||
votstrs[] =
|
||||
{
|
||||
{ "halt", {"", 0x00 } },
|
||||
{ "nop", {"", 0x01 } },
|
||||
{ "rei", {"", 0x02 } },
|
||||
{ "bpt", {"", 0x03 } },
|
||||
{ "ret", {"", 0x04 } },
|
||||
{ "rsb", {"", 0x05 } },
|
||||
{ "ldpctx", {"", 0x06 } },
|
||||
{ "svpctx", {"", 0x07 } },
|
||||
{ "cvtps", {"rwabrwab", 0x08 } },
|
||||
{ "cvtsp", {"rwabrwab", 0x09 } },
|
||||
{ "index", {"rlrlrlrlrlwl", 0x0a } },
|
||||
{ "crc", {"abrlrwab", 0x0b } },
|
||||
{ "prober", {"rbrwab", 0x0c } },
|
||||
{ "probew", {"rbrwab", 0x0d } },
|
||||
{ "insque", {"abab", 0x0e } },
|
||||
{ "remque", {"abwl", 0x0f } },
|
||||
{ "bsbb", {"bb", 0x10 } },
|
||||
{ "brb", {"bb", 0x11 } },
|
||||
{ "bneq", {"bb", 0x12 } },
|
||||
{ "bnequ", {"bb", 0x12 } },
|
||||
{ "beql", {"bb", 0x13 } },
|
||||
{ "beqlu", {"bb", 0x13 } },
|
||||
{ "bgtr", {"bb", 0x14 } },
|
||||
{ "bleq", {"bb", 0x15 } },
|
||||
{ "jsb", {"ab", 0x16 } },
|
||||
{ "jmp", {"ab", 0x17 } },
|
||||
{ "bgeq", {"bb", 0x18 } },
|
||||
{ "blss", {"bb", 0x19 } },
|
||||
{ "bgtru", {"bb", 0x1a } },
|
||||
{ "blequ", {"bb", 0x1b } },
|
||||
{ "bvc", {"bb", 0x1c } },
|
||||
{ "bvs", {"bb", 0x1d } },
|
||||
{ "bcc", {"bb", 0x1e } },
|
||||
{ "bgequ", {"bb", 0x1e } },
|
||||
{ "blssu", {"bb", 0x1f } },
|
||||
{ "bcs", {"bb", 0x1f } },
|
||||
{ "addp4", {"rwabrwab", 0x20 } },
|
||||
{ "addp6", {"rwabrwabrwab", 0x21 } },
|
||||
{ "subp4", {"rwabrwab", 0x22 } },
|
||||
{ "subp6", {"rwabrwabrwab", 0x23 } },
|
||||
{ "cvtpt", {"rwababrwab", 0x24 } },
|
||||
{ "mulp", {"rwabrwabrwab", 0x25 } },
|
||||
{ "cvttp", {"rwababrwab", 0x26 } },
|
||||
{ "divp", {"rwabrwabrwab", 0x27 } },
|
||||
{ "movc3", {"rwabab", 0x28 } },
|
||||
{ "cmpc3", {"rwabab", 0x29 } },
|
||||
{ "scanc", {"rwababrb", 0x2a } },
|
||||
{ "spanc", {"rwababrb", 0x2b } },
|
||||
{ "movc5", {"rwabrbrwab", 0x2c } },
|
||||
{ "cmpc5", {"rwabrbrwab", 0x2d } },
|
||||
{ "movtc", {"rwabrbabrwab", 0x2e } },
|
||||
{ "movtuc", {"rwabrbabrwab", 0x2f } },
|
||||
{ "bsbw", {"bw", 0x30 } },
|
||||
{ "brw", {"bw", 0x31 } },
|
||||
{ "cvtwl", {"rwwl", 0x32 } },
|
||||
{ "cvtwb", {"rwwb", 0x33 } },
|
||||
{ "movp", {"rwabab", 0x34 } },
|
||||
{ "cmpp3", {"rwabab", 0x35 } },
|
||||
{ "cvtpl", {"rwabwl", 0x36 } },
|
||||
{ "cmpp4", {"rwabrwab", 0x37 } },
|
||||
{ "editpc", {"rwababab", 0x38 } },
|
||||
{ "matchc", {"rwabrwab", 0x39 } },
|
||||
{ "locc", {"rbrwab", 0x3a } },
|
||||
{ "skpc", {"rbrwab", 0x3b } },
|
||||
{ "movzwl", {"rwwl", 0x3c } },
|
||||
{ "acbw", {"rwrwmwbw", 0x3d } },
|
||||
{ "movaw", {"awwl", 0x3e } },
|
||||
{ "pushaw", {"aw", 0x3f } },
|
||||
{ "addf2", {"rfmf", 0x40 } },
|
||||
{ "addf3", {"rfrfwf", 0x41 } },
|
||||
{ "subf2", {"rfmf", 0x42 } },
|
||||
{ "subf3", {"rfrfwf", 0x43 } },
|
||||
{ "mulf2", {"rfmf", 0x44 } },
|
||||
{ "mulf3", {"rfrfwf", 0x45 } },
|
||||
{ "divf2", {"rfmf", 0x46 } },
|
||||
{ "divf3", {"rfrfwf", 0x47 } },
|
||||
{ "cvtfb", {"rfwb", 0x48 } },
|
||||
{ "cvtfw", {"rfww", 0x49 } },
|
||||
{ "cvtfl", {"rfwl", 0x4a } },
|
||||
{ "cvtrfl", {"rfwl", 0x4b } },
|
||||
{ "cvtbf", {"rbwf", 0x4c } },
|
||||
{ "cvtwf", {"rwwf", 0x4d } },
|
||||
{ "cvtlf", {"rlwf", 0x4e } },
|
||||
{ "acbf", {"rfrfmfbw", 0x4f } },
|
||||
{ "movf", {"rfwf", 0x50 } },
|
||||
{ "cmpf", {"rfrf", 0x51 } },
|
||||
{ "mnegf", {"rfwf", 0x52 } },
|
||||
{ "tstf", {"rf", 0x53 } },
|
||||
{ "emodf", {"rfrbrfwlwf", 0x54 } },
|
||||
{ "polyf", {"rfrwab", 0x55 } },
|
||||
{ "cvtfd", {"rfwd", 0x56 } },
|
||||
/* opcode 57 is not defined yet */
|
||||
{ "adawi", {"rwmw", 0x58 } },
|
||||
/* opcode 59 is not defined yet */
|
||||
/* opcode 5a is not defined yet */
|
||||
/* opcode 5b is not defined yet */
|
||||
{ "insqhi", {"abaq", 0x5c } },
|
||||
{ "insqti", {"abaq", 0x5d } },
|
||||
{ "remqhi", {"aqwl", 0x5e } },
|
||||
{ "remqti", {"aqwl", 0x5f } },
|
||||
{ "addd2", {"rdmd", 0x60 } },
|
||||
{ "addd3", {"rdrdwd", 0x61 } },
|
||||
{ "subd2", {"rdmd", 0x62 } },
|
||||
{ "subd3", {"rdrdwd", 0x63 } },
|
||||
{ "muld2", {"rdmd", 0x64 } },
|
||||
{ "muld3", {"rdrdwd", 0x65 } },
|
||||
{ "divd2", {"rdmd", 0x66 } },
|
||||
{ "divd3", {"rdrdwd", 0x67 } },
|
||||
{ "cvtdb", {"rdwb", 0x68 } },
|
||||
{ "cvtdw", {"rdww", 0x69 } },
|
||||
{ "cvtdl", {"rdwl", 0x6a } },
|
||||
{ "cvtrdl", {"rdwl", 0x6b } },
|
||||
{ "cvtbd", {"rbwd", 0x6c } },
|
||||
{ "cvtwd", {"rwwd", 0x6d } },
|
||||
{ "cvtld", {"rlwd", 0x6e } },
|
||||
{ "acbd", {"rdrdmdbw", 0x6f } },
|
||||
{ "movd", {"rdwd", 0x70 } },
|
||||
{ "cmpd", {"rdrd", 0x71 } },
|
||||
{ "mnegd", {"rdwd", 0x72 } },
|
||||
{ "tstd", {"rd", 0x73 } },
|
||||
{ "emodd", {"rdrbrdwlwd", 0x74 } },
|
||||
{ "polyd", {"rdrwab", 0x75 } },
|
||||
{ "cvtdf", {"rdwf", 0x76 } },
|
||||
/* opcode 77 is not defined yet */
|
||||
{ "ashl", {"rbrlwl", 0x78 } },
|
||||
{ "ashq", {"rbrqwq", 0x79 } },
|
||||
{ "emul", {"rlrlrlwq", 0x7a } },
|
||||
{ "ediv", {"rlrqwlwl", 0x7b } },
|
||||
{ "clrd", {"wd", 0x7c } },
|
||||
{ "clrg", {"wg", 0x7c } },
|
||||
{ "clrq", {"wd", 0x7c } },
|
||||
{ "movq", {"rqwq", 0x7d } },
|
||||
{ "movaq", {"aqwl", 0x7e } },
|
||||
{ "movad", {"adwl", 0x7e } },
|
||||
{ "pushaq", {"aq", 0x7f } },
|
||||
{ "pushad", {"ad", 0x7f } },
|
||||
{ "addb2", {"rbmb", 0x80 } },
|
||||
{ "addb3", {"rbrbwb", 0x81 } },
|
||||
{ "subb2", {"rbmb", 0x82 } },
|
||||
{ "subb3", {"rbrbwb", 0x83 } },
|
||||
{ "mulb2", {"rbmb", 0x84 } },
|
||||
{ "mulb3", {"rbrbwb", 0x85 } },
|
||||
{ "divb2", {"rbmb", 0x86 } },
|
||||
{ "divb3", {"rbrbwb", 0x87 } },
|
||||
{ "bisb2", {"rbmb", 0x88 } },
|
||||
{ "bisb3", {"rbrbwb", 0x89 } },
|
||||
{ "bicb2", {"rbmb", 0x8a } },
|
||||
{ "bicb3", {"rbrbwb", 0x8b } },
|
||||
{ "xorb2", {"rbmb", 0x8c } },
|
||||
{ "xorb3", {"rbrbwb", 0x8d } },
|
||||
{ "mnegb", {"rbwb", 0x8e } },
|
||||
{ "caseb", {"rbrbrb", 0x8f } },
|
||||
{ "movb", {"rbwb", 0x90 } },
|
||||
{ "cmpb", {"rbrb", 0x91 } },
|
||||
{ "mcomb", {"rbwb", 0x92 } },
|
||||
{ "bitb", {"rbrb", 0x93 } },
|
||||
{ "clrb", {"wb", 0x94 } },
|
||||
{ "tstb", {"rb", 0x95 } },
|
||||
{ "incb", {"mb", 0x96 } },
|
||||
{ "decb", {"mb", 0x97 } },
|
||||
{ "cvtbl", {"rbwl", 0x98 } },
|
||||
{ "cvtbw", {"rbww", 0x99 } },
|
||||
{ "movzbl", {"rbwl", 0x9a } },
|
||||
{ "movzbw", {"rbww", 0x9b } },
|
||||
{ "rotl", {"rbrlwl", 0x9c } },
|
||||
{ "acbb", {"rbrbmbbw", 0x9d } },
|
||||
{ "movab", {"abwl", 0x9e } },
|
||||
{ "pushab", {"ab", 0x9f } },
|
||||
{ "addw2", {"rwmw", 0xa0 } },
|
||||
{ "addw3", {"rwrwww", 0xa1 } },
|
||||
{ "subw2", {"rwmw", 0xa2 } },
|
||||
{ "subw3", {"rwrwww", 0xa3 } },
|
||||
{ "mulw2", {"rwmw", 0xa4 } },
|
||||
{ "mulw3", {"rwrwww", 0xa5 } },
|
||||
{ "divw2", {"rwmw", 0xa6 } },
|
||||
{ "divw3", {"rwrwww", 0xa7 } },
|
||||
{ "bisw2", {"rwmw", 0xa8 } },
|
||||
{ "bisw3", {"rwrwww", 0xa9 } },
|
||||
{ "bicw2", {"rwmw", 0xaa } },
|
||||
{ "bicw3", {"rwrwww", 0xab } },
|
||||
{ "xorw2", {"rwmw", 0xac } },
|
||||
{ "xorw3", {"rwrwww", 0xad } },
|
||||
{ "mnegw", {"rwww", 0xae } },
|
||||
{ "casew", {"rwrwrw", 0xaf } },
|
||||
{ "movw", {"rwww", 0xb0 } },
|
||||
{ "cmpw", {"rwrw", 0xb1 } },
|
||||
{ "mcomw", {"rwww", 0xb2 } },
|
||||
{ "bitw", {"rwrw", 0xb3 } },
|
||||
{ "clrw", {"ww", 0xb4 } },
|
||||
{ "tstw", {"rw", 0xb5 } },
|
||||
{ "incw", {"mw", 0xb6 } },
|
||||
{ "decw", {"mw", 0xb7 } },
|
||||
{ "bispsw", {"rw", 0xb8 } },
|
||||
{ "bicpsw", {"rw", 0xb9 } },
|
||||
{ "popr", {"rw", 0xba } },
|
||||
{ "pushr", {"rw", 0xbb } },
|
||||
{ "chmk", {"rw", 0xbc } },
|
||||
{ "chme", {"rw", 0xbd } },
|
||||
{ "chms", {"rw", 0xbe } },
|
||||
{ "chmu", {"rw", 0xbf } },
|
||||
{ "addl2", {"rlml", 0xc0 } },
|
||||
{ "addl3", {"rlrlwl", 0xc1 } },
|
||||
{ "subl2", {"rlml", 0xc2 } },
|
||||
{ "subl3", {"rlrlwl", 0xc3 } },
|
||||
{ "mull2", {"rlml", 0xc4 } },
|
||||
{ "mull3", {"rlrlwl", 0xc5 } },
|
||||
{ "divl2", {"rlml", 0xc6 } },
|
||||
{ "divl3", {"rlrlwl", 0xc7 } },
|
||||
{ "bisl2", {"rlml", 0xc8 } },
|
||||
{ "bisl3", {"rlrlwl", 0xc9 } },
|
||||
{ "bicl2", {"rlml", 0xca } },
|
||||
{ "bicl3", {"rlrlwl", 0xcb } },
|
||||
{ "xorl2", {"rlml", 0xcc } },
|
||||
{ "xorl3", {"rlrlwl", 0xcd } },
|
||||
{ "mnegl", {"rlwl", 0xce } },
|
||||
{ "casel", {"rlrlrl", 0xcf } },
|
||||
{ "movl", {"rlwl", 0xd0 } },
|
||||
{ "cmpl", {"rlrl", 0xd1 } },
|
||||
{ "mcoml", {"rlwl", 0xd2 } },
|
||||
{ "bitl", {"rlrl", 0xd3 } },
|
||||
{ "clrf", {"wf", 0xd4 } },
|
||||
{ "clrl", {"wl", 0xd4 } },
|
||||
{ "tstl", {"rl", 0xd5 } },
|
||||
{ "incl", {"ml", 0xd6 } },
|
||||
{ "decl", {"ml", 0xd7 } },
|
||||
{ "adwc", {"rlml", 0xd8 } },
|
||||
{ "sbwc", {"rlml", 0xd9 } },
|
||||
{ "mtpr", {"rlrl", 0xda } },
|
||||
{ "mfpr", {"rlwl", 0xdb } },
|
||||
{ "movpsl", {"wl", 0xdc } },
|
||||
{ "pushl", {"rl", 0xdd } },
|
||||
{ "moval", {"alwl", 0xde } },
|
||||
{ "movaf", {"afwl", 0xde } },
|
||||
{ "pushal", {"al", 0xdf } },
|
||||
{ "pushaf", {"af", 0xdf } },
|
||||
{ "bbs", {"rlvbbb", 0xe0 } },
|
||||
{ "bbc", {"rlvbbb", 0xe1 } },
|
||||
{ "bbss", {"rlvbbb", 0xe2 } },
|
||||
{ "bbcs", {"rlvbbb", 0xe3 } },
|
||||
{ "bbsc", {"rlvbbb", 0xe4 } },
|
||||
{ "bbcc", {"rlvbbb", 0xe5 } },
|
||||
{ "bbssi", {"rlvbbb", 0xe6 } },
|
||||
{ "bbcci", {"rlvbbb", 0xe7 } },
|
||||
{ "blbs", {"rlbb", 0xe8 } },
|
||||
{ "blbc", {"rlbb", 0xe9 } },
|
||||
{ "ffs", {"rlrbvbwl", 0xea } },
|
||||
{ "ffc", {"rlrbvbwl", 0xeb } },
|
||||
{ "cmpv", {"rlrbvbrl", 0xec } },
|
||||
{ "cmpzv", {"rlrbvbrl", 0xed } },
|
||||
{ "extv", {"rlrbvbwl", 0xee } },
|
||||
{ "extzv", {"rlrbvbwl", 0xef } },
|
||||
{ "insv", {"rlrlrbvb", 0xf0 } },
|
||||
{ "acbl", {"rlrlmlbw", 0xf1 } },
|
||||
{ "aoblss", {"rlmlbb", 0xf2 } },
|
||||
{ "aobleq", {"rlmlbb", 0xf3 } },
|
||||
{ "sobgeq", {"mlbb", 0xf4 } },
|
||||
{ "sobgtr", {"mlbb", 0xf5 } },
|
||||
{ "cvtlb", {"rlwb", 0xf6 } },
|
||||
{ "cvtlw", {"rlww", 0xf7 } },
|
||||
{ "ashp", {"rbrwabrbrwab", 0xf8 } },
|
||||
{ "cvtlp", {"rlrwab", 0xf9 } },
|
||||
{ "callg", {"abab", 0xfa } },
|
||||
{ "calls", {"rlab", 0xfb } },
|
||||
{ "xfc", {"", 0xfc } },
|
||||
/* undefined opcodes here */
|
||||
{ "cvtdh", {"rdwh", 0x32fd } },
|
||||
{ "cvtgf", {"rgwh", 0x33fd } },
|
||||
{ "addg2", {"rgmg", 0x40fd } },
|
||||
{ "addg3", {"rgrgwg", 0x41fd } },
|
||||
{ "subg2", {"rgmg", 0x42fd } },
|
||||
{ "subg3", {"rgrgwg", 0x43fd } },
|
||||
{ "mulg2", {"rgmg", 0x44fd } },
|
||||
{ "mulg3", {"rgrgwg", 0x45fd } },
|
||||
{ "divg2", {"rgmg", 0x46fd } },
|
||||
{ "divg3", {"rgrgwg", 0x47fd } },
|
||||
{ "cvtgb", {"rgwb", 0x48fd } },
|
||||
{ "cvtgw", {"rgww", 0x49fd } },
|
||||
{ "cvtgl", {"rgwl", 0x4afd } },
|
||||
{ "cvtrgl", {"rgwl", 0x4bfd } },
|
||||
{ "cvtbg", {"rbwg", 0x4cfd } },
|
||||
{ "cvtwg", {"rwwg", 0x4dfd } },
|
||||
{ "cvtlg", {"rlwg", 0x4efd } },
|
||||
{ "acbg", {"rgrgmgbw", 0x4ffd } },
|
||||
{ "movg", {"rgwg", 0x50fd } },
|
||||
{ "cmpg", {"rgrg", 0x51fd } },
|
||||
{ "mnegg", {"rgwg", 0x52fd } },
|
||||
{ "tstg", {"rg", 0x53fd } },
|
||||
{ "emodg", {"rgrwrgwlwg", 0x54fd } },
|
||||
{ "polyg", {"rgrwab", 0x55fd } },
|
||||
{ "cvtgh", {"rgwh", 0x56fd } },
|
||||
/* undefined opcodes here */
|
||||
{ "addh2", {"rhmh", 0x60fd } },
|
||||
{ "addh3", {"rhrhwh", 0x61fd } },
|
||||
{ "subh2", {"rhmh", 0x62fd } },
|
||||
{ "subh3", {"rhrhwh", 0x63fd } },
|
||||
{ "mulh2", {"rhmh", 0x64fd } },
|
||||
{ "mulh3", {"rhrhwh", 0x65fd } },
|
||||
{ "divh2", {"rhmh", 0x66fd } },
|
||||
{ "divh3", {"rhrhwh", 0x67fd } },
|
||||
{ "cvthb", {"rhwb", 0x68fd } },
|
||||
{ "cvthw", {"rhww", 0x69fd } },
|
||||
{ "cvthl", {"rhwl", 0x6afd } },
|
||||
{ "cvtrhl", {"rhwl", 0x6bfd } },
|
||||
{ "cvtbh", {"rbwh", 0x6cfd } },
|
||||
{ "cvtwh", {"rwwh", 0x6dfd } },
|
||||
{ "cvtlh", {"rlwh", 0x6efd } },
|
||||
{ "acbh", {"rhrhmhbw", 0x6ffd } },
|
||||
{ "movh", {"rhwh", 0x70fd } },
|
||||
{ "cmph", {"rhrh", 0x71fd } },
|
||||
{ "mnegh", {"rhwh", 0x72fd } },
|
||||
{ "tsth", {"rh", 0x73fd } },
|
||||
{ "emodh", {"rhrwrhwlwh", 0x74fd } },
|
||||
{ "polyh", {"rhrwab", 0x75fd } },
|
||||
{ "cvthg", {"rhwg", 0x76fd } },
|
||||
/* undefined opcodes here */
|
||||
{ "clrh", {"wh", 0x7cfd } },
|
||||
{ "clro", {"wo", 0x7cfd } },
|
||||
{ "movo", {"rowo", 0x7dfd } },
|
||||
{ "movah", {"ahwl", 0x7efd } },
|
||||
{ "movao", {"aowl", 0x7efd } },
|
||||
{ "pushah", {"ah", 0x7ffd } },
|
||||
{ "pushao", {"ao", 0x7ffd } },
|
||||
/* undefined opcodes here */
|
||||
{ "cvtfh", {"rfwh", 0x98fd } },
|
||||
{ "cvtfg", {"rfwg", 0x99fd } },
|
||||
/* undefined opcodes here */
|
||||
{ "cvthf", {"rhwf", 0xf6fd } },
|
||||
{ "cvthd", {"rhwd", 0xf7fd } },
|
||||
/* undefined opcodes here */
|
||||
{ "bugl", {"rl", 0xfdff } },
|
||||
{ "bugw", {"rw", 0xfeff } },
|
||||
/* undefined opcodes here */
|
||||
|
||||
{ "", {"", 0} } /* empty is end sentinel */
|
||||
|
||||
}; /* votstrs */
|
||||
|
||||
/* end: vax.opcode.h */
|
||||
|
|
@ -403,7 +403,6 @@ if get_option('use_gpl')
|
|||
'arc_gnu',
|
||||
'cris_gnu',
|
||||
'lanai_gnu',
|
||||
'vax_gnu',
|
||||
'z80_gnu',
|
||||
]
|
||||
|
||||
|
|
@ -412,7 +411,6 @@ if get_option('use_gpl')
|
|||
'p_gnu/arch_arc.c',
|
||||
'p_gnu/arch_cris.c',
|
||||
'p_gnu/arch_lanai.c',
|
||||
'p_gnu/arch_vax.c',
|
||||
'p_gnu/arch_z80.c',
|
||||
]
|
||||
|
||||
|
|
@ -426,7 +424,6 @@ if get_option('use_gpl')
|
|||
'isa_gnu/cris/cris-opc.c',
|
||||
'isa_gnu/lanai/lanai-dis.c',
|
||||
'isa_gnu/lanai/lanai-opc.c',
|
||||
'isa_gnu/vax/vax-dis.c',
|
||||
# 'isa_gnu/z80/expressions.c',
|
||||
# 'isa_gnu/z80/z80.c',
|
||||
# 'isa_gnu/z80/z80asm.c',
|
||||
|
|
|
|||
|
|
@ -1,91 +0,0 @@
|
|||
// SPDX-FileCopyrightText: 2015 pancake <pancake@nopcode.org>
|
||||
// SPDX-License-Identifier: LGPL-3.0-only
|
||||
|
||||
#include <string.h>
|
||||
#include <rz_types.h>
|
||||
#include <rz_util.h>
|
||||
#include <rz_lib.h>
|
||||
#include <rz_asm.h>
|
||||
#include <rz_analysis.h>
|
||||
|
||||
// XXX: this is just a PoC
|
||||
// XXX: do not hardcode size/type here, use proper decoding table
|
||||
// http://hotkosc.ru:8080/method-vax.doc
|
||||
|
||||
static int vax_op(RzAnalysis *analysis, RzAnalysisOp *op, ut64 addr, const ut8 *buf, int len, RzAnalysisOpMask mask) {
|
||||
op->size = 1;
|
||||
if (len < 1) {
|
||||
return -1;
|
||||
}
|
||||
op->type = RZ_ANALYSIS_OP_TYPE_UNK;
|
||||
switch (buf[0]) {
|
||||
case 0xd0:
|
||||
case 0x2e:
|
||||
op->type = RZ_ANALYSIS_OP_TYPE_MOV;
|
||||
op->size = 8;
|
||||
break;
|
||||
case 0x78:
|
||||
op->type = RZ_ANALYSIS_OP_TYPE_SHL;
|
||||
op->size = 8;
|
||||
break;
|
||||
case 0xc0:
|
||||
case 0xd8:
|
||||
op->type = RZ_ANALYSIS_OP_TYPE_ADD;
|
||||
op->size = 8;
|
||||
break;
|
||||
case 0x00:
|
||||
op->type = RZ_ANALYSIS_OP_TYPE_TRAP; // HALT
|
||||
break;
|
||||
case 0x01:
|
||||
op->type = RZ_ANALYSIS_OP_TYPE_NOP;
|
||||
break;
|
||||
case 0x51:
|
||||
case 0x73:
|
||||
op->type = RZ_ANALYSIS_OP_TYPE_CMP;
|
||||
break;
|
||||
case 0xac:
|
||||
op->type = RZ_ANALYSIS_OP_TYPE_XOR;
|
||||
op->size = 4;
|
||||
break;
|
||||
case 0x5a:
|
||||
op->size = 2;
|
||||
break;
|
||||
case 0x11:
|
||||
case 0x18:
|
||||
op->size = 2;
|
||||
op->type = RZ_ANALYSIS_OP_TYPE_CJMP;
|
||||
break;
|
||||
case 0x31:
|
||||
case 0xe9:
|
||||
op->size = 3;
|
||||
op->type = RZ_ANALYSIS_OP_TYPE_CJMP;
|
||||
break;
|
||||
case 0xc6:
|
||||
case 0xc7:
|
||||
op->size = 8;
|
||||
op->type = RZ_ANALYSIS_OP_TYPE_DIV;
|
||||
break;
|
||||
case 0xd6:
|
||||
case 0x61:
|
||||
op->size = 2;
|
||||
op->type = RZ_ANALYSIS_OP_TYPE_ADD;
|
||||
break;
|
||||
case 0x62:
|
||||
op->type = RZ_ANALYSIS_OP_TYPE_SUB;
|
||||
break;
|
||||
case 0xff:
|
||||
op->size = 2;
|
||||
break;
|
||||
}
|
||||
return op->size;
|
||||
}
|
||||
|
||||
RzAnalysisPlugin rz_analysis_plugin_vax_gnu = {
|
||||
.name = "vax",
|
||||
.desc = "VAX code analysis plugin",
|
||||
.license = "LGPL3",
|
||||
.arch = "vax",
|
||||
.esil = false,
|
||||
.bits = 8 | 32,
|
||||
.op = &vax_op,
|
||||
};
|
||||
|
|
@ -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_vax_gnu.c"
|
||||
#include "asm/asm_vax_gnu.c"
|
||||
|
||||
RZ_ARCH_PLUGIN_DEFINE_DEPRECATED(vax_gnu);
|
||||
|
|
@ -1,121 +0,0 @@
|
|||
// SPDX-FileCopyrightText: 2015 pancake <pancake@nopcode.org>
|
||||
// SPDX-License-Identifier: LGPL-3.0-only
|
||||
|
||||
// TODO: add support for the assembler
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdarg.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <rz_types.h>
|
||||
#include <rz_util.h>
|
||||
#include <rz_lib.h>
|
||||
#include <rz_asm.h>
|
||||
|
||||
#include <common_gnu/disas-asm.h>
|
||||
#include "vax/vax.h"
|
||||
|
||||
typedef struct {
|
||||
unsigned long Offset;
|
||||
RzStrBuf *buf_global;
|
||||
const ut8 *bytes;
|
||||
int bytes_size;
|
||||
} VaxContext;
|
||||
|
||||
static int vax_buffer_read_memory(bfd_vma memaddr, bfd_byte *myaddr, ut32 length, struct disassemble_info *info, void *data) {
|
||||
VaxContext *ctx = (VaxContext *)data;
|
||||
int delta = (memaddr - ctx->Offset);
|
||||
if (delta < 0) {
|
||||
return -1; // disable backward reads
|
||||
}
|
||||
if (delta > length) {
|
||||
return -1;
|
||||
}
|
||||
memcpy(myaddr, ctx->bytes + delta, RZ_MIN(length, ctx->bytes_size));
|
||||
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) {
|
||||
//--
|
||||
}
|
||||
|
||||
static void generic_print_address_func(bfd_vma address, void *data, struct disassemble_info *info) {
|
||||
VaxContext *ctx = (VaxContext *)data;
|
||||
if (!ctx->buf_global) {
|
||||
return;
|
||||
}
|
||||
rz_strbuf_appendf(ctx->buf_global, "0x%08" PFMT64x, (ut64)address);
|
||||
}
|
||||
|
||||
static int generic_fprintf_func(void *stream, void *data, const char *format, ...) {
|
||||
VaxContext *ctx = (VaxContext *)data;
|
||||
int ret;
|
||||
va_list ap;
|
||||
if (!ctx->buf_global || !format) {
|
||||
return 0;
|
||||
}
|
||||
va_start(ap, format);
|
||||
ret = rz_strbuf_vappendf(ctx->buf_global, format, ap);
|
||||
va_end(ap);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int vax_gnu_disassemble(const RzAsm *a, RzAsmOp *op, const ut8 *buf, int len) {
|
||||
VaxContext *ctx = (VaxContext *)a->plugin_data;
|
||||
struct disassemble_info disasm_obj;
|
||||
if (len < 4) {
|
||||
return -1;
|
||||
}
|
||||
ctx->buf_global = &op->buf_asm;
|
||||
ctx->bytes = buf;
|
||||
ctx->bytes_size = len;
|
||||
ctx->Offset = a->pc;
|
||||
|
||||
/* prepare disassembler */
|
||||
memset(&disasm_obj, '\0', sizeof(struct disassemble_info));
|
||||
disasm_obj.buffer = (ut8 *)ctx->bytes;
|
||||
disasm_obj.read_memory_func = &vax_buffer_read_memory;
|
||||
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 = BFD_ENDIAN_LITTLE;
|
||||
disasm_obj.fprintf_func = &generic_fprintf_func;
|
||||
disasm_obj.stream = stdout;
|
||||
op->size = print_insn_vax((bfd_vma)ctx->Offset, &disasm_obj, ctx);
|
||||
|
||||
if (op->size == -1) {
|
||||
rz_asm_op_set_asm(op, "(data)");
|
||||
}
|
||||
return op->size;
|
||||
}
|
||||
|
||||
static bool vax_gnu_init(void **user) {
|
||||
VaxContext *ctx = RZ_NEW0(VaxContext);
|
||||
rz_return_val_if_fail(ctx, false);
|
||||
*user = ctx;
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool vax_gnu_fini(void *p) {
|
||||
VaxContext *ctx = (VaxContext *)p;
|
||||
if (ctx) {
|
||||
RZ_FREE(ctx);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
RzAsmPlugin rz_asm_plugin_vax_gnu = {
|
||||
.name = "vax",
|
||||
.arch = "vax",
|
||||
.license = "GPL3",
|
||||
.bits = 8 | 32,
|
||||
.endian = RZ_SYS_ENDIAN_LITTLE,
|
||||
.desc = "DEC VAX disassembler",
|
||||
.disassemble = &vax_gnu_disassemble,
|
||||
.init = &vax_gnu_init,
|
||||
.fini = &vax_gnu_fini
|
||||
};
|
||||
Loading…
Reference in a new issue