Skip to content
Snippets Groups Projects
Commit 356757cf authored by Jason Hiser's avatar Jason Hiser :tractor:
Browse files

refactored to deal with options better

parent 2ca8f310
No related branches found
No related tags found
No related merge requests found
......@@ -39,18 +39,14 @@ using namespace std;
#define ALLOF(a) begin(a), end(a)
Push64Relocs_t::Push64Relocs_t(MemorySpace_t *p_ms,
FileIR_t *p_firp,
InstructionLocationMap_t *p_fil) :
m_memory_space(*p_ms),
m_firp(*p_firp),
final_insn_locations(*p_fil),
m_verbose("verbose")
Push64Relocs_t::Push64Relocs_t(Zipr_SDK::Zipr_t* zipr_object)
:
m_memory_space (*zipr_object->getMemorySpace()),
m_firp (*zipr_object->getFileIR()),
final_insn_locations(*zipr_object->getLocationMap())
{
}
ZiprOptionsNamespace_t *Push64Relocs_t::registerOptions(ZiprOptionsNamespace_t *global) {
global->addOption(&m_verbose);
return NULL;
auto global= zipr_object->getOptionsManager()->getNamespace("global");
m_verbose = global->getBooleanOption("verbose");
}
bool Push64Relocs_t::IsRelocationWithType(Relocation_t *reloc,std::string type)
......@@ -99,7 +95,7 @@ void Push64Relocs_t::HandlePush64Relocation(Instruction_t *insn, Relocation_t *r
*/
push_addr = *((VirtualOffset_t*)(&push_data_bits[1]));
if (m_verbose)
if (*m_verbose)
cout << "push_addr: 0x" << std::hex << push_addr << endl;
assert(push_addr != 0);
......@@ -149,7 +145,7 @@ void Push64Relocs_t::HandlePush64Relocation(Instruction_t *insn, Relocation_t *r
*/
auto add_reloc=m_firp.addNewRelocation(add_insn,push_addr,"add64");
if (m_verbose)
if (*m_verbose)
cout << "Adding an add/sub with reloc offset 0x"
<< std::hex << add_reloc->getOffset()
<< endl;
......@@ -173,7 +169,7 @@ void Push64Relocs_t::HandlePush64Relocs()
// caution, side effect in if statement.
if (reloc = FindPushRelocation(insn))
{
if (m_verbose)
if (*m_verbose)
cout << "Found a Push relocation:" << insn->getDisassembly()<<endl;
HandlePush64Relocation(insn,reloc);
push64_relocations_count++;
......@@ -181,7 +177,7 @@ void Push64Relocs_t::HandlePush64Relocs()
// caution, side effect in if statement.
else if (reloc = FindPcrelRelocation(insn))
{
if (m_verbose)
if (*m_verbose)
cout << "Found a pcrel relocation." << endl;
plopped_relocs.insert(insn);
pcrel_relocations_count++;
......@@ -199,7 +195,7 @@ void Push64Relocs_t::HandlePush64Relocs()
void Push64Relocs_t::UpdatePush64Adds()
{
if (m_verbose)
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++)
......@@ -232,7 +228,7 @@ void Push64Relocs_t::UpdatePush64Adds()
if (call_addr == 0 || add_addr == 0)
{
if (m_verbose)
if (*m_verbose)
cout << "push64:Call/Add pair not plopped?" << endl;
continue;
}
......@@ -291,8 +287,5 @@ extern "C"
Zipr_SDK::ZiprPluginInterface_t* GetPluginInterface(
Zipr_SDK::Zipr_t* zipr_object)
{
auto *p_ms=zipr_object->getMemorySpace();
auto *p_firp=zipr_object->getFileIR();
auto *p_fil=zipr_object->getLocationMap();
return new Push64Relocs_t(p_ms,p_firp,p_fil);
return new Push64Relocs_t(zipr_object);
}
......@@ -37,9 +37,8 @@
class Push64Relocs_t : public Zipr_SDK::ZiprPluginInterface_t
{
public:
Push64Relocs_t(Zipr_SDK::MemorySpace_t *p_ms,
IRDB_SDK::FileIR_t *p_firp,
Zipr_SDK::InstructionLocationMap_t *p_fil);
Push64Relocs_t(Zipr_SDK::Zipr_t* zipr_object);
virtual void doPinningEnd() override
{
// if(m_elfio.get_type()==ET_EXEC)
......@@ -63,7 +62,7 @@ class Push64Relocs_t : public Zipr_SDK::ZiprPluginInterface_t
UpdatePush64Adds();
}
virtual Zipr_SDK::ZiprOptionsNamespace_t *registerOptions(Zipr_SDK::ZiprOptionsNamespace_t *) override;
// virtual Zipr_SDK::ZiprOptionsNamespace_t *registerOptions(Zipr_SDK::ZiprOptionsNamespace_t *) override;
private:
// main workhorses
void HandlePush64Relocs();
......@@ -119,7 +118,7 @@ class Push64Relocs_t : public Zipr_SDK::ZiprPluginInterface_t
// local data.
IRDB_SDK::InstructionSet_t plopped_relocs;
Zipr_SDK::ZiprBooleanOption_t m_verbose;
Zipr_SDK::ZiprBooleanOption_t *m_verbose;
};
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment