aboutsummaryrefslogtreecommitdiff
path: root/gas/config
diff options
context:
space:
mode:
authorAndreas Krebbel <krebbel@linux.ibm.com>2018-11-09 11:00:47 +0100
committerAndreas Krebbel <krebbel@linux.ibm.com>2018-11-09 11:01:01 +0100
commit13daa8e4889a971309f7d46a8d49129cb26088a5 (patch)
treef91d0ec075f4c52dc043950d19ea9d3bf55c12cb /gas/config
parent0e2779e98dc1251b469db690458d14262c72e303 (diff)
downloadgdb-13daa8e4889a971309f7d46a8d49129cb26088a5.zip
gdb-13daa8e4889a971309f7d46a8d49129cb26088a5.tar.gz
gdb-13daa8e4889a971309f7d46a8d49129cb26088a5.tar.bz2
S/390: Fix optional operand handling after memory addresses
Instructions having an optional argument following a memory address operand were not handled correctly if the optional argument was not specified. gas/ChangeLog: 2018-11-09 Andreas Krebbel <krebbel@linux.ibm.com> * config/tc-s390.c (skip_optargs_p): New function. (md_gather_operands): Use skip_optargs_p. * testsuite/gas/s390/s390.exp: Run the new test. * testsuite/gas/s390/zarch-optargs.d: New test. * testsuite/gas/s390/zarch-optargs.s: New test.
Diffstat (limited to 'gas/config')
-rw-r--r--gas/config/tc-s390.c47
1 files changed, 23 insertions, 24 deletions
diff --git a/gas/config/tc-s390.c b/gas/config/tc-s390.c
index 6b58c4c..c343c5f 100644
--- a/gas/config/tc-s390.c
+++ b/gas/config/tc-s390.c
@@ -1228,6 +1228,24 @@ s390_elf_cons (int nbytes /* 1=.byte, 2=.word, 4=.long */)
demand_empty_rest_of_line ();
}
+/* Return true if all remaining operands in the opcode with
+ OPCODE_FLAGS can be skipped. */
+static bfd_boolean
+skip_optargs_p (unsigned int opcode_flags, const unsigned char *opindex_ptr)
+{
+ if ((opcode_flags & (S390_INSTR_FLAG_OPTPARM | S390_INSTR_FLAG_OPTPARM2))
+ && opindex_ptr[0] != '\0'
+ && opindex_ptr[1] == '\0')
+ return TRUE;
+
+ if ((opcode_flags & S390_INSTR_FLAG_OPTPARM2)
+ && opindex_ptr[0] != '\0'
+ && opindex_ptr[1] != '\0'
+ && opindex_ptr[2] == '\0')
+ return TRUE;
+ return FALSE;
+}
+
/* We need to keep a list of fixups. We can't simply generate them as
we go, because that would require us to first create the frag, and
that would screw up references to ``.''. */
@@ -1467,6 +1485,9 @@ md_gather_operands (char *str,
while (!(operand->flags & S390_OPERAND_BASE))
operand = s390_operands + *(++opindex_ptr);
+ if (*str == '\0' && skip_optargs_p (opcode->flags, &opindex_ptr[1]))
+ continue;
+
/* If there is a next operand it must be separated by a comma. */
if (opindex_ptr[1] != '\0')
{
@@ -1510,18 +1531,7 @@ md_gather_operands (char *str,
as_bad (_("syntax error; missing ')' after base register"));
skip_optional = 0;
- if ((opcode->flags & (S390_INSTR_FLAG_OPTPARM
- | S390_INSTR_FLAG_OPTPARM2))
- && opindex_ptr[1] != '\0'
- && opindex_ptr[2] == '\0'
- && *str == '\0')
- continue;
-
- if ((opcode->flags & S390_INSTR_FLAG_OPTPARM2)
- && opindex_ptr[1] != '\0'
- && opindex_ptr[2] != '\0'
- && opindex_ptr[3] == '\0'
- && *str == '\0')
+ if (*str == '\0' && skip_optargs_p (opcode->flags, &opindex_ptr[1]))
continue;
/* If there is a next operand it must be separated by a comma. */
@@ -1553,18 +1563,7 @@ md_gather_operands (char *str,
str++;
}
- if ((opcode->flags & (S390_INSTR_FLAG_OPTPARM
- | S390_INSTR_FLAG_OPTPARM2))
- && opindex_ptr[1] != '\0'
- && opindex_ptr[2] == '\0'
- && *str == '\0')
- continue;
-
- if ((opcode->flags & S390_INSTR_FLAG_OPTPARM2)
- && opindex_ptr[1] != '\0'
- && opindex_ptr[2] != '\0'
- && opindex_ptr[3] == '\0'
- && *str == '\0')
+ if (*str == '\0' && skip_optargs_p (opcode->flags, &opindex_ptr[1]))
continue;
/* If there is a next operand it must be separated by a comma. */