Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • opensrc/SMPStaticAnalyzer
1 result
Show changes
...@@ -477,38 +477,46 @@ bool STARS_IDA_Interface_t::AuditEHFunctionBoundaries(void) { ...@@ -477,38 +477,46 @@ bool STARS_IDA_Interface_t::AuditEHFunctionBoundaries(void) {
// Use the FDEs (Frame Descriptor Entries) from the eh_frame section // 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. // to perform the same algorithm as above: an FDE should contain only one func.
const string ExeFileName = global_STARS_program->GetRootFileName(); const string ExeFileName = global_STARS_program->GetRootFileName();
auto EHParser = EHP::EHFrameParser_t::factory(ExeFileName); try
const auto FDEvecptr = EHParser->getFDEs(); {
for (const auto FDEveciter : *FDEvecptr) { auto EHParser = EHP::EHFrameParser_t::factory(ExeFileName);
uint64_t startAddr = FDEveciter->getStartAddress(); const auto FDEvecptr = EHParser->getFDEs();
uint64_t endAddr = FDEveciter->getEndAddress(); for (const auto FDEveciter : *FDEvecptr) {
uint64_t startAddr = FDEveciter->getStartAddress();
// See if start and end of FDE landing pad are in the same IDA Pro func. uint64_t endAddr = FDEveciter->getEndAddress();
STARS_ea_t CurrStartEA = (STARS_ea_t) startAddr;
STARS_ea_t CurrEndEA = (STARS_ea_t) endAddr; // See if start and end of FDE landing pad are in the same IDA Pro func.
func_t *StartFunc = ::get_func(CurrStartEA); STARS_ea_t CurrStartEA = (STARS_ea_t) startAddr;
func_t *EndFunc = ::get_func(CurrEndEA - 1); STARS_ea_t CurrEndEA = (STARS_ea_t) endAddr;
func_t *StartFunc = ::get_func(CurrStartEA);
if (StartFunc != EndFunc) { func_t *EndFunc = ::get_func(CurrEndEA - 1);
STARS_Segment_t *FuncSeg = this->getseg(CurrStartEA);
assert(nullptr != FuncSeg); if (StartFunc != EndFunc) {
char SegName[STARS_MAXSTR]; STARS_Segment_t *FuncSeg = this->getseg(CurrStartEA);
STARS_ssize_t SegNameLen = FuncSeg->GetSegmentName(SegName, STARS_MAXSTR - 1); assert(nullptr != FuncSeg);
assert(0 < SegNameLen); char SegName[STARS_MAXSTR];
const bool PLTflag = (nullptr != strstr(SegName, "plt")); STARS_ssize_t SegNameLen = FuncSeg->GetSegmentName(SegName, STARS_MAXSTR - 1);
const bool DYNflag = (nullptr != strstr(SegName, "dyn")); assert(0 < SegNameLen);
if (!(PLTflag || DYNflag)) { const bool PLTflag = (nullptr != strstr(SegName, "plt"));
ProblemFound = true; const bool DYNflag = (nullptr != strstr(SegName, "dyn"));
SMP_msg("INFO: FUNCBOUNDS: FDE range from %llx to %llx spans functions in segment %s\n", if (!(PLTflag || DYNflag)) {
(uint64_t) CurrStartEA, (uint64_t) (CurrEndEA - 1), SegName); ProblemFound = true;
bool success = this->RedefineIDAFuncBounds(StartFunc, EndFunc, CurrStartEA, CurrEndEA); SMP_msg("INFO: FUNCBOUNDS: FDE range from %llx to %llx spans functions in segment %s\n",
if (success) (uint64_t) CurrStartEA, (uint64_t) (CurrEndEA - 1), SegName);
SMP_msg("INFO: Redefined IDA FuncBounds successfully.\n"); bool success = this->RedefineIDAFuncBounds(StartFunc, EndFunc, CurrStartEA, CurrEndEA);
else if (success)
SMP_msg("ERROR: Failed to redefine IDA FuncBounds.\n"); SMP_msg("INFO: Redefined IDA FuncBounds successfully.\n");
else
SMP_msg("ERROR: Failed to redefine IDA FuncBounds.\n");
}
} }
} } // end for (const auto FDEveciter : *FDEvecptr)
} // end for (const auto FDEveciter : *FDEvecptr) }
catch(const std::exception& e)
{
const auto msg = string("WARN: Unhandled exception when processing EH frame: ")+e.what();
SMP_msg(msg.c_str());
}
#endif // __X64__ #endif // __X64__
#endif // STARS_USE_EHP_LIB #endif // STARS_USE_EHP_LIB
......