diff --git a/libIRDB/test/fill_in_cfg.cpp b/libIRDB/test/fill_in_cfg.cpp index 597830db3cd40cf66673089f5cfd9dcf2997c45f..e0719bcce5cd5f0a60ecaed62ec1fe1752715108 100644 --- a/libIRDB/test/fill_in_cfg.cpp +++ b/libIRDB/test/fill_in_cfg.cpp @@ -561,17 +561,19 @@ void fill_in_landing_pads(FileIR_t *firp) map<Function_t*,set<Instruction_t*> > insns_to_add_to_funcs; - for_each(firp->GetInstructions().begin(), firp->GetInstructions().end(), [&](Instruction_t* t) + // for_each(firp->GetInstructions().begin(), firp->GetInstructions().end(), [&](Instruction_t* t) + for(const auto t : firp->GetInstructions()) { if(t->GetFunction()==NULL) - return; + continue; auto lp=eh_frame_rep_ptr->find_lp(t); if(lp && lp->GetFunction()==NULL) insns_to_add_to_funcs[t->GetFunction()].insert(lp); - }); + }; - for_each(insns_to_add_to_funcs.begin(), insns_to_add_to_funcs.end(), [&](pair<Function_t* const,set<Instruction_t*> > & p) + // for_each(insns_to_add_to_funcs.begin(), insns_to_add_to_funcs.end(), [&](pair<Function_t* const,set<Instruction_t*> > & p) + for(const auto & p : insns_to_add_to_funcs) { auto & func=p.first; auto insns=p.second; /* copy */ @@ -603,7 +605,7 @@ void fill_in_landing_pads(FileIR_t *firp) if(fallthru) insns.insert(fallthru); } cout<<"Found LP outside of function "<<func->GetName()<<" added "<<insn_count<<" instructions"<<endl; - }); + }; } diff --git a/libIRDB/test/split_eh_frame.cpp b/libIRDB/test/split_eh_frame.cpp index 1c551957d39dac968779249edae9291e03c455ad..5fe9917ca74eb45169f5d3deee9bc383ddf9c387 100644 --- a/libIRDB/test/split_eh_frame.cpp +++ b/libIRDB/test/split_eh_frame.cpp @@ -270,13 +270,17 @@ void split_eh_frame_impl_t<ptrsize>::build_ir() const const auto fie_it=fdes.find(tofind); */ const auto find_addr=insn->GetAddress()->GetVirtualOffset(); + /* + too slow const auto finder=[&](const shared_ptr<FDEContents_t>& fde) -> bool { return fde->getStartAddress() <= find_addr && find_addr < fde->getEndAddress(); }; const auto fie_ptr_it=find_if ( ALLOF(*fdes), finder); + */ + const auto fie_ptr=eh_frame_parser->findFDE(find_addr); - if(fie_ptr_it!=fdes->end()) + if(fie_ptr != nullptr ) { - const auto fie_ptr=*fie_ptr_it; + // const auto fie_ptr=*fie_ptr_it; if(getenv("EHIR_VERBOSE")!=NULL) { @@ -486,20 +490,21 @@ void split_eh_frame_impl_t<ptrsize>::build_ir() const template <int ptrsize> libIRDB::Instruction_t* split_eh_frame_impl_t<ptrsize>::find_lp(libIRDB::Instruction_t* i) const { + const auto find_addr=i->GetAddress()->GetVirtualOffset(); //const auto tofind=fde_contents_t<ptrsize>( i->GetAddress()->GetVirtualOffset(), i->GetAddress()->GetVirtualOffset()+1); //const auto fde_it=fdes.find(tofind); - const auto find_addr=i->GetAddress()->GetVirtualOffset(); + /* too slow const auto fde_ptr_it=find_if ( ALLOF(*fdes), [&](const shared_ptr<FDEContents_t>& fde) { return fde->getStartAddress() <= find_addr && find_addr < fde->getEndAddress(); } ); + */ + const auto fde_ptr=eh_frame_parser->findFDE(find_addr); - if(fde_ptr_it==fdes->end()) - return NULL; + if(fde_ptr==nullptr) + return nullptr; - const auto fde_ptr=*fde_ptr_it; - const auto &the_fde=*fde_ptr; const auto &the_lsda_ptr=the_fde.getLSDA(); const auto &the_lsda=*the_lsda_ptr; @@ -510,7 +515,7 @@ libIRDB::Instruction_t* split_eh_frame_impl_t<ptrsize>::find_lp(libIRDB::Instruc { return lsda_call_site_appliesTo(*cs,i); }); if(cstab_it==cstab.end()) - return NULL; + return nullptr; const auto &the_cstab_entry_ptr=*cstab_it; const auto &the_cstab_entry=*the_cstab_entry_ptr; @@ -519,7 +524,7 @@ libIRDB::Instruction_t* split_eh_frame_impl_t<ptrsize>::find_lp(libIRDB::Instruc const auto om_it=offset_to_insn_map.find(lp_addr); if(om_it==offset_to_insn_map.end()) - return NULL; + return nullptr; auto lp=om_it->second; return lp; @@ -573,6 +578,8 @@ split_eh_frame_impl_t<ptrsize>::split_eh_frame_impl_t(FileIR_t* p_firp) if(eh_frame_parser!=NULL) fdes=eh_frame_parser->getFDEs(); + + (void)init_offset_map(); } unique_ptr<split_eh_frame_t> split_eh_frame_t::factory(FileIR_t *firp) diff --git a/libehp b/libehp index 3a620bef44acdb168c54cfa6a1a5354e1439fc25..9e90afedeaa8474d158a452205f6271172c7d78d 160000 --- a/libehp +++ b/libehp @@ -1 +1 @@ -Subproject commit 3a620bef44acdb168c54cfa6a1a5354e1439fc25 +Subproject commit 9e90afedeaa8474d158a452205f6271172c7d78d