Address some review comments
This commit is contained in:
parent
8fab363237
commit
6de2edcca1
12 changed files with 30 additions and 35 deletions
|
@ -204,7 +204,7 @@ static bool LoadNroImpl(Core::System& system, Kernel::KProcess& process,
|
|||
#ifdef ARCHITECTURE_arm64
|
||||
const auto& code = codeset.CodeSegment();
|
||||
|
||||
// NROs are always 64-bit programs.
|
||||
// NROs always have a 39-bit address space.
|
||||
Settings::SetNceEnabled(true);
|
||||
|
||||
// Create NCE patcher
|
||||
|
@ -215,12 +215,12 @@ static bool LoadNroImpl(Core::System& system, Kernel::KProcess& process,
|
|||
patch.PatchText(program_image, code);
|
||||
|
||||
// We only support PostData patching for NROs.
|
||||
ASSERT(patch.Mode() == Core::NCE::PatchMode::PostData);
|
||||
ASSERT(patch.GetPatchMode() == Core::NCE::PatchMode::PostData);
|
||||
|
||||
// Update patch section.
|
||||
auto& patch_segment = codeset.PatchSegment();
|
||||
patch_segment.addr = image_size;
|
||||
patch_segment.size = static_cast<u32>(patch.SectionSize());
|
||||
patch_segment.size = static_cast<u32>(patch.GetSectionSize());
|
||||
|
||||
// Add patch section size to the module size.
|
||||
image_size += patch_segment.size;
|
||||
|
|
|
@ -94,8 +94,8 @@ std::optional<VAddr> AppLoader_NSO::LoadModule(Kernel::KProcess& process, Core::
|
|||
// Allocate some space at the beginning if we are patching in PreText mode.
|
||||
const size_t module_start = [&]() -> size_t {
|
||||
#ifdef ARCHITECTURE_arm64
|
||||
if (patch && patch->Mode() == Core::NCE::PatchMode::PreText) {
|
||||
return patch->SectionSize();
|
||||
if (patch && patch->GetPatchMode() == Core::NCE::PatchMode::PreText) {
|
||||
return patch->GetSectionSize();
|
||||
}
|
||||
#endif
|
||||
return 0;
|
||||
|
@ -158,24 +158,25 @@ std::optional<VAddr> AppLoader_NSO::LoadModule(Kernel::KProcess& process, Core::
|
|||
#ifdef ARCHITECTURE_arm64
|
||||
// If we are computing the process code layout and using nce backend, patch.
|
||||
const auto& code = codeset.CodeSegment();
|
||||
if (patch && patch->Mode() == Core::NCE::PatchMode::None) {
|
||||
if (patch && patch->GetPatchMode() == Core::NCE::PatchMode::None) {
|
||||
// Patch SVCs and MRS calls in the guest code
|
||||
patch->PatchText(program_image, code);
|
||||
|
||||
// Add patch section size to the module size.
|
||||
image_size += patch->SectionSize();
|
||||
image_size += patch->GetSectionSize();
|
||||
} else if (patch) {
|
||||
// Relocate code patch and copy to the program_image.
|
||||
patch->RelocateAndCopy(load_base, code, program_image, &process.GetPostHandlers());
|
||||
|
||||
// Update patch section.
|
||||
auto& patch_segment = codeset.PatchSegment();
|
||||
patch_segment.addr = patch->Mode() == Core::NCE::PatchMode::PreText ? 0 : image_size;
|
||||
patch_segment.size = static_cast<u32>(patch->SectionSize());
|
||||
patch_segment.addr =
|
||||
patch->GetPatchMode() == Core::NCE::PatchMode::PreText ? 0 : image_size;
|
||||
patch_segment.size = static_cast<u32>(patch->GetSectionSize());
|
||||
|
||||
// Add patch section size to the module size. In PreText mode image_size
|
||||
// already contains the patch segment as part of module_start.
|
||||
if (patch->Mode() == Core::NCE::PatchMode::PostData) {
|
||||
if (patch->GetPatchMode() == Core::NCE::PatchMode::PostData) {
|
||||
image_size += patch_segment.size;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue