summaryrefslogtreecommitdiff
path: root/src/core/loader/nro.cpp
diff options
context:
space:
mode:
authorGravatar bunnei2017-10-09 21:39:32 -0400
committerGravatar bunnei2017-10-09 21:39:32 -0400
commit23ce4f5afc66eb04a7aafc4f89685b8109b8d5c6 (patch)
tree168e7793c6d68eb8b195850a056443ea98f430a9 /src/core/loader/nro.cpp
parentloader: Add support for NRO, as well as various fixes and shared linker. (diff)
downloadyuzu-23ce4f5afc66eb04a7aafc4f89685b8109b8d5c6.tar.gz
yuzu-23ce4f5afc66eb04a7aafc4f89685b8109b8d5c6.tar.xz
yuzu-23ce4f5afc66eb04a7aafc4f89685b8109b8d5c6.zip
loader: Various improvements for NSO/NRO loaders.
Diffstat (limited to 'src/core/loader/nro.cpp')
-rw-r--r--src/core/loader/nro.cpp17
1 files changed, 3 insertions, 14 deletions
diff --git a/src/core/loader/nro.cpp b/src/core/loader/nro.cpp
index ed638e1fa..753e7e08b 100644
--- a/src/core/loader/nro.cpp
+++ b/src/core/loader/nro.cpp
@@ -75,17 +75,6 @@ static std::vector<u8> ReadSegment(FileUtil::IOFile& file, const NroSegmentHeade
75 return data; 75 return data;
76} 76}
77 77
78VAddr AppLoader_NRO::GetEntryPoint(VAddr load_base) const {
79 // Find nnMain function, set entrypoint to that address
80 const auto& search = exports.find("nnMain");
81 if (search != exports.end()) {
82 return load_base + search->second;
83 }
84 const VAddr entry_point{load_base + sizeof(NroHeader)};
85 LOG_ERROR(Loader, "Unable to find entrypoint, defaulting to: 0x%llx", entry_point);
86 return entry_point;
87}
88
89bool AppLoader_NRO::LoadNro(const std::string& path, VAddr load_base) { 78bool AppLoader_NRO::LoadNro(const std::string& path, VAddr load_base) {
90 FileUtil::IOFile file(path, "rb"); 79 FileUtil::IOFile file(path, "rb");
91 if (!file.IsOpen()) { 80 if (!file.IsOpen()) {
@@ -152,9 +141,9 @@ ResultStatus AppLoader_NRO::Load() {
152 } 141 }
153 142
154 // Load and relocate "main" and "sdk" NSO 143 // Load and relocate "main" and "sdk" NSO
155 static constexpr VAddr main_base{0x10000000}; 144 static constexpr VAddr base_addr{Memory::PROCESS_IMAGE_VADDR};
156 Kernel::g_current_process = Kernel::Process::Create("main"); 145 Kernel::g_current_process = Kernel::Process::Create("main");
157 if (!LoadNro(filepath, main_base)) { 146 if (!LoadNro(filepath, base_addr)) {
158 return ResultStatus::ErrorInvalidFormat; 147 return ResultStatus::ErrorInvalidFormat;
159 } 148 }
160 149
@@ -162,7 +151,7 @@ ResultStatus AppLoader_NRO::Load() {
162 Kernel::g_current_process->address_mappings = default_address_mappings; 151 Kernel::g_current_process->address_mappings = default_address_mappings;
163 Kernel::g_current_process->resource_limit = 152 Kernel::g_current_process->resource_limit =
164 Kernel::ResourceLimit::GetForCategory(Kernel::ResourceLimitCategory::APPLICATION); 153 Kernel::ResourceLimit::GetForCategory(Kernel::ResourceLimitCategory::APPLICATION);
165 Kernel::g_current_process->Run(GetEntryPoint(main_base), 48, Kernel::DEFAULT_STACK_SIZE); 154 Kernel::g_current_process->Run(base_addr, 48, Kernel::DEFAULT_STACK_SIZE);
166 155
167 ResolveImports(); 156 ResolveImports();
168 157