diff options
author | Jan Beulich <jbeulich@suse.com> | 2022-03-23 12:31:04 +0100 |
---|---|---|
committer | Jan Beulich <jbeulich@suse.com> | 2022-03-23 12:31:04 +0100 |
commit | 64d23078e30e54e1bb095962540e4c6138edaf5a (patch) | |
tree | a36e9f7c6c89c5fd750401bea90e6c20fb32f76e /gas | |
parent | 3b55a1d00ad3cf9fe3db7e9347e6f3bbe4d04b9b (diff) | |
download | gdb-64d23078e30e54e1bb095962540e4c6138edaf5a.zip gdb-64d23078e30e54e1bb095962540e4c6138edaf5a.tar.gz gdb-64d23078e30e54e1bb095962540e4c6138edaf5a.tar.bz2 |
x86: improve resolution of register equates
Allow transitive (or recursive) equates to work in addition to direct
ones. The only requirements are that
- the equate being straight of a register, i.e. no expressions involved
(albeit I'm afraid something like "%eax + 0" will be viewed as %eax),
- at the point of use there's no forward ref left which cannot be
resolved, yet.
Diffstat (limited to 'gas')
-rw-r--r-- | gas/config/tc-i386-intel.c | 3 | ||||
-rw-r--r-- | gas/config/tc-i386.c | 8 | ||||
-rw-r--r-- | gas/testsuite/gas/i386/equ.d | 6 | ||||
-rw-r--r-- | gas/testsuite/gas/i386/equ.s | 14 |
4 files changed, 29 insertions, 2 deletions
diff --git a/gas/config/tc-i386-intel.c b/gas/config/tc-i386-intel.c index d0c30dd..83d2240 100644 --- a/gas/config/tc-i386-intel.c +++ b/gas/config/tc-i386-intel.c @@ -536,6 +536,9 @@ static int i386_intel_simplify (expressionS *e) if (e->X_add_symbol && !i386_intel_simplify_symbol (e->X_add_symbol)) return 0; + if (!the_reg && this_operand >= 0 + && e->X_op == O_symbol && !e->X_add_number) + the_reg = i.op[this_operand].regs; if (e->X_op == O_add || e->X_op == O_subtract) { base = intel_state.base; diff --git a/gas/config/tc-i386.c b/gas/config/tc-i386.c index ec82144..93eec1c 100644 --- a/gas/config/tc-i386.c +++ b/gas/config/tc-i386.c @@ -12974,6 +12974,14 @@ parse_register (char *reg_string, char **end_op) input_line_pointer = reg_string; c = get_symbol_name (®_string); symbolP = symbol_find (reg_string); + while (symbolP && S_GET_SEGMENT (symbolP) != reg_section) + { + const expressionS *e = symbol_get_value_expression(symbolP); + + if (e->X_op != O_symbol || e->X_add_number) + break; + symbolP = e->X_add_symbol; + } if (symbolP && S_GET_SEGMENT (symbolP) == reg_section) { const expressionS *e = symbol_get_value_expression (symbolP); diff --git a/gas/testsuite/gas/i386/equ.d b/gas/testsuite/gas/i386/equ.d index 0f270a6..d7c863f 100644 --- a/gas/testsuite/gas/i386/equ.d +++ b/gas/testsuite/gas/i386/equ.d @@ -13,6 +13,8 @@ Disassembly of section .text: [ 0-9a-f]+:[ 0-9a-f]+test[ ]+%ecx,%ecx [ 0-9a-f]+:[ 0-9a-f]+mov[ ]+%fs:\(%ecx,%ecx,4\),%ecx [ 0-9a-f]+:[ 0-9a-f]+fadd[ ]+%st\(1\),%st +[ 0-9a-f]+:[ 0-9a-f]+fmul[ ]+%st\(1\),%st +[ 0-9a-f]+:[ 0-9a-f]+fsub[ ]+%st\(1\),%st [ 0-9a-f]+:[ 0-9a-f]+mov[ ]+\$0xfffffffe,%eax [ 0-9a-f]+:[ 0-9a-f]+mov[ ]+0xfffffffe,%eax [ 0-9a-f]+:[ 0-9a-f]+mov[ ]+\$0x0,%eax[ 0-9a-f]+:[ a-zA-Z0-9_]+xtrn @@ -21,7 +23,11 @@ Disassembly of section .text: [ 0-9a-f]+:[ 0-9a-f]+mov[ ]+%gs:\(%edx,%edx,8\),%edx [ 0-9a-f]+:[ 0-9a-f]+mov[ ]+%gs:\(%edx,%edx,8\),%edx [ 0-9a-f]+:[ 0-9a-f]+fadd[ ]+%st\(1\),%st +[ 0-9a-f]+:[ 0-9a-f]+fmul[ ]+%st\(1\),%st +[ 0-9a-f]+:[ 0-9a-f]+fsub[ ]+%st\(1\),%st [ 0-9a-f]+:[ 0-9a-f]+fadd[ ]+%st\(7\),%st +[ 0-9a-f]+:[ 0-9a-f]+fmul[ ]+%st\(7\),%st +[ 0-9a-f]+:[ 0-9a-f]+fsub[ ]+%st\(7\),%st [ 0-9a-f]+:[ 0-9a-f]+mov[ ]+0x4\(%edx\),%eax [ 0-9a-f]+:[ 0-9a-f]+mov[ ]+0x4\(%edx\),%eax #pass diff --git a/gas/testsuite/gas/i386/equ.s b/gas/testsuite/gas/i386/equ.s index e15148a..c7c4e60 100644 --- a/gas/testsuite/gas/i386/equ.s +++ b/gas/testsuite/gas/i386/equ.s @@ -13,8 +13,12 @@ _start: .equ s, %fs testl r, r movl s:(r,r,4), r + .equ z, y + .equ y, x .equ x, %st(1) fadd x + fmul y + fsub z .if r <> %ecx .err @@ -37,8 +41,14 @@ _start: mov r, s:[r+r*8] mov r, s:[8*r+r] fadd x - .equ x, st(7) - fadd x + fmul y + fsub z + .equ c, b + .equ b, a + .equ a, st(7) + fadd a + fmul b + fsub c .equ r, edx + 4 mov eax, [r] mov eax, [r] |