Skip to content

Commit

Permalink
Refactor how map file sections are printed
Browse files Browse the repository at this point in the history
This makes size-0 sections print as "($0000 bytes)" instead of
"(0 bytes)", which is more consistent.
  • Loading branch information
Rangi42 committed Oct 22, 2024
1 parent 6547644 commit c3471ae
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
13 changes: 3 additions & 10 deletions src/link/output.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -452,17 +452,10 @@ static void writeMapBank(SortedSections const &sectList, 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);

Expand Down
4 changes: 4 additions & 0 deletions test/link/map-file/a.asm
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,7 @@ wLabel1:: ds 6
SECTION "hram", HRAM
hLabel:: ds 7
.local::

SECTION "empty", ROM0
EmptyLabel::
.local::
3 changes: 3 additions & 0 deletions test/link/map-file/ref.out.map
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ SUMMARY:
HRAM: 7 bytes used / 120 free

ROM0 bank #0:
SECTION: $0000 ($0000 bytes) ["empty"]
$0000 = EmptyLabel.local
$0000 = EmptyLabel
SECTION: $0000-$0000 ($0001 byte) ["rom0"]
$0000 = Label0
$0001 = Label0.local
Expand Down

0 comments on commit c3471ae

Please sign in to comment.