]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
x86: Check for more than 2 memory references
authorH.J. Lu <hjl.tools@gmail.com>
Fri, 27 Jul 2018 13:35:09 +0000 (06:35 -0700)
committerH.J. Lu <hjl.tools@gmail.com>
Fri, 27 Jul 2018 13:35:09 +0000 (06:35 -0700)
For

movsd (%esi), %ss:(%edi), %ss:(%eax)

we got

[hjl@gnu-tools-1 tmp]$ as -o x.o x.s
x.s: Assembler messages:
x.s:1: Error: too many memory references for `movsd'
munmap_chunk(): invalid pointer
x.s:1: Internal error (Aborted).
Please report this bug.
[hjl@gnu-tools-1 tmp]$

struct _i386_insn has

const seg_entry *seg[2];

3 memory references will overflow the seg array.  We should issue an
error if there are more than 2 memory references.

PR gas/23453
* config/tc-i386.c (parse_operands): Check for more than 2
memory references.
* testsuite/gas/i386/inval.s: Add a movsd test with 3 memory
references.
* testsuite/gas/i386/x86-64-inval.s: Likewise.
* testsuite/gas/i386/inval.l: Updated.
* testsuite/gas/i386/x86-64-inval.l: Likewise.

gas/ChangeLog
gas/config/tc-i386.c
gas/testsuite/gas/i386/inval.l
gas/testsuite/gas/i386/inval.s
gas/testsuite/gas/i386/x86-64-inval.l
gas/testsuite/gas/i386/x86-64-inval.s

index e8c500a2c0ebf6246f01cee80a907e45cfdd3692..0cc4e55d2448d52f8d75708a62f133b28504c9fd 100644 (file)
@@ -1,3 +1,14 @@
+2018-07-26  H.J. Lu  <hongjiu.lu@intel.com>
+
+       PR gas/23453
+       * config/tc-i386.c (parse_operands): Check for more than 2
+       memory references.
+       * testsuite/gas/i386/inval.s: Add a movsd test with 3 memory
+       references.
+       * testsuite/gas/i386/x86-64-inval.s: Likewise.
+       * testsuite/gas/i386/inval.l: Updated.
+       * testsuite/gas/i386/x86-64-inval.l: Likewise.
+
 2018-07-26  H.J. Lu  <hongjiu.lu@intel.com>
 
        * config/tc-i386.c (check_VecOperations): Initialize
index 9e9c676580a10485637206e022781eac100252c0..cc01a588e410bda1655707893dd1ef504d6da6d4 100644 (file)
@@ -4675,6 +4675,13 @@ parse_operands (char *l, const char *mnemonic)
          /* Now parse operand adding info to 'i' as we go along.  */
          END_STRING_AND_SAVE (l);
 
+         if (i.mem_operands > 1)
+           {
+             as_bad (_("too many memory references for `%s'"),
+                     mnemonic);
+             return 0;
+           }
+
          if (intel_syntax)
            operand_ok =
              i386_intel_operand (token_start,
index d5d8500bbe4d654e2f735d3db03889fb90b64758..3d52a17d2e57e09606437f20f457296abe70041e 100644 (file)
@@ -87,6 +87,7 @@
 .*:97: Error: .*shl.*
 .*:98: Error: .*rol.*
 .*:99: Error: .*rcl.*
+.*:102: Error: .*
 GAS LISTING .*
 
 
@@ -192,3 +193,6 @@ GAS LISTING .*
 [      ]*[1-9][0-9]*[  ]+shl \[eax\], 1
 [      ]*[1-9][0-9]*[  ]+rol \[ecx\], 2
 [      ]*[1-9][0-9]*[  ]+rcl \[edx\], cl
+[      ]*[1-9][0-9]*[  ]+
+[      ]*[1-9][0-9]*[  ]+\.att_syntax prefix
+[      ]*[1-9][0-9]*[  ]+movsd \(%esi\), %ss:\(%edi\), %ss:\(%eax\)
index dbf8b965a13f82d3da24aaf006b6292f67f7bc0c..47655e545ee54390df500391d08c70845c01f93d 100644 (file)
@@ -97,3 +97,6 @@ movnti word ptr [eax], ax
        shl [eax], 1
        rol [ecx], 2
        rcl [edx], cl
+
+       .att_syntax prefix
+       movsd (%esi), %ss:(%edi), %ss:(%eax)
index 099cc62e48d155d047ad3b3d10fc54b8ef0aea5c..bbb8ba295cbdfc5fbc46337164493e6a3a0f5bb0 100644 (file)
 .*:116: Error: .*
 .*:117: Error: .*
 .*:118: Error: .*
+.*:121: Error: .*
 GAS LISTING .*
 
 
@@ -237,3 +238,6 @@ GAS LISTING .*
 [      ]*116[  ]+jmpd \[rax\]  \# 32-bit data size not allowed
 [      ]*117[  ]+jmpq \[ax\]   \# no 16-bit addressing
 [      ]*[1-9][0-9]*[  ]+mov eax,\[rax\+0x876543210\] \# out of range displacement
+[      ]*[1-9][0-9]*[  ]+
+[      ]*[1-9][0-9]*[  ]+\.att_syntax prefix
+[      ]*[1-9][0-9]*[  ]+movsd \(%rsi\), %ss:\(%rdi\), %ss:\(%rax\)
index 1ce832099beb3c7ea7bdb0df167b2a9ed7d1950a..85c3582d4b2501805b5cdb4545ec72a1a151515b 100644 (file)
@@ -116,3 +116,6 @@ movnti word ptr [rax], ax
        jmpd [rax]      # 32-bit data size not allowed
        jmpq [ax]       # no 16-bit addressing
        mov eax,[rax+0x876543210] # out of range displacement
+
+       .att_syntax prefix
+       movsd (%rsi), %ss:(%rdi), %ss:(%rax)