+2021-06-07 Jan Beulich <jbeulich@suse.com>
+
+ * config/tc-i386.c (parse_operands): Reduce scope of
+ paren_not_balanced, to match the new in_quotes. Skip over quoted
+ regions of operands.
+ (i386_att_operand): Remove (mis-named) parens_balanced. Respect
+ double quote.
+ * testsuite/gas/i386/unary.s: Add more cases.
+ * testsuite/gas/i386/unary.d: Adjust expectations.
+
2021-06-07 Jan Beulich <jbeulich@suse.com>
* config/tc-i386.c (digit_chars, is_digit_char): Delete.
/* 1 if operand is pending after ','. */
unsigned int expecting_operand = 0;
- /* Non-zero if operand parens not balanced. */
- unsigned int paren_not_balanced;
-
while (*l != END_OF_INSN)
{
+ /* Non-zero if operand parens not balanced. */
+ unsigned int paren_not_balanced = 0;
+ /* True if inside double quotes. */
+ bool in_quotes = false;
+
/* Skip optional white space before operand. */
if (is_space_char (*l))
++l;
return NULL;
}
token_start = l; /* After white space. */
- paren_not_balanced = 0;
- while (paren_not_balanced || *l != ',')
+ while (in_quotes || paren_not_balanced || *l != ',')
{
if (*l == END_OF_INSN)
{
+ if (in_quotes)
+ {
+ as_bad (_("unbalanced double quotes in operand %d."),
+ i.operands + 1);
+ return NULL;
+ }
if (paren_not_balanced)
{
know (!intel_syntax);
else
break; /* we are done */
}
- else if (!is_operand_char (*l) && !is_space_char (*l) && *l != '"')
+ else if (*l == '\\' && l[1] == '"')
+ ++l;
+ else if (*l == '"')
+ in_quotes = !in_quotes;
+ else if (!in_quotes && !is_operand_char (*l) && !is_space_char (*l))
{
as_bad (_("invalid character %s in operand %d"),
output_invalid (*l),
i.operands + 1);
return NULL;
}
- if (!intel_syntax)
+ if (!intel_syntax && !in_quotes)
{
if (*l == '(')
++paren_not_balanced;
if (*base_string == ')')
{
char *temp_string;
- unsigned int parens_balanced = 1;
+
/* We've already checked that the number of left & right ()'s are
equal, so this loop will not be infinite. */
do
{
base_string--;
- if (*base_string == ')')
- parens_balanced++;
- if (*base_string == '(')
- parens_balanced--;
}
- while (parens_balanced);
+ while (*base_string != '(' && *base_string != ')'
+ && *base_string != '"');
temp_string = base_string;
/* Skip past '(' and whitespace. */
- ++base_string;
+ if (*base_string == '(')
+ ++base_string;
if (is_space_char (*base_string))
++base_string;
[ ]*[a-f0-9]+:[ ]*8b 80 00 00 00 00[ ]+mov 0x0\(%eax\),%eax [a-f0-9]+: (R_386_|dir)32 x\(y\)
[ ]*[a-f0-9]+:[ ]*26 a1 00 00 00 00[ ]+mov %es:0x0,%eax [a-f0-9]+: (R_386_|dir)32 x\(y\)
[ ]*[a-f0-9]+:[ ]*26 8b 80 00 00 00 00[ ]+mov %es:0x0\(%eax\),%eax [a-f0-9]+: (R_386_|dir)32 x\(y\)
+[ ]*[a-f0-9]+:[ ]*a1 00 00 00 00[ ]+mov 0x0,%eax [a-f0-9]+: (R_386_|dir)32 x\(y
+[ ]*[a-f0-9]+:[ ]*a1 00 00 00 00[ ]+mov 0x0,%eax [a-f0-9]+: (R_386_|dir)32 x\)y
+[ ]*[a-f0-9]+:[ ]*a1 00 00 00 00[ ]+mov 0x0,%eax [a-f0-9]+: (R_386_|dir)32 x\?y
[ ]*[a-f0-9]+:[ ]*ff 15 00 00 00 00[ ]+call \*0x0 [a-f0-9]+: (R_386_|dir)32 x\(y\)
[ ]*[a-f0-9]+:[ ]*26 ff 15 00 00 00 00[ ]+call \*%es:0x0 [a-f0-9]+: (R_386_|dir)32 x\(y\)
[ ]*[a-f0-9]+:[ ]*26 ff 15 00 00 00 00[ ]+call \*%es:0x0 [a-f0-9]+: (R_386_|dir)32 x\(y\)