From 4ca7afa60103729277e19321be47b927142e4c5a Mon Sep 17 00:00:00 2001 From: Michael Scire Date: Sun, 17 Jan 2021 22:51:40 -0800 Subject: [PATCH] nso/kip: fix miscalculation when printing rwdata/bss extents --- kip.c | 4 ++-- nso.c | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/kip.c b/kip.c index 22f6600..768a51e 100644 --- a/kip.c +++ b/kip.c @@ -255,8 +255,8 @@ void kip1_print(kip1_ctx_t *ctx, int suppress) { printf(" Sections:\n"); printf(" .text: %08"PRIx32"-%08"PRIx32"\n", ctx->header->section_headers[0].out_offset, ctx->header->section_headers[0].out_offset + align(ctx->header->section_headers[0].out_size, 0x1000)); printf(" .rodata: %08"PRIx32"-%08"PRIx32"\n", ctx->header->section_headers[1].out_offset, ctx->header->section_headers[1].out_offset + align(ctx->header->section_headers[1].out_size, 0x1000)); - printf(" .rwdata: %08"PRIx32"-%08"PRIx32"\n", ctx->header->section_headers[2].out_offset, ctx->header->section_headers[2].out_offset + align(ctx->header->section_headers[2].out_size, 0x1000)); - printf(" .bss: %08"PRIx32"-%08"PRIx32"\n", ctx->header->section_headers[3].out_offset, ctx->header->section_headers[3].out_offset + align(ctx->header->section_headers[3].out_size, 0x1000)); + printf(" .rwdata: %08"PRIx32"-%08"PRIx32"\n", ctx->header->section_headers[2].out_offset, ctx->header->section_headers[2].out_offset + ctx->header->section_headers[2].out_size); + printf(" .bss: %08"PRIx32"-%08"PRIx32"\n",ctx->header->section_headers[2].out_offset + ctx->header->section_headers[2].out_size, ctx->header->section_headers[3].out_offset + align(ctx->header->section_headers[3].out_size, 0x1000)); printf(" Kernel Access Control:\n"); kac_print(ctx->header->capabilities, 0x20); printf("\n"); diff --git a/nso.c b/nso.c index 84184cd..df39404 100644 --- a/nso.c +++ b/nso.c @@ -102,11 +102,11 @@ void nso0_print(nso0_ctx_t *ctx) { printf(" .rodata: %08"PRIx32"-%08"PRIx32"\n", ctx->header->segments[1].dst_off, ctx->header->segments[1].dst_off + align(ctx->header->segments[1].decomp_size, 0x1000)); } if ((ctx->tool_ctx->action & ACTION_VERIFY) && ctx->segment_validities[2] != VALIDITY_UNCHECKED) { - printf(" .rwdata (%s): %08"PRIx32"-%08"PRIx32"\n", GET_VALIDITY_STR(ctx->segment_validities[2]), ctx->header->segments[2].dst_off, ctx->header->segments[2].dst_off + align(ctx->header->segments[2].decomp_size, 0x1000)); + printf(" .rwdata (%s): %08"PRIx32"-%08"PRIx32"\n", GET_VALIDITY_STR(ctx->segment_validities[2]), ctx->header->segments[2].dst_off, ctx->header->segments[2].dst_off + ctx->header->segments[2].decomp_size); } else { - printf(" .rwdata: %08"PRIx32"-%08"PRIx32"\n", ctx->header->segments[2].dst_off, ctx->header->segments[2].dst_off + align(ctx->header->segments[2].decomp_size, 0x1000)); + printf(" .rwdata: %08"PRIx32"-%08"PRIx32"\n", ctx->header->segments[2].dst_off, ctx->header->segments[2].dst_off + ctx->header->segments[2].decomp_size); } - printf(" .bss: %08"PRIx32"-%08"PRIx32"\n", ctx->header->segments[2].dst_off + align(ctx->header->segments[2].decomp_size, 0x1000), ctx->header->segments[2].dst_off + align(ctx->header->segments[2].decomp_size, 0x1000) + align(ctx->header->segments[2].align_or_total_size, 0x1000)); + printf(" .bss: %08"PRIx32"-%08"PRIx32"\n", ctx->header->segments[2].dst_off + ctx->header->segments[2].decomp_size, ctx->header->segments[2].dst_off + align(ctx->header->segments[2].decomp_size + ctx->header->segments[2].align_or_total_size, 0x1000)); } void nso0_save(nso0_ctx_t *ctx) {