Skip to content
Snippets Groups Projects
Commit 5150a62a authored by jdh8d's avatar jdh8d
Browse files

updates (all over the place) for CFI with multimodule support.

parent e0638f64
No related branches found
No related tags found
No related merge requests found
...@@ -221,7 +221,7 @@ void Push64Relocs_t::HandlePush64Relocs() ...@@ -221,7 +221,7 @@ void Push64Relocs_t::HandlePush64Relocs()
void Push64Relocs_t::UpdatePush64Adds() void Push64Relocs_t::UpdatePush64Adds()
{ {
if (m_verbose) if (m_verbose)
cout << "UpdatePush64Adds()" << endl; cout << "push64:UpdatePush64Adds()" << endl;
InstructionSet_t::iterator insn_it = plopped_relocs.begin(); InstructionSet_t::iterator insn_it = plopped_relocs.begin();
for (insn_it; insn_it != plopped_relocs.end(); insn_it++) for (insn_it; insn_it != plopped_relocs.end(); insn_it++)
{ {
...@@ -234,6 +234,7 @@ void Push64Relocs_t::UpdatePush64Adds() ...@@ -234,6 +234,7 @@ void Push64Relocs_t::UpdatePush64Adds()
bool change_to_add = false; bool change_to_add = false;
RangeAddress_t call_addr = 0; RangeAddress_t call_addr = 0;
RangeAddress_t add_addr = 0; RangeAddress_t add_addr = 0;
RangeAddress_t wrt_addr = 0;
int add_offset = 0; int add_offset = 0;
uint32_t relocated_value = 0; uint32_t relocated_value = 0;
Instruction_t *call = NULL, *add = NULL; Instruction_t *call = NULL, *add = NULL;
...@@ -246,16 +247,19 @@ void Push64Relocs_t::UpdatePush64Adds() ...@@ -246,16 +247,19 @@ void Push64Relocs_t::UpdatePush64Adds()
call_addr = final_insn_locations[call]; call_addr = final_insn_locations[call];
add_addr = final_insn_locations[add]; add_addr = final_insn_locations[add];
Instruction_t* wrt_insn=dynamic_cast<Instruction_t*>(reloc->GetWRT());
if(wrt_insn)
wrt_addr=final_insn_locations[wrt_insn];
if (call_addr == 0 || add_addr == 0) if (call_addr == 0 || add_addr == 0)
{ {
if (m_verbose) if (m_verbose)
cout << "Call/Add pair not plopped?" << endl; cout << "push64:Call/Add pair not plopped?" << endl;
continue; continue;
} }
add_reloc = FindAdd64Relocation(add); add_reloc = FindAdd64Relocation(add);
assert(add_reloc && "Add in Call/Add pair must have relocation."); assert(add_reloc && "push64:Add in Call/Add pair must have relocation.");
add_offset = add_reloc->GetOffset(); add_offset = add_reloc->GetOffset();
...@@ -270,19 +274,26 @@ void Push64Relocs_t::UpdatePush64Adds() ...@@ -270,19 +274,26 @@ void Push64Relocs_t::UpdatePush64Adds()
if (add_offset>call_addr) if (add_offset>call_addr)
{ {
change_to_add = true; change_to_add = true;
relocated_value = add_offset-call_addr; if(wrt_insn)
relocated_value= wrt_addr - call_addr;
else
relocated_value = add_offset - call_addr;
} }
else else
// never covert it, a sub with a negative value is just fine.
{ {
relocated_value = call_addr-add_offset; if(wrt_insn)
relocated_value= call_addr - wrt_addr;
else
relocated_value = call_addr - add_offset;
} }
cout << "Relocating a(n) "<< ((change_to_add) ? "add":"sub") << " from " cout << "Push64:Relocating a(n) "<< ((change_to_add) ? "add":"sub") << " from "
<< std::hex << call_addr << std::hex << call_addr
<< " at " << " at "
<< std::hex << add_addr << std::hex << add_addr
<< endl << endl
<< "Using 0x" << std::hex << relocated_value << "push64:Using 0x" << std::hex << relocated_value
<< " as the updated offset." << endl << " as the updated offset." << endl
<< "Using 0x" << std::hex << add_offset << "Using 0x" << std::hex << add_offset
<< " as the base offset." << endl; << " as the base offset." << endl;
...@@ -313,7 +324,7 @@ void Push64Relocs_t::UpdatePush64Adds() ...@@ -313,7 +324,7 @@ void Push64Relocs_t::UpdatePush64Adds()
if (insn_addr == 0) if (insn_addr == 0)
{ {
if (m_verbose) if (m_verbose)
cout << "Skipping unplopped Pcrel relocation." << endl; cout << "push64:Skipping unplopped Pcrel relocation." << endl;
continue; continue;
} }
assert(insn_addr != 0); assert(insn_addr != 0);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment