]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
x86-64: Zero-extend lower 32 bits displacement to 64 bits
authorH.J. Lu <hjl.tools@gmail.com>
Tue, 14 Jul 2020 16:57:52 +0000 (09:57 -0700)
committerH.J. Lu <hjl.tools@gmail.com>
Wed, 15 Jul 2020 14:18:45 +0000 (07:18 -0700)
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.

(cherry picked from commit 8e58ef803cf752cbde547a5064540f05470ea714)

gas/ChangeLog
gas/testsuite/gas/i386/addr32.d
gas/testsuite/gas/i386/addr32.s
gas/testsuite/gas/i386/ilp32/x86-64-addr32-intel.d
gas/testsuite/gas/i386/ilp32/x86-64-addr32.d
gas/testsuite/gas/i386/x86-64-addr32-intel.d
gas/testsuite/gas/i386/x86-64-addr32.d
gas/testsuite/gas/i386/x86-64-addr32.s
opcodes/ChangeLog
opcodes/i386-dis.c

index 0b1ac57e6105a436679afc092825f3280f5fd09b..69971c0b8f60d02820ba44d5b121d643297094c6 100644 (file)
@@ -1,3 +1,15 @@
+2020-07-15  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-15  H.J. Lu  <hongjiu.lu@intel.com>
 
        PR gas/26237
index 8553fc3e0cf8890b805ecf3b2c9a924a9caded24..a355c30f3f1eac5ea6ab7864b12584c7754f3b9d 100644 (file)
@@ -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
index b899ebd5a38fb4fe5cc4b71b0169926763044364..0f455606024f6c8c00b6cc2f4f68908ab6d8f644 100644 (file)
@@ -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
index 86e8cf8039a85924ac5097328940b4dfafdc800d..d6d2e1d8b45e5695d6b1b40b4448d2b235e90675 100644 (file)
@@ -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
index b866473acc622abbdf6fc19bfa40abf0e9890d9a..9c4d3729ceb60500b26e7e842eafef4f6823a5cb 100644 (file)
@@ -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
index ec0966caf4eb01b006901b33fb060c4af4e45b44..0988457b34c5e4e5691ee59105f17ade3588415d 100644 (file)
@@ -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
index 6b73de951fe0a2d5244530772dae095f24c92d14..d9481a7439ec363a18ec7050367fba0e485eaff6 100644 (file)
@@ -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
index 5acdce9dae8ab5b996988d4dc13735f59a14cb7a..9d3aa6afaae2520bec74f63f9991a88e7a8e2a25 100644 (file)
        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)
index d598f3669ae5e411f4130d7f9f413fcee0722929..5d4fbc68d1f5059379deafac41b652260686e499 100644 (file)
@@ -1,3 +1,9 @@
+2020-07-15  H.J. Lu  <hongjiu.lu@intel.com>
+
+       PR gas/26237
+       * i386-dis.c (OP_E_memory): Without base nor index registers,
+       zero-extend lower 32-bit displacement to 64 bits.
+
 2020-07-06  Nick Clifton  <nickc@redhat.com>
 
        * po/pt_BR.po: Updated Brazilian Portugugese translation.
index e1ebb485535a84b2a03aa68a9fbba175149cf69e..e0cee46956b2b39477932918917be53fce5784a8 100644 (file)
@@ -14185,8 +14185,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