ref: f1b74fa610990b5bbf89480647950911aaded0fe
parent: c7a92d3104807f2831b706642adbd3492e440ac3
author: Rangi <remy.oukaour+rangi42@gmail.com>
date: Sat Aug 27 10:26:35 EDT 2022
Report empty space between sections in map file
--- a/src/link/output.c
+++ b/src/link/output.c
@@ -375,6 +375,7 @@
bank + sectionTypeInfo[type].firstBank);
uint16_t used = 0;
+ uint16_t prevEndAddr = sectionTypeInfo[type].startAddr;
while (section || zeroLenSection) {
struct SortedSection const **pickedSection =
@@ -382,12 +383,21 @@
struct Section const *sect = (*pickedSection)->section;
used += sect->size;
-
assert(sect->offset == 0);
+
+ if (prevEndAddr < sect->org) {
+ uint16_t empty = sect->org - prevEndAddr;
+
+ fprintf(mapFile, " EMPTY: $%04" PRIx16 " byte%s\n", empty,
+ empty == 1 ? "" : "s");
+ }
+
+ prevEndAddr = sect->org + sect->size;
+
if (sect->size != 0)
fprintf(mapFile, " SECTION: $%04" PRIx16 "-$%04x ($%04" PRIx16
" byte%s) [\"%s\"]\n",
- sect->org, sect->org + sect->size - 1,
+ sect->org, prevEndAddr - 1,
sect->size, sect->size == 1 ? "" : "s",
sect->name);
else
@@ -414,6 +424,14 @@
*pickedSection = (*pickedSection)->next;
}
+ uint16_t bankEndAddr = sectionTypeInfo[type].startAddr + sectionTypeInfo[type].size;
+
+ if (prevEndAddr < bankEndAddr) {
+ uint16_t empty = bankEndAddr - prevEndAddr;
+
+ fprintf(mapFile, " EMPTY: $%04" PRIx16 " byte%s\n", empty,
+ empty == 1 ? "" : "s");
+ }
if (used == 0) {
fputs(" EMPTY\n\n", mapFile);