diff --git a/include/interfaces/abstract/STARSOp.h b/include/interfaces/abstract/STARSOp.h index 067c6ba8858677b28237ec69aa579cdcef3834d8..495c7b0d5894e84f555380c8800e7f2fd532f8c8 100644 --- a/include/interfaces/abstract/STARSOp.h +++ b/include/interfaces/abstract/STARSOp.h @@ -71,12 +71,6 @@ class STARS_op_t virtual bool IsFarPointer(void) const = 0; virtual bool HasSegReg(void) const = 0; // Has a segment register - // Printing methods. - virtual void MDPrintSIBByte(void) = 0; // print x86 Scale/Indexreg/Basereg byte - - // Analysis methods. - virtual void MDExtractMemAddressFields(int &BaseReg, int &IndexReg, uint16_t &Scale, STARS_ea_t &Offset); - }; #endif diff --git a/include/interfaces/idapro/STARSOp.h b/include/interfaces/idapro/STARSOp.h index 5eaf2d154d086a4df53d90f98f30fde1a14cbaa1..d221340adcd2c81281f2baeb6843d8eae385a9ee 100644 --- a/include/interfaces/idapro/STARSOp.h +++ b/include/interfaces/idapro/STARSOp.h @@ -87,13 +87,7 @@ class STARS_IDA_op_t : public STARS_op_t bool MDIsSpecialRegOpType(void) const { return ((m_Opnd.type >= o_trreg) && (m_Opnd.type <= o_ymmreg)); }; bool HasSegReg(void) const { return is_segreg(GetSegReg()); }; // Has a segment register - // Printing methods. - virtual void MDPrintSIBByte(void); // print x86 Scale/Indexreg/Basereg byte - - // Analysis methods. - virtual void MDExtractMemAddressFields(int &BaseReg, int &IndexReg, uint16_t &Scale, STARS_ea_t &Offset); - -protected: + protected: op_t m_Opnd; private: diff --git a/include/interfaces/irdb/STARSOp.h b/include/interfaces/irdb/STARSOp.h index 647ee36b358f3350dd610324d0c404c4fafeca6b..665f9af03b70f47a9eccead757eaa826d99bed39 100644 --- a/include/interfaces/irdb/STARSOp.h +++ b/include/interfaces/irdb/STARSOp.h @@ -229,9 +229,6 @@ class STARS_IRDB_op_t : public STARS_op_t } - // Printing methods. - virtual void MDPrintSIBByte(void); // print x86 Scale/Indexreg/Basereg byte - private: diff --git a/src/base/SMPDataFlowAnalysis.cpp b/src/base/SMPDataFlowAnalysis.cpp index ce02591e86f7fa7b30dce4ffb2c3e5b1fb2a8f48..099283a9040ec0b37c0db43b2abc7e6496ddfd3e 100644 --- a/src/base/SMPDataFlowAnalysis.cpp +++ b/src/base/SMPDataFlowAnalysis.cpp @@ -340,10 +340,10 @@ bool IsEqOp(const STARSOpndTypePtr &Opnd1, const STARSOpndTypePtr &Opnd2) // truth table: // // O1 O2 O1<O2 !(O1<O2) O2<O1 !(O2<O1) !(O1<O2)&&!(O2<O1) == - // 0 0 0 1 0 1 1 1 - // 0 1 1 0 0 0 0 0 - // 1 0 0 1 1 0 0 0 - // 1 1 0 1 0 0 1 1 + // 0 0 0 1 0 1 1 1 + // 0 1 1 0 0 0 0 0 + // 1 0 0 1 1 0 0 0 + // 1 1 0 1 0 0 1 1 return !(*Opnd1 < *Opnd2) && !(*Opnd2 < *Opnd1); } // end of function IsEqOp() @@ -459,8 +459,8 @@ bool MDIsIndirectMemoryOpnd(const STARSOpndTypePtr &CurrOp, bool UseFP) { return false; if (CurrOp->HasSIBByte()) { - int BaseReg = MD_STARS_sib_base(CurrOp); - short IndexReg = MD_STARS_sib_index(CurrOp); + STARS_RegNo BaseReg = (STARS_RegNo)MD_STARS_sib_base(CurrOp); + STARS_RegNo IndexReg = (STARS_RegNo)MD_STARS_sib_index(CurrOp); if ((STARS_x86_R_none != IndexReg) && (MD_STACK_POINTER_REG != IndexReg)) { if ((MD_FRAME_POINTER_REG == IndexReg) && UseFP) ; @@ -483,9 +483,9 @@ bool MDIsIndirectMemoryOpnd(const STARSOpndTypePtr &CurrOp, bool UseFP) { } } // end if hasSIB else { // no SIB; can have base register only - uint16_t BaseReg = CurrOp->GetReg(); + STARS_RegNo BaseReg = (STARS_RegNo)CurrOp->GetReg(); if (CurrOp->IsStaticMemOp()) { // no base register for o_mem - if (!((0 == BaseReg) || (MD_FRAME_POINTER_REG == BaseReg))) { + if (!((STARS_x86_R_none == BaseReg) || (MD_FRAME_POINTER_REG == BaseReg))) { SMP_msg("base reg %d ignored \n", BaseReg); } } @@ -672,7 +672,23 @@ void PrintDefUse(unsigned long feature, int OpNum) { // DEBUG print SIB info for an operand. void PrintSIB(const STARSOpndTypePtr &Opnd) { - Opnd->MDPrintSIBByte(); + int BaseReg; + int IndexReg; + uint16_t ScaleFactor; + STARS_ea_t offset; +#define NAME_LEN 5 + char BaseName[NAME_LEN] = {'N', 'o', 'n', 'e', '\0'}; + char IndexName[NAME_LEN] = {'N', 'o', 'n', 'e', '\0'}; + + MDExtractAddressFields(Opnd, BaseReg, IndexReg, ScaleFactor, offset); + + if (BaseReg != STARS_x86_R_none) + SMP_strncpy(BaseName, RegNames[BaseReg], NAME_LEN - 1); + + if (IndexReg != STARS_x86_R_none) { + SMP_strncpy(IndexName, RegNames[IndexReg], NAME_LEN -1); + } + SMP_msg(" Base %s Index %s Scale %d Flag4 %d", BaseName, IndexName, ScaleFactor, Opnd->GetSpecFlag4()); } // end PrintSIB() // Annotations: concisely print SIB info for an operand. diff --git a/src/interfaces/idapro/STARSIDAOp.cpp b/src/interfaces/idapro/STARSIDAOp.cpp index f78f26d7eeb480ff02013f670924c81972110734..d740f3e50ea7ceac5c4fd69afdd58a3ceb3c191c 100644 --- a/src/interfaces/idapro/STARSIDAOp.cpp +++ b/src/interfaces/idapro/STARSIDAOp.cpp @@ -211,59 +211,3 @@ void STARS_IDA_op_t::SetReg(uint16_t NewReg) { this->m_Opnd.reg = NewReg; this->SetByteWidth(GetRegSize(NewReg)); }; - -// DEBUG print SIB info for an operand. -void STARS_IDA_op_t::MDPrintSIBByte(void) { - int BaseReg; - int IndexReg; - uint16_t ScaleFactor; - STARS_ea_t offset; -#define NAME_LEN 5 - char BaseName[NAME_LEN] = { 'N', 'o', 'n', 'e', '\0' }; - char IndexName[NAME_LEN] = { 'N', 'o', 'n', 'e', '\0' }; - - this->MDExtractMemAddressFields(BaseReg, IndexReg, ScaleFactor, offset); - - if (BaseReg != STARS_x86_R_none) - SMP_strncpy(BaseName, RegNames[BaseReg], NAME_LEN - 1); - - if (IndexReg != STARS_x86_R_none) { - SMP_strncpy(IndexName, RegNames[IndexReg], NAME_LEN - 1); - } - SMP_msg(" Base %s Index %s Scale %d Flag4 %d", BaseName, IndexName, ScaleFactor, this->GetSpecFlag4()); -} // end PrintSIB() - -// Extract the base and index registers and scale factor and displacement from the -// memory operand. -void STARS_IDA_op_t::MDExtractMemAddressFields(int &BaseReg, int &IndexReg, uint16_t &Scale, STARS_ea_t &Offset) { - assert(this->IsMemOp()); - - Scale = 0; - BaseReg = STARS_x86_R_none; - IndexReg = STARS_x86_R_none; - Offset = this->GetAddr(); - - if (this->HasSIBByte()) { - BaseReg = this->MDGetSIBBaseReg(); - IndexReg = (int) this->MDGetSIBIndexReg(); - if (MD_STACK_POINTER_REG == IndexReg) // signifies no index register - IndexReg = STARS_x86_R_none; - if (STARS_x86_R_none != IndexReg) { - Scale = (uint16_t) this->GetSIBScaleFactor(); - } - if (STARS_x86_R_none != BaseReg) { - if ((BaseReg == MD_FRAME_POINTER_REG) && this->IsStaticMemOp()) { - BaseReg = STARS_x86_R_none; - // **!!** BaseReg allowed for o_mem with SIB byte??? - } - } - } - else { // no SIB byte; can have base reg but no index reg or scale factor - BaseReg = (int) this->GetReg(); // cannot be STARS_x86_R_none for no SIB case - if (this->IsStaticMemOp()) { - BaseReg = STARS_x86_R_none; // no Base register for o_mem operands - } - } - - return; -} // end of MDExtractMemAddressFields() diff --git a/src/interfaces/irdb/STARS_IRDB_Op.cpp b/src/interfaces/irdb/STARS_IRDB_Op.cpp index 0bd99ac8f22fc14f0710c1fda7a1a14325b6624d..cf15cb62b108f6e1d84a953a8e12b564a77d423c 100644 --- a/src/interfaces/irdb/STARS_IRDB_Op.cpp +++ b/src/interfaces/irdb/STARS_IRDB_Op.cpp @@ -1,5 +1,4 @@ -#include "base/SMPDataFlowAnalysis.h" -#include "interfaces/SMPDBInterface.h" + #include "interfaces/irdb/STARSOp.h" #include <libIRDB-core.hpp> @@ -313,58 +312,3 @@ void STARS_IRDB_op_t::SetSIB(char value) operand.mem.scale=(STARS_RegNo)0; } -// DEBUG print SIB info for an operand. -void STARS_IRDB_op_t::MDPrintSIBByte(void) { - int BaseReg; - int IndexReg; - uint16_t ScaleFactor; - STARS_ea_t offset; -#define NAME_LEN 5 - char BaseName[NAME_LEN] = { 'N', 'o', 'n', 'e', '\0' }; - char IndexName[NAME_LEN] = { 'N', 'o', 'n', 'e', '\0' }; - - this->MDExtractMemAddressFields(BaseReg, IndexReg, ScaleFactor, offset); - - if (BaseReg != STARS_x86_R_none) - SMP_strncpy(BaseName, RegNames[BaseReg], NAME_LEN - 1); - - if (IndexReg != STARS_x86_R_none) { - SMP_strncpy(IndexName, RegNames[IndexReg], NAME_LEN - 1); - } - SMP_msg(" Base %s Index %s Scale %d ", BaseName, IndexName, ScaleFactor); -} // end PrintSIB() - -// Extract the base and index registers and scale factor and displacement from the -// memory operand. -void STARS_IRDB_op_t::MDExtractMemAddressFields(int &BaseReg, int &IndexReg, uint16_t &Scale, STARS_ea_t &Offset) { - assert(this->IsMemOp()); - - Scale = 0; - BaseReg = STARS_x86_R_none; - IndexReg = STARS_x86_R_none; - Offset = this->GetAddr(); - - if (this->HasSIBByte()) { - BaseReg = this->MDGetSIBBaseReg(); - IndexReg = (int) this->MDGetSIBIndexReg(); - if (MD_STACK_POINTER_REG == IndexReg) // signifies no index register - IndexReg = STARS_x86_R_none; - if (STARS_x86_R_none != IndexReg) { - Scale = (uint16_t) this->GetSIBScaleFactor(); - } - if (STARS_x86_R_none != BaseReg) { - if ((BaseReg == MD_FRAME_POINTER_REG) && this->IsStaticMemOp()) { - BaseReg = STARS_x86_R_none; - // **!!** BaseReg allowed for o_mem with SIB byte??? - } - } - } - else { // no SIB byte; can have base reg but no index reg or scale factor - BaseReg = (int) this->GetReg(); // cannot be STARS_x86_R_none for no SIB case - if (this->IsStaticMemOp()) { - BaseReg = STARS_x86_R_none; // no Base register for o_mem operands - } - } - - return; -} // end of MDExtractMemAddressFields()