shithub: rgbds

Download patch

ref: e27da737c6aca9659458d95c32d606ebbea7380c
parent: e6ae1992fe04525c9f9cf95ad2e4d72f4cd63c3e
author: ISSOtm <eldredhabert0@gmail.com>
date: Thu Apr 14 19:58:32 EDT 2022

Print name of up to 10 floating sections on overlay error

--- a/src/link/assign.c
+++ b/src/link/assign.c
@@ -8,6 +8,7 @@
 
 #include <inttypes.h>
 #include <stdbool.h>
+#include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
 
@@ -446,9 +447,27 @@
 
 	/* Overlaying requires only fully-constrained sections */
 	verbosePrint("Assigning other sections...\n");
-	if (overlayFileName)
-		errx("All sections must be fixed when using an overlay file; %" PRIu64 " %sn't",
-		     nbSectionsToAssign, nbSectionsToAssign == 1 ? "is" : "are");
+	if (overlayFileName) {
+		fprintf(stderr, "FATAL: All sections must be fixed when using an overlay file");
+		uint8_t nbSections = 0;
+		for (int8_t constraints = BANK_CONSTRAINED | ALIGN_CONSTRAINED; constraints >= 0; constraints--) {
+			for (sectionPtr = unassignedSections[constraints];
+			     sectionPtr;
+			     sectionPtr = sectionPtr->next) {
+				fprintf(stderr, "%c \"%s\"",
+					nbSections == 0 ? ';': ',', sectionPtr->section->name);
+				nbSections++;
+				if (nbSections == 10)
+					goto max_out;
+			}
+		}
+
+max_out:
+		if (nbSectionsToAssign != nbSections)
+			fprintf(stderr, " and %" PRIu64 " more", nbSectionsToAssign - nbSections);
+		fprintf(stderr, " %sn't\n", nbSectionsToAssign == 1 ? "is" : "are");
+		exit(1);
+	}
 
 	/* Assign all remaining sections by decreasing constraint order */
 	for (int8_t constraints = BANK_CONSTRAINED | ALIGN_CONSTRAINED;