aboutsummaryrefslogtreecommitdiff
path: root/gas/config
diff options
context:
space:
mode:
authorH.J. Lu <hjl.tools@gmail.com>2022-11-04 13:47:59 -0700
committerH.J. Lu <hjl.tools@gmail.com>2022-11-10 10:11:25 -0800
commit9373f27599a82ed94d9366ad59f0235085a931af (patch)
tree9e2a3bce8a0497bb42f7c27cf0af8d7a851f6426 /gas/config
parent0be837be9fb4fc1f882a52a6fb7ad27e2f3023ae (diff)
downloadgdb-9373f27599a82ed94d9366ad59f0235085a931af.zip
gdb-9373f27599a82ed94d9366ad59f0235085a931af.tar.gz
gdb-9373f27599a82ed94d9366ad59f0235085a931af.tar.bz2
i386: Check invalid (%dx) usage
(%dx) isn't a valid memory address in any modes. It is used as a special memory operand for input/output port address in AT&T syntax and should only be used with input/output instructions. Update i386_att_operand to set i.input_output_operand to true for (%dx) and issue an error if (%dx) is used with non-input/output instructions. PR gas/29751 * config/tc-i386.c (_i386_insn): Add input_output_operand. (md_assemble): Issue an error if input/output memory operand is used with non-input/output instructions. (i386_att_operand): Set i.input_output_operand to true for (%dx). * testsuite/gas/i386/inval.l: Updated. * testsuite/gas/i386/x86-64-inval.l: Likewise. * testsuite/gas/i386/inval.s: Add tests for invalid (%dx) usage. * testsuite/gas/i386/x86-64-inval.s: Likewise.
Diffstat (limited to 'gas/config')
-rw-r--r--gas/config/tc-i386.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/gas/config/tc-i386.c b/gas/config/tc-i386.c
index da005c5..142b937 100644
--- a/gas/config/tc-i386.c
+++ b/gas/config/tc-i386.c
@@ -311,6 +311,10 @@ struct _i386_insn
/* The operand to a branch insn indicates an absolute branch. */
bool jumpabsolute;
+ /* There is a memory operand of (%dx) which should be only used
+ with input/output instructions. */
+ bool input_output_operand;
+
/* Extended states. */
enum
{
@@ -5045,6 +5049,17 @@ md_assemble (char *line)
i.disp_operands = 0;
}
+ /* The memory operand of (%dx) should be only used with input/output
+ instructions (base opcodes: 0x6c, 0x6e, 0xec, 0xee). */
+ if (i.input_output_operand
+ && ((i.tm.base_opcode | 0x82) != 0xee
+ || i.tm.opcode_modifier.opcodespace != SPACE_BASE))
+ {
+ as_bad (_("input/output port address isn't allowed with `%s'"),
+ i.tm.name);
+ return;
+ }
+
if (optimize && !i.no_optimize && i.tm.opcode_modifier.optimize)
optimize_encoding ();
@@ -11752,6 +11767,7 @@ i386_att_operand (char *operand_string)
&& !operand_type_check (i.types[this_operand], disp))
{
i.types[this_operand] = i.base_reg->reg_type;
+ i.input_output_operand = true;
return 1;
}