Fixed bss handling

This commit is contained in:
plutoo 2017-09-09 04:48:27 +02:00
parent 866c11ff0e
commit a26953776e

View File

@ -14,7 +14,7 @@ typedef struct {
u32 FileOff; u32 FileOff;
u32 DstOff; u32 DstOff;
u32 DecompSz; u32 DecompSz;
u32 Align; u32 AlignOrTotalSz;
} NsoSegment; } NsoSegment;
typedef u8 Sha2Hash[0x20]; typedef u8 Sha2Hash[0x20];
@ -112,11 +112,16 @@ int main(int argc, char* argv[]) {
uint8_t* comp_buf[3]; uint8_t* comp_buf[3];
size_t comp_sz[3]; size_t comp_sz[3];
for (i=0; i<hdr->e_phnum; i++, phdr++) { for (i=0; i<3; i++, phdr++) {
nso_hdr.Segments[i].FileOff = file_off; nso_hdr.Segments[i].FileOff = file_off;
nso_hdr.Segments[i].DstOff = phdr->p_vaddr; nso_hdr.Segments[i].DstOff = phdr->p_vaddr;
nso_hdr.Segments[i].DecompSz = phdr->p_filesz; nso_hdr.Segments[i].DecompSz = phdr->p_filesz;
nso_hdr.Segments[i].Align = 1;
// for .data segment this field contains total sz including bss
if (i == 2)
nso_hdr.Segments[i].AlignOrTotalSz = phdr->p_memsz;
else
nso_hdr.Segments[i].AlignOrTotalSz = 1;
SHA256_CTX ctx; SHA256_CTX ctx;
sha256_init(&ctx); sha256_init(&ctx);