diff --git a/include/zipr_impl.h b/include/zipr_impl.h index 2114643fe71ddd0dc927dfe15805dc97adb18385..68c034eb3941d64e9d408127bc4de37246abcb03 100644 --- a/include/zipr_impl.h +++ b/include/zipr_impl.h @@ -444,8 +444,10 @@ class ZiprImpl_t : public Zipr_t { assert(p1.GetInstruction()); assert(p2.GetInstruction()); - assert(p1.GetInstruction()->GetIndirectBranchTargetAddress()); - assert(p2.GetInstruction()->GetIndirectBranchTargetAddress()); + assert(p1.GetInstruction()->GetIndirectBranchTargetAddress() + && p1.GetInstruction()->GetIndirectBranchTargetAddress()->GetVirtualOffset()!=0); + assert(p2.GetInstruction()->GetIndirectBranchTargetAddress() + && p2.GetInstruction()->GetIndirectBranchTargetAddress()->GetVirtualOffset()!=0); return p1.GetInstruction()->GetIndirectBranchTargetAddress()->GetVirtualOffset() < p2.GetInstruction()->GetIndirectBranchTargetAddress()->GetVirtualOffset() ; diff --git a/src/dollop.cpp b/src/dollop.cpp index 23160aed9f5248e16956a3451cfa94c1b1918b04..589183f49e6d469e6c3fdf8c516a5d041b1eaa32 100644 --- a/src/dollop.cpp +++ b/src/dollop.cpp @@ -25,7 +25,8 @@ namespace Zipr_SDK { /* * If this is a pinned instruction, we want to stop! */ - (NULL == loop->GetIndirectBranchTargetAddress()) + (NULL == loop->GetIndirectBranchTargetAddress() + || loop->GetIndirectBranchTargetAddress()->GetVirtualOffset()==0) ); m_size = CalculateWorstCaseSize(); diff --git a/src/zipr.cpp b/src/zipr.cpp index ed0f94038a923005ac6faf730b491e9cc19335f6..14fa4d79ee834b7a11117d9f3b24d7f085e998ec 100644 --- a/src/zipr.cpp +++ b/src/zipr.cpp @@ -790,7 +790,8 @@ void ZiprImpl_t::RecordPinnedInsnAddrs() Instruction_t* insn=*it; assert(insn); - if(!insn->GetIndirectBranchTargetAddress()) + if(!insn->GetIndirectBranchTargetAddress() + || insn->GetIndirectBranchTargetAddress()->GetVirtualOffset()==0) { continue; } @@ -838,7 +839,7 @@ bool ZiprImpl_t::ShouldPinImmediately(Instruction_t *upinsn) return true; upinsn_ibta=upinsn->GetIndirectBranchTargetAddress(); - assert(upinsn_ibta!=NULL); + assert(upinsn_ibta!=NULL && upinsn_ibta->GetVirtualOffset()!=0); if (upinsn->GetFallthrough() != NULL) ft_ibta=upinsn->GetFallthrough()->GetIndirectBranchTargetAddress(); @@ -2249,10 +2250,17 @@ void ZiprImpl_t::PlaceDollops() * possibility of the validity of the placement in (2). */ initial_placement_abuts_pin = to_place->FallthroughDollop() && - to_place->FallthroughDollop()-> + ( to_place->FallthroughDollop()-> front()-> Instruction()-> - GetIndirectBranchTargetAddress() && + GetIndirectBranchTargetAddress() + && + to_place->FallthroughDollop()-> + front()-> + Instruction()-> + GetIndirectBranchTargetAddress()-> + GetVirtualOffset()!=0 + ) && to_place->FallthroughDollop()-> front()-> Instruction()-> @@ -2367,8 +2375,9 @@ void ZiprImpl_t::PlaceDollops() << "a fallthrough" << endl; } - if (to_place->front()->Instruction()->GetIndirectBranchTargetAddress() && - cur_addr == to_place-> + if (( to_place->front()->Instruction()->GetIndirectBranchTargetAddress() + && to_place->front()->Instruction()->GetIndirectBranchTargetAddress()->GetVirtualOffset()!=0 + ) && cur_addr == to_place-> front()-> Instruction()-> GetIndirectBranchTargetAddress()-> @@ -2636,11 +2645,17 @@ void ZiprImpl_t::PlaceDollops() * first instruction is pinned AND the last entry of this * dollop abuts that pin. */ - if ((fallthrough-> - front()-> - Instruction()-> - GetIndirectBranchTargetAddress() - ) && + if (( fallthrough-> + front()-> + Instruction()-> + GetIndirectBranchTargetAddress() + && + fallthrough-> + front()-> + Instruction()-> + GetIndirectBranchTargetAddress()-> + GetVirtualOffset()!=0 + ) && (cur_addr == fallthrough-> front()-> Instruction()->