From ee81cb7fd377959981a87e21b58b0d40aded4c2d Mon Sep 17 00:00:00 2001 From: wheremyfoodat <44909372+wheremyfoodat@users.noreply.github.com> Date: Tue, 5 Aug 2025 23:00:09 +0300 Subject: [PATCH] NCSD loader: Fix BSS (again) (again) --- src/core/loader/ncsd.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/core/loader/ncsd.cpp b/src/core/loader/ncsd.cpp index 5ae6de15..dd3366af 100644 --- a/src/core/loader/ncsd.cpp +++ b/src/core/loader/ncsd.cpp @@ -39,7 +39,6 @@ bool Memory::mapCXI(NCSD& ncsd, NCCH& cxi) { u32 bssSize = (cxi.bssSize + 0xfff) & ~0xfff; // Round BSS size up to a page boundary // Total memory to allocate for loading u32 totalSize = (cxi.text.pageCount + cxi.rodata.pageCount + cxi.data.pageCount) * pageSize + bssSize; - code.resize(code.size() + bssSize, 0); // Pad the .code file with zeroes for the BSS segment if (code.size() < totalSize) { Helpers::panic("Total code size as reported by the exheader is larger than the .code file"); @@ -69,8 +68,10 @@ bool Memory::mapCXI(NCSD& ncsd, NCCH& cxi) { copyToVaddr(textAddr, code.data(), textSize); copyToVaddr(rodataAddr, code.data() + textSize, rodataSize); copyToVaddr(dataAddr, code.data() + textSize + rodataSize, cxi.data.pageCount << 12); + // Set BSS to zeroes - copyToVaddr(bssAddr, code.data() + textSize + rodataSize + (cxi.data.pageCount << 12), bssSize); + std::vector bss(bssSize, 0); + copyToVaddr(bssAddr, bss.data(), bssSize); ncsd.entrypoint = cxi.text.address;