From 1415a2a767bf5ed24c4b4f3b1fc1c45c9a876614 Mon Sep 17 00:00:00 2001 From: Anthony Green Date: Fri, 28 Sep 2012 03:53:39 +0000 Subject: [PATCH] Don't abort() when disassembling bad moxie instructions. --- include/ChangeLog | 4 ++ include/opcode/moxie.h | 4 +- opcodes/ChangeLog | 5 ++ opcodes/moxie-dis.c | 11 +++- opcodes/moxie-opc.c | 115 +++++++++++++++++++++++++++++++---------- 5 files changed, 109 insertions(+), 30 deletions(-) diff --git a/include/ChangeLog b/include/ChangeLog index c0b69ad7177..4a535eb2535 100644 --- a/include/ChangeLog +++ b/include/ChangeLog @@ -1,3 +1,7 @@ +2012-09-27 Anthony Green + + * opcode/moxie.h (MOXIE_BAD): New define. + 2012-09-12 Chris Schlumberger-Socha * elf/aarch64.h (R_AARCH64_GOT_LD_PREL19): New reloc. diff --git a/include/opcode/moxie.h b/include/opcode/moxie.h index e2bc374f044..dae40c8e83c 100644 --- a/include/opcode/moxie.h +++ b/include/opcode/moxie.h @@ -60,6 +60,8 @@ #define MOXIE_F3_NARG 0x300 #define MOXIE_F3_PCREL 0x301 +#define MOXIE_BAD 0x400 + typedef struct moxie_opc_info_t { short opcode; @@ -67,6 +69,6 @@ typedef struct moxie_opc_info_t const char * name; } moxie_opc_info_t; -extern const moxie_opc_info_t moxie_form1_opc_info[64]; +extern const moxie_opc_info_t moxie_form1_opc_info[128]; extern const moxie_opc_info_t moxie_form2_opc_info[4]; extern const moxie_opc_info_t moxie_form3_opc_info[16]; diff --git a/opcodes/ChangeLog b/opcodes/ChangeLog index ad10a204646..4fe082a615d 100644 --- a/opcodes/ChangeLog +++ b/opcodes/ChangeLog @@ -1,3 +1,8 @@ +2012-09-27 Anthony Green + + * moxie-dis.c (print_insn_moxie): Print 'bad' instructions. + * moxie-opc.c: All 'bad' instructions have the itype MOXIE_BAD. + 2012-09-25 Saravanan Ekanathan * i386-gen.c (cpu_flag_init): Add missing Cpu flags in diff --git a/opcodes/moxie-dis.c b/opcodes/moxie-dis.c index 38429de1ae5..f726f21d680 100644 --- a/opcodes/moxie-dis.c +++ b/opcodes/moxie-dis.c @@ -174,8 +174,11 @@ print_insn_moxie (bfd_vma addr, struct disassemble_info * info) length = 6; } break; + case MOXIE_BAD: + fpr (stream, "bad"); + break; default: - abort (); + abort(); } } else if ((iword & (1<<14)) == 0) @@ -193,6 +196,9 @@ print_insn_moxie (bfd_vma addr, struct disassemble_info * info) case MOXIE_F2_NARG: fpr (stream, "%s", opcode->name); break; + case MOXIE_BAD: + fpr (stream, "bad"); + break; default: abort(); } @@ -208,6 +214,9 @@ print_insn_moxie (bfd_vma addr, struct disassemble_info * info) info->print_address_func ((bfd_vma) (addr + INST2OFFSET(iword) + 2), info); break; + case MOXIE_BAD: + fpr (stream, "bad"); + break; default: abort(); } diff --git a/opcodes/moxie-opc.c b/opcodes/moxie-opc.c index b493d1fb36f..7f3a552b892 100644 --- a/opcodes/moxie-opc.c +++ b/opcodes/moxie-opc.c @@ -50,12 +50,9 @@ oooo - form 3 opcode number vvvvvvvvvv - 10-bit immediate value. */ -/* Note that currently two opcodes are reserved as bad, so that all - instructions starting with 0x00 and 0xff fault. */ - -const moxie_opc_info_t moxie_form1_opc_info[64] = +const moxie_opc_info_t moxie_form1_opc_info[128] = { - { 0x00, MOXIE_F1_NARG, "bad" }, // Reserved as bad. + { 0x00, MOXIE_BAD, "bad" }, // Reserved as bad. { 0x01, MOXIE_F1_A4, "ldi.l" }, { 0x02, MOXIE_F1_AB, "mov" }, { 0x03, MOXIE_F1_M, "jsra" }, @@ -71,15 +68,15 @@ const moxie_opc_info_t moxie_form1_opc_info[64] = { 0x0d, MOXIE_F1_AiB4, "sto.l" }, { 0x0e, MOXIE_F1_AB, "cmp" }, { 0x0f, MOXIE_F1_NARG, "nop" }, - { 0x10, MOXIE_F1_NARG, "bad" }, - { 0x11, MOXIE_F1_NARG, "bad" }, - { 0x12, MOXIE_F1_NARG, "bad" }, - { 0x13, MOXIE_F1_NARG, "bad" }, - { 0x14, MOXIE_F1_NARG, "bad" }, - { 0x15, MOXIE_F1_NARG, "bad" }, - { 0x16, MOXIE_F1_NARG, "bad" }, - { 0x17, MOXIE_F1_NARG, "bad" }, - { 0x18, MOXIE_F1_NARG, "bad" }, + { 0x10, MOXIE_BAD, "bad" }, + { 0x11, MOXIE_BAD, "bad" }, + { 0x12, MOXIE_BAD, "bad" }, + { 0x13, MOXIE_BAD, "bad" }, + { 0x14, MOXIE_BAD, "bad" }, + { 0x15, MOXIE_BAD, "bad" }, + { 0x16, MOXIE_BAD, "bad" }, + { 0x17, MOXIE_BAD, "bad" }, + { 0x18, MOXIE_BAD, "bad" }, { 0x19, MOXIE_F1_A, "jsr" }, { 0x1a, MOXIE_F1_M, "jmpa" }, { 0x1b, MOXIE_F1_A4, "ldi.b" }, @@ -113,12 +110,76 @@ const moxie_opc_info_t moxie_form1_opc_info[64] = { 0x37, MOXIE_F1_AiB4, "sto.b" }, { 0x38, MOXIE_F1_ABi4, "ldo.s" }, { 0x39, MOXIE_F1_AiB4, "sto.s" }, - { 0x3a, MOXIE_F1_NARG, "bad" }, - { 0x3b, MOXIE_F1_NARG, "bad" }, - { 0x3c, MOXIE_F1_NARG, "bad" }, - { 0x3d, MOXIE_F1_NARG, "bad" }, - { 0x3e, MOXIE_F1_NARG, "bad" }, - { 0x3f, MOXIE_F1_NARG, "bad" } + { 0x3a, MOXIE_BAD, "bad" }, + { 0x3b, MOXIE_BAD, "bad" }, + { 0x3c, MOXIE_BAD, "bad" }, + { 0x3d, MOXIE_BAD, "bad" }, + { 0x3e, MOXIE_BAD, "bad" }, + { 0x3f, MOXIE_BAD, "bad" }, + { 0x40, MOXIE_BAD, "bad" }, + { 0x41, MOXIE_BAD, "bad" }, + { 0x42, MOXIE_BAD, "bad" }, + { 0x43, MOXIE_BAD, "bad" }, + { 0x44, MOXIE_BAD, "bad" }, + { 0x45, MOXIE_BAD, "bad" }, + { 0x46, MOXIE_BAD, "bad" }, + { 0x47, MOXIE_BAD, "bad" }, + { 0x48, MOXIE_BAD, "bad" }, + { 0x49, MOXIE_BAD, "bad" }, + { 0x4a, MOXIE_BAD, "bad" }, + { 0x4b, MOXIE_BAD, "bad" }, + { 0x4c, MOXIE_BAD, "bad" }, + { 0x4d, MOXIE_BAD, "bad" }, + { 0x4e, MOXIE_BAD, "bad" }, + { 0x4f, MOXIE_BAD, "bad" }, + { 0x50, MOXIE_BAD, "bad" }, + { 0x51, MOXIE_BAD, "bad" }, + { 0x52, MOXIE_BAD, "bad" }, + { 0x53, MOXIE_BAD, "bad" }, + { 0x54, MOXIE_BAD, "bad" }, + { 0x55, MOXIE_BAD, "bad" }, + { 0x56, MOXIE_BAD, "bad" }, + { 0x57, MOXIE_BAD, "bad" }, + { 0x58, MOXIE_BAD, "bad" }, + { 0x59, MOXIE_BAD, "bad" }, + { 0x5a, MOXIE_BAD, "bad" }, + { 0x5b, MOXIE_BAD, "bad" }, + { 0x5c, MOXIE_BAD, "bad" }, + { 0x5d, MOXIE_BAD, "bad" }, + { 0x5e, MOXIE_BAD, "bad" }, + { 0x5f, MOXIE_BAD, "bad" }, + { 0x60, MOXIE_BAD, "bad" }, + { 0x61, MOXIE_BAD, "bad" }, + { 0x62, MOXIE_BAD, "bad" }, + { 0x63, MOXIE_BAD, "bad" }, + { 0x64, MOXIE_BAD, "bad" }, + { 0x65, MOXIE_BAD, "bad" }, + { 0x66, MOXIE_BAD, "bad" }, + { 0x67, MOXIE_BAD, "bad" }, + { 0x68, MOXIE_BAD, "bad" }, + { 0x69, MOXIE_BAD, "bad" }, + { 0x6a, MOXIE_BAD, "bad" }, + { 0x6b, MOXIE_BAD, "bad" }, + { 0x6c, MOXIE_BAD, "bad" }, + { 0x6d, MOXIE_BAD, "bad" }, + { 0x6e, MOXIE_BAD, "bad" }, + { 0x6f, MOXIE_BAD, "bad" }, + { 0x70, MOXIE_BAD, "bad" }, + { 0x71, MOXIE_BAD, "bad" }, + { 0x72, MOXIE_BAD, "bad" }, + { 0x73, MOXIE_BAD, "bad" }, + { 0x74, MOXIE_BAD, "bad" }, + { 0x75, MOXIE_BAD, "bad" }, + { 0x76, MOXIE_BAD, "bad" }, + { 0x77, MOXIE_BAD, "bad" }, + { 0x78, MOXIE_BAD, "bad" }, + { 0x79, MOXIE_BAD, "bad" }, + { 0x7a, MOXIE_BAD, "bad" }, + { 0x7b, MOXIE_BAD, "bad" }, + { 0x7c, MOXIE_BAD, "bad" }, + { 0x7d, MOXIE_BAD, "bad" }, + { 0x7e, MOXIE_BAD, "bad" }, + { 0x7f, MOXIE_BAD, "bad" } }; const moxie_opc_info_t moxie_form2_opc_info[4] = @@ -141,12 +202,10 @@ const moxie_opc_info_t moxie_form3_opc_info[16] = { 0x07, MOXIE_F3_PCREL,"ble" }, { 0x08, MOXIE_F3_PCREL,"bgeu" }, { 0x09, MOXIE_F3_PCREL,"bleu" }, - { 0x0a, MOXIE_F3_NARG, "bad" }, - { 0x0b, MOXIE_F3_NARG, "bad" }, - { 0x0c, MOXIE_F3_NARG, "bad" }, - { 0x0d, MOXIE_F3_NARG, "bad" }, - { 0x0e, MOXIE_F3_NARG, "bad" }, - { 0x0f, MOXIE_F3_NARG, "bad" } // Reserved as bad. + { 0x0a, MOXIE_BAD, "bad" }, + { 0x0b, MOXIE_BAD, "bad" }, + { 0x0c, MOXIE_BAD, "bad" }, + { 0x0d, MOXIE_BAD, "bad" }, + { 0x0e, MOXIE_BAD, "bad" }, + { 0x0f, MOXIE_BAD, "bad" } // Reserved as bad. }; - - -- 2.30.2