shithub: rgbds

Download patch

ref: e400eac42b497ca11387de0a7f3e8100d33cf6ab
parent: 3cd1d46a1bf66df5fafe04dde885cc6f3dfcdb28
author: ISSOtm <[email protected]>
date: Tue Jun 25 20:44:26 EDT 2019

Improve section overflow error message
When trying to fix a section becoming too large, the size it reached is necessary to know whether to optimize away a few bytes or split it entirely.
This error is also commonly encountered when INCBINing too large a slice of a file, in which case the amount of bytes by which the section is too large is again an useful information

--- a/src/asm/output.c
+++ b/src/asm/output.c
@@ -1,7 +1,7 @@
 /*
  * This file is part of RGBDS.
  *
- * Copyright (c) 1997-2018, Carsten Sorensen and RGBDS contributors.
+ * Copyright (c) 1997-2019, Carsten Sorensen and RGBDS contributors.
  *
  * SPDX-License-Identifier: MIT
  */
@@ -516,8 +516,9 @@
 {
 	uint32_t maxsize = getmaxsectionsize(pCurrentSection->nType,
 					  pCurrentSection->pzName);
+	uint32_t new_size = pCurrentSection->nPC + delta_size;
 
-	if (pCurrentSection->nPC + delta_size > maxsize) {
+	if (new_size > maxsize) {
 		/*
 		 * This check is here to trap broken code that generates
 		 * sections that are too big and to prevent the assembler from
@@ -525,8 +526,8 @@
 		 * memory.
 		 * The real check must be done at the linking stage.
 		 */
-		fatalerror("Section '%s' is too big (max size = 0x%X bytes).",
-			   pCurrentSection->pzName, maxsize);
+		fatalerror("Section '%s' is too big (max size = 0x%X bytes, reached 0x%X).",
+			   pCurrentSection->pzName, maxsize, new_size);
 	}
 }