diff --git a/include/interfaces/irdb/STARSInstruction.h b/include/interfaces/irdb/STARSInstruction.h index 3394c643c696f8d0b6e2e28617137fb178b86882..f91f5c474edd9b7913b934f0adc090a04e681a3e 100644 --- a/include/interfaces/irdb/STARSInstruction.h +++ b/include/interfaces/irdb/STARSInstruction.h @@ -95,14 +95,14 @@ class STARS_IRDB_Instruction_t : public STARS_Instruction_t // Query methods virtual bool HasRepeatIfEqualPrefix(void) const - { return disasm.hasRepnePrefix(); /*disasm.Prefix.RepnePrefix!=NotUsedPrefix;*/ } + { return disasm.hasRelevantRepnePrefix(); /*disasm.Prefix.RepnePrefix!=NotUsedPrefix;*/ } virtual bool HasRepeatIfNotEqualPrefix(void) const - { return disasm.hasRepPrefix(); /* disasm.Prefix.RepPrefix!=NotUsedPrefix; */ } + { return disasm.hasRelevantRepPrefix(); /* disasm.Prefix.RepPrefix!=NotUsedPrefix; */ } virtual bool HasAnyRepeatPrefix(void) const { return HasRepeatIfEqualPrefix() || HasRepeatIfNotEqualPrefix(); } virtual bool HasOperandSizePrefix(void) const - { return disasm.hasOperandSizePrefix(); /* Prefix.OperandSize!=NotUsedPrefix; */} + { return disasm.hasRelevantOperandSizePrefix(); /* Prefix.OperandSize!=NotUsedPrefix; */} virtual bool HasREXWPrefix(void) const { return disasm.hasRexWPrefix(); /*disasm.Prefix.REX.W_!=0; */} @@ -131,7 +131,7 @@ class STARS_IRDB_Instruction_t : public STARS_Instruction_t return true; // no size prefix and opcode defaults to 64-bit - if (!this->HasOperandSizePrefix() && this->OpcodeDefaultsTo64BitOperands() ) + if ( this->OpcodeDefaultsTo64BitOperands() && !this->HasOperandSizePrefix() ) return true; // size prefix or non-64 bit operand diff --git a/src/base/SMPFunction.cpp b/src/base/SMPFunction.cpp index 54488ec69f6dd1babc091ab3b57067abe02910d6..797f1ca61b40247e110cca48f60f1d7ac8a5e187 100644 --- a/src/base/SMPFunction.cpp +++ b/src/base/SMPFunction.cpp @@ -4796,7 +4796,7 @@ void SMPFunction::AnalyzeFunc(void) { InstAddr = CurrInst->GetAddr(); pair<STARS_ea_t, SMPBasicBlock *> MapItem(InstAddr, CurrBlock); this->InstBlockMap.insert(MapItem); - if (CurrInst->MDHasAnyRepeatPrefix() && CurrInst->MDIsPossibleStringLoopingOpcode()) { + if ( CurrInst->MDIsPossibleStringLoopingOpcode() && CurrInst->MDHasAnyRepeatPrefix() ) { CurrBlock->SetHasLoopingStringOpcode(); } } diff --git a/src/base/SMPInstr.cpp b/src/base/SMPInstr.cpp index a7d1a7c7282b095517ee6941c10c7964f04c4f2a..8a93b4c04ceaeab7ff098b58cdfdb0e38adb8d90 100644 --- a/src/base/SMPInstr.cpp +++ b/src/base/SMPInstr.cpp @@ -19174,7 +19174,6 @@ bool SMPInstr::BuildMoveRTL(SMPoperator GuardOp) { bool SourceFound = false; bool MemSrc = this->HasSourceMemoryOperand(); bool MemDest = this->HasDestMemoryOperand(); - bool HasRepeatPrefix = this->STARSInstPtr->HasAnyRepeatPrefix(); bool AltersRSI = false; // for string operations bool AltersRDI = false; // for string operations unsigned short opcode = this->GetIDAOpcode(); @@ -19363,6 +19362,7 @@ bool SMPInstr::BuildMoveRTL(SMPoperator GuardOp) { STARSOpndTypePtr FirstOpnd = this->GetOperand(0); uint16_t ByteWidth = FirstOpnd->GetByteWidth(); STARSOpndTypePtr IncrementOp = this->MakeImmediateOpnd((STARS_uval_t) ByteWidth); + bool HasRepeatPrefix = this->STARSInstPtr->HasAnyRepeatPrefix(); if (HasRepeatPrefix) { // Must be MOVS or STOS or INS or OUTS // The repeat causes USE and DEF of ECX as a counter STARSOpndTypePtr CountOp = this->STARSInstPtr->MakeRegOpnd(STARS_x86_R_cx); @@ -19522,7 +19522,6 @@ bool SMPInstr::BuildCompareStringRTL(void) { std::size_t OpNum; bool Src1Found = false; bool Src2Found = false; - bool HasRepeatPrefix = this->STARSInstPtr->HasAnyRepeatPrefix(); STARSOpndTypePtr FlagsOp = this->STARSInstPtr->MakeRegOpnd(X86_FLAGS_REG); @@ -19578,6 +19577,7 @@ bool SMPInstr::BuildCompareStringRTL(void) { else { this->RTL.push_back(TempRT); // Now, create the repeat prefix effects + bool HasRepeatPrefix = this->STARSInstPtr->HasAnyRepeatPrefix(); if (HasRepeatPrefix) { // The repeat causes USE and DEF of ECX as a counter SMPRegTransfer *CounterRT = new SMPRegTransfer; @@ -19871,7 +19871,6 @@ bool SMPInstr::BuildFlagsDestBinaryRTL(SMPoperator BinaryOp) { bool Source1Found = false; bool Source2Found = false; bool NoOperandsRequired = ((STARS_NN_scas == opcode) || (STARS_NN_cmps == opcode)); - bool HasRepeatPrefix = this->STARSInstPtr->HasAnyRepeatPrefix(); SMPRegTransfer *TempRT = new SMPRegTransfer; TempRT->SetParentInst(this); @@ -19950,6 +19949,7 @@ bool SMPInstr::BuildFlagsDestBinaryRTL(SMPoperator BinaryOp) { else { this->RTL.push_back(TempRT); // Now, create the repeat prefix effects + bool HasRepeatPrefix = this->STARSInstPtr->HasAnyRepeatPrefix(); if (HasRepeatPrefix) { // Must be CMPS or SCAS // The repeat causes USE and DEF of ECX as a counter SMPRegTransfer *CounterRT = new SMPRegTransfer; diff --git a/tests/scripts/SMP-analyze32.sh b/tests/scripts/SMP-analyze32.sh index 39fbfa63eeb3123c75688662a2d1caa6350e193a..6d24db7469d8d4653d94cfa94247b5e1f40cf1fe 100755 --- a/tests/scripts/SMP-analyze32.sh +++ b/tests/scripts/SMP-analyze32.sh @@ -34,7 +34,11 @@ old_stty=`stty -g` # jdh - added -B for batch mode, avoids any prompts. # jdh - note: can't use -B, as the plugin doesn't run! # time ${IDAROOT}/idal -A -Telf -OSMPStaticAnalyzer:run $1 2>&1 >/dev/null -TVHEADLESS=1 time ${IDAROOT}/idal -A -SSMP.idc $1 > $1.idaoutput +if [[ -f ${IDAROOT}/idal ]] ; then + TVHEADLESS=1 time ${IDAROOT}/idal -A -SSMP.idc $1 > $1.idaoutput +else + TVHEADLESS=1 time ${IDAROOT}/idat -A -SSMP.idc $1 > $1.idaoutput +fi # valgrind -v --leak-check=full --show-reachable=yes --track-origins=yes --log-file=$1.valgrind.log ${IDAROOT}/idal -A -SSMP.idc $1 diff --git a/tests/scripts/SMP-analyze64.sh b/tests/scripts/SMP-analyze64.sh index cc241b9adb022a229326ca2e1b9c5944ea6ea518..cdb3a1bb13d8ed0ba9c02b8998896f6887a65744 100755 --- a/tests/scripts/SMP-analyze64.sh +++ b/tests/scripts/SMP-analyze64.sh @@ -34,8 +34,11 @@ old_stty=`stty -g` # jdh - added -B for batch mode, avoids any prompts. # jdh - note: can't use -B, as the plugin doesn't run! # TVHEADLESS=1 time ${IDAROOT}/idal64 -A -Telf -OSMPStaticAnalyzer:run $1 2>&1 >/dev/null -echo "TVHEADLESS=1 time ${IDAROOT}/idal64 -A -SSMP.idc $1 > $1.idaoutput" -TVHEADLESS=1 time ${IDAROOT}/idal64 -A -SSMP.idc $1 > $1.idaoutput +if [[ -f ${IDAROOT}/idal64 ]]; then + (set -x; TVHEADLESS=1 time ${IDAROOT}/idal64 -A -SSMP.idc $1 > $1.idaoutput ) +else + (set -x ; TVHEADLESS=1 time ${IDAROOT}/idat64 -A -SSMP.idc $1 > $1.idaoutput ) +fi # TVHEADLESS=1 valgrind -v --leak-check=full --show-reachable=yes --track-origins=yes --log-file=$1.valgrind.log ${IDAROOT}/idal64 -A -SSMP.idc $1