summaryrefslogtreecommitdiff
path: root/src/core/arm/nce/patcher.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/core/arm/nce/patcher.h')
-rw-r--r--src/core/arm/nce/patcher.h27
1 files changed, 17 insertions, 10 deletions
diff --git a/src/core/arm/nce/patcher.h b/src/core/arm/nce/patcher.h
index c6d1608c1..a44f385e2 100644
--- a/src/core/arm/nce/patcher.h
+++ b/src/core/arm/nce/patcher.h
@@ -31,9 +31,9 @@ public:
31 explicit Patcher(); 31 explicit Patcher();
32 ~Patcher(); 32 ~Patcher();
33 33
34 void PatchText(const Kernel::PhysicalMemory& program_image, 34 bool PatchText(const Kernel::PhysicalMemory& program_image,
35 const Kernel::CodeSet::Segment& code); 35 const Kernel::CodeSet::Segment& code);
36 void RelocateAndCopy(Common::ProcessAddress load_base, const Kernel::CodeSet::Segment& code, 36 bool RelocateAndCopy(Common::ProcessAddress load_base, const Kernel::CodeSet::Segment& code,
37 Kernel::PhysicalMemory& program_image, EntryTrampolines* out_trampolines); 37 Kernel::PhysicalMemory& program_image, EntryTrampolines* out_trampolines);
38 size_t GetSectionSize() const noexcept; 38 size_t GetSectionSize() const noexcept;
39 39
@@ -61,16 +61,16 @@ private:
61 61
62private: 62private:
63 void BranchToPatch(uintptr_t module_dest) { 63 void BranchToPatch(uintptr_t module_dest) {
64 m_branch_to_patch_relocations.push_back({c.offset(), module_dest}); 64 curr_patch->m_branch_to_patch_relocations.push_back({c.offset(), module_dest});
65 } 65 }
66 66
67 void BranchToModule(uintptr_t module_dest) { 67 void BranchToModule(uintptr_t module_dest) {
68 m_branch_to_module_relocations.push_back({c.offset(), module_dest}); 68 curr_patch->m_branch_to_module_relocations.push_back({c.offset(), module_dest});
69 c.dw(0); 69 c.dw(0);
70 } 70 }
71 71
72 void WriteModulePc(uintptr_t module_dest) { 72 void WriteModulePc(uintptr_t module_dest) {
73 m_write_module_pc_relocations.push_back({c.offset(), module_dest}); 73 curr_patch->m_write_module_pc_relocations.push_back({c.offset(), module_dest});
74 c.dx(0); 74 c.dx(0);
75 } 75 }
76 76
@@ -84,15 +84,22 @@ private:
84 uintptr_t module_offset; ///< Offset in bytes from the start of the text section. 84 uintptr_t module_offset; ///< Offset in bytes from the start of the text section.
85 }; 85 };
86 86
87 struct ModulePatch {
88 std::vector<Trampoline> m_trampolines;
89 std::vector<Relocation> m_branch_to_patch_relocations{};
90 std::vector<Relocation> m_branch_to_module_relocations{};
91 std::vector<Relocation> m_write_module_pc_relocations{};
92 std::vector<ModuleTextAddress> m_exclusives{};
93 };
94
87 oaknut::VectorCodeGenerator c; 95 oaknut::VectorCodeGenerator c;
88 std::vector<Trampoline> m_trampolines;
89 std::vector<Relocation> m_branch_to_patch_relocations{};
90 std::vector<Relocation> m_branch_to_module_relocations{};
91 std::vector<Relocation> m_write_module_pc_relocations{};
92 std::vector<ModuleTextAddress> m_exclusives{};
93 oaknut::Label m_save_context{}; 96 oaknut::Label m_save_context{};
94 oaknut::Label m_load_context{}; 97 oaknut::Label m_load_context{};
95 PatchMode mode{PatchMode::None}; 98 PatchMode mode{PatchMode::None};
99 size_t total_program_size{};
100 size_t m_relocate_module_index{};
101 std::vector<ModulePatch> modules;
102 ModulePatch* curr_patch;
96}; 103};
97 104
98} // namespace Core::NCE 105} // namespace Core::NCE