summaryrefslogtreecommitdiff
path: root/src/core/loader/nso.cpp
diff options
context:
space:
mode:
authorGravatar Rozlette2018-01-16 11:14:36 -0600
committerGravatar Rozlette2018-01-16 11:14:36 -0600
commit09bcc2042c9a695e202041f4d545a0e4639e3dda (patch)
tree07f7cfe638eab20aeccb2c55b27673f908168b5b /src/core/loader/nso.cpp
parentImplement Pull #3333 from citra: citra_qt: Pause emulation on CoreError (#39) (diff)
downloadyuzu-09bcc2042c9a695e202041f4d545a0e4639e3dda.tar.gz
yuzu-09bcc2042c9a695e202041f4d545a0e4639e3dda.tar.xz
yuzu-09bcc2042c9a695e202041f4d545a0e4639e3dda.zip
nso: Modify .bss size calculation logic
Diffstat (limited to 'src/core/loader/nso.cpp')
-rw-r--r--src/core/loader/nso.cpp10
1 files changed, 7 insertions, 3 deletions
diff --git a/src/core/loader/nso.cpp b/src/core/loader/nso.cpp
index 7e1953701..833399511 100644
--- a/src/core/loader/nso.cpp
+++ b/src/core/loader/nso.cpp
@@ -19,7 +19,10 @@ struct NsoSegmentHeader {
19 u32_le offset; 19 u32_le offset;
20 u32_le location; 20 u32_le location;
21 u32_le size; 21 u32_le size;
22 u32_le alignment; 22 union {
23 u32_le alignment;
24 u32_le bss_size;
25 };
23}; 26};
24static_assert(sizeof(NsoSegmentHeader) == 0x10, "NsoSegmentHeader has incorrect size."); 27static_assert(sizeof(NsoSegmentHeader) == 0x10, "NsoSegmentHeader has incorrect size.");
25 28
@@ -120,14 +123,15 @@ VAddr AppLoader_NSO::LoadNso(const std::string& path, VAddr load_base, bool relo
120 123
121 // Read MOD header 124 // Read MOD header
122 ModHeader mod_header{}; 125 ModHeader mod_header{};
123 u32 bss_size{Memory::PAGE_SIZE}; // Default .bss to page size if MOD0 section doesn't exist 126 // Default .bss to size in segment header if MOD0 section doesn't exist
127 u32 bss_size{PageAlignSize(nso_header.segments[2].bss_size)};
124 std::memcpy(&mod_header, program_image.data() + module_offset, sizeof(ModHeader)); 128 std::memcpy(&mod_header, program_image.data() + module_offset, sizeof(ModHeader));
125 const bool has_mod_header{mod_header.magic == Common::MakeMagic('M', 'O', 'D', '0')}; 129 const bool has_mod_header{mod_header.magic == Common::MakeMagic('M', 'O', 'D', '0')};
126 if (has_mod_header) { 130 if (has_mod_header) {
127 // Resize program image to include .bss section and page align each section 131 // Resize program image to include .bss section and page align each section
128 bss_size = PageAlignSize(mod_header.bss_end_offset - mod_header.bss_start_offset); 132 bss_size = PageAlignSize(mod_header.bss_end_offset - mod_header.bss_start_offset);
129 codeset->data.size += bss_size;
130 } 133 }
134 codeset->data.size += bss_size;
131 const u32 image_size{PageAlignSize(static_cast<u32>(program_image.size()) + bss_size)}; 135 const u32 image_size{PageAlignSize(static_cast<u32>(program_image.size()) + bss_size)};
132 program_image.resize(image_size); 136 program_image.resize(image_size);
133 137