MCPcopy Create free account
hub / github.com/GJDuck/e9patch / tactic_T2

Function tactic_T2

src/e9patch/e9tactics.cpp:522–552  ·  view source on GitHub ↗

* Tactic T2: evict the successor instruction. */

Source from the content-addressed store, hash-verified

520 * Tactic T2: evict the successor instruction.
521 */
522static Patch *tactic_T2(Binary &B, Instr *I, const Trampoline *T)
523{
524 if (I->size >= JMP_SIZE || !option_tactic_T2 || !canPatch(I))
525 return nullptr;
526
527 // Step (1): Evict the successor instruction:
528 Instr *J = I->succ();
529 if (J == nullptr || !canPatch(J))
530 return nullptr;
531 const Trampoline *U = evicteeTrampoline;
532 Patch *Q = nullptr;
533 Q = (Q == nullptr? tactic_B2(B, J, U, TACTIC_T2): Q);
534 Q = (Q == nullptr? tactic_T1(B, J, U, TACTIC_T2): Q);
535 if (Q == nullptr)
536 return nullptr;
537
538 // Step (2): Patch the instruction:
539 Patch *P = nullptr;
540 P = (P == nullptr? tactic_B2(B, I, T, TACTIC_T2): P);
541 P = (P == nullptr? tactic_T1(B, I, T, TACTIC_T2): P);
542
543 if (P == nullptr)
544 {
545 undo(B, Q);
546 return nullptr;
547 }
548 P->tactic = TACTIC_T2;
549 P->next = Q;
550
551 return P;
552}
553
554/*
555 * Tactic T3 (single-byte instruction): evict a neighbour instruction.

Callers 1

patchFunction · 0.85

Calls 5

canPatchFunction · 0.85
tactic_B2Function · 0.85
tactic_T1Function · 0.85
undoFunction · 0.85
succMethod · 0.80

Tested by

no test coverage detected