5#include "tpde/FunctionWriter.hpp"
6#include "tpde/base.hpp"
16 void align(
size_t align)
noexcept {
18 FunctionWriter::align(align);
20 if (u32 cur_off =
offset(); cur_off > old_off) {
21 fe64_NOP(
cur_ptr() - (cur_off - old_off), cur_off - old_off);
26 void handle_fixups()
noexcept;
29inline void FunctionWriterX64::handle_fixups() noexcept {
31 u32 label_off = label_offset(fixup.label);
34 case LabelFixupKind::X64_JMP_OR_MEM_DISP: {
36 u32 value = (label_off - fixup.off) - 4;
37 std::memcpy(dst_ptr, &value,
sizeof(u32));
40 case LabelFixupKind::X64_JUMP_TABLE: {
41 const auto table_off = *
reinterpret_cast<u32 *
>(dst_ptr);
42 const auto diff = (i32)label_off - (i32)table_off;
43 std::memcpy(dst_ptr, &diff,
sizeof(u32));
46 default: TPDE_UNREACHABLE(
"unexpected label fixup kind");
size_t offset() const noexcept
util::SmallVector< LabelFixup > label_fixups
u8 * begin_ptr() noexcept
Helper class to write function text for X64.