Don't comment "; Next fragment/union" in .map files for empty section pieces

Fixes #1821
This commit is contained in:
Rangi42
2025-09-05 15:17:21 -04:00
parent f7fb3af615
commit e569e0c200
9 changed files with 54 additions and 16 deletions

View File

@@ -433,25 +433,28 @@ uint16_t forEachSection(SortedSections const &sectList, F callback) {
}
static void writeMapSymbols(Section const *sect) {
for (uint16_t org = sect->org; sect; sect = sect->nextu.get()) {
uint16_t org = sect->org;
for (bool announced = true; sect; sect = sect->nextu.get(), announced = false) {
for (Symbol *sym : sect->symbols) {
// Don't output symbols that begin with an illegal character
if (sym->name.empty() || !startsIdentifier(sym->name[0])) {
continue;
}
// Announce this "piece" before its contents
if (!announced) {
if (sect->modifier == SECTION_UNION) {
fputs("\t ; Next union\n", mapFile);
} else if (sect->modifier == SECTION_FRAGMENT) {
fputs("\t ; Next fragment\n", mapFile);
}
announced = true;
}
// Space matches "\tSECTION: $xxxx ..."
fprintf(mapFile, "\t $%04" PRIx32 " = ", sym->label().offset + org);
writeSymName(sym->name, mapFile);
putc('\n', mapFile);
}
// Announce the following "piece"
if (SectionModifier mod = sect->nextu ? sect->nextu->modifier : SECTION_NORMAL;
mod == SECTION_UNION) {
fputs("\t ; Next union\n", mapFile);
} else if (mod == SECTION_FRAGMENT) {
fputs("\t ; Next fragment\n", mapFile);
}
}
}

View File

@@ -0,0 +1,18 @@
section "PrintHL", rom0
PrintHL::
; ...
ret
section "PrintNth", rom0
PrintNth::
ld hl, [[
dw [[ db "one\0" ]]
dw [[ db "two\0" ]]
dw [[ db "three\0" ]]
dw [[ db "four\0" ]]
]]
ld d, 0
ld e, a
add hl, de
add hl, de
call PrintHL

Binary file not shown.

View File

@@ -0,0 +1,10 @@
SUMMARY:
ROM0: 39 bytes used / 16345 free
ROM0 bank #0:
SECTION: $0000-$0025 ($0026 bytes) ["PrintNth"]
$0000 = PrintNth
SECTION: $0026-$0026 ($0001 byte) ["PrintHL"]
$0026 = PrintHL
EMPTY: $0027-$3fff ($3fd9 bytes)
TOTAL EMPTY: $3fd9 bytes

View File

@@ -0,0 +1,3 @@
; File generated by rgblink
00:0000 PrintNth
00:0026 PrintHL

View File

@@ -1,8 +1,7 @@
SECTION FRAGMENT "rom", ROM0
Part3::
; No labels in this fragment
LOAD FRAGMENT "ram", WRAM0
wPart3::
jr wPart1
jr wPart3
ENDL
Part3End::

View File

@@ -7,9 +7,6 @@ ROM0 bank #0:
$0000 = Part1
$0004 = Part1End
; Next fragment
$0010 = Part3
$0014 = Part3End
; Next fragment
$0004 = Part2
$0010 = Part2End
EMPTY: $0014-$3fff ($3fec bytes)

View File

@@ -3,7 +3,5 @@
00:0004 Part1End
00:0004 Part2
00:0010 Part2End
00:0010 Part3
00:0014 Part3End
00:c000 wPart1
00:c004 wPart3

View File

@@ -174,6 +174,16 @@ for test in fragment-align/*; do
evaluateTest
done
test="fragment-literals"
startTest
"$RGBASM" -o "$otemp" "$test"/a.asm
continueTest
rgblinkQuiet -o "$gbtemp" -m "$outtemp" -n "$outtemp2" "$otemp"
tryCmpRom "$test"/ref.out.bin
tryDiff "$test"/ref.out.map "$outtemp"
tryDiff "$test"/ref.out.sym "$outtemp2"
evaluateTest
test="high-low"
startTest
"$RGBASM" -o "$otemp" "$test"/a.asm