diff options
author | bunnei <bunneidev@gmail.com> | 2020-04-21 00:16:55 +0200 |
---|---|---|
committer | bunnei <bunneidev@gmail.com> | 2020-04-21 00:19:45 +0200 |
commit | 9c12aef2f85ae50d6e6b25df54720fcb0bd46f14 (patch) | |
tree | b798e5946d27b5e8e10d079f7cf054f616addedd /src | |
parent | loader: elf: Fix process initialization using ProgramMetadata default. (diff) | |
download | yuzu-9c12aef2f85ae50d6e6b25df54720fcb0bd46f14.tar yuzu-9c12aef2f85ae50d6e6b25df54720fcb0bd46f14.tar.gz yuzu-9c12aef2f85ae50d6e6b25df54720fcb0bd46f14.tar.bz2 yuzu-9c12aef2f85ae50d6e6b25df54720fcb0bd46f14.tar.lz yuzu-9c12aef2f85ae50d6e6b25df54720fcb0bd46f14.tar.xz yuzu-9c12aef2f85ae50d6e6b25df54720fcb0bd46f14.tar.zst yuzu-9c12aef2f85ae50d6e6b25df54720fcb0bd46f14.zip |
Diffstat (limited to 'src')
-rw-r--r-- | src/core/loader/nro.cpp | 23 | ||||
-rw-r--r-- | src/core/loader/nro.h | 2 |
2 files changed, 14 insertions, 11 deletions
diff --git a/src/core/loader/nro.cpp b/src/core/loader/nro.cpp index 5d7e8136e..906544bc9 100644 --- a/src/core/loader/nro.cpp +++ b/src/core/loader/nro.cpp @@ -131,7 +131,7 @@ static constexpr u32 PageAlignSize(u32 size) { } static bool LoadNroImpl(Kernel::Process& process, const std::vector<u8>& data, - const std::string& name, VAddr load_base) { + const std::string& name) { if (data.size() < sizeof(NroHeader)) { return {}; } @@ -187,19 +187,25 @@ static bool LoadNroImpl(Kernel::Process& process, const std::vector<u8>& data, codeset.DataSegment().size += bss_size; program_image.resize(static_cast<u32>(program_image.size()) + bss_size); + // Setup the process code layout + if (process.LoadFromMetadata(FileSys::ProgramMetadata::GetDefault(), program_image.size()) + .IsError()) { + return false; + } + // Load codeset for current process codeset.memory = std::move(program_image); - process.LoadModule(std::move(codeset), load_base); + process.LoadModule(std::move(codeset), process.PageTable().GetCodeRegionStart()); // Register module with GDBStub - GDBStub::RegisterModule(name, load_base, load_base); + GDBStub::RegisterModule(name, process.PageTable().GetCodeRegionStart(), + process.PageTable().GetCodeRegionEnd()); return true; } -bool AppLoader_NRO::LoadNro(Kernel::Process& process, const FileSys::VfsFile& file, - VAddr load_base) { - return LoadNroImpl(process, file.ReadAllBytes(), file.GetName(), load_base); +bool AppLoader_NRO::LoadNro(Kernel::Process& process, const FileSys::VfsFile& file) { + return LoadNroImpl(process, file.ReadAllBytes(), file.GetName()); } AppLoader_NRO::LoadResult AppLoader_NRO::Load(Kernel::Process& process) { @@ -207,10 +213,7 @@ AppLoader_NRO::LoadResult AppLoader_NRO::Load(Kernel::Process& process) { return {ResultStatus::ErrorAlreadyLoaded, {}}; } - // Load NRO - const VAddr base_address = process.PageTable().GetCodeRegionStart(); - - if (!LoadNro(process, *file, base_address)) { + if (!LoadNro(process, *file)) { return {ResultStatus::ErrorLoadingNRO, {}}; } diff --git a/src/core/loader/nro.h b/src/core/loader/nro.h index 71811bc29..4593d48fb 100644 --- a/src/core/loader/nro.h +++ b/src/core/loader/nro.h @@ -47,7 +47,7 @@ public: bool IsRomFSUpdatable() const override; private: - bool LoadNro(Kernel::Process& process, const FileSys::VfsFile& file, VAddr load_base); + bool LoadNro(Kernel::Process& process, const FileSys::VfsFile& file); std::vector<u8> icon_data; std::unique_ptr<FileSys::NACP> nacp; |