Added POP intruction support to arithmetic partitioning transform.

This commit is contained in:
Ege Balcı
2024-03-18 15:36:47 +01:00
parent 11fe4e7ab4
commit b56595be70
3 changed files with 27 additions and 1 deletions
+1 -1
View File
@@ -240,7 +240,7 @@ impl Deoptimizer {
let mut decoder = Decoder::with_ip(bitness, bytes, start_addr, DecoderOptions::NONE);
let replaced_bytes: Vec<u8>;
if self.skipped_offsets.is_some() {
replaced_bytes = self.replace_skipped_offsets(&bytes.clone(), 0x90)?;
replaced_bytes = self.replace_skipped_offsets(&bytes, 0x90)?;
decoder = Decoder::with_ip(bitness, &replaced_bytes, start_addr, DecoderOptions::NONE);
}
+14
View File
@@ -536,6 +536,20 @@ mod tests {
let mut decoder32 = Decoder::new(32, code_32, DecoderOptions::NONE);
let mut inst = Instruction::default();
let mut offset = 0;
fn convert_to_byte_value_instructions(
bitness: u32,
bytes: &[u8],
rip: u64,
) -> Result<Vec<Instruction>, DeoptimizerError> {
let mut result = Vec::new();
// let bytes = get_instruction_bytes(bitness, [inst].to_vec())?;
for b in bytes.iter() {
result.push(Instruction::with_declare_byte_1(*b));
}
Ok(rencode(bitness, result, rip)?)
}
while decoder64.can_decode() {
decoder64.decode_out(&mut inst);
let mut dbs = convert_to_byte_value_instructions(
@@ -28,6 +28,18 @@ pub fn apply_ap_transform(
0,
)?;
}
if inst.mnemonic() == Mnemonic::Pop {
let mut info_factory = InstructionInfoFactory::new();
let info = info_factory.info(&inst);
let op0_size = get_op_size(0, inst)? * 8;
let rand_reg =
get_random_gp_register(bitness == 64, op0_size, Some(info.used_registers()))?;
fix_inst = Instruction::with1(
get_code_with_str(&format!("Xchg_rm{op0_size}_rm{op0_size}")),
rand_reg,
)?;
return Ok(rencode(bitness, [*inst, fix_inst].to_vec(), rip)?);
}
if inst.mnemonic() == Mnemonic::Mov && inst.op1_kind() == OpKind::Immediate64 {
set_op_immediate(inst, 1, !imm)?;
fix_inst = Instruction::with1(get_code_with_str("Not_rm64"), inst.op0_register())?;