generate a sequence of transformations given an instruction that has a relocation in it.
49 auto num_transforms = transform::operation_t::random(low, high);
51 std::vector<std::uint8_t> new_inst_bytes;
53 std::uint32_t inst_len = {};
54 std::uint8_t inst_buff[XED_MAX_INSTRUCTION_BYTES];
55 xed_encoder_request_t req;
57 xed_state_t istate{XED_MACHINE_MODE_LONG_64, XED_ADDRESS_WIDTH_64b};
58 xed_encoder_request_zero_set_mode(&req, &istate);
59 xed_encoder_request_set_effective_operand_width(&req, 64);
60 xed_encoder_request_set_iclass(&req, XED_ICLASS_PUSHFQ);
61 xed_encode(&req, inst_buff,
sizeof(inst_buff), &inst_len);
62 new_inst_bytes.insert(new_inst_bytes.end(), inst_buff, inst_buff + inst_len);
64 for (
auto cnt = 0u; cnt < num_transforms; ++cnt) {
65 std::uint32_t imm = transform::operation_t::random(
66 0, std::numeric_limits<std::int32_t>::max());
69 std::advance(itr, transform::operation_t::random(0, num_ops - 1));
70 auto transform_bytes = itr->second->native(inst, imm);
71 new_inst_bytes.insert(new_inst_bytes.end(), transform_bytes.begin(),
72 transform_bytes.end());
78 xed_encoder_request_zero_set_mode(&req, &istate);
79 xed_encoder_request_set_effective_operand_width(&req, 64);
80 xed_encoder_request_set_iclass(&req, XED_ICLASS_POPFQ);
81 xed_encode(&req, inst_buff,
sizeof(inst_buff), &inst_len);
82 new_inst_bytes.insert(new_inst_bytes.end(), inst_buff, inst_buff + inst_len);
86 std::reverse(reloc->get_transforms().begin(), reloc->get_transforms().end());
87 return new_inst_bytes;