From 817fec685993ff4f9ee486c5169a6fc2c26ba9d8 Mon Sep 17 00:00:00 2001 From: yellows8 Date: Sun, 10 Dec 2017 23:12:15 -0500 Subject: [PATCH] Fixed bss handling in tools. --- tools/elf2nro.c | 2 +- tools/elf2nso.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/tools/elf2nro.c b/tools/elf2nro.c index f4e84ead..72e56ced 100644 --- a/tools/elf2nro.c +++ b/tools/elf2nro.c @@ -126,7 +126,7 @@ int main(int argc, char* argv[]) { // .bss is special if (i == 3) { - nro_hdr.bssSize = (phdr->p_memsz + 0xFFF) & ~0xFFF; + nro_hdr.bssSize = ((phdr->p_memsz - phdr->p_filesz) + 0xFFF) & ~0xFFF; break; } diff --git a/tools/elf2nso.c b/tools/elf2nso.c index 7ec34996..bf2ce3a5 100644 --- a/tools/elf2nso.c +++ b/tools/elf2nso.c @@ -127,9 +127,9 @@ int main(int argc, char* argv[]) { nso_hdr.Segments[i].DstOff = phdr->p_vaddr; nso_hdr.Segments[i].DecompSz = phdr->p_filesz; - // for .data segment this field contains total sz including bss + // for .data segment this field contains bss size if (i == 2) - nso_hdr.Segments[i].AlignOrTotalSz = phdr->p_memsz; + nso_hdr.Segments[i].AlignOrTotalSz = phdr->p_memsz - phdr->p_filesz; else nso_hdr.Segments[i].AlignOrTotalSz = 1;