This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

PATCH: Properly handle suffix for iret and sysret


Hi,

I checked in this patch to properly handle suffix for iret and sysret in
Intel mode.


H.J.
---
diff --git a/gas/testsuite/ChangeLog b/gas/testsuite/ChangeLog
index d705f8a..f67448b 100644
--- a/gas/testsuite/ChangeLog
+++ b/gas/testsuite/ChangeLog
@@ -1,3 +1,16 @@
+2014-09-10  H.J. Lu  <hongjiu.lu@intel.com>
+
+	* gas/i386/i386.exp: Run suffix-intel, x86-64-suffix and
+	x86-64-suffix-intel.
+
+	* gas/i386/suffix.s: Add tests for iret and sysret.
+	* gas/i386/suffix.d: Updated.
+
+	* gas/i386/suffix-intel.d: New file.
+	* gas/i386/x86-64-suffix-intel.d: Likewise.
+	* gas/i386/x86-64-suffix.d: Likewise.
+	* gas/i386/x86-64-suffix.s: Likewise.
+
 2014-09-10  Alan Modra  <amodra@gmail.com>
 
 	* gas/arm/got_prel.d: Adjust for changed section header placement.
diff --git a/gas/testsuite/gas/i386/i386.exp b/gas/testsuite/gas/i386/i386.exp
index 680d28c..4446426 100644
--- a/gas/testsuite/gas/i386/i386.exp
+++ b/gas/testsuite/gas/i386/i386.exp
@@ -73,6 +73,7 @@ if [expr ([istarget "i*86-*-*"] ||  [istarget "x86_64-*-*"]) && [gas_32_check]]
     run_dump_test "vmfunc"
     run_dump_test "smx"
     run_dump_test "suffix"
+    run_dump_test "suffix-intel"
     run_dump_test "immed32"
     run_dump_test "equ"
     run_dump_test "divide"
@@ -627,6 +628,8 @@ if [expr ([istarget "i*86-*-*"] || [istarget "x86_64-*-*"]) && [gas_64_check]] t
     run_dump_test "x86-64-avx512dq"
     run_dump_test "x86-64-avx512dq_vl-intel"
     run_dump_test "x86-64-avx512dq_vl"
+    run_dump_test "x86-64-suffix"
+    run_dump_test "x86-64-suffix-intel"
 
     if { ![istarget "*-*-aix*"]
       && ![istarget "*-*-beos*"]
diff --git a/gas/testsuite/gas/i386/suffix.d b/gas/testsuite/gas/i386/suffix.d
index fa57bb7..44be5ed 100644
--- a/gas/testsuite/gas/i386/suffix.d
+++ b/gas/testsuite/gas/i386/suffix.d
@@ -5,11 +5,21 @@
 
 Disassembly of section .text:
 
-0+000 <foo>:
-   0:	0f 01 c8 [ 	]*monitor %eax,%ecx,%edx
-   3:	0f 01 c9 [ 	]*mwait  %eax,%ecx
-   6:	0f 01 c1 [ 	]*vmcall 
-   9:	0f 01 c2 [ 	]*vmlaunch 
-   c:	0f 01 c3 [ 	]*vmresume 
-   f:	0f 01 c4 [ 	]*vmxoff 
-	...
+0+ <foo>:
+[ 	]*[a-f0-9]+:	0f 01 c8             	monitor %eax,%ecx,%edx
+[ 	]*[a-f0-9]+:	0f 01 c9             	mwait  %eax,%ecx
+[ 	]*[a-f0-9]+:	0f 01 c1             	vmcall 
+[ 	]*[a-f0-9]+:	0f 01 c2             	vmlaunch 
+[ 	]*[a-f0-9]+:	0f 01 c3             	vmresume 
+[ 	]*[a-f0-9]+:	0f 01 c4             	vmxoff 
+[ 	]*[a-f0-9]+:	66 cf                	iretw  
+[ 	]*[a-f0-9]+:	cf                   	iretl  
+[ 	]*[a-f0-9]+:	cf                   	iretl  
+[ 	]*[a-f0-9]+:	0f 07                	sysretl 
+[ 	]*[a-f0-9]+:	0f 07                	sysretl 
+[ 	]*[a-f0-9]+:	66 cf                	iretw  
+[ 	]*[a-f0-9]+:	cf                   	iretl  
+[ 	]*[a-f0-9]+:	cf                   	iretl  
+[ 	]*[a-f0-9]+:	0f 07                	sysretl 
+[ 	]*[a-f0-9]+:	0f 07                	sysretl 
+#pass
diff --git a/gas/testsuite/gas/i386/suffix.s b/gas/testsuite/gas/i386/suffix.s
index 2ce1c3d..7f2864d 100644
--- a/gas/testsuite/gas/i386/suffix.s
+++ b/gas/testsuite/gas/i386/suffix.s
@@ -10,4 +10,15 @@ foo:
 	vmresume
 	vmxoff
 
-	.p2align	4,0
+	iretw
+	iretl
+	iret
+	sysretl
+	sysret
+
+	.intel_syntax noprefix
+	iretw
+	iretd
+	iret
+	sysretd
+	sysret
diff --git a/opcodes/ChangeLog b/opcodes/ChangeLog
index 83118a5..09fb297 100644
--- a/opcodes/ChangeLog
+++ b/opcodes/ChangeLog
@@ -1,3 +1,8 @@
+2014-09-10  H.J. Lu  <hongjiu.lu@intel.com>
+
+	* i386-dis.c (dis386): Replace "P" with "%LP" for iret and sysret.
+	(putop): Handle "%LP".
+
 2014-09-03  Jiong Wang  <jiong.wang@arm.com>
 
 	* aarch64-tbl.h (aarch64_opcode_table): Update encoding for mrs/msr.
diff --git a/opcodes/i386-dis.c b/opcodes/i386-dis.c
index 34bb61d..79abe09 100644
--- a/opcodes/i386-dis.c
+++ b/opcodes/i386-dis.c
@@ -2397,6 +2397,9 @@ struct dis386 {
    "LS" => print "abs" in 64bit mode and behave as 'S' otherwise
    "LV" => print "abs" for 64bit operand and behave as 'S' otherwise
    "LW" => print 'd', 'q' depending on the VEX.W bit
+   "LP" => print 'w' or 'l' ('d' in Intel mode) if instruction has
+	   an operand size prefix, or suffix_always is true.  print
+	   'q' if rex prefix is present.
 
    Many of the above letters print nothing in Intel mode.  See "putop"
    for the details.
@@ -2638,7 +2641,7 @@ static const struct dis386 dis386[] = {
   { "int3",		{ XX } },
   { "int",		{ Ib } },
   { X86_64_TABLE (X86_64_CE) },
-  { "iretP",		{ XX } },
+  { "iret%LP",		{ XX } },
   /* d0 */
   { REG_TABLE (REG_D0) },
   { REG_TABLE (REG_D1) },
@@ -2704,7 +2707,7 @@ static const struct dis386 dis386_twobyte[] = {
   { Bad_Opcode },
   { "syscall",		{ XX } },
   { "clts",		{ XX } },
-  { "sysretP",		{ XX } },
+  { "sysret%LP",		{ XX } },
   /* 08 */
   { "invd",		{ XX } },
   { "wbinvd",		{ XX } },
@@ -13835,32 +13838,62 @@ case_L:
 	      break;
 	    }
 	  /* Fall through.  */
+	  goto case_P;
 	case 'P':
-	  if (intel_syntax)
+	  if (l == 0 && len == 1)
 	    {
-	      if ((rex & REX_W) == 0
-		  && (prefixes & PREFIX_DATA))
+case_P:
+	      if (intel_syntax)
 		{
-		  if ((sizeflag & DFLAG) == 0)
-		    *obufp++ = 'w';
-		   used_prefixes |= (prefixes & PREFIX_DATA);
+		  if ((rex & REX_W) == 0
+		      && (prefixes & PREFIX_DATA))
+		    {
+		      if ((sizeflag & DFLAG) == 0)
+			*obufp++ = 'w';
+		      used_prefixes |= (prefixes & PREFIX_DATA);
+		    }
+		  break;
+		}
+	      if ((prefixes & PREFIX_DATA)
+		  || (rex & REX_W)
+		  || (sizeflag & SUFFIX_ALWAYS))
+		{
+		  USED_REX (REX_W);
+		  if (rex & REX_W)
+		    *obufp++ = 'q';
+		  else
+		    {
+		      if (sizeflag & DFLAG)
+			*obufp++ = 'l';
+		      else
+			*obufp++ = 'w';
+		      used_prefixes |= (prefixes & PREFIX_DATA);
+		    }
 		}
-	      break;
 	    }
-	  if ((prefixes & PREFIX_DATA)
-	      || (rex & REX_W)
-	      || (sizeflag & SUFFIX_ALWAYS))
+	  else
 	    {
-	      USED_REX (REX_W);
-	      if (rex & REX_W)
-		*obufp++ = 'q';
-	      else
+	      if (l != 1 || len != 2 || last[0] != 'L')
+		{
+		  SAVE_LAST (*p);
+		  break;
+		}
+
+	      if ((prefixes & PREFIX_DATA)
+		  || (rex & REX_W)
+		  || (sizeflag & SUFFIX_ALWAYS))
 		{
-		   if (sizeflag & DFLAG)
-		      *obufp++ = 'l';
-		   else
-		     *obufp++ = 'w';
-		   used_prefixes |= (prefixes & PREFIX_DATA);
+		  USED_REX (REX_W);
+		  if (rex & REX_W)
+		    *obufp++ = 'q';
+		  else
+		    {
+		      if (sizeflag & DFLAG)
+			*obufp++ = intel_syntax ? 'd' : 'l';
+		      else
+			*obufp++ = 'w';
+		      used_prefixes |= (prefixes & PREFIX_DATA);
+		    }
 		}
 	    }
 	  break;


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]