ref: 0d3401058d83b469ef7be63d066ca9bed819735c
parent: 6e123ccc364b8bed9c38f884666271810c37578c
author: Antonio Niño Díaz <[email protected]>
date: Sun Apr 23 21:29:40 EDT 2017
Check max section sizes in rgblink The max size of some section types depends on the flags passed to rgblink. Instead of doing in rgbasm some checks (for the sections with fixed size) and others in rgblink, all checks are now done in rgblink. Signed-off-by: Antonio Niño Díaz <[email protected]>
--- a/src/link/object.c
+++ b/src/link/object.c
@@ -169,6 +169,42 @@
}
}
+ unsigned int maxsize = 0;
+
+ /* Verify that the section isn't too big */
+ switch (pSection->Type)
+ {
+ case SECT_ROM0:
+ maxsize = (options & OPT_TINY) ? 0x8000 : 0x4000;
+ break;
+ case SECT_ROMX:
+ maxsize = 0x4000;
+ break;
+ case SECT_VRAM:
+ case SECT_SRAM:
+ maxsize = 0x2000;
+ break;
+ case SECT_WRAM0:
+ maxsize = (options & OPT_CONTWRAM) ? 0x2000 : 0x1000;
+ break;
+ case SECT_WRAMX:
+ maxsize = 0x1000;
+ break;
+ case SECT_OAM:
+ maxsize = 0xA0;
+ break;
+ case SECT_HRAM:
+ maxsize = 0x7F;
+ break;
+ default:
+ errx(1, "Section \"%s\" has an invalid section type.", pzName);
+ break;
+ }
+ if (pSection->nByteSize > maxsize) {
+ errx(1, "Section \"%s\" is bigger than the max size for that type: 0x%X > 0x%X",
+ pzName, pSection->nByteSize, maxsize);
+ }
+
if ((pSection->Type == SECT_ROMX) || (pSection->Type == SECT_ROM0)) {
/*
* These sectiontypes contain data...