harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gshiman...@apache.org
Subject svn commit: r605232 - /harmony/enhanced/drlvm/trunk/vm/port/src/encoder/ia32_em64t/dec_base.cpp
Date Tue, 18 Dec 2007 15:28:08 GMT
Author: gshimansky
Date: Tue Dec 18 07:27:51 2007
New Revision: 605232

URL: http://svn.apache.org/viewvc?rev=605232&view=rev
Log:
Applied patch from HARMONY-5320
[drlvm][NCAI][encoder] Decoder incorrectly parses special case with modrm.mod=0 and sib.base=5


Modified:
    harmony/enhanced/drlvm/trunk/vm/port/src/encoder/ia32_em64t/dec_base.cpp

Modified: harmony/enhanced/drlvm/trunk/vm/port/src/encoder/ia32_em64t/dec_base.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/port/src/encoder/ia32_em64t/dec_base.cpp?rev=605232&r1=605231&r2=605232&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/port/src/encoder/ia32_em64t/dec_base.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/port/src/encoder/ia32_em64t/dec_base.cpp Tue Dec 18 07:27:51
2007
@@ -306,7 +306,6 @@
     const ModRM& modrm = *(ModRM*)*pbuf;
     *pbuf += 1;
     
-    RegName reg = RegName_Null;
     RegName base = RegName_Null;
     RegName index = RegName_Null;
     int disp = 0;
@@ -318,10 +317,9 @@
         reg_size = OpndSize_64;
 #endif
 
-    reg = getRegName(OpndKind_GPReg, reg_size, EXTEND_REG(modrm.reg, r));
     if (modrm.mod == 3) {
         // we have only modrm. no sib, no disp.
-        reg = getRegName(OpndKind_GPReg, opndDesc.size, EXTEND_REG(modrm.rm, b));
+        RegName reg = getRegName(OpndKind_GPReg, opndDesc.size, EXTEND_REG(modrm.rm, b));
         opnd = EncoderBase::Operand(reg);
         return true;
     }
@@ -331,13 +329,17 @@
         // yes, we have SIB
         *pbuf += 1;
         scale = sib.scale == 0 ? 0 : (1<<sib.scale);
-        if (sib.index == 4) {
-            // no index
+        if (sib.index != 4) {
+			index = getRegName(OpndKind_GPReg, reg_size, EXTEND_REG(sib.index, x));
+        } else {
+            // (sib.index == 4) => no index
         }
-        else {
-            index = getRegName(OpndKind_GPReg, reg_size, EXTEND_REG(sib.index, x));
+
+        if (sib.base != 5 && modrm.mod != 0) {
+            base = getRegName(OpndKind_GPReg, reg_size, EXTEND_REG(sib.base, b));
+        } else {
+            // (sib.base == 5 && modrm.mod == 0) => no base
         }
-        base = getRegName(OpndKind_GPReg, reg_size, EXTEND_REG(sib.base, b));
     }
     else {
         if (modrm.mod != 0 || modrm.rm != 5) {
@@ -366,7 +368,8 @@
             *pbuf += 4;
         }
         else if (modrm.rm == 4 && sib.base == 5) {
-            // have to analyze sib, special case without EBP: have disp32+SI
+            // have disp32 with SI in sib
+            disp = *(int*)*pbuf;
             *pbuf += 4;
         }
     }



Mime
View raw message