diff options
author | H.J. Lu <hjl.tools@gmail.com> | 2020-07-14 09:57:52 -0700 |
---|---|---|
committer | H.J. Lu <hjl.tools@gmail.com> | 2020-07-14 09:58:07 -0700 |
commit | 8e58ef803cf752cbde547a5064540f05470ea714 (patch) | |
tree | 9b809d30f1943d72b1a9d8c6c28dff2a3d1953aa | |
parent | f63dcaf808b8e253e197446aeb318e49eddfd260 (diff) | |
download | gdb-8e58ef803cf752cbde547a5064540f05470ea714.zip gdb-8e58ef803cf752cbde547a5064540f05470ea714.tar.gz gdb-8e58ef803cf752cbde547a5064540f05470ea714.tar.bz2 |
x86-64: Zero-extend lower 32 bits displacement to 64 bits
Since the addr32 (0x67) prefix zero-extends the lower 32 bits address to
64 bits, change disassembler to zero-extend the lower 32 bits displacement
to 64 bits when there is no base nor index registers.
gas/
PR gas/26237
* testsuite/gas/i386/addr32.s: Add tests for 32-bit wrapped around
address.
* testsuite/gas/i386/x86-64-addr32.s: Likewise.
* testsuite/gas/i386/addr32.d: Updated.
* testsuite/gas/i386/x86-64-addr32-intel.d: Likewise.
* testsuite/gas/i386/x86-64-addr32.d: Likewise.
* testsuite/gas/i386/ilp32/x86-64-addr32-intel.d: Likewise.
* testsuite/gas/i386/ilp32/x86-64-addr32.d: Likewise.
opcodes/
PR gas/26237
* i386-dis.c (OP_E_memory): Without base nor index registers,
32-bit displacement to 64 bits.
-rw-r--r-- | gas/ChangeLog | 12 | ||||
-rw-r--r-- | gas/testsuite/gas/i386/addr32.d | 6 | ||||
-rw-r--r-- | gas/testsuite/gas/i386/addr32.s | 6 | ||||
-rw-r--r-- | gas/testsuite/gas/i386/ilp32/x86-64-addr32-intel.d | 26 | ||||
-rw-r--r-- | gas/testsuite/gas/i386/ilp32/x86-64-addr32.d | 26 | ||||
-rw-r--r-- | gas/testsuite/gas/i386/x86-64-addr32-intel.d | 10 | ||||
-rw-r--r-- | gas/testsuite/gas/i386/x86-64-addr32.d | 10 | ||||
-rw-r--r-- | gas/testsuite/gas/i386/x86-64-addr32.s | 6 | ||||
-rw-r--r-- | opcodes/ChangeLog | 6 | ||||
-rw-r--r-- | opcodes/i386-dis.c | 9 |
10 files changed, 61 insertions, 56 deletions
diff --git a/gas/ChangeLog b/gas/ChangeLog index 581e169..b841a4c 100644 --- a/gas/ChangeLog +++ b/gas/ChangeLog @@ -1,3 +1,15 @@ +2020-07-14 H.J. Lu <hongjiu.lu@intel.com> + + PR gas/26237 + * testsuite/gas/i386/addr32.s: Add tests for 32-bit wrapped around + address. + * testsuite/gas/i386/x86-64-addr32.s: Likewise. + * testsuite/gas/i386/addr32.d: Updated. + * testsuite/gas/i386/x86-64-addr32-intel.d: Likewise. + * testsuite/gas/i386/x86-64-addr32.d: Likewise. + * testsuite/gas/i386/ilp32/x86-64-addr32-intel.d: Likewise. + * testsuite/gas/i386/ilp32/x86-64-addr32.d: Likewise. + 2020-07-14 Jan Beulich <jbeulich@suse.com> * testsuite/gas/i386/intel.s: Use dr<N> instead of db<N>. diff --git a/gas/testsuite/gas/i386/addr32.d b/gas/testsuite/gas/i386/addr32.d index 8553fc3..a355c30 100644 --- a/gas/testsuite/gas/i386/addr32.d +++ b/gas/testsuite/gas/i386/addr32.d @@ -13,4 +13,10 @@ Disassembly of section .text: [ ]*19:[ ]+67 a3 98 08 60 00[ ]+addr32[ ]+mov[ ]+%ax,0x600898 [ ]*1f:[ ]+67 66 a3 98 08 60 00[ ]+addr32[ ]+mov[ ]+%eax,0x600898 [ ]*26:[ ]+67 66 c7 04 24 01 00 00 00[ ]+movl[ ]+\$0x1,\(%esp\) +[ ]*2f:[ ]+67 66 a1 ef cd ab 89[ ]+addr32[ ]+mov[ ]+0x89abcdef,%eax +[ ]*36:[ ]+67 66 8b 1d ef cd ab 89[ ]+addr32[ ]+mov[ ]+0x89abcdef,%ebx +[ ]*3e:[ ]+67 66 b8 ef cd ab 89[ ]+addr32[ ]+mov[ ]+\$0x89abcdef,%eax +[ ]*45:[ ]+67 66 bb ef cd ab 89[ ]+addr32[ ]+mov[ ]+\$0x89abcdef,%ebx +[ ]*4c:[ ]+67 66 a3 ef cd ab 89[ ]+addr32[ ]+mov[ ]+%eax,0x89abcdef +[ ]*53:[ ]+67 66 89 1d ef cd ab 89[ ]+addr32[ ]+mov[ ]+%ebx,0x89abcdef #pass diff --git a/gas/testsuite/gas/i386/addr32.s b/gas/testsuite/gas/i386/addr32.s index b899ebd..0f45560 100644 --- a/gas/testsuite/gas/i386/addr32.s +++ b/gas/testsuite/gas/i386/addr32.s @@ -7,3 +7,9 @@ addr32 mov %ax,0x600898 addr32 mov %eax,0x600898 addr32 movl $0x1,(%esp) + addr32 mov 0x89abcdef,%eax + addr32 mov 0x89abcdef,%ebx + addr32 mov $0x89abcdef,%eax + addr32 mov $0x89abcdef,%ebx + addr32 mov %eax,0x89abcdef + addr32 mov %ebx,0x89abcdef diff --git a/gas/testsuite/gas/i386/ilp32/x86-64-addr32-intel.d b/gas/testsuite/gas/i386/ilp32/x86-64-addr32-intel.d index 86e8cf8..d6d2e1d 100644 --- a/gas/testsuite/gas/i386/ilp32/x86-64-addr32-intel.d +++ b/gas/testsuite/gas/i386/ilp32/x86-64-addr32-intel.d @@ -2,28 +2,4 @@ #objdump: -drwMintel #source: ../x86-64-addr32.s #name: x86-64 (ILP32) 32-bit addressing (Intel mode) - -.*: +file format .* - -Disassembly of section .text: - -0+ <.text>: -[ ]*[a-f0-9]+: 67 48 8d 80 00 00 00 00[ ]+lea[ ]+rax,\[eax\+0x0\].* -[ ]*[a-f0-9]+: 67 49 8d 80 00 00 00 00[ ]+lea[ ]+rax,\[r8d\+0x0\].* -[ ]*[a-f0-9]+: 67 48 8d 05 00 00 00 00[ ]+lea[ ]+rax,\[eip\+0x0\].* -[ ]*[a-f0-9]+: 67 48 8d 04 25 00 00 00 00 lea[ ]+rax,\[eiz\*1\+0x0\].* -[ ]*[a-f0-9]+: 67 a0 98 08 60 00 addr32 mov al,ds:0x600898 -[ ]*[a-f0-9]+: 67 66 a1 98 08 60 00 addr32 mov ax,ds:0x600898 -[ ]*[a-f0-9]+: 67 a1 98 08 60 00 addr32 mov eax,ds:0x600898 -[ ]*[a-f0-9]+: 67 48 a1 98 08 60 00 addr32 mov rax,ds:0x600898 -[ ]*[a-f0-9]+: 67 48 a1 98 08 80 00 addr32 mov rax,ds:0x800898 -[ ]*[a-f0-9]+: 67 48 8b 1c 25 98 08 80 00 mov[ ]+rbx,QWORD PTR \[eiz\*1\+0x800898\] -[ ]*[a-f0-9]+: 67 a2 98 08 60 00 addr32 mov ds:0x600898,al -[ ]*[a-f0-9]+: 67 66 a3 98 08 60 00 addr32 mov ds:0x600898,ax -[ ]*[a-f0-9]+: 67 a3 98 08 60 00 addr32 mov ds:0x600898,eax -[ ]*[a-f0-9]+: 67 48 a3 98 08 60 00 addr32 mov ds:0x600898,rax -[ ]*[a-f0-9]+: 67 48 a3 98 08 80 00 addr32 mov ds:0x800898,rax -[ ]*[a-f0-9]+: 67 48 89 1c 25 98 08 80 00 mov[ ]+QWORD PTR \[eiz\*1\+0x800898\],rbx -[ ]*[a-f0-9]+: 67 89 04 25 11 22 33 ff mov[ ]+DWORD PTR \[eiz\*1-0xccddef\],eax -[ ]*[a-f0-9]+: 67 89 04 65 11 22 33 ff mov[ ]+DWORD PTR \[eiz\*2-0xccddef\],eax -#pass +#dump: ../x86-64-addr32-intel.d diff --git a/gas/testsuite/gas/i386/ilp32/x86-64-addr32.d b/gas/testsuite/gas/i386/ilp32/x86-64-addr32.d index b866473..9c4d372 100644 --- a/gas/testsuite/gas/i386/ilp32/x86-64-addr32.d +++ b/gas/testsuite/gas/i386/ilp32/x86-64-addr32.d @@ -2,28 +2,4 @@ #as: -J #objdump: -drw #name: x86-64 (ILP32) 32-bit addressing - -.*: +file format .* - -Disassembly of section .text: - -0+ <.text>: -[ ]*[a-f0-9]+: 67 48 8d 80 00 00 00 00[ ]+lea[ ]+0x0\(%eax\),%rax.* -[ ]*[a-f0-9]+: 67 49 8d 80 00 00 00 00[ ]+lea[ ]+0x0\(%r8d\),%rax.* -[ ]*[a-f0-9]+: 67 48 8d 05 00 00 00 00[ ]+lea[ ]+0x0\(%eip\),%rax.* -[ ]*[a-f0-9]+: 67 48 8d 04 25 00 00 00 00[ ]+lea[ ]+0x0\(,%eiz,1\),%rax.* -[ ]*[a-f0-9]+: 67 a0 98 08 60 00 addr32 mov 0x600898,%al -[ ]*[a-f0-9]+: 67 66 a1 98 08 60 00 addr32 mov 0x600898,%ax -[ ]*[a-f0-9]+: 67 a1 98 08 60 00 addr32 mov 0x600898,%eax -[ ]*[a-f0-9]+: 67 48 a1 98 08 60 00 addr32 mov 0x600898,%rax -[ ]*[a-f0-9]+: 67 48 a1 98 08 80 00 addr32 mov 0x800898,%rax -[ ]*[a-f0-9]+: 67 48 8b 1c 25 98 08 80 00 mov[ ]+0x800898\(,%eiz,1\),%rbx -[ ]*[a-f0-9]+: 67 a2 98 08 60 00 addr32 mov %al,0x600898 -[ ]*[a-f0-9]+: 67 66 a3 98 08 60 00 addr32 mov %ax,0x600898 -[ ]*[a-f0-9]+: 67 a3 98 08 60 00 addr32 mov %eax,0x600898 -[ ]*[a-f0-9]+: 67 48 a3 98 08 60 00 addr32 mov %rax,0x600898 -[ ]*[a-f0-9]+: 67 48 a3 98 08 80 00 addr32 mov %rax,0x800898 -[ ]*[a-f0-9]+: 67 48 89 1c 25 98 08 80 00 mov[ ]+%rbx,0x800898\(,%eiz,1\) -[ ]*[a-f0-9]+: 67 89 04 25 11 22 33 ff mov[ ]+%eax,-0xccddef\(,%eiz,1\) -[ ]*[a-f0-9]+: 67 89 04 65 11 22 33 ff mov[ ]+%eax,-0xccddef\(,%eiz,2\) -#pass +#dump: ../x86-64-addr32.d diff --git a/gas/testsuite/gas/i386/x86-64-addr32-intel.d b/gas/testsuite/gas/i386/x86-64-addr32-intel.d index ec0966c..0988457 100644 --- a/gas/testsuite/gas/i386/x86-64-addr32-intel.d +++ b/gas/testsuite/gas/i386/x86-64-addr32-intel.d @@ -18,12 +18,18 @@ Disassembly of section .text: [ ]*[a-f0-9]+: 67 48 a1 98 08 60 00 addr32 mov rax,ds:0x600898 [ ]*[a-f0-9]+: 67 48 a1 98 08 80 00 addr32 mov rax,ds:0x800898 [ ]*[a-f0-9]+: 67 48 8b 1c 25 98 08 80 00 mov[ ]+rbx,QWORD PTR \[eiz\*1\+0x800898\] +[ ]*[a-f0-9]+: 67 48 a1 ef cd ab 89 addr32 mov rax,ds:0x89abcdef +[ ]*[a-f0-9]+: 67 48 8b 1c 25 ef cd ab 89 mov[ ]+rbx,QWORD PTR \[eiz\*1\+0x89abcdef\] +[ ]*[a-f0-9]+: 67 48 b8 ef cd ab 89 00 00 00 00 addr32 movabs rax,0x89abcdef +[ ]*[a-f0-9]+: 67 48 bb ef cd ab 89 00 00 00 00 addr32 movabs rbx,0x89abcdef [ ]*[a-f0-9]+: 67 a2 98 08 60 00 addr32 mov ds:0x600898,al [ ]*[a-f0-9]+: 67 66 a3 98 08 60 00 addr32 mov ds:0x600898,ax [ ]*[a-f0-9]+: 67 a3 98 08 60 00 addr32 mov ds:0x600898,eax [ ]*[a-f0-9]+: 67 48 a3 98 08 60 00 addr32 mov ds:0x600898,rax [ ]*[a-f0-9]+: 67 48 a3 98 08 80 00 addr32 mov ds:0x800898,rax [ ]*[a-f0-9]+: 67 48 89 1c 25 98 08 80 00 mov[ ]+QWORD PTR \[eiz\*1\+0x800898\],rbx -[ ]*[a-f0-9]+: 67 89 04 25 11 22 33 ff mov[ ]+DWORD PTR \[eiz\*1-0xccddef\],eax -[ ]*[a-f0-9]+: 67 89 04 65 11 22 33 ff mov[ ]+DWORD PTR \[eiz\*2-0xccddef\],eax +[ ]*[a-f0-9]+: 67 48 a3 ef cd ab 89 addr32 mov ds:0x89abcdef,rax +[ ]*[a-f0-9]+: 67 48 89 1c 25 ef cd ab 89 mov[ ]+QWORD PTR \[eiz\*1\+0x89abcdef\],rbx +[ ]*[a-f0-9]+: 67 89 04 25 11 22 33 ff mov[ ]+DWORD PTR \[eiz\*1\+0xff332211\],eax +[ ]*[a-f0-9]+: 67 89 04 65 11 22 33 ff mov[ ]+DWORD PTR \[eiz\*2\+0xff332211\],eax #pass diff --git a/gas/testsuite/gas/i386/x86-64-addr32.d b/gas/testsuite/gas/i386/x86-64-addr32.d index 6b73de9..d9481a7 100644 --- a/gas/testsuite/gas/i386/x86-64-addr32.d +++ b/gas/testsuite/gas/i386/x86-64-addr32.d @@ -17,12 +17,18 @@ Disassembly of section .text: [ ]*[a-f0-9]+: 67 48 a1 98 08 60 00 addr32 mov 0x600898,%rax [ ]*[a-f0-9]+: 67 48 a1 98 08 80 00 addr32 mov 0x800898,%rax [ ]*[a-f0-9]+: 67 48 8b 1c 25 98 08 80 00 mov[ ]+0x800898\(,%eiz,1\),%rbx +[ ]*[a-f0-9]+: 67 48 a1 ef cd ab 89 addr32 mov 0x89abcdef,%rax +[ ]*[a-f0-9]+: 67 48 8b 1c 25 ef cd ab 89 mov[ ]+0x89abcdef\(,%eiz,1\),%rbx +[ ]*[a-f0-9]+: 67 48 b8 ef cd ab 89 00 00 00 00 addr32 movabs \$0x89abcdef,%rax +[ ]*[a-f0-9]+: 67 48 bb ef cd ab 89 00 00 00 00 addr32 movabs \$0x89abcdef,%rbx [ ]*[a-f0-9]+: 67 a2 98 08 60 00 addr32 mov %al,0x600898 [ ]*[a-f0-9]+: 67 66 a3 98 08 60 00 addr32 mov %ax,0x600898 [ ]*[a-f0-9]+: 67 a3 98 08 60 00 addr32 mov %eax,0x600898 [ ]*[a-f0-9]+: 67 48 a3 98 08 60 00 addr32 mov %rax,0x600898 [ ]*[a-f0-9]+: 67 48 a3 98 08 80 00 addr32 mov %rax,0x800898 [ ]*[a-f0-9]+: 67 48 89 1c 25 98 08 80 00 mov[ ]+%rbx,0x800898\(,%eiz,1\) -[ ]*[a-f0-9]+: 67 89 04 25 11 22 33 ff mov[ ]+%eax,-0xccddef\(,%eiz,1\) -[ ]*[a-f0-9]+: 67 89 04 65 11 22 33 ff mov[ ]+%eax,-0xccddef\(,%eiz,2\) +[ ]*[a-f0-9]+: 67 48 a3 ef cd ab 89 addr32 mov %rax,0x89abcdef +[ ]*[a-f0-9]+: 67 48 89 1c 25 ef cd ab 89 mov[ ]+%rbx,0x89abcdef\(,%eiz,1\) +[ ]*[a-f0-9]+: 67 89 04 25 11 22 33 ff mov[ ]+%eax,0xff332211\(,%eiz,1\) +[ ]*[a-f0-9]+: 67 89 04 65 11 22 33 ff mov[ ]+%eax,0xff332211\(,%eiz,2\) #pass diff --git a/gas/testsuite/gas/i386/x86-64-addr32.s b/gas/testsuite/gas/i386/x86-64-addr32.s index 5acdce9..9d3aa6a 100644 --- a/gas/testsuite/gas/i386/x86-64-addr32.s +++ b/gas/testsuite/gas/i386/x86-64-addr32.s @@ -10,11 +10,17 @@ addr32 mov 0x600898,%rax addr32 mov 0x800898,%rax addr32 mov 0x800898,%rbx + addr32 mov 0x89abcdef,%rax + addr32 mov 0x89abcdef,%rbx + addr32 mov $0x89abcdef,%rax + addr32 mov $0x89abcdef,%rbx addr32 mov %al,0x600898 addr32 mov %ax,0x600898 addr32 mov %eax,0x600898 addr32 mov %rax,0x600898 addr32 mov %rax,0x800898 addr32 mov %rbx,0x800898 + addr32 mov %rax,0x89abcdef + addr32 mov %rbx,0x89abcdef mov %eax, -0xccddef(,%eiz,) mov %eax, -0xccddef(,%eiz,2) diff --git a/opcodes/ChangeLog b/opcodes/ChangeLog index f571884..9a972d4 100644 --- a/opcodes/ChangeLog +++ b/opcodes/ChangeLog @@ -1,3 +1,9 @@ +2020-07-14 H.J. Lu <hongjiu.lu@intel.com> + + PR gas/26237 + * i386-dis.c (OP_E_memory): Without base nor index registers, + 32-bit displacement to 64 bits. + 2020-07-14 Claudiu Zissulescu <claziss@gmail.com> * arc-dis.c (print_insn_arc): Detect and emit a warning when a diff --git a/opcodes/i386-dis.c b/opcodes/i386-dis.c index a6cc013..511e632 100644 --- a/opcodes/i386-dis.c +++ b/opcodes/i386-dis.c @@ -11877,8 +11877,13 @@ OP_E_memory (int bytemode, int sizeflag) { if (address_mode == mode_64bit) { - /* Display eiz instead of addr32. */ - needindex = addr32flag; + if (addr32flag) + { + /* Without base nor index registers, zero-extend the + lower 32-bit displacement to 64 bits. */ + disp = (unsigned int) disp; + needindex = 1; + } needaddr32 = 1; } else |