summaryrefslogtreecommitdiffstats
path: root/src/core/loader
diff options
context:
space:
mode:
authorbunnei <bunneidev@gmail.com>2018-01-16 23:24:49 +0100
committerGitHub <noreply@github.com>2018-01-16 23:24:49 +0100
commit07b465d24e2181ce1e233041b1f24c179e2f96f6 (patch)
treedf93cc8b4e63bf736a5fb4bc449b6782133b5792 /src/core/loader
parentMerge pull request #47 from MerryMage/build-fixes (diff)
parentnso: Modify .bss size calculation logic (diff)
downloadyuzu-07b465d24e2181ce1e233041b1f24c179e2f96f6.tar
yuzu-07b465d24e2181ce1e233041b1f24c179e2f96f6.tar.gz
yuzu-07b465d24e2181ce1e233041b1f24c179e2f96f6.tar.bz2
yuzu-07b465d24e2181ce1e233041b1f24c179e2f96f6.tar.lz
yuzu-07b465d24e2181ce1e233041b1f24c179e2f96f6.tar.xz
yuzu-07b465d24e2181ce1e233041b1f24c179e2f96f6.tar.zst
yuzu-07b465d24e2181ce1e233041b1f24c179e2f96f6.zip
Diffstat (limited to 'src/core/loader')
-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 a7d714bc8..ff96e129b 100644
--- a/src/core/loader/nso.cpp
+++ b/src/core/loader/nso.cpp
@@ -19,7 +19,10 @@ struct NsoSegmentHeader {
u32_le offset;
u32_le location;
u32_le size;
- u32_le alignment;
+ union {
+ u32_le alignment;
+ u32_le bss_size;
+ };
};
static_assert(sizeof(NsoSegmentHeader) == 0x10, "NsoSegmentHeader has incorrect size.");
@@ -120,14 +123,15 @@ VAddr AppLoader_NSO::LoadNso(const std::string& path, VAddr load_base, bool relo
// Read MOD header
ModHeader mod_header{};
- u32 bss_size{Memory::PAGE_SIZE}; // Default .bss to page size if MOD0 section doesn't exist
+ // Default .bss to size in segment header if MOD0 section doesn't exist
+ u32 bss_size{PageAlignSize(nso_header.segments[2].bss_size)};
std::memcpy(&mod_header, program_image.data() + module_offset, sizeof(ModHeader));
const bool has_mod_header{mod_header.magic == Common::MakeMagic('M', 'O', 'D', '0')};
if (has_mod_header) {
// Resize program image to include .bss section and page align each section
bss_size = PageAlignSize(mod_header.bss_end_offset - mod_header.bss_start_offset);
- codeset->data.size += bss_size;
}
+ codeset->data.size += bss_size;
const u32 image_size{PageAlignSize(static_cast<u32>(program_image.size()) + bss_size)};
program_image.resize(image_size);