diff options
| author | lizzie <lizzie@eden-emu.dev> | 2026-02-28 01:06:33 +0100 |
|---|---|---|
| committer | crueter <crueter@eden-emu.dev> | 2026-02-28 01:06:33 +0100 |
| commit | 06a08de68a95506a9cbe4633c58f6bdb5ded0c70 (patch) | |
| tree | 122a2d66da07e0fdbdbf3c466c1cf88d4d4b4d01 /src/core/arm | |
| parent | f8712e50e6860616b4ea86d57a9b09cd99aad728 (diff) | |
[core/loader] prevent program_image reallocations in NSO+KIP loading methods (#3639)
also changes some methods to std::span<> as well, but mainly std::vector<> in the NSO/KIP loading stuff is not needed to be memcpy'ed and memmove'd around
this should save a marginal amount of loading time (RDR1)
Signed-off-by: lizzie <lizzie@eden-emu.dev>
Reviewed-on: https://git.eden-emu.dev/eden-emu/eden/pulls/3639
Reviewed-by: DraVee <dravee@eden-emu.dev>
Reviewed-by: Maufeat <sahyno1996@gmail.com>
Co-authored-by: lizzie <lizzie@eden-emu.dev>
Co-committed-by: lizzie <lizzie@eden-emu.dev>
Diffstat (limited to 'src/core/arm')
| -rw-r--r-- | src/core/arm/nce/patcher.cpp | 9 | ||||
| -rw-r--r-- | src/core/arm/nce/patcher.h | 7 |
2 files changed, 5 insertions, 11 deletions
diff --git a/src/core/arm/nce/patcher.cpp b/src/core/arm/nce/patcher.cpp index bd8e4fd7fb..ea77166645 100644 --- a/src/core/arm/nce/patcher.cpp +++ b/src/core/arm/nce/patcher.cpp @@ -4,6 +4,7 @@ #include <numeric> #include <bit> #include "common/arm64/native_clock.h" +#include "common/alignment.h" #include "common/literals.h" #include "core/arm/nce/arm_nce.h" #include "core/arm/nce/guest_context.h" @@ -46,8 +47,7 @@ Patcher::Patcher() : c(m_patch_instructions), c_pre(m_patch_instructions_pre) { Patcher::~Patcher() = default; -bool Patcher::PatchText(const Kernel::PhysicalMemory& program_image, - const Kernel::CodeSet::Segment& code) { +bool Patcher::PatchText(std::span<const u8> program_image, const Kernel::CodeSet::Segment& code) { // If we have patched modules but cannot reach the new module, then it needs its own patcher. const size_t image_size = program_image.size(); @@ -175,10 +175,7 @@ bool Patcher::PatchText(const Kernel::PhysicalMemory& program_image, return true; } -bool Patcher::RelocateAndCopy(Common::ProcessAddress load_base, - const Kernel::CodeSet::Segment& code, - Kernel::PhysicalMemory& program_image, - EntryTrampolines* out_trampolines) { +bool Patcher::RelocateAndCopy(Common::ProcessAddress load_base, const Kernel::CodeSet::Segment& code, std::vector<u8>& program_image, EntryTrampolines* out_trampolines) { const size_t patch_size = GetSectionSize(); const size_t pre_patch_size = GetPreSectionSize(); diff --git a/src/core/arm/nce/patcher.h b/src/core/arm/nce/patcher.h index 303cf68ec6..499c98c901 100644 --- a/src/core/arm/nce/patcher.h +++ b/src/core/arm/nce/patcher.h @@ -14,7 +14,6 @@ #include "common/settings.h" #include "core/hle/kernel/code_set.h" #include "core/hle/kernel/k_typed_address.h" -#include "core/hle/kernel/physical_memory.h" #include <utility> using ModuleID = std::array<u8, 32>; // NSO build ID struct PatchCacheKey { @@ -56,10 +55,8 @@ public: } explicit Patcher(); ~Patcher(); - bool PatchText(const Kernel::PhysicalMemory& program_image, - const Kernel::CodeSet::Segment& code); - bool RelocateAndCopy(Common::ProcessAddress load_base, const Kernel::CodeSet::Segment& code, - Kernel::PhysicalMemory& program_image, EntryTrampolines* out_trampolines); + bool PatchText(std::span<const u8> program_image, const Kernel::CodeSet::Segment& code); + bool RelocateAndCopy(Common::ProcessAddress load_base, const Kernel::CodeSet::Segment& code, std::vector<u8>& program_image, EntryTrampolines* out_trampolines); size_t GetSectionSize() const noexcept; size_t GetPreSectionSize() const noexcept; |
