From: Andrew Stubbs Date: Tue, 2 Mar 2010 09:32:21 +0000 (+0000) Subject: 2010-03-02 Andrew Stubbs X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=772657e99586665e8465ad0bb3c722a0af7a76ad;p=binutils-gdb.git 2010-03-02 Andrew Stubbs * config/tc-sh.c (get_specific): Move overflow checking code to avoid reading uninitialized data. --- diff --git a/gas/ChangeLog b/gas/ChangeLog index 1d4bd0e3861..e34574c220b 100644 --- a/gas/ChangeLog +++ b/gas/ChangeLog @@ -1,3 +1,8 @@ +2010-03-02 Andrew Stubbs + + * config/tc-sh.c (get_specific): Move overflow checking code to avoid + reading uninitialized data. + 2010-03-01 Tristan Gingold * config/tc-score7.c (s7_frag_check): Add ATTRIBUTE_UNUSED. diff --git a/gas/config/tc-sh.c b/gas/config/tc-sh.c index 42f01e9ba5e..a7cdd0eccee 100644 --- a/gas/config/tc-sh.c +++ b/gas/config/tc-sh.c @@ -1,6 +1,7 @@ /* tc-sh.c -- Assemble code for the Renesas / SuperH SH Copyright 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, - 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation, Inc. + 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 + Free Software Foundation, Inc. This file is part of GAS, the GNU Assembler. @@ -1679,36 +1680,6 @@ get_specific (sh_opcode_info *opcode, sh_operand_info *operands) sh_operand_info *user = operands + n; sh_arg_type arg = this_try->arg[n]; - if (SH_MERGE_ARCH_SET_VALID (valid_arch, arch_sh2a_nofpu_up) - && ( arg == A_DISP_REG_M - || arg == A_DISP_REG_N)) - { - /* Check a few key IMM* fields for overflow. */ - int opf; - long val = user->immediate.X_add_number; - - for (opf = 0; opf < 4; opf ++) - switch (this_try->nibbles[opf]) - { - case IMM0_4: - case IMM1_4: - if (val < 0 || val > 15) - goto fail; - break; - case IMM0_4BY2: - case IMM1_4BY2: - if (val < 0 || val > 15 * 2) - goto fail; - break; - case IMM0_4BY4: - case IMM1_4BY4: - if (val < 0 || val > 15 * 4) - goto fail; - break; - default: - break; - } - } switch (arg) { case A_DISP_PC: @@ -2202,6 +2173,36 @@ get_specific (sh_opcode_info *opcode, sh_operand_info *operands) printf (_("unhandled %d\n"), arg); goto fail; } + if (SH_MERGE_ARCH_SET_VALID (valid_arch, arch_sh2a_nofpu_up) + && ( arg == A_DISP_REG_M + || arg == A_DISP_REG_N)) + { + /* Check a few key IMM* fields for overflow. */ + int opf; + long val = user->immediate.X_add_number; + + for (opf = 0; opf < 4; opf ++) + switch (this_try->nibbles[opf]) + { + case IMM0_4: + case IMM1_4: + if (val < 0 || val > 15) + goto fail; + break; + case IMM0_4BY2: + case IMM1_4BY2: + if (val < 0 || val > 15 * 2) + goto fail; + break; + case IMM0_4BY4: + case IMM1_4BY4: + if (val < 0 || val > 15 * 4) + goto fail; + break; + default: + break; + } + } } if ( !SH_MERGE_ARCH_SET_VALID (valid_arch, this_try->arch)) goto fail;