summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/core/loader/deconstructed_rom_directory.cpp4
-rw-r--r--src/core/loader/nro.cpp14
-rw-r--r--src/core/loader/nso.cpp14
-rw-r--r--src/core/loader/nso.h2
4 files changed, 20 insertions, 14 deletions
diff --git a/src/core/loader/deconstructed_rom_directory.cpp b/src/core/loader/deconstructed_rom_directory.cpp
index 61808d094..951fd8257 100644
--- a/src/core/loader/deconstructed_rom_directory.cpp
+++ b/src/core/loader/deconstructed_rom_directory.cpp
@@ -141,8 +141,8 @@ ResultStatus AppLoader_DeconstructedRomDirectory::Load(Kernel::Process& process)
const FileSys::VirtualFile module_file = dir->GetFile(module);
if (module_file != nullptr) {
const VAddr load_addr = next_load_addr;
- next_load_addr =
- AppLoader_NSO::LoadModule(module_file, load_addr, std::strcmp(module, "rtld") == 0, pm);
+ next_load_addr = AppLoader_NSO::LoadModule(module_file, load_addr,
+ std::strcmp(module, "rtld") == 0, pm);
LOG_DEBUG(Loader, "loaded module {} @ 0x{:X}", module, load_addr);
// Register module with GDBStub
GDBStub::RegisterModule(module, load_addr, next_load_addr - 1, false);
diff --git a/src/core/loader/nro.cpp b/src/core/loader/nro.cpp
index 0d7c1dcfa..25dd3f04e 100644
--- a/src/core/loader/nro.cpp
+++ b/src/core/loader/nro.cpp
@@ -154,12 +154,14 @@ bool AppLoader_NRO::LoadNro(FileSys::VirtualFile file, VAddr load_base) {
if (!Settings::values.program_args.empty()) {
const auto arg_data = Settings::values.program_args;
- codeset->DataSegment().size += 0x9000;
- NSOArgumentHeader args_header{0x9000, static_cast<u32_le>(arg_data.size()), {}};
- program_image.resize(static_cast<u32>(program_image.size()) + 0x9000);
- std::memcpy(program_image.data() + program_image.size() - 0x9000, &args_header,
- sizeof(NSOArgumentHeader));
- std::memcpy(program_image.data() + program_image.size() - 0x8FE0, arg_data.data(),
+ codeset->DataSegment().size += NSO_ARGUMENT_DATA_ALLOCATION_SIZE;
+ NSOArgumentHeader args_header{
+ NSO_ARGUMENT_DATA_ALLOCATION_SIZE, static_cast<u32_le>(arg_data.size()), {}};
+ const auto end_offset = program_image.size();
+ program_image.resize(static_cast<u32>(program_image.size()) +
+ NSO_ARGUMENT_DATA_ALLOCATION_SIZE);
+ std::memcpy(program_image.data() + end_offset, &args_header, sizeof(NSOArgumentHeader));
+ std::memcpy(program_image.data() + end_offset + sizeof(NSOArgumentHeader), arg_data.data(),
arg_data.size());
}
diff --git a/src/core/loader/nso.cpp b/src/core/loader/nso.cpp
index c225e2d24..28c6dd9b7 100644
--- a/src/core/loader/nso.cpp
+++ b/src/core/loader/nso.cpp
@@ -129,12 +129,14 @@ VAddr AppLoader_NSO::LoadModule(FileSys::VirtualFile file, VAddr load_base,
if (should_pass_arguments && !Settings::values.program_args.empty()) {
const auto arg_data = Settings::values.program_args;
- codeset->DataSegment().size += 0x9000;
- NSOArgumentHeader args_header{0x9000, static_cast<u32_le>(arg_data.size()), {}};
- program_image.resize(static_cast<u32>(program_image.size()) + 0x9000);
- std::memcpy(program_image.data() + program_image.size() - 0x9000, &args_header,
- sizeof(NSOArgumentHeader));
- std::memcpy(program_image.data() + program_image.size() - 0x8FE0, arg_data.data(),
+ codeset->DataSegment().size += NSO_ARGUMENT_DATA_ALLOCATION_SIZE;
+ NSOArgumentHeader args_header{
+ NSO_ARGUMENT_DATA_ALLOCATION_SIZE, static_cast<u32_le>(arg_data.size()), {}};
+ const auto end_offset = program_image.size();
+ program_image.resize(static_cast<u32>(program_image.size()) +
+ NSO_ARGUMENT_DATA_ALLOCATION_SIZE);
+ std::memcpy(program_image.data() + end_offset, &args_header, sizeof(NSOArgumentHeader));
+ std::memcpy(program_image.data() + end_offset + sizeof(NSOArgumentHeader), arg_data.data(),
arg_data.size());
}
diff --git a/src/core/loader/nso.h b/src/core/loader/nso.h
index 7833af6ee..70ab3b718 100644
--- a/src/core/loader/nso.h
+++ b/src/core/loader/nso.h
@@ -11,6 +11,8 @@
namespace Loader {
+constexpr u64 NSO_ARGUMENT_DATA_ALLOCATION_SIZE = 0x9000;
+
struct NSOArgumentHeader {
u32_le allocated_size;
u32_le actual_size;