ref: 10140f74dc10fcc624f3686e09246277b8c7c93a
parent: 558e8f46ff578f713147343148c8b46e789c965f
author: ISSOtm <[email protected]>
date: Thu Jan 16 13:10:35 EST 2020
Allow RGBLINK to report multiple sanity check errors
--- a/src/link/section.c
+++ b/src/link/section.c
@@ -97,22 +97,28 @@
hash_EmptyMap(sections);
}
+static bool sanityChecksFailed;
+
static void doSanityChecks(struct Section *section, void *ptr)
{
(void)ptr;
+#define fail(...) do { \
+ warnx(__VA_ARGS__); \
+ sanityChecksFailed = true; \
+} while (0)
/* Sanity check the section's type */
if (section->type < 0 || section->type >= SECTTYPE_INVALID)
- errx(1, "Section \"%s\" has an invalid type.", section->name);
+ fail("Section \"%s\" has an invalid type.", section->name);
if (is32kMode && section->type == SECTTYPE_ROMX)
- errx(1, "%s: ROMX sections cannot be used with option -t.",
+ fail("%s: ROMX sections cannot be used with option -t.",
section->name);
if (isWRA0Mode && section->type == SECTTYPE_WRAMX)
- errx(1, "%s: WRAMX sections cannot be used with options -w or -d.",
+ fail("%s: WRAMX sections cannot be used with options -w or -d.",
section->name);
if (isDmgMode && section->type == SECTTYPE_VRAM && section->bank == 1)
- errx(1, "%s: VRAM bank 1 can't be used with option -d.",
+ fail("%s: VRAM bank 1 can't be used with option -d.",
section->name);
/*
@@ -127,7 +133,7 @@
if (section->isBankFixed && section->bank < minbank
&& section->bank > maxbank)
- errx(1, minbank == maxbank
+ fail(minbank == maxbank
? "Cannot place section \"%s\" in bank %d, it must be %d"
: "Cannot place section \"%s\" in bank %d, it must be between %d and %d",
section->name, section->bank, minbank, maxbank);
@@ -134,7 +140,7 @@
/* Check if section has a chance to be placed */
if (section->size > maxsize[section->type])
- errx(1, "Section \"%s\" is bigger than the max size for that type: %#x > %#x",
+ fail("Section \"%s\" is bigger than the max size for that type: %#x > %#x",
section->size, maxsize[section->type]);
/* Translate loose constraints to strong ones when they're equivalent */
@@ -150,7 +156,7 @@
/* It doesn't make sense to have both org and alignment set */
if (section->isAddressFixed) {
if (section->org & section->alignMask)
- errx(1, "Section \"%s\"'s fixed address doesn't match its alignment",
+ fail("Section \"%s\"'s fixed address doesn't match its alignment",
section->name);
section->isAlignFixed = false;
} else if ((endaddr(type) & section->alignMask)
@@ -165,18 +171,22 @@
/* Ensure the target address is valid */
if (section->org < startaddr[section->type]
|| section->org > endaddr(section->type))
- errx(1, "Section \"%s\"'s fixed address %#x is outside of range [%#x; %#x]",
+ fail("Section \"%s\"'s fixed address %#x is outside of range [%#x; %#x]",
section->name, section->org,
startaddr[section->type], endaddr(section->type));
if (section->org + section->size > endaddr(section->type) + 1)
- errx(1, "Section \"%s\"'s end address %#x is greater than last address %#x",
+ fail("Section \"%s\"'s end address %#x is greater than last address %#x",
section->name, section->org + section->size,
endaddr(section->type) + 1);
}
+
+#undef fail
}
void sect_DoSanityChecks(void)
{
sect_ForEach(doSanityChecks, NULL);
+ if (sanityChecksFailed)
+ errx(1, "Sanity checks failed");
}
--- a/test/link/romx-tiny-t.out
+++ b/test/link/romx-tiny-t.out
@@ -1,1 +1,2 @@
-error: rx: ROMX sections cannot be used with option -t.
+warning: rx: ROMX sections cannot be used with option -t.
+error: Sanity checks failed
--- a/test/link/vram-fixed-dmg-mode-d.out
+++ b/test/link/vram-fixed-dmg-mode-d.out
@@ -1,1 +1,2 @@
-error: v1: VRAM bank 1 can't be used with option -d.
+warning: v1: VRAM bank 1 can't be used with option -d.
+error: Sanity checks failed
--- a/test/link/wramx-dmg-mode-d.out
+++ b/test/link/wramx-dmg-mode-d.out
@@ -1,1 +1,2 @@
-error: wx: WRAMX sections cannot be used with options -w or -d.
+warning: wx: WRAMX sections cannot be used with options -w or -d.
+error: Sanity checks failed