shithub: rgbds

Download patch

ref: 573003113b7ddc17c42085fa059b32bf8754f48d
parent: 106ef895ee8030c49e9ac821568f1a330dc17798
author: ISSOtm <[email protected]>
date: Fri Apr 17 07:34:53 EDT 2020

Fix 0-byte sections incorrectly printed in map files

Fixes #515

--- a/src/link/output.c
+++ b/src/link/output.c
@@ -312,9 +312,14 @@
 
 		slack -= sect->size;
 
-		fprintf(mapFile, "  SECTION: $%04x-$%04x ($%04x byte%s) [\"%s\"]\n",
-			sect->org, sect->org + sect->size - 1, sect->size,
-			sect->size == 1 ? "" : "s", sect->name);
+		if (sect->size != 0)
+			fprintf(mapFile, "  SECTION: $%04x-$%04x ($%04x byte%s) [\"%s\"]\n",
+				sect->org, sect->org + sect->size - 1,
+				sect->size, sect->size == 1 ? "" : "s",
+				sect->name);
+		else
+			fprintf(mapFile, "  SECTION: $%04x (0 bytes) [\"%s\"]\n",
+				sect->org, sect->name);
 
 		for (size_t i = 0; i < sect->nbSymbols; i++)
 			fprintf(mapFile, "           $%04x = %s\n",