diff options
| author | 2018-10-12 22:52:12 -0400 | |
|---|---|---|
| committer | 2018-10-12 22:52:12 -0400 | |
| commit | c2aa4293ec647a3712299c5b53f3ca592aaf9c0e (patch) | |
| tree | 08a703b6913733042091e16c7c90cc34d991f537 /src/core/loader/nso.cpp | |
| parent | Merge pull request #1484 from FernandoS27/calculate-size (diff) | |
| parent | kernel/process: Make CodeSet a regular non-inherited object (diff) | |
| download | yuzu-c2aa4293ec647a3712299c5b53f3ca592aaf9c0e.tar.gz yuzu-c2aa4293ec647a3712299c5b53f3ca592aaf9c0e.tar.xz yuzu-c2aa4293ec647a3712299c5b53f3ca592aaf9c0e.zip | |
Merge pull request #1483 from lioncash/codeset
kernel/process: Make CodeSet a regular non-inherited object
Diffstat (limited to 'src/core/loader/nso.cpp')
| -rw-r--r-- | src/core/loader/nso.cpp | 21 |
1 files changed, 9 insertions, 12 deletions
diff --git a/src/core/loader/nso.cpp b/src/core/loader/nso.cpp index 28c6dd9b7..ba57db9bf 100644 --- a/src/core/loader/nso.cpp +++ b/src/core/loader/nso.cpp | |||
| @@ -12,7 +12,6 @@ | |||
| 12 | #include "core/core.h" | 12 | #include "core/core.h" |
| 13 | #include "core/file_sys/patch_manager.h" | 13 | #include "core/file_sys/patch_manager.h" |
| 14 | #include "core/gdbstub/gdbstub.h" | 14 | #include "core/gdbstub/gdbstub.h" |
| 15 | #include "core/hle/kernel/kernel.h" | ||
| 16 | #include "core/hle/kernel/process.h" | 15 | #include "core/hle/kernel/process.h" |
| 17 | #include "core/hle/kernel/vm_manager.h" | 16 | #include "core/hle/kernel/vm_manager.h" |
| 18 | #include "core/loader/nso.h" | 17 | #include "core/loader/nso.h" |
| @@ -111,8 +110,7 @@ VAddr AppLoader_NSO::LoadModule(FileSys::VirtualFile file, VAddr load_base, | |||
| 111 | return {}; | 110 | return {}; |
| 112 | 111 | ||
| 113 | // Build program image | 112 | // Build program image |
| 114 | auto& kernel = Core::System::GetInstance().Kernel(); | 113 | Kernel::CodeSet codeset; |
| 115 | Kernel::SharedPtr<Kernel::CodeSet> codeset = Kernel::CodeSet::Create(kernel, ""); | ||
| 116 | std::vector<u8> program_image; | 114 | std::vector<u8> program_image; |
| 117 | for (std::size_t i = 0; i < nso_header.segments.size(); ++i) { | 115 | for (std::size_t i = 0; i < nso_header.segments.size(); ++i) { |
| 118 | std::vector<u8> data = | 116 | std::vector<u8> data = |
| @@ -122,14 +120,14 @@ VAddr AppLoader_NSO::LoadModule(FileSys::VirtualFile file, VAddr load_base, | |||
| 122 | } | 120 | } |
| 123 | program_image.resize(nso_header.segments[i].location); | 121 | program_image.resize(nso_header.segments[i].location); |
| 124 | program_image.insert(program_image.end(), data.begin(), data.end()); | 122 | program_image.insert(program_image.end(), data.begin(), data.end()); |
| 125 | codeset->segments[i].addr = nso_header.segments[i].location; | 123 | codeset.segments[i].addr = nso_header.segments[i].location; |
| 126 | codeset->segments[i].offset = nso_header.segments[i].location; | 124 | codeset.segments[i].offset = nso_header.segments[i].location; |
| 127 | codeset->segments[i].size = PageAlignSize(static_cast<u32>(data.size())); | 125 | codeset.segments[i].size = PageAlignSize(static_cast<u32>(data.size())); |
| 128 | } | 126 | } |
| 129 | 127 | ||
| 130 | if (should_pass_arguments && !Settings::values.program_args.empty()) { | 128 | if (should_pass_arguments && !Settings::values.program_args.empty()) { |
| 131 | const auto arg_data = Settings::values.program_args; | 129 | const auto arg_data = Settings::values.program_args; |
| 132 | codeset->DataSegment().size += NSO_ARGUMENT_DATA_ALLOCATION_SIZE; | 130 | codeset.DataSegment().size += NSO_ARGUMENT_DATA_ALLOCATION_SIZE; |
| 133 | NSOArgumentHeader args_header{ | 131 | NSOArgumentHeader args_header{ |
| 134 | NSO_ARGUMENT_DATA_ALLOCATION_SIZE, static_cast<u32_le>(arg_data.size()), {}}; | 132 | NSO_ARGUMENT_DATA_ALLOCATION_SIZE, static_cast<u32_le>(arg_data.size()), {}}; |
| 135 | const auto end_offset = program_image.size(); | 133 | const auto end_offset = program_image.size(); |
| @@ -154,7 +152,7 @@ VAddr AppLoader_NSO::LoadModule(FileSys::VirtualFile file, VAddr load_base, | |||
| 154 | // Resize program image to include .bss section and page align each section | 152 | // Resize program image to include .bss section and page align each section |
| 155 | bss_size = PageAlignSize(mod_header.bss_end_offset - mod_header.bss_start_offset); | 153 | bss_size = PageAlignSize(mod_header.bss_end_offset - mod_header.bss_start_offset); |
| 156 | } | 154 | } |
| 157 | codeset->DataSegment().size += bss_size; | 155 | codeset.DataSegment().size += bss_size; |
| 158 | const u32 image_size{PageAlignSize(static_cast<u32>(program_image.size()) + bss_size)}; | 156 | const u32 image_size{PageAlignSize(static_cast<u32>(program_image.size()) + bss_size)}; |
| 159 | program_image.resize(image_size); | 157 | program_image.resize(image_size); |
| 160 | 158 | ||
| @@ -170,12 +168,11 @@ VAddr AppLoader_NSO::LoadModule(FileSys::VirtualFile file, VAddr load_base, | |||
| 170 | } | 168 | } |
| 171 | 169 | ||
| 172 | // Load codeset for current process | 170 | // Load codeset for current process |
| 173 | codeset->name = file->GetName(); | 171 | codeset.memory = std::make_shared<std::vector<u8>>(std::move(program_image)); |
| 174 | codeset->memory = std::make_shared<std::vector<u8>>(std::move(program_image)); | 172 | Core::CurrentProcess()->LoadModule(std::move(codeset), load_base); |
| 175 | Core::CurrentProcess()->LoadModule(codeset, load_base); | ||
| 176 | 173 | ||
| 177 | // Register module with GDBStub | 174 | // Register module with GDBStub |
| 178 | GDBStub::RegisterModule(codeset->name, load_base, load_base); | 175 | GDBStub::RegisterModule(file->GetName(), load_base, load_base); |
| 179 | 176 | ||
| 180 | return load_base + image_size; | 177 | return load_base + image_size; |
| 181 | } | 178 | } |