From 0d3980d039a7d93a8294e4eb299d1f22ee6501d8 Mon Sep 17 00:00:00 2001 From: Rangi42 Date: Tue, 22 Oct 2024 17:05:26 -0400 Subject: [PATCH] Refactor how map file sections are printed This makes size-0 sections print as "($0000 bytes)" instead of "(0 bytes)", which is more consistent. --- src/link/output.cpp | 13 +++---------- test/link/map-file/a.asm | 2 ++ test/link/map-file/ref.out.map | 1 + 3 files changed, 6 insertions(+), 10 deletions(-) diff --git a/src/link/output.cpp b/src/link/output.cpp index 3e9329e2..f7760ce7 100644 --- a/src/link/output.cpp +++ b/src/link/output.cpp @@ -452,17 +452,10 @@ static void writeMapBank(SortedSections const §List, SectionType type, uint3 prevEndAddr = sect->org + sect->size; + fprintf(mapFile, "\tSECTION: $%04" PRIx16, sect->org); if (sect->size != 0) - fprintf( - mapFile, - "\tSECTION: $%04" PRIx16 "-$%04x ($%04" PRIx16 " byte%s) [\"", - sect->org, - prevEndAddr - 1, - sect->size, - sect->size == 1 ? "" : "s" - ); - else - fprintf(mapFile, "\tSECTION: $%04" PRIx16 " (0 bytes) [\"", sect->org); + fprintf(mapFile, "-$%04x", prevEndAddr - 1); + fprintf(mapFile, " ($%04" PRIx16 " byte%s) [\"", sect->size, sect->size == 1 ? "" : "s"); printSectionName(sect->name, mapFile); fputs("\"]\n", mapFile); diff --git a/test/link/map-file/a.asm b/test/link/map-file/a.asm index dd9f676e..9f19a174 100644 --- a/test/link/map-file/a.asm +++ b/test/link/map-file/a.asm @@ -25,3 +25,5 @@ wLabel1:: ds 6 SECTION "hram", HRAM hLabel:: ds 7 .local:: + +SECTION "\n\r\t\"\\", ROM0[1] diff --git a/test/link/map-file/ref.out.map b/test/link/map-file/ref.out.map index 5ad9797a..b12a8348 100644 --- a/test/link/map-file/ref.out.map +++ b/test/link/map-file/ref.out.map @@ -10,6 +10,7 @@ ROM0 bank #0: SECTION: $0000-$0000 ($0001 byte) ["rom0"] $0000 = Label0 $0001 = Label0.local + SECTION: $0001 ($0000 bytes) ["\n\r\t\"\\"] EMPTY: $0001-$3fff ($3fff bytes) TOTAL EMPTY: $3fff bytes