X-Git-Url: http://drtracing.org/?a=blobdiff_plain;f=opcodes%2Fns32k-dis.c;h=22a9389ecff2dee701885b045e063c9c5b4fdb2a;hb=334175b693a1cbab8850f5faa6937e7c6ca3db7d;hp=7ed4ab2fbe57f8dd5f0c3d685e3294d568bece0a;hpb=47b0e7ad8c60ea4b45b22ad5cb376f068991bc88;p=deliverable%2Fbinutils-gdb.git diff --git a/opcodes/ns32k-dis.c b/opcodes/ns32k-dis.c index 7ed4ab2fbe..22a9389ecf 100644 --- a/opcodes/ns32k-dis.c +++ b/opcodes/ns32k-dis.c @@ -1,28 +1,26 @@ /* Print National Semiconductor 32000 instructions. - Copyright 1986, 1988, 1991, 1992, 1994, 1998, 2001, 2002, 2005 - Free Software Foundation, Inc. + Copyright (C) 1986-2019 Free Software Foundation, Inc. - This file is part of opcodes library. + This file is part of the GNU opcodes library. - This program is free software; you can redistribute it and/or modify + 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 2 of the License, or - (at your option) any later version. + the Free Software Foundation; either version 3, or (at your option) + any later version. - This program 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. + 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 "bfd.h" #include "sysdep.h" -#include "dis-asm.h" +#include "bfd.h" +#include "disassemble.h" #if !defined(const) && !defined(__STDC__) #define const #endif @@ -59,7 +57,7 @@ struct private bfd_byte *max_fetched; bfd_byte the_buffer[MAXLEN]; bfd_vma insn_start; - jmp_buf bailout; + OPCODES_SIGJMP_BUF bailout; }; @@ -84,7 +82,7 @@ fetch_data (struct disassemble_info *info, bfd_byte *addr) if (status != 0) { (*info->memory_error_func) (status, start, info); - longjmp (priv->bailout, 1); + OPCODES_SIGLONGJMP (priv->bailout, 1); } else priv->max_fetched = addr; @@ -267,6 +265,8 @@ bit_extract (bfd_byte *buffer, int offset, int count) int result; int bit; + if (offset < 0 || count < 0) + return 0; buffer += offset >> 3; offset &= 7; bit = 1; @@ -294,6 +294,8 @@ bit_extract_simple (bfd_byte *buffer, int offset, int count) int result; int bit; + if (offset < 0 || count < 0) + return 0; buffer += offset >> 3; offset &= 7; bit = 1; @@ -315,6 +317,8 @@ bit_extract_simple (bfd_byte *buffer, int offset, int count) static void bit_copy (bfd_byte *buffer, int offset, int count, char *to) { + if (offset < 0 || count < 0) + return; for (; count > 8; count -= 8, to++, offset += 8) *to = bit_extract (buffer, offset, 8); *to = bit_extract (buffer, offset, count); @@ -415,7 +419,7 @@ invalid_float (bfd_byte *p, int len) #else /* Assumes the bytes have been swapped to local order. */ typedef union -{ +{ double d; float f; struct { unsigned m:23, e:8, :1;} sf; @@ -467,7 +471,6 @@ print_insn_arg (int d, int Ivalue; int addr_mode; int disp1, disp2; - int index; int size; switch (d) @@ -475,6 +478,7 @@ print_insn_arg (int d, case 'f': /* A "gen" operand but 5 bits from the end of instruction. */ ioffset -= 5; + /* Fall through. */ case 'Z': case 'F': case 'L': @@ -617,17 +621,17 @@ print_insn_arg (int d, case 0x1d: case 0x1e: case 0x1f: - /* Scaled index basemode[R0 -- R7:B,W,D,Q]. */ - index = bit_extract (buffer, index_offset - 8, 3); - print_insn_arg (d, index_offset, aoffsetp, buffer, addr, - result, 0); { + int bit_index; static const char *ind = "bwdq"; char *off; + /* Scaled index basemode[R0 -- R7:B,W,D,Q]. */ + bit_index = bit_extract (buffer, index_offset - 8, 3); + print_insn_arg (d, index_offset, aoffsetp, buffer, addr, + result, 0); off = result + strlen (result); - sprintf (off, "[r%d:%c]", index, - ind[addr_mode & 3]); + sprintf (off, "[r%d:%c]", bit_index, ind[addr_mode & 3]); } break; } @@ -748,7 +752,7 @@ print_insn_ns32k (bfd_vma memaddr, disassemble_info *info) info->private_data = & priv; priv.max_fetched = priv.the_buffer; priv.insn_start = memaddr; - if (setjmp (priv.bailout) != 0) + if (OPCODES_SIGSETJMP (priv.bailout) != 0) /* Error return. */ return -1; @@ -797,7 +801,7 @@ print_insn_ns32k (bfd_vma memaddr, disassemble_info *info) /* 0 for operand A, 1 for operand B, greater for other args. */ int whicharg = 0; - + (*dis_info->fprintf_func)(dis_info->stream, "\t"); maxarg = 0; @@ -838,8 +842,10 @@ print_insn_ns32k (bfd_vma memaddr, disassemble_info *info) memaddr, arg_bufs[argnum], index_offset[whicharg]); d++; - whicharg++; + if (whicharg++ >= 1) + break; } + for (argnum = 0; argnum <= maxarg; argnum++) { bfd_vma addr;