Index: binutils/gas/config/tc-crx.c diff -c binutils/gas/config/tc-crx.c:1.1.1.1.2.1 binutils/gas/config/tc-crx.c:1.1.1.1.2.5 *** binutils/gas/config/tc-crx.c:1.1.1.1.2.1 Tue Jul 27 17:50:28 2004 --- binutils/gas/config/tc-crx.c Sun Aug 22 12:27:15 2004 *************** *** 28,34 **** #include "opcode/crx.h" #include "elf/crx.h" - /* Include do define ULONG_MAX, LONG_MAX, LONG_MIN. */ #include /* Word is considered here as a 16-bit unsigned short int. */ --- 28,33 ---- *************** *** 879,895 **** switch (crx_ins->exp.X_op) { case O_constant: crx_ins->arg[number].constant = crx_ins->exp.X_add_number; constant_val = crx_ins->exp.X_add_number; if ((IS_INSN_TYPE (CMPBR_INS) || IS_INSN_TYPE (COP_BRANCH_INS)) && number == 2) { - /* This variable causes a warning (is to be handles by string - type implementation). */ LONGLONG temp64 = 0; ! ! char ptr[20]; char temp_str[30]; unsigned int jump_value = 0; int BR_MASK = 0, BR_SIZE = 0; --- 878,902 ---- switch (crx_ins->exp.X_op) { + case O_big: + case O_absent: + /* Missing or bad expr becomes absolute 0. */ + as_bad (_("missing or invalid displacement expression `%s' taken as 0"), + str); + crx_ins->exp.X_op = O_constant; + crx_ins->exp.X_add_number = 0; + crx_ins->exp.X_add_symbol = (symbolS *) 0; + crx_ins->exp.X_op_symbol = (symbolS *) 0; + break; + case O_constant: crx_ins->arg[number].constant = crx_ins->exp.X_add_number; constant_val = crx_ins->exp.X_add_number; if ((IS_INSN_TYPE (CMPBR_INS) || IS_INSN_TYPE (COP_BRANCH_INS)) && number == 2) { LONGLONG temp64 = 0; ! char ptr; char temp_str[30]; unsigned int jump_value = 0; int BR_MASK = 0, BR_SIZE = 0; *************** *** 900,926 **** temp_str[1] = '\0'; } strncat (temp_str, str, strlen (str)); ! temp64 = strtol (temp_str, (char **) &ptr,0); ! /* This is not accurate : ! Actually overflow is allowed here (see comment below). ! Originally the call was to 'strtoll', which isn't ! identified by MSVC. */ ! if ((temp64 == LONG_MAX) || (temp64 == LONG_MIN)) ! as_bad (_("Overflow in displacement in Instruction `%s'"), ! ins_parse); ! ! /* If br *+x ! It will be returned as '0' padded with 'x' uptill 64 bits ! If br *-x ! It will be returned as sign extended form ! ! Then search for validity of representation ! Check whether upper 38 bits are all zeroes or all ones ! If not report error. */ ! if (!(((temp64 & UPPER31_MASK) == UPPER31_MASK) ! || ((temp64 & UPPER31_MASK) == 0x0))) ! as_bad (_("Overflow in displacement in Instruction `%s'"), ! ins_parse); if (temp64 % 2 != 0) as_bad (_("Odd Offset in displacement in Instruction `%s'"), --- 907,913 ---- temp_str[1] = '\0'; } strncat (temp_str, str, strlen (str)); ! temp64 = strtoll (temp_str, (char **) &ptr,0); if (temp64 % 2 != 0) as_bad (_("Odd Offset in displacement in Instruction `%s'"), *************** *** 955,961 **** || IS_INSN_TYPE (DCR_BRANCH_INS)) { LONGLONG temp64 = 0; ! char ptr[20]; char temp_str[30]; unsigned int jump_value = 0; int BR_MASK = 0, BR_SIZE = 0; --- 942,948 ---- || IS_INSN_TYPE (DCR_BRANCH_INS)) { LONGLONG temp64 = 0; ! char ptr; char temp_str[30]; unsigned int jump_value = 0; int BR_MASK = 0, BR_SIZE = 0; *************** *** 967,993 **** temp_str[1] = '\0'; } strncat (temp_str, str, strlen (str)); ! temp64 = strtol (temp_str, (char **) &ptr,0); ! /* This is not accurate : ! Actually overflow is allowed here (see comment below). ! Originally the call was to 'strtoll', which isn't ! identified by MSVC. */ ! if ((temp64 == LONG_MAX) || (temp64 == LONG_MIN)) ! as_bad (_("Overflow in displacement in Instruction `%s'"), ! ins_parse); ! ! /* If br *+x ! It will be returned as '0' padded with 'x' uptill 64 bits ! If br *-x ! It will be returned as sign extended form ! ! Then search for validity of representation ! Check whether upper 31 bits are all zeroes or all ones ! If not report error. */ ! if (!(((temp64 & UPPER31_MASK) == UPPER31_MASK) ! || ((temp64 & UPPER31_MASK) == 0x0))) ! as_bad (_("Overflow in displacement in Instruction `%s'"), ! ins_parse); if (temp64 % 2 != 0) as_bad (_("Odd Offset in displacement in Instruction `%s'"), --- 954,960 ---- temp_str[1] = '\0'; } strncat (temp_str, str, strlen (str)); ! temp64 = strtoll (temp_str, (char **) &ptr,0); if (temp64 % 2 != 0) as_bad (_("Odd Offset in displacement in Instruction `%s'"), *************** *** 1002,1010 **** BR_MASK = 0xFF; BR_SIZE = 8; } ! else ! if (((jump_value & 0xFFFF0000) == 0xFFFF0000) ! || ((jump_value & 0xFFFF0000) == 0x0)) { BR_MASK = 0xFFFF; BR_SIZE = 16; --- 969,976 ---- BR_MASK = 0xFF; BR_SIZE = 8; } ! else if (((jump_value & 0xFFFF0000) == 0xFFFF0000) ! || ((jump_value & 0xFFFF0000) == 0x0)) { BR_MASK = 0xFFFF; BR_SIZE = 16; *************** *** 1069,1096 **** ~(crx_ins->arg[number].constant) + 1; if (IS_INSN_TYPE (ARITH_INS) || IS_INSN_TYPE (ARITH_BYTE_INS)) { ! char ptr[30]; LONGLONG temp64; ! /* Tomer - Originally the call was to 'strtoull', which isn't ! identified by MSVC. Instead we check for overflow. */ ! temp64 = strtoul (str, (char **) &ptr, 0); if (cnt < 4) crx_ins->arg[number].size = 5; if (IS_INSN_TYPE (ARITH_INS)) { if (crx_ins->arg[number].size > 32 ! /* Tomer - check for overflow. */ ! || (temp64 == ULONG_MAX)) { if (crx_ins->arg[number].size > 32) as_bad (_("In Instruction `%s': Immediate size is \ %lu bits cannot be accomodated"), ins_parse, cnt + 1); ! /* Tomer - check for overflow. */ ! if (temp64 == ULONG_MAX) as_bad (_("Value given more than 32 bits in \ Instruction `%s'"), ins_parse); } --- 1035,1058 ---- ~(crx_ins->arg[number].constant) + 1; if (IS_INSN_TYPE (ARITH_INS) || IS_INSN_TYPE (ARITH_BYTE_INS)) { ! char ptr; LONGLONG temp64; ! temp64 = strtoull (str, (char **) &ptr, 0); if (cnt < 4) crx_ins->arg[number].size = 5; if (IS_INSN_TYPE (ARITH_INS)) { if (crx_ins->arg[number].size > 32 ! || (temp64 > ULONG_MAX)) { if (crx_ins->arg[number].size > 32) as_bad (_("In Instruction `%s': Immediate size is \ %lu bits cannot be accomodated"), ins_parse, cnt + 1); ! if (temp64 > ULONG_MAX) as_bad (_("Value given more than 32 bits in \ Instruction `%s'"), ins_parse); } *************** *** 1191,1196 **** --- 1153,1159 ---- case O_symbol: case O_subtract: crx_ins->arg[number].constant = 0; + crx_ins->rtype = BFD_RELOC_NONE; relocatable = 1; switch (crx_ins->arg[number].type) *************** *** 1536,1542 **** { crx_ins->arg[number].type = arg_cr; crx_ins->arg[number].constant = 0; ! set_cons_rparams (operand, crx_ins, number); get_number_of_bits (crx_ins, number); if ((! strneq (instruction->mnemonic, "load", 4)) && (! strneq (instruction->mnemonic, "stor", 4))) --- 1499,1505 ---- { crx_ins->arg[number].type = arg_cr; crx_ins->arg[number].constant = 0; ! set_cons_rparams (temp_operand, crx_ins, number); get_number_of_bits (crx_ins, number); if ((! strneq (instruction->mnemonic, "load", 4)) && (! strneq (instruction->mnemonic, "stor", 4))) *************** *** 1696,1702 **** const trap_entry *trap; for (trap = crx_traps; trap < (crx_traps + NUMTRAPS); trap++) ! if (streq (trap->name, s)) return trap->entry; as_bad (_("Unknown exception: `%s'"), s); --- 1659,1665 ---- const trap_entry *trap; for (trap = crx_traps; trap < (crx_traps + NUMTRAPS); trap++) ! if (strcasecmp (trap->name, s) == 0) return trap->entry; as_bad (_("Unknown exception: `%s'"), s);