Skip to content
Snippets Groups Projects
Commit 8676455f authored by an7s's avatar an7s
Browse files

made coloring cfi work for cgc, and added clamp-mask option

parent 795de7f4
No related branches found
No related tags found
No related merge requests found
......@@ -271,32 +271,15 @@ void NonceRelocs_t::AddSlowPathInstructions()
// cmp ecx/r11, end_segment_addr
// jgt out_of_range_handler
#ifdef CGC
// CGC needs to keep from faulting, so we have to check to make sure the IB is an intra-module IB.
// if not, we terminate immediately.
// we aren't doing the pop/cmp before jumping to the slow path, so we have to do it here.
Instruction_t* after = insertAssemblyBefore(&m_firp,slow_path,"pop "+reg); // pop ecx (get ret addr)
tmp = insertAssemblyAfter(&m_firp,slow_path,"cmp "+reg+", 0x12345678");
out_of_range_handler=exit_node; // cgc is statically linked, so we can just go to the exit node.
#else
Instruction_t* after = insertAssemblyBefore(&m_firp,slow_path,"cmp "+reg+", 0x12345678");
tmp=slow_path;
#endif
min_addr_update.insert(tmp);
tmp = insertAssemblyAfter(&m_firp,tmp,"jl 0",out_of_range_handler); // cross library jump detected
tmp = insertAssemblyAfter(&m_firp,tmp,"cmp "+reg+", 0x87654321");
max_addr_update.insert(tmp);
tmp = insertAssemblyAfter(&m_firp,tmp,"jg 0",out_of_range_handler); // cross library jump detected
#ifdef CGC
// After we're sure it's in this segment, we can
// go ahead and check for a nonce that we layed down previously.
// cmp byte [ecx/r11-1], 0xf4
// jeq slow_path
tmp = insertAssemblyAfter(&m_firp,tmp,"cmp byte ["+reg+"-1], 0xf4");
tmp = insertAssemblyAfter(&m_firp,tmp,"jne 0",after); // finally, go to the slow path checks when a nonce didn't work.
tmp = insertAssemblyAfter(&m_firp,tmp,"jmp "+reg);
#endif // CGC
m_firp.AssembleRegistry(); // resolve all assembly into actual bits.
......
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