mirror of
https://github.com/gbdev/rgbds.git
synced 2026-08-25 16:24:36 +00:00
Fix condition for invalid bank range check (#2016)
This commit is contained in:
@@ -204,12 +204,14 @@ static void doSanityChecks(Section §ion) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool bankModeError = false;
|
||||||
if (options.is32kMode && section.type == SECTTYPE_ROMX) {
|
if (options.is32kMode && section.type == SECTTYPE_ROMX) {
|
||||||
if (section.isBankFixed && section.bank != 1) {
|
if (section.isBankFixed && section.bank != 1) {
|
||||||
error(
|
error(
|
||||||
"Section \"%s\" has type `ROMX`, which must be in bank 1 (if any) with option '-t'",
|
"Section \"%s\" has type `ROMX`, which must be in bank 1 (if any) with option '-t'",
|
||||||
section.name.c_str()
|
section.name.c_str()
|
||||||
);
|
);
|
||||||
|
bankModeError = true;
|
||||||
} else {
|
} else {
|
||||||
section.type = SECTTYPE_ROM0;
|
section.type = SECTTYPE_ROM0;
|
||||||
}
|
}
|
||||||
@@ -221,15 +223,18 @@ static void doSanityChecks(Section §ion) {
|
|||||||
"'-d'",
|
"'-d'",
|
||||||
section.name.c_str()
|
section.name.c_str()
|
||||||
);
|
);
|
||||||
|
bankModeError = true;
|
||||||
} else {
|
} else {
|
||||||
section.type = SECTTYPE_WRAM0;
|
section.type = SECTTYPE_WRAM0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (options.isDmgMode && section.type == SECTTYPE_VRAM && section.bank == 1) {
|
if (options.isDmgMode && section.type == SECTTYPE_VRAM && section.isBankFixed
|
||||||
|
&& section.bank != 0) {
|
||||||
error(
|
error(
|
||||||
"Section \"%s\" has type `VRAM`, which must be in bank 0 with option '-d'",
|
"Section \"%s\" has type `VRAM`, which must be in bank 0 with option '-d'",
|
||||||
section.name.c_str()
|
section.name.c_str()
|
||||||
);
|
);
|
||||||
|
bankModeError = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check if alignment is reasonable, this is important to avoid UB
|
// Check if alignment is reasonable, this is important to avoid UB
|
||||||
@@ -251,7 +256,8 @@ static void doSanityChecks(Section §ion) {
|
|||||||
uint32_t minbank = sectionTypeInfo[section.type].firstBank,
|
uint32_t minbank = sectionTypeInfo[section.type].firstBank,
|
||||||
maxbank = sectionTypeInfo[section.type].lastBank;
|
maxbank = sectionTypeInfo[section.type].lastBank;
|
||||||
|
|
||||||
if (section.isBankFixed && section.bank < minbank && section.bank > maxbank) {
|
if (!bankModeError && section.isBankFixed
|
||||||
|
&& (section.bank < minbank || section.bank > maxbank)) {
|
||||||
error(
|
error(
|
||||||
minbank == maxbank
|
minbank == maxbank
|
||||||
? "Cannot place section \"%s\" in bank %" PRIu32 ", it must be %" PRIu32
|
? "Cannot place section \"%s\" in bank %" PRIu32 ", it must be %" PRIu32
|
||||||
|
|||||||
Reference in New Issue
Block a user