diff options
author | Jan Beulich <jbeulich@suse.com> | 2021-06-07 12:03:32 +0200 |
---|---|---|
committer | Jan Beulich <jbeulich@suse.com> | 2021-06-07 12:03:32 +0200 |
commit | 9d299bea8cca3bfd91a3c7a47510c52a9e829858 (patch) | |
tree | 69ea736234165bda8e0922c83669213a7dabbc36 /gas | |
parent | c8d541e2e73493228f332f4bdc9ecc8164d3744f (diff) | |
download | gdb-9d299bea8cca3bfd91a3c7a47510c52a9e829858.zip gdb-9d299bea8cca3bfd91a3c7a47510c52a9e829858.tar.gz gdb-9d299bea8cca3bfd91a3c7a47510c52a9e829858.tar.bz2 |
x86: make symbol quotation check consistent in i386_att_operand()
When d02603dc201f ("Allow symbol and label names to be enclosed in
double quotes") added the check for a leading double quote to
i386_att_operand(), it missed a second similar check after having found
a segment override. To avoid the two checks going out of sync again,
introduce an inline helper.
Diffstat (limited to 'gas')
-rw-r--r-- | gas/ChangeLog | 7 | ||||
-rw-r--r-- | gas/config/tc-i386.c | 17 | ||||
-rw-r--r-- | gas/testsuite/gas/i386/i386.exp | 1 | ||||
-rw-r--r-- | gas/testsuite/gas/i386/quoted.d | 16 | ||||
-rw-r--r-- | gas/testsuite/gas/i386/quoted.s | 10 |
5 files changed, 44 insertions, 7 deletions
diff --git a/gas/ChangeLog b/gas/ChangeLog index 008027b..b5686ee 100644 --- a/gas/ChangeLog +++ b/gas/ChangeLog @@ -1,5 +1,12 @@ 2021-06-07 Jan Beulich <jbeulich@suse.com> + * config/tc-i386.c (starts_memory_operand): New. + (i386_att_operand): Use it. + * testsuite/gas/i386/quoted.s, testsuite/gas/i386/quoted.d: New. + * testsuite/gas/i386/i386.exp: Run new test. + +2021-06-07 Jan Beulich <jbeulich@suse.com> + * config/tc-i386.c (i386_att_operand): Flip checking for '*' and start-of-expression. Don't permit '*' when one was already seen. diff --git a/gas/config/tc-i386.c b/gas/config/tc-i386.c index 0fe439e..063383c 100644 --- a/gas/config/tc-i386.c +++ b/gas/config/tc-i386.c @@ -11368,6 +11368,14 @@ maybe_adjust_templates (void) return 1; } +static INLINE bool starts_memory_operand (char c) +{ + return is_digit_char (c) + || is_identifier_char (c) + || c == '"' + || c == '('; +} + /* Parse OPERAND_STRING into the i386_insn structure I. Returns zero on error. */ @@ -11422,9 +11430,7 @@ i386_att_operand (char *operand_string) i.jumpabsolute = true; } - if (!is_digit_char (*op_string) - && !is_identifier_char (*op_string) - && *op_string != '(') + if (!starts_memory_operand (*op_string)) { as_bad (_("bad memory operand `%s'"), op_string); return 0; @@ -11474,10 +11480,7 @@ i386_att_operand (char *operand_string) /* If it is a RC or SAE immediate, do nothing. */ ; } - else if (is_digit_char (*op_string) - || is_identifier_char (*op_string) - || *op_string == '"' - || *op_string == '(') + else if (starts_memory_operand (*op_string)) { /* This is a memory reference of some sort. */ char *base_string; diff --git a/gas/testsuite/gas/i386/i386.exp b/gas/testsuite/gas/i386/i386.exp index efcccaf..001c5f9 100644 --- a/gas/testsuite/gas/i386/i386.exp +++ b/gas/testsuite/gas/i386/i386.exp @@ -96,6 +96,7 @@ if [gas_32_check] then { run_dump_test "equ" run_list_test "equ-bad" run_dump_test "divide" + run_dump_test "quoted" run_dump_test "padlock" run_dump_test "crx" run_list_test "cr-err" "" diff --git a/gas/testsuite/gas/i386/quoted.d b/gas/testsuite/gas/i386/quoted.d new file mode 100644 index 0000000..704329d --- /dev/null +++ b/gas/testsuite/gas/i386/quoted.d @@ -0,0 +1,16 @@ +#objdump: -drw +#name: i386 quoted symbols + +.*: +file format .* + +Disassembly of section .text: + +0+ <quoted>: +[ ]*[a-f0-9]+:[ ]*a1 00 00 00 00[ ]+mov 0x0,%eax [a-f0-9]+: (R_386_|dir)32 x\(y\) +[ ]*[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]+:[ ]*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\) +#pass diff --git a/gas/testsuite/gas/i386/quoted.s b/gas/testsuite/gas/i386/quoted.s new file mode 100644 index 0000000..3bbeedf --- /dev/null +++ b/gas/testsuite/gas/i386/quoted.s @@ -0,0 +1,10 @@ + .text +quoted: + mov "x(y)", %eax + mov "x(y)"(%eax), %eax + mov %es:"x(y)", %eax + mov %es:"x(y)"(%eax), %eax + + call *"x(y)" + call *%es:"x(y)" + call %es:*"x(y)" |