39 std::optional<recomp::reloc_t*> reloc;
40 if (!(reloc = has_next_inst_reloc(sym)).has_value())
43 xed_decoded_inst_t inst = m_tmp_inst;
44 std::vector<std::uint8_t> new_inst_bytes =
49 std::uint32_t inst_len = {};
50 std::uint8_t inst_buff[XED_MAX_INSTRUCTION_BYTES];
53 xed_encoder_request_t req;
54 xed_state_t istate{XED_MACHINE_MODE_LONG_64, XED_ADDRESS_WIDTH_64b};
56 xed_encoder_request_zero_set_mode(&req, &istate);
57 xed_encoder_request_set_effective_operand_width(&req, 64);
58 xed_encoder_request_set_iclass(&req, XED_ICLASS_PUSH);
60 xed_encoder_request_set_mem0(&req);
61 xed_encoder_request_set_operand_order(&req, 0, XED_OPERAND_MEM0);
63 xed_encoder_request_set_base0(&req, XED_REG_RIP);
64 xed_encoder_request_set_seg0(&req, XED_REG_INVALID);
65 xed_encoder_request_set_index(&req, XED_REG_INVALID);
66 xed_encoder_request_set_scale(&req, 0);
68 xed_encoder_request_set_memory_operand_length(&req, 8);
69 xed_encoder_request_set_memory_displacement(&req, new_inst_bytes.size() + 1,
72 if ((err = xed_encode(&req, inst_buff,
sizeof(inst_buff), &inst_len)) !=
74 spdlog::info(
"failed to encode instruction... reason: {}",
75 xed_error_enum_t2str(err));
77 assert(err == XED_ERROR_NONE);
80 new_inst_bytes.insert(new_inst_bytes.begin(), inst_buff,
81 inst_buff + inst_len);
85 new_inst_bytes.push_back(0xC3);
87 sym->
data().insert(sym->
data().end(), new_inst_bytes.begin(),
88 new_inst_bytes.end());
90 reloc.value()->offset(sym->
data().size());
91 sym->
data().resize(sym->
data().size() + 8);
94std::optional<recomp::reloc_t*> next_inst_pass_t::has_next_inst_reloc(
96 auto res = std::find_if(
100 return res != sym->
relocs().end() ? &(*res)
101 : std::optional<recomp::reloc_t*>();