nso/nro: Use default allocation size for arg_data
This commit is contained in:
parent
081f5c1dbf
commit
f945e9767c
@ -141,8 +141,8 @@ ResultStatus AppLoader_DeconstructedRomDirectory::Load(Kernel::Process& process)
|
|||||||
const FileSys::VirtualFile module_file = dir->GetFile(module);
|
const FileSys::VirtualFile module_file = dir->GetFile(module);
|
||||||
if (module_file != nullptr) {
|
if (module_file != nullptr) {
|
||||||
const VAddr load_addr = next_load_addr;
|
const VAddr load_addr = next_load_addr;
|
||||||
next_load_addr =
|
next_load_addr = AppLoader_NSO::LoadModule(module_file, load_addr,
|
||||||
AppLoader_NSO::LoadModule(module_file, load_addr, std::strcmp(module, "rtld") == 0, pm);
|
std::strcmp(module, "rtld") == 0, pm);
|
||||||
LOG_DEBUG(Loader, "loaded module {} @ 0x{:X}", module, load_addr);
|
LOG_DEBUG(Loader, "loaded module {} @ 0x{:X}", module, load_addr);
|
||||||
// Register module with GDBStub
|
// Register module with GDBStub
|
||||||
GDBStub::RegisterModule(module, load_addr, next_load_addr - 1, false);
|
GDBStub::RegisterModule(module, load_addr, next_load_addr - 1, false);
|
||||||
|
@ -154,12 +154,14 @@ bool AppLoader_NRO::LoadNro(FileSys::VirtualFile file, VAddr load_base) {
|
|||||||
|
|
||||||
if (!Settings::values.program_args.empty()) {
|
if (!Settings::values.program_args.empty()) {
|
||||||
const auto arg_data = Settings::values.program_args;
|
const auto arg_data = Settings::values.program_args;
|
||||||
codeset->DataSegment().size += 0x9000;
|
codeset->DataSegment().size += NSO_ARGUMENT_DATA_ALLOCATION_SIZE;
|
||||||
NSOArgumentHeader args_header{0x9000, static_cast<u32_le>(arg_data.size()), {}};
|
NSOArgumentHeader args_header{
|
||||||
program_image.resize(static_cast<u32>(program_image.size()) + 0x9000);
|
NSO_ARGUMENT_DATA_ALLOCATION_SIZE, static_cast<u32_le>(arg_data.size()), {}};
|
||||||
std::memcpy(program_image.data() + program_image.size() - 0x9000, &args_header,
|
const auto end_offset = program_image.size();
|
||||||
sizeof(NSOArgumentHeader));
|
program_image.resize(static_cast<u32>(program_image.size()) +
|
||||||
std::memcpy(program_image.data() + program_image.size() - 0x8FE0, arg_data.data(),
|
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());
|
arg_data.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -129,12 +129,14 @@ VAddr AppLoader_NSO::LoadModule(FileSys::VirtualFile file, VAddr load_base,
|
|||||||
|
|
||||||
if (should_pass_arguments && !Settings::values.program_args.empty()) {
|
if (should_pass_arguments && !Settings::values.program_args.empty()) {
|
||||||
const auto arg_data = Settings::values.program_args;
|
const auto arg_data = Settings::values.program_args;
|
||||||
codeset->DataSegment().size += 0x9000;
|
codeset->DataSegment().size += NSO_ARGUMENT_DATA_ALLOCATION_SIZE;
|
||||||
NSOArgumentHeader args_header{0x9000, static_cast<u32_le>(arg_data.size()), {}};
|
NSOArgumentHeader args_header{
|
||||||
program_image.resize(static_cast<u32>(program_image.size()) + 0x9000);
|
NSO_ARGUMENT_DATA_ALLOCATION_SIZE, static_cast<u32_le>(arg_data.size()), {}};
|
||||||
std::memcpy(program_image.data() + program_image.size() - 0x9000, &args_header,
|
const auto end_offset = program_image.size();
|
||||||
sizeof(NSOArgumentHeader));
|
program_image.resize(static_cast<u32>(program_image.size()) +
|
||||||
std::memcpy(program_image.data() + program_image.size() - 0x8FE0, arg_data.data(),
|
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());
|
arg_data.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -11,6 +11,8 @@
|
|||||||
|
|
||||||
namespace Loader {
|
namespace Loader {
|
||||||
|
|
||||||
|
constexpr u64 NSO_ARGUMENT_DATA_ALLOCATION_SIZE = 0x9000;
|
||||||
|
|
||||||
struct NSOArgumentHeader {
|
struct NSOArgumentHeader {
|
||||||
u32_le allocated_size;
|
u32_le allocated_size;
|
||||||
u32_le actual_size;
|
u32_le actual_size;
|
||||||
|
Loading…
Reference in New Issue
Block a user