+2017-11-13 Jan Beulich <jbeulich@suse.com>
+
+ * config/tc-i386.c (i386_index_check): Break out ...
+ (i386_addressing_mode): ... this new function.
+ * config/tc-i386-intel.c (i386_intel_operand): Do base/index
+ swapping and the setting of .baseindex earlier. Call
+ i386_addressing_mode.
+ * testsuite/gas/i386/x86-64-inval.s: Add out of range
+ displacement case.
+ * testsuite/gas/i386/x86-64-inval.l: Adjust expectations.
+
2017-11-09 Jim Wilson <jimw@sifive.com>
* testsuite/gas/elf/dwarf2-10.l: Accept optional line number in error.
return 0;
}
+ /* Swap base and index in 16-bit memory operands like
+ [si+bx]. Since i386_index_check is also used in AT&T
+ mode we have to do this here. */
+ if (intel_state.base
+ && intel_state.index
+ && intel_state.base->reg_type.bitfield.reg16
+ && intel_state.index->reg_type.bitfield.reg16
+ && intel_state.base->reg_num >= 6
+ && intel_state.index->reg_num < 6)
+ {
+ i.base_reg = intel_state.index;
+ i.index_reg = intel_state.base;
+ }
+ else
+ {
+ i.base_reg = intel_state.base;
+ i.index_reg = intel_state.index;
+ }
+
+ if (i.base_reg || i.index_reg)
+ i.types[this_operand].bitfield.baseindex = 1;
+
expP = &disp_expressions[i.disp_operands];
memcpy (expP, &exp, sizeof(exp));
resolve_expression (expP);
if (expP->X_op != O_constant
|| expP->X_add_number
- || (!intel_state.base
- && !intel_state.index))
+ || !i.types[this_operand].bitfield.baseindex)
{
i.op[this_operand].disps = expP;
i.disp_operands++;
+ i386_addressing_mode ();
+
if (flag_code == CODE_64BIT)
{
i.types[this_operand].bitfield.disp32 = 1;
return 0;
}
- if (intel_state.base || intel_state.index)
- i.types[this_operand].bitfield.baseindex = 1;
-
if (intel_state.seg)
{
expP = symbol_get_value_expression (intel_state.seg);
}
}
- /* Swap base and index in 16-bit memory operands like
- [si+bx]. Since i386_index_check is also used in AT&T
- mode we have to do that here. */
- if (intel_state.base
- && intel_state.index
- && intel_state.base->reg_type.bitfield.reg16
- && intel_state.index->reg_type.bitfield.reg16
- && intel_state.base->reg_num >= 6
- && intel_state.index->reg_num < 6)
- {
- i.base_reg = intel_state.index;
- i.index_reg = intel_state.base;
- }
- else
- {
- i.base_reg = intel_state.base;
- i.index_reg = intel_state.index;
- }
-
if (!i386_index_check (operand_string))
return 0;
return ret;
}
-/* Make sure the memory operand we've been dealt is valid.
- Return 1 on success, 0 on a failure. */
+/* Return the active addressing mode, taking address override and
+ registers forming the address into consideration. Update the
+ address override prefix if necessary. */
-static int
-i386_index_check (const char *operand_string)
+static enum flag_code
+i386_addressing_mode (void)
{
- const char *kind = "base/index";
enum flag_code addr_mode;
if (i.prefix[ADDR_PREFIX])
#endif
}
+ return addr_mode;
+}
+
+/* Make sure the memory operand we've been dealt is valid.
+ Return 1 on success, 0 on a failure. */
+
+static int
+i386_index_check (const char *operand_string)
+{
+ const char *kind = "base/index";
+ enum flag_code addr_mode = i386_addressing_mode ();
+
if (current_templates->start->opcode_modifier.isstring
&& !current_templates->start->opcode_modifier.immext
&& (current_templates->end[-1].opcode_modifier.isstring