From 2ca0c9b46aa82106726e9620b84cf2c1a527f7c0 Mon Sep 17 00:00:00 2001 From: jdh8d <jdh8d@git.zephyr-software.com> Date: Fri, 9 Oct 2015 18:18:44 +0000 Subject: [PATCH] Undid -r 18423 commit. Former-commit-id: 46ab830edeaf305a2f0d8244acf492cf43a2bdbd --- include/interfaces/abstract/STARSOp.h | 6 --- include/interfaces/idapro/STARSOp.h | 8 +--- include/interfaces/irdb/STARSOp.h | 3 -- src/base/SMPDataFlowAnalysis.cpp | 34 +++++++++++----- src/interfaces/idapro/STARSIDAOp.cpp | 56 -------------------------- src/interfaces/irdb/STARS_IRDB_Op.cpp | 58 +-------------------------- 6 files changed, 27 insertions(+), 138 deletions(-) diff --git a/include/interfaces/abstract/STARSOp.h b/include/interfaces/abstract/STARSOp.h index 067c6ba8..495c7b0d 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 5eaf2d15..d221340a 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 647ee36b..665f9af0 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 ce02591e..099283a9 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 f78f26d7..d740f3e5 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 0bd99ac8..cf15cb62 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() -- GitLab