diff options
-rw-r--r-- | gas/ChangeLog | 5 | ||||
-rw-r--r-- | gas/config/tc-sh.c | 63 |
2 files changed, 37 insertions, 31 deletions
diff --git a/gas/ChangeLog b/gas/ChangeLog index 1d4bd0e..e34574c 100644 --- a/gas/ChangeLog +++ b/gas/ChangeLog @@ -1,3 +1,8 @@ +2010-03-02 Andrew Stubbs <ams@codesourcery.com> + + * config/tc-sh.c (get_specific): Move overflow checking code to avoid + reading uninitialized data. + 2010-03-01 Tristan Gingold <gingold@adacore.com> * 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 42f01e9..a7cdd0e 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; |