Avoid aligning BSS and .data individually and instead align as one

As both of these are in the same memory segment they have no individual
alignment requirements, this created a bug in
にゃんらぶ~私の恋の見つけ方~ where the data segment would be larger
than the game expected and invalid command line arguments would be read.
This commit is contained in:
Billy Laws 2021-05-31 17:23:59 +01:00
parent e1ca24d35f
commit d57883705d

View File

@ -46,10 +46,10 @@ namespace skyline::loader {
executable.ro.offset = header.ro.memoryOffset;
executable.data.contents = GetSegment(backing, header.data, header.flags.dataCompressed ? header.dataCompressedSize : 0);
executable.data.contents.resize(util::AlignUp(executable.data.contents.size(), PAGE_SIZE));
executable.data.offset = header.data.memoryOffset;
executable.bssSize = util::AlignUp(header.bssSize, PAGE_SIZE);
// Data and BSS are aligned together
executable.bssSize = util::AlignUp(executable.data.contents.size() + header.bssSize, PAGE_SIZE) - executable.data.contents.size();
if (header.dynsym.offset + header.dynsym.size <= header.ro.decompressedSize && header.dynstr.offset + header.dynstr.size <= header.ro.decompressedSize) {
executable.dynsym = {header.dynsym.offset, header.dynsym.size};