Skip to content

Commit 0d3980d

Browse files
Rangi42ISSOtm
authored andcommitted
Refactor how map file sections are printed
This makes size-0 sections print as "($0000 bytes)" instead of "(0 bytes)", which is more consistent.
1 parent ab6244d commit 0d3980d

File tree

3 files changed

+6
-10
lines changed

3 files changed

+6
-10
lines changed

src/link/output.cpp

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -452,17 +452,10 @@ static void writeMapBank(SortedSections const &sectList, SectionType type, uint3
452452

453453
prevEndAddr = sect->org + sect->size;
454454

455+
fprintf(mapFile, "\tSECTION: $%04" PRIx16, sect->org);
455456
if (sect->size != 0)
456-
fprintf(
457-
mapFile,
458-
"\tSECTION: $%04" PRIx16 "-$%04x ($%04" PRIx16 " byte%s) [\"",
459-
sect->org,
460-
prevEndAddr - 1,
461-
sect->size,
462-
sect->size == 1 ? "" : "s"
463-
);
464-
else
465-
fprintf(mapFile, "\tSECTION: $%04" PRIx16 " (0 bytes) [\"", sect->org);
457+
fprintf(mapFile, "-$%04x", prevEndAddr - 1);
458+
fprintf(mapFile, " ($%04" PRIx16 " byte%s) [\"", sect->size, sect->size == 1 ? "" : "s");
466459
printSectionName(sect->name, mapFile);
467460
fputs("\"]\n", mapFile);
468461

test/link/map-file/a.asm

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,3 +25,5 @@ wLabel1:: ds 6
2525
SECTION "hram", HRAM
2626
hLabel:: ds 7
2727
.local::
28+
29+
SECTION "\n\r\t\"\\", ROM0[1]

test/link/map-file/ref.out.map

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ ROM0 bank #0:
1010
SECTION: $0000-$0000 ($0001 byte) ["rom0"]
1111
$0000 = Label0
1212
$0001 = Label0.local
13+
SECTION: $0001 ($0000 bytes) ["\n\r\t\"\\"]
1314
EMPTY: $0001-$3fff ($3fff bytes)
1415
TOTAL EMPTY: $3fff bytes
1516

0 commit comments

Comments
 (0)