diff options
| author | 2018-12-02 22:24:43 -0500 | |
|---|---|---|
| committer | 2018-12-02 23:39:03 -0500 | |
| commit | 7695febfa1f3ef45fbac5fe674c1371c88f483b6 (patch) | |
| tree | 7e92abf7033e72996c8025cabf633b2d47b14229 /src | |
| parent | loader/nro: Make the static LoadNro function internally linked (diff) | |
| download | yuzu-7695febfa1f3ef45fbac5fe674c1371c88f483b6.tar.gz yuzu-7695febfa1f3ef45fbac5fe674c1371c88f483b6.tar.xz yuzu-7695febfa1f3ef45fbac5fe674c1371c88f483b6.zip | |
loader/nso: Remove dependency on the System class
Similar to the NRO changes, we can also pass the process explicitly as a
parameter from Load instead of indirecting through the System class.
Diffstat (limited to 'src')
| -rw-r--r-- | src/core/loader/deconstructed_rom_directory.cpp | 3 | ||||
| -rw-r--r-- | src/core/loader/nso.cpp | 8 | ||||
| -rw-r--r-- | src/core/loader/nso.h | 8 |
3 files changed, 11 insertions, 8 deletions
diff --git a/src/core/loader/deconstructed_rom_directory.cpp b/src/core/loader/deconstructed_rom_directory.cpp index 8518dddcb..ac04d72d7 100644 --- a/src/core/loader/deconstructed_rom_directory.cpp +++ b/src/core/loader/deconstructed_rom_directory.cpp | |||
| @@ -7,7 +7,6 @@ | |||
| 7 | #include "common/common_funcs.h" | 7 | #include "common/common_funcs.h" |
| 8 | #include "common/file_util.h" | 8 | #include "common/file_util.h" |
| 9 | #include "common/logging/log.h" | 9 | #include "common/logging/log.h" |
| 10 | #include "core/core.h" | ||
| 11 | #include "core/file_sys/content_archive.h" | 10 | #include "core/file_sys/content_archive.h" |
| 12 | #include "core/file_sys/control_metadata.h" | 11 | #include "core/file_sys/control_metadata.h" |
| 13 | #include "core/file_sys/patch_manager.h" | 12 | #include "core/file_sys/patch_manager.h" |
| @@ -146,7 +145,7 @@ ResultStatus AppLoader_DeconstructedRomDirectory::Load(Kernel::Process& process) | |||
| 146 | const VAddr load_addr = next_load_addr; | 145 | const VAddr load_addr = next_load_addr; |
| 147 | const bool should_pass_arguments = std::strcmp(module, "rtld") == 0; | 146 | const bool should_pass_arguments = std::strcmp(module, "rtld") == 0; |
| 148 | const auto tentative_next_load_addr = | 147 | const auto tentative_next_load_addr = |
| 149 | AppLoader_NSO::LoadModule(*module_file, load_addr, should_pass_arguments, pm); | 148 | AppLoader_NSO::LoadModule(process, *module_file, load_addr, should_pass_arguments, pm); |
| 150 | if (!tentative_next_load_addr) { | 149 | if (!tentative_next_load_addr) { |
| 151 | return ResultStatus::ErrorLoadingNSO; | 150 | return ResultStatus::ErrorLoadingNSO; |
| 152 | } | 151 | } |
diff --git a/src/core/loader/nso.cpp b/src/core/loader/nso.cpp index aaf006309..6ded0b707 100644 --- a/src/core/loader/nso.cpp +++ b/src/core/loader/nso.cpp | |||
| @@ -9,7 +9,6 @@ | |||
| 9 | #include "common/file_util.h" | 9 | #include "common/file_util.h" |
| 10 | #include "common/logging/log.h" | 10 | #include "common/logging/log.h" |
| 11 | #include "common/swap.h" | 11 | #include "common/swap.h" |
| 12 | #include "core/core.h" | ||
| 13 | #include "core/file_sys/patch_manager.h" | 12 | #include "core/file_sys/patch_manager.h" |
| 14 | #include "core/gdbstub/gdbstub.h" | 13 | #include "core/gdbstub/gdbstub.h" |
| 15 | #include "core/hle/kernel/process.h" | 14 | #include "core/hle/kernel/process.h" |
| @@ -93,7 +92,8 @@ static constexpr u32 PageAlignSize(u32 size) { | |||
| 93 | return (size + Memory::PAGE_MASK) & ~Memory::PAGE_MASK; | 92 | return (size + Memory::PAGE_MASK) & ~Memory::PAGE_MASK; |
| 94 | } | 93 | } |
| 95 | 94 | ||
| 96 | std::optional<VAddr> AppLoader_NSO::LoadModule(const FileSys::VfsFile& file, VAddr load_base, | 95 | std::optional<VAddr> AppLoader_NSO::LoadModule(Kernel::Process& process, |
| 96 | const FileSys::VfsFile& file, VAddr load_base, | ||
| 97 | bool should_pass_arguments, | 97 | bool should_pass_arguments, |
| 98 | std::optional<FileSys::PatchManager> pm) { | 98 | std::optional<FileSys::PatchManager> pm) { |
| 99 | if (file.GetSize() < sizeof(NsoHeader)) | 99 | if (file.GetSize() < sizeof(NsoHeader)) |
| @@ -166,7 +166,7 @@ std::optional<VAddr> AppLoader_NSO::LoadModule(const FileSys::VfsFile& file, VAd | |||
| 166 | 166 | ||
| 167 | // Load codeset for current process | 167 | // Load codeset for current process |
| 168 | codeset.memory = std::make_shared<std::vector<u8>>(std::move(program_image)); | 168 | codeset.memory = std::make_shared<std::vector<u8>>(std::move(program_image)); |
| 169 | Core::CurrentProcess()->LoadModule(std::move(codeset), load_base); | 169 | process.LoadModule(std::move(codeset), load_base); |
| 170 | 170 | ||
| 171 | // Register module with GDBStub | 171 | // Register module with GDBStub |
| 172 | GDBStub::RegisterModule(file.GetName(), load_base, load_base); | 172 | GDBStub::RegisterModule(file.GetName(), load_base, load_base); |
| @@ -181,7 +181,7 @@ ResultStatus AppLoader_NSO::Load(Kernel::Process& process) { | |||
| 181 | 181 | ||
| 182 | // Load module | 182 | // Load module |
| 183 | const VAddr base_address = process.VMManager().GetCodeRegionBaseAddress(); | 183 | const VAddr base_address = process.VMManager().GetCodeRegionBaseAddress(); |
| 184 | if (!LoadModule(*file, base_address, true)) { | 184 | if (!LoadModule(process, *file, base_address, true)) { |
| 185 | return ResultStatus::ErrorLoadingNSO; | 185 | return ResultStatus::ErrorLoadingNSO; |
| 186 | } | 186 | } |
| 187 | LOG_DEBUG(Loader, "loaded module {} @ 0x{:X}", file->GetName(), base_address); | 187 | LOG_DEBUG(Loader, "loaded module {} @ 0x{:X}", file->GetName(), base_address); |
diff --git a/src/core/loader/nso.h b/src/core/loader/nso.h index 433306139..0c1defbb6 100644 --- a/src/core/loader/nso.h +++ b/src/core/loader/nso.h | |||
| @@ -10,6 +10,10 @@ | |||
| 10 | #include "core/loader/linker.h" | 10 | #include "core/loader/linker.h" |
| 11 | #include "core/loader/loader.h" | 11 | #include "core/loader/loader.h" |
| 12 | 12 | ||
| 13 | namespace Kernel { | ||
| 14 | class Process; | ||
| 15 | } | ||
| 16 | |||
| 13 | namespace Loader { | 17 | namespace Loader { |
| 14 | 18 | ||
| 15 | constexpr u64 NSO_ARGUMENT_DATA_ALLOCATION_SIZE = 0x9000; | 19 | constexpr u64 NSO_ARGUMENT_DATA_ALLOCATION_SIZE = 0x9000; |
| @@ -37,8 +41,8 @@ public: | |||
| 37 | return IdentifyType(file); | 41 | return IdentifyType(file); |
| 38 | } | 42 | } |
| 39 | 43 | ||
| 40 | static std::optional<VAddr> LoadModule(const FileSys::VfsFile& file, VAddr load_base, | 44 | static std::optional<VAddr> LoadModule(Kernel::Process& process, const FileSys::VfsFile& file, |
| 41 | bool should_pass_arguments, | 45 | VAddr load_base, bool should_pass_arguments, |
| 42 | std::optional<FileSys::PatchManager> pm = {}); | 46 | std::optional<FileSys::PatchManager> pm = {}); |
| 43 | 47 | ||
| 44 | ResultStatus Load(Kernel::Process& process) override; | 48 | ResultStatus Load(Kernel::Process& process) override; |