diff options
author | Jan Beulich <jbeulich@suse.com> | 2022-10-05 09:16:24 +0200 |
---|---|---|
committer | Jan Beulich <jbeulich@suse.com> | 2022-10-05 09:16:24 +0200 |
commit | e87fb6a6d0cdfc0e9c471b7825c20c238c2cf506 (patch) | |
tree | 4e96772ab18b992195cbb0a848ca006adbfb9e11 /gas/config | |
parent | bb5cb85b465a9327fb0cf48ebe4b7ab661ed0971 (diff) | |
download | gdb-e87fb6a6d0cdfc0e9c471b7825c20c238c2cf506.zip gdb-e87fb6a6d0cdfc0e9c471b7825c20c238c2cf506.tar.gz gdb-e87fb6a6d0cdfc0e9c471b7825c20c238c2cf506.tar.bz2 |
x86/gas: support quoted address scale factor in AT&T syntax
An earlier attempt (e68c3d59acd0 ["x86: better respect quotes in
parse_operands()"]) needed undoing (cc0f96357e0b ["x86: permit
parenthesized expressions again as addressing scale factor"]) as far its
effect here went. As indicated back then, the issue is the backwards
scanning of the operand string to find the matching opening parenthesis.
Switch to forward scanning, finding the last outermost unquoted opening
parenthesis (which is the one matching the trailing closing one).
Diffstat (limited to 'gas/config')
-rw-r--r-- | gas/config/tc-i386.c | 31 |
1 files changed, 19 insertions, 12 deletions
diff --git a/gas/config/tc-i386.c b/gas/config/tc-i386.c index 3435cb5..6d04e83 100644 --- a/gas/config/tc-i386.c +++ b/gas/config/tc-i386.c @@ -11589,25 +11589,32 @@ i386_att_operand (char *operand_string) if (*base_string == ')') { char *temp_string; - unsigned int parens_not_balanced = 1; + unsigned int parens_not_balanced = 0; + bool in_quotes = false; /* 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_not_balanced++; - if (*base_string == '(') - parens_not_balanced--; + equal, and that there's a matching set of double quotes. */ + end_op = base_string; + for (temp_string = op_string; temp_string < end_op; temp_string++) + { + if (*temp_string == '\\' && temp_string[1] == '"') + ++temp_string; + else if (*temp_string == '"') + in_quotes = !in_quotes; + else if (!in_quotes) + { + if (*temp_string == '(' && !parens_not_balanced++) + base_string = temp_string; + if (*temp_string == ')') + --parens_not_balanced; + } } - while (parens_not_balanced && *base_string != '"'); temp_string = base_string; /* Skip past '(' and whitespace. */ - if (*base_string == '(') - ++base_string; + gas_assert (*base_string == '('); + ++base_string; if (is_space_char (*base_string)) ++base_string; |