X-Git-Url: http://drtracing.org/?a=blobdiff_plain;f=opcodes%2Fia64-opc.c;h=ba60f8a78295d2bf9ff7b839586bad59f376bcd4;hb=7936714c0c5030f872ced475f848692ce835708a;hp=fc90213a6b545fcce3476cdd3800396fcbe8203e;hpb=26ca545091edbd761ec3e0ff05e5f2f15fc6f68b;p=deliverable%2Fbinutils-gdb.git diff --git a/opcodes/ia64-opc.c b/opcodes/ia64-opc.c index fc90213a6b..ba60f8a782 100644 --- a/opcodes/ia64-opc.c +++ b/opcodes/ia64-opc.c @@ -1,27 +1,26 @@ /* ia64-opc.c -- Functions to access the compacted opcode table - Copyright 1999, 2000, 2003 Free Software Foundation, Inc. + Copyright (C) 1999-2019 Free Software Foundation, Inc. Written by Bob Manson of Cygnus Solutions, - This file is part of GDB, GAS, and the GNU binutils. + This file is part of the GNU opcodes library. - GDB, GAS, and the GNU binutils are free software; you can redistribute - them and/or modify them under the terms of the GNU General Public - License as published by the Free Software Foundation; either version - 2, or (at your option) any later version. + 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. - GDB, GAS, and the GNU binutils are distributed in the hope that they - 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 file; see the file COPYING. If not, write to the - Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA - 02111-1307, USA. */ + Free Software Foundation, 51 Franklin Street - Fifth Floor, Boston, + MA 02110-1301, USA. */ -#include "ansidecl.h" -#include "libiberty.h" #include "sysdep.h" +#include "libiberty.h" #include "ia64-asmtab.h" #include "ia64-asmtab.c" @@ -124,7 +123,7 @@ static short find_main_ent (short nameindex) { short start = 0; - short end = sizeof (main_table) / sizeof (struct ia64_main_table); + short end = ARRAY_SIZE (main_table); short i = (start + end) / 2; if (nameindex < main_table[0].name_index @@ -365,7 +364,7 @@ locate_opcode_ent (ia64_insn opcode, enum ia64_insn_type type) unsigned int op; int currbitnum = bitpos[currstatenum]; int oplen; - int opval[3]; + int opval[3] = {0}; int next_op; int currbit; @@ -373,13 +372,16 @@ locate_opcode_ent (ia64_insn opcode, enum ia64_insn_type type) bitpos[currstatenum] = currbitnum; - /* Skip opval[0] bits in the instruction. */ + /* Skip opval[0] bits in the instruction. */ if (op & 0x40) { currbitnum -= opval[0]; } - /* The value of the current bit being tested. */ + if (currbitnum < 0) + currbitnum = 0; + + /* The value of the current bit being tested. */ currbit = opcode & (((ia64_insn) 1) << currbitnum) ? 1 : 0; next_op = -1; @@ -464,7 +466,7 @@ locate_opcode_ent (ia64_insn opcode, enum ia64_insn_type type) if (next_op > 65535) { - abort (); + return -1; } /* Run through the list of opcodes to check, trying to find @@ -613,6 +615,9 @@ ia64_find_matching_opcode (const char *name, short place) const char *suffix; short name_index; + if ((unsigned) place >= ARRAY_SIZE (main_table)) + return NULL; + if (strlen (name) > 128) { return NULL; @@ -718,13 +723,13 @@ ia64_free_opcode (struct ia64_opcode *ent) } const struct ia64_dependency * -ia64_find_dependency (int index) +ia64_find_dependency (int dep_index) { - index = DEP(index); + dep_index = DEP(dep_index); - if (index < 0 - || index >= (int)(sizeof(dependencies) / sizeof(dependencies[0]))) + if (dep_index < 0 + || dep_index >= (int) ARRAY_SIZE (dependencies)) return NULL; - return &dependencies[index]; + return &dependencies[dep_index]; }