From e400eac42b497ca11387de0a7f3e8100d33cf6ab Mon Sep 17 00:00:00 2001 From: ISSOtm Date: Wed, 26 Jun 2019 00:44:26 +0200 Subject: [PATCH] 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 --- src/asm/output.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/asm/output.c b/src/asm/output.c index 7e729118..a0d76d79 100644 --- 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 @@ static void checksectionoverflow(uint32_t delta_size) { 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 @@ static void checksectionoverflow(uint32_t delta_size) * 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); } }