diff options
| author | 2023-11-19 11:21:53 +0200 | |
|---|---|---|
| committer | 2023-11-25 00:47:35 -0500 | |
| commit | 6de2edcca1624982e99a72741d4fa289dc9d7551 (patch) | |
| tree | 8c355b39a6f71e333ccc2f929816ce96e40d3f2c /src/core/loader | |
| parent | android: Add cpu bakend gui toggle (diff) | |
| download | yuzu-6de2edcca1624982e99a72741d4fa289dc9d7551.tar.gz yuzu-6de2edcca1624982e99a72741d4fa289dc9d7551.tar.xz yuzu-6de2edcca1624982e99a72741d4fa289dc9d7551.zip | |
Address some review comments
Diffstat (limited to 'src/core/loader')
| -rw-r--r-- | src/core/loader/nro.cpp | 6 | ||||
| -rw-r--r-- | src/core/loader/nso.cpp | 15 |
2 files changed, 11 insertions, 10 deletions
diff --git a/src/core/loader/nro.cpp b/src/core/loader/nro.cpp index 76ff38041..49d4d7e43 100644 --- a/src/core/loader/nro.cpp +++ b/src/core/loader/nro.cpp | |||
| @@ -204,7 +204,7 @@ static bool LoadNroImpl(Core::System& system, Kernel::KProcess& process, | |||
| 204 | #ifdef ARCHITECTURE_arm64 | 204 | #ifdef ARCHITECTURE_arm64 |
| 205 | const auto& code = codeset.CodeSegment(); | 205 | const auto& code = codeset.CodeSegment(); |
| 206 | 206 | ||
| 207 | // NROs are always 64-bit programs. | 207 | // NROs always have a 39-bit address space. |
| 208 | Settings::SetNceEnabled(true); | 208 | Settings::SetNceEnabled(true); |
| 209 | 209 | ||
| 210 | // Create NCE patcher | 210 | // Create NCE patcher |
| @@ -215,12 +215,12 @@ static bool LoadNroImpl(Core::System& system, Kernel::KProcess& process, | |||
| 215 | patch.PatchText(program_image, code); | 215 | patch.PatchText(program_image, code); |
| 216 | 216 | ||
| 217 | // We only support PostData patching for NROs. | 217 | // We only support PostData patching for NROs. |
| 218 | ASSERT(patch.Mode() == Core::NCE::PatchMode::PostData); | 218 | ASSERT(patch.GetPatchMode() == Core::NCE::PatchMode::PostData); |
| 219 | 219 | ||
| 220 | // Update patch section. | 220 | // Update patch section. |
| 221 | auto& patch_segment = codeset.PatchSegment(); | 221 | auto& patch_segment = codeset.PatchSegment(); |
| 222 | patch_segment.addr = image_size; | 222 | patch_segment.addr = image_size; |
| 223 | patch_segment.size = static_cast<u32>(patch.SectionSize()); | 223 | patch_segment.size = static_cast<u32>(patch.GetSectionSize()); |
| 224 | 224 | ||
| 225 | // Add patch section size to the module size. | 225 | // Add patch section size to the module size. |
| 226 | image_size += patch_segment.size; | 226 | image_size += patch_segment.size; |
diff --git a/src/core/loader/nso.cpp b/src/core/loader/nso.cpp index 34b10ef2e..1ad2e917c 100644 --- a/src/core/loader/nso.cpp +++ b/src/core/loader/nso.cpp | |||
| @@ -94,8 +94,8 @@ std::optional<VAddr> AppLoader_NSO::LoadModule(Kernel::KProcess& process, Core:: | |||
| 94 | // Allocate some space at the beginning if we are patching in PreText mode. | 94 | // Allocate some space at the beginning if we are patching in PreText mode. |
| 95 | const size_t module_start = [&]() -> size_t { | 95 | const size_t module_start = [&]() -> size_t { |
| 96 | #ifdef ARCHITECTURE_arm64 | 96 | #ifdef ARCHITECTURE_arm64 |
| 97 | if (patch && patch->Mode() == Core::NCE::PatchMode::PreText) { | 97 | if (patch && patch->GetPatchMode() == Core::NCE::PatchMode::PreText) { |
| 98 | return patch->SectionSize(); | 98 | return patch->GetSectionSize(); |
| 99 | } | 99 | } |
| 100 | #endif | 100 | #endif |
| 101 | return 0; | 101 | return 0; |
| @@ -158,24 +158,25 @@ std::optional<VAddr> AppLoader_NSO::LoadModule(Kernel::KProcess& process, Core:: | |||
| 158 | #ifdef ARCHITECTURE_arm64 | 158 | #ifdef ARCHITECTURE_arm64 |
| 159 | // If we are computing the process code layout and using nce backend, patch. | 159 | // If we are computing the process code layout and using nce backend, patch. |
| 160 | const auto& code = codeset.CodeSegment(); | 160 | const auto& code = codeset.CodeSegment(); |
| 161 | if (patch && patch->Mode() == Core::NCE::PatchMode::None) { | 161 | if (patch && patch->GetPatchMode() == Core::NCE::PatchMode::None) { |
| 162 | // Patch SVCs and MRS calls in the guest code | 162 | // Patch SVCs and MRS calls in the guest code |
| 163 | patch->PatchText(program_image, code); | 163 | patch->PatchText(program_image, code); |
| 164 | 164 | ||
| 165 | // Add patch section size to the module size. | 165 | // Add patch section size to the module size. |
| 166 | image_size += patch->SectionSize(); | 166 | image_size += patch->GetSectionSize(); |
| 167 | } else if (patch) { | 167 | } else if (patch) { |
| 168 | // Relocate code patch and copy to the program_image. | 168 | // Relocate code patch and copy to the program_image. |
| 169 | patch->RelocateAndCopy(load_base, code, program_image, &process.GetPostHandlers()); | 169 | patch->RelocateAndCopy(load_base, code, program_image, &process.GetPostHandlers()); |
| 170 | 170 | ||
| 171 | // Update patch section. | 171 | // Update patch section. |
| 172 | auto& patch_segment = codeset.PatchSegment(); | 172 | auto& patch_segment = codeset.PatchSegment(); |
| 173 | patch_segment.addr = patch->Mode() == Core::NCE::PatchMode::PreText ? 0 : image_size; | 173 | patch_segment.addr = |
| 174 | patch_segment.size = static_cast<u32>(patch->SectionSize()); | 174 | patch->GetPatchMode() == Core::NCE::PatchMode::PreText ? 0 : image_size; |
| 175 | patch_segment.size = static_cast<u32>(patch->GetSectionSize()); | ||
| 175 | 176 | ||
| 176 | // Add patch section size to the module size. In PreText mode image_size | 177 | // Add patch section size to the module size. In PreText mode image_size |
| 177 | // already contains the patch segment as part of module_start. | 178 | // already contains the patch segment as part of module_start. |
| 178 | if (patch->Mode() == Core::NCE::PatchMode::PostData) { | 179 | if (patch->GetPatchMode() == Core::NCE::PatchMode::PostData) { |
| 179 | image_size += patch_segment.size; | 180 | image_size += patch_segment.size; |
| 180 | } | 181 | } |
| 181 | } | 182 | } |