From 31d86f8a7217ce03b5718222005e28326e3492bd Mon Sep 17 00:00:00 2001 From: Matthew McGill <mm8bx@mega-techx41.maas> Date: Wed, 18 Jul 2018 16:53:42 +0000 Subject: [PATCH] No longer lying about IBTA --- unpin.cpp | 28 ++++++++++++++++++++++------ 1 file changed, 22 insertions(+), 6 deletions(-) diff --git a/unpin.cpp b/unpin.cpp index 02620f1da..a9cacb64b 100644 --- a/unpin.cpp +++ b/unpin.cpp @@ -160,8 +160,8 @@ void Unpin_t::DoUnpinForFixedCalls() if(should_cfi_pin(wrt_insn)) continue; - - if(wrt_insn->GetIndirectBranchTargetAddress()) + // leave this for debugging I guess? + if(wrt_insn->GetIndirectBranchTargetAddress() && wrt_insn->GetIndirectBranchTargetAddress()->GetVirtualOffset()!=0) { cout<<"Unpin::Found "<<reloc->GetType()<<" relocation for pinned insn at "<<hex<< wrt_insn->GetIndirectBranchTargetAddress()->GetVirtualOffset()<<endl; @@ -171,6 +171,14 @@ void Unpin_t::DoUnpinForFixedCalls() cout<<"Unpin::Warn: unpin found non-IBTA to unpin. probably it's unpinned twice. continuing anyhow."<<endl; } + PlacementQueue_t* pq=zo->GetPlacementQueue(); + assert(pq); + + // create a new dollop for the unpinned IBT + // and add it to the placement queue. + Dollop_t *newDoll=zo->GetDollopManager()->AddNewDollops(wrt_insn); + pq->insert(std::pair<Dollop_t*,RangeAddress_t>(newDoll, 0)); + unpins++; insn_unpins++; if(m_max_unpins != -1 && unpins>=m_max_unpins) @@ -215,9 +223,9 @@ void Unpin_t::DoUnpinForScoops() // safe cast and check. assert(insn); - - if(insn->GetIndirectBranchTargetAddress()) - { + // leave this for debugging I guess? + if(insn->GetIndirectBranchTargetAddress() && insn->GetIndirectBranchTargetAddress()->GetVirtualOffset()!=0) + { cout<<"Unpin::Found data_to_insn_ptr relocation for pinned insn:" <<hex<<insn->GetBaseID()<<":" <<insn->getDisassembly()<<" at " <<hex<< insn->GetIndirectBranchTargetAddress()->GetVirtualOffset()<<endl; @@ -238,7 +246,15 @@ void Unpin_t::DoUnpinForScoops() missed_unpins++; } else - { + { + PlacementQueue_t* pq=zo->GetPlacementQueue(); + assert(pq); + + // create a new dollop for the unpinned IBT + // and add it to the placement queue. + Dollop_t *newDoll=zo->GetDollopManager()->AddNewDollops(insn); + pq->insert(std::pair<Dollop_t*,RangeAddress_t>(newDoll, 0)); + unpins++; scoop_unpins++; if(m_max_unpins != -1 && unpins>=m_max_unpins) -- GitLab