diff --git a/include/interfaces/irdb/STARSInstruction.h b/include/interfaces/irdb/STARSInstruction.h index 689cb1fd41b5fc2d486ee65fa54f81641d3ac8ec..46b3659ca843405eea6a5cb78d3eb12ede1dad48 100644 --- a/include/interfaces/irdb/STARSInstruction.h +++ b/include/interfaces/irdb/STARSInstruction.h @@ -62,8 +62,7 @@ class STARS_IRDB_Instruction_t : public STARS_Instruction_t // see .cpp virtual uint16_t GetIDAOpcode(void); - virtual STARS_InstructionID_t GetNextInstructionID(void) const - { return STARS_InstructionID_t(irdb_insn->GetFallthrough()->GetBaseID()); } + virtual STARS_InstructionID_t GetNextInstructionID(void) const; virtual STARS_InstructionID_t GetTargetInstructionID(void) const { return STARS_InstructionID_t(irdb_insn->GetTarget()->GetBaseID()); } diff --git a/src/interfaces/idapro/STARSInterface.cpp b/src/interfaces/idapro/STARSInterface.cpp index fc6a60f739508d29a764d8fc2ebef852e2844a00..272edc7bb6e77e6ac63fd673e36472b0126b39ec 100644 --- a/src/interfaces/idapro/STARSInterface.cpp +++ b/src/interfaces/idapro/STARSInterface.cpp @@ -22,6 +22,8 @@ #include <xref.hpp> #endif +#include <funcs.hpp> + #if (IDA_SDK_VERSION < 700) #include <area.hpp> #else @@ -455,24 +457,24 @@ bool STARS_IDA_Interface_t::AuditEHFunctionBoundaries(void) const { // Use the FDEs (Frame Descriptor Entries) from the eh_frame section // to perform the same algorithm as above: an FDE should contain only one func. const auto & EHParser = EHFrameParser_t::factory(global_STARS_program->GetRootFileName()); - for (auto &FDEvecptr : EHParser->getFDEs()) { - for (auto &FDEveciter = FDEvecptr->begin(); FDEveciter != FDEvecptr->end(); ++FDEveciter) { - uint64_t startAddr = (*FDEveciter)->getStartAddress(); - uint64_t endAddr = (*FDEveciter)->getEndAddress(); - - // See if start and end of FDE landing pad are in the same func. - STARS_ea_t CurrStartEA = (STARS_ea_t) startAddr; - STARS_ea_t CurrEndEA = (STARS_ea_t) endAddr; - STARS_Function_t *StartFunc = SMP_get_func(CurrStartEA); - STARS_Function_t *EndFunc = SMP_get_func(CurrEndEA - 1); - - if (StartFunc != EndFunc) { - ProblemFound = true; - SMP_msg("ERROR: FUNCBOUNDS: FDE range from %llx to %llx spans functions\n", - (uint64_t) CurrStartEA, (uint64_t) (CurrEndEA - 1)); - } + const auto FDEvecptr = EHParser->getFDEs(); + for (const auto FDEveciter : *FDEvecptr) { + uint64_t startAddr = FDEveciter->getStartAddress(); + uint64_t endAddr = FDEveciter->getEndAddress(); + + // See if start and end of FDE landing pad are in the same IDA Pro func. + STARS_ea_t CurrStartEA = (STARS_ea_t) startAddr; + STARS_ea_t CurrEndEA = (STARS_ea_t) endAddr; + func_t *StartFunc = ::get_func(CurrStartEA); + func_t *EndFunc = ::get_func(CurrEndEA - 1); + + if (StartFunc != EndFunc) { + ProblemFound = true; + SMP_msg("ERROR: FUNCBOUNDS: FDE range from %llx to %llx spans functions\n", + (uint64_t) CurrStartEA, (uint64_t) (CurrEndEA - 1)); } - } + } // end for (const auto FDEveciter : *FDEvecptr) + #endif return ProblemFound; diff --git a/src/interfaces/irdb/STARS_IRDB_Instruction.cpp b/src/interfaces/irdb/STARS_IRDB_Instruction.cpp index 361247ebd4c428cbc787cc760ff7173838b63844..6bc1233645274e312ee531bb16595e6b40abb65e 100644 --- a/src/interfaces/irdb/STARS_IRDB_Instruction.cpp +++ b/src/interfaces/irdb/STARS_IRDB_Instruction.cpp @@ -17,6 +17,18 @@ static uint32_t UseMacros[STARS_UA_MAXOP] = {STARS_CF_USE1, STARS_CF_USE2, STARS static uint32_t DefMacros[STARS_UA_MAXOP] = {STARS_CF_CHG1, STARS_CF_CHG2, STARS_CF_CHG3, STARS_CF_CHG4, STARS_CF_CHG5, STARS_CF_CHG6}; +STARS_InstructionID_t STARS_IRDB_Instruction_t::GetNextInstructionID(void) const +{ + Instruction_t *FallthroughID = irdb_insn->GetFallthrough(); + if (nullptr == FallthroughID) { + // For robustness, permit a no-op to have no fall through inst. + cerr << "ERROR: No fallthrough inst in GetNextInstructionID()" << endl; + return STARS_InstructionID_t(STARS_BADADDR); + } + else { + return STARS_InstructionID_t(FallthroughID->GetBaseID()); + } +} uint16_t STARS_IRDB_Instruction_t::GetIDAOpcode(void) {