diff --git a/include/zipr_impl.h b/include/zipr_impl.h index 73206ce75caa42b68d792ea02f62fe1d1aede7bb..8e31913ddd25e201d14f8f2fd6f306c0a7b856e6 100644 --- a/include/zipr_impl.h +++ b/include/zipr_impl.h @@ -80,7 +80,8 @@ class ZiprImpl_t : public Zipr_t Zipr_SDK::RangeAddress_t PlopDollopEntry( DollopEntry_t *, - RangeAddress_t override_place = 0); + RangeAddress_t override_place = 0, + RangeAddress_t override_target = 0); Zipr_SDK::RangeAddress_t PlopDollopEntryWithTarget( DollopEntry_t *, diff --git a/src/zipr.cpp b/src/zipr.cpp index 6c786b339c7e58d6e464e17e5b4ab877b70c6904..4744a716e6cd4bdd6b683ece8b98fc66103724cc 100644 --- a/src/zipr.cpp +++ b/src/zipr.cpp @@ -2488,8 +2488,24 @@ RangeAddress_t ZiprImpl_t::_PlopDollopEntry(DollopEntry_t *entry, RangeAddress_t size_t insn_wcis = DetermineWorstCaseInsnSize(insn, false); RangeAddress_t updated_addr = 0; RangeAddress_t placed_address = entry->Place(); + RangeAddress_t target_address = 0; bool placed_insn = false; + if (entry->TargetDollop() && entry->TargetDollop()->front()) + { + auto target_address_iter = final_insn_locations.find(entry-> + TargetDollop()-> + front()-> + Instruction()); + if (target_address_iter != final_insn_locations.end()) + { + target_address = target_address_iter->second; + if (m_verbose) + cout << "Found an updated target address location: " + << std::hex << target_address << endl; + } + } + map<Instruction_t*,unique_ptr<std::list<DLFunctionHandle_t>>>::const_iterator plop_it; if (override_address != 0) @@ -2505,6 +2521,7 @@ RangeAddress_t ZiprImpl_t::_PlopDollopEntry(DollopEntry_t *entry, RangeAddress_t ZiprPluginInterface_t *zpi = dynamic_cast<ZiprPluginInterface_t*>(handle); updated_addr = std::max(zpi->PlopDollopEntry(entry, placed_address, + target_address, insn_wcis, pp_placed_insn), updated_addr); @@ -2526,7 +2543,7 @@ RangeAddress_t ZiprImpl_t::_PlopDollopEntry(DollopEntry_t *entry, RangeAddress_t */ if (!placed_insn) { - updated_addr = PlopDollopEntry(entry, placed_address); + updated_addr = PlopDollopEntry(entry, placed_address, target_address); } final_insn_locations[insn] = placed_address; @@ -2538,7 +2555,8 @@ RangeAddress_t ZiprImpl_t::_PlopDollopEntry(DollopEntry_t *entry, RangeAddress_t RangeAddress_t ZiprImpl_t::PlopDollopEntry( DollopEntry_t *entry, - RangeAddress_t override_place) + RangeAddress_t override_place, + RangeAddress_t override_target) { Instruction_t *insn = entry->Instruction(); RangeAddress_t ret = entry->Place(), addr = entry->Place(); @@ -2617,9 +2635,19 @@ RangeAddress_t ZiprImpl_t::PlopDollopEntry( { RangeAddress_t target_address = 0; Instruction_t *target_insn = entry->TargetDollop()->front()->Instruction(); - - if (final_insn_locations.end() != final_insn_locations.find(target_insn)) - target_address = final_insn_locations[target_insn]; + + if (override_target != 0) + { + if (final_insn_locations.end() != final_insn_locations.find(target_insn)) + target_address = final_insn_locations[target_insn]; + } + else + { + if (m_verbose) + cout << "Plopping with overriden target: " + << std::hex << override_target << endl; + target_address = override_target; + } if (m_verbose) cout << "Plopping at " << std::hex << addr