From 707b1dc686d2831914e2b8d75d0f18d848bfbd22 Mon Sep 17 00:00:00 2001 From: clc5q <clc5q@git.zephyr-software.com> Date: Tue, 1 Dec 2015 23:42:25 +0000 Subject: [PATCH] Better safeguard for call to GetNextInstructionID() in INDIR_JUMP case with no fall-through instruction. Former-commit-id: 66b1d3656c858024caa44655e595b12fa79ebb7f --- src/base/SMPBasicBlock.cpp | 2 +- src/base/SMPFunction.cpp | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/base/SMPBasicBlock.cpp b/src/base/SMPBasicBlock.cpp index faf0c461..c75e9719 100644 --- a/src/base/SMPBasicBlock.cpp +++ b/src/base/SMPBasicBlock.cpp @@ -462,7 +462,7 @@ list<SMPBasicBlock *>::iterator SMPBasicBlock::GetFallThroughSucc(void) { SMPInstr *LastInst = (*LastInstIter); SMPitype LastDataFlow = LastInst->GetDataFlowType(); - if ((JUMP != LastDataFlow) && (RETURN != LastDataFlow) && (HALT != LastDataFlow) && (!LastInst->IsFixedCallJump())) { + if ((JUMP != LastDataFlow) && (INDIR_JUMP != LastDataFlow) && (RETURN != LastDataFlow) && (HALT != LastDataFlow) && (!LastInst->IsFixedCallJump())) { // Block has fall-through. STARS_InstructionID_t NextInstID = LastInst->GetInstID().GetInstruction()->GetNextInstructionID(); STARS_ea_t FallThroughSuccAddr = NextInstID.GetIDWithinFile(); diff --git a/src/base/SMPFunction.cpp b/src/base/SMPFunction.cpp index e11739e2..36005472 100644 --- a/src/base/SMPFunction.cpp +++ b/src/base/SMPFunction.cpp @@ -3858,8 +3858,10 @@ void SMPFunction::DetectLinkerStubFunction(void) { // have two basic blocks, with the second block being reached only by an indirect jump from // the first block (which happens through the PLT, but we are not checking that here), and then // the second block ending with a tail call jump, with no return instruction in the func. - if (this->RPOBlocks[0]->HasIndirectJump() - && ((1 == this->GetNumBlocks()) || this->RPOBlocks[this->GetNumBlocks() - 1]->EndsWithTailCall())) { + bool IDA_PLT = (this->RPOBlocks[0]->HasIndirectJump() + && ((1 == this->GetNumBlocks()) || this->RPOBlocks[this->GetNumBlocks() - 1]->EndsWithTailCall())); + bool IRDB_PLT = ((1 == this->GetNumBlocks()) && this->RPOBlocks[0]->EndsWithTailCall()); + if (IDA_PLT || IRDB_PLT) { this->LinkerStub = true; SMP_msg("INFO: Linker stub function found at %llx \n", (unsigned long long) this->GetFirstFuncAddr()); } -- GitLab