From b0a00fafb98416b235b17fbb4ae749babfa47681 Mon Sep 17 00:00:00 2001 From: Jason Hiser <jdhiser@gmail.com> Date: Sat, 1 Jun 2019 18:56:40 -0400 Subject: [PATCH] made sure landing pads are emitted into the binary --- src/zipr.cpp | 17 +++++++++++------ src/zipr_dollop_man.cpp | 9 ++++----- 2 files changed, 15 insertions(+), 11 deletions(-) diff --git a/src/zipr.cpp b/src/zipr.cpp index 7c636fa2f..143c701c5 100644 --- a/src/zipr.cpp +++ b/src/zipr.cpp @@ -827,16 +827,15 @@ void ZiprImpl_t::PlaceDollops() /* * used to check if a reference dollop needs to be added to the placement queue */ - const auto handle_reloc=[&](const Relocation_t* reloc) + const auto ensure_insn_is_placed=[&](Instruction_t* insn) { - auto wrt_insn=dynamic_cast<Instruction_t*>(reloc->getWRT()); - if(wrt_insn) + if(insn != nullptr) { - auto containing=m_dollop_mgr.getContainingDollop(wrt_insn); + auto containing=m_dollop_mgr.addNewDollops(insn); assert(containing!=nullptr); if(!containing->isPlaced()) { - placement_queue.insert({containing, wrt_insn->getAddress()->getVirtualOffset()}); + placement_queue.insert({containing, insn->getAddress()->getVirtualOffset()}); } } }; @@ -844,7 +843,13 @@ void ZiprImpl_t::PlaceDollops() // Make sure each instruction referenced in a relocation (regardless // of if that relocation is on an instruction or a scoop) gets placed. for(const auto &reloc : m_firp->getRelocations()) - handle_reloc(reloc); + ensure_insn_is_placed(dynamic_cast<Instruction_t*>(reloc->getWRT())); + + // Make sure each landing pad in a program gets placed. + for(const auto &cs : m_firp->getAllEhCallSites()) + ensure_insn_is_placed(cs->getLandingPad()); + + m_dollop_mgr.UpdateAllTargets(); while (!placement_queue.empty()) { diff --git a/src/zipr_dollop_man.cpp b/src/zipr_dollop_man.cpp index 72582ba43..c7c374f93 100644 --- a/src/zipr_dollop_man.cpp +++ b/src/zipr_dollop_man.cpp @@ -159,11 +159,10 @@ namespace zipr { } } - Zipr_SDK::Dollop_t *ZiprDollopManager_t::getContainingDollop(IRDB_SDK::Instruction_t *insn) { - InsnToDollopMap_t::iterator it=m_insn_to_dollop.find(insn); - if(it!=m_insn_to_dollop.end()) - return it->second; - return nullptr; + Zipr_SDK::Dollop_t *ZiprDollopManager_t::getContainingDollop(IRDB_SDK::Instruction_t *insn) + { + const auto it=m_insn_to_dollop.find(insn); + return it!=m_insn_to_dollop.end() ? it->second : nullptr; } -- GitLab