From d918e4ae5ebae423ee43799c0d9cfb87650b741e Mon Sep 17 00:00:00 2001 From: Jason Hiser <jdhiser@gmail.com> Date: Sat, 16 Feb 2019 09:13:37 -0500 Subject: [PATCH] changes to support scons from peasoup-umbrella dir --- .gitignore | 2 ++ SConscript | 3 ++- push64_relocs.cpp | 33 ++++++++++++--------------------- push64_relocs.h | 7 ++++--- 4 files changed, 20 insertions(+), 25 deletions(-) diff --git a/.gitignore b/.gitignore index f96c1da91..b788bd0e3 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,5 @@ +*.os +*.zpi .sconsign.dblite build *.swp diff --git a/SConscript b/SConscript index e5ab635a3..8f4105044 100644 --- a/SConscript +++ b/SConscript @@ -65,4 +65,5 @@ Default( pedi ) - +ret=pedi+lib +Return('ret') diff --git a/push64_relocs.cpp b/push64_relocs.cpp index 532ee7689..82b78bb13 100644 --- a/push64_relocs.cpp +++ b/push64_relocs.cpp @@ -57,11 +57,8 @@ bool Push64Relocs_t::IsRelocationWithType(Relocation_t *reloc,std::string type) // would be nice to have a FindRelocation function that takes a parameterized type. Relocation_t* Push64Relocs_t::FindRelocationWithType(Instruction_t* insn, std::string type) { - Instruction_t* first_slow_path_insn=NULL; - RelocationSet_t::iterator rit = insn->getRelocations().begin(); - for(rit; rit!=insn->getRelocations().end(); rit++) + for(auto reloc : insn->getRelocations()) { - Relocation_t *reloc=*rit; if (IsRelocationWithType(reloc, type)) return reloc; } @@ -160,22 +157,19 @@ void Push64Relocs_t::HandlePush64Relocs() int push64_relocations_count=0; int pcrel_relocations_count=0; // for each instruction - InstructionSet_t::iterator iit = m_firp.getInstructions().begin(); - for(iit; iit!=m_firp.getInstructions().end(); iit++) + for(auto insn : m_firp.getInstructions()) { - Instruction_t *insn=*iit; - - Relocation_t *reloc=NULL; + auto reloc= FindPushRelocation(insn); // caution, side effect in if statement. - if (reloc = FindPushRelocation(insn)) + if (reloc) { if (*m_verbose) cout << "Found a Push relocation:" << insn->getDisassembly()<<endl; HandlePush64Relocation(insn,reloc); push64_relocations_count++; } - // caution, side effect in if statement. - else if (reloc = FindPcrelRelocation(insn)) + reloc = FindPcrelRelocation(insn); + if (reloc) { if (*m_verbose) cout << "Found a pcrel relocation." << endl; @@ -197,13 +191,10 @@ void Push64Relocs_t::UpdatePush64Adds() { if (*m_verbose) cout << "push64:UpdatePush64Adds()" << endl; - InstructionSet_t::iterator insn_it = plopped_relocs.begin(); - for (insn_it; insn_it != plopped_relocs.end(); insn_it++) + for(auto insn : plopped_relocs) { - Relocation_t *reloc = NULL; - Instruction_t *insn = *insn_it; - // caution, side effect in if statement. - if (reloc = FindPushRelocation(insn)) + auto reloc = FindPushRelocation(insn); + if (reloc) { // would consider updating this if statement to be a function call for simplicity/readability. bool change_to_add = false; @@ -215,14 +206,14 @@ void Push64Relocs_t::UpdatePush64Adds() Instruction_t *call = NULL, *add = NULL; Relocation_t *add_reloc = NULL; - call = *insn_it; + call = insn; add = call->getTarget(); assert(call && add); call_addr = final_insn_locations[call]; add_addr = final_insn_locations[add]; - Instruction_t* wrt_insn=dynamic_cast<Instruction_t*>(reloc->getWRT()); + auto wrt_insn=dynamic_cast<Instruction_t*>(reloc->getWRT()); if(wrt_insn) wrt_addr=final_insn_locations[wrt_insn]; @@ -246,7 +237,7 @@ void Push64Relocs_t::UpdatePush64Adds() // would this be simpler if we always used an add (or sub) // and just signed the sign of the value we are adding (or subbing)? - if (add_offset>call_addr) + if ((size_t)add_offset>(size_t)call_addr) { change_to_add = true; if(wrt_insn) diff --git a/push64_relocs.h b/push64_relocs.h index af5a60f2d..f97caaa3a 100644 --- a/push64_relocs.h +++ b/push64_relocs.h @@ -92,12 +92,13 @@ class Push64Relocs_t : public Zipr_SDK::ZiprPluginInterface_t IRDB_SDK::Relocation_t* FindPushRelocation(IRDB_SDK::Instruction_t* insn) { - IRDB_SDK::Relocation_t* reloc=NULL; - if(reloc=FindPush64Relocation(insn)) + auto reloc=FindPush64Relocation(insn); + if(reloc) { return reloc; } - if(reloc=Find32BitRelocation(insn)) + reloc=Find32BitRelocation(insn); + if(reloc) { return reloc; } -- GitLab