mirror of
https://github.com/gbdev/rgbds.git
synced 2026-08-19 13:24:27 +00:00
Fix OOM for too-small overlay files in 32K mode (rgblink -t)
This commit is contained in:
+7
-4
@@ -126,7 +126,8 @@ static uint32_t checkOverlaySize() {
|
||||
warnx("Overlay file does not have a size multiple of 0x4000");
|
||||
} else if (options.is32kMode && overlaySize != 0x8000) {
|
||||
warnx("Overlay is not exactly 0x8000 bytes large");
|
||||
} else if (overlaySize < 0x8000) {
|
||||
}
|
||||
if (overlaySize < 0x8000) {
|
||||
warnx("Overlay is less than 0x8000 bytes large");
|
||||
}
|
||||
|
||||
@@ -140,9 +141,11 @@ static void coverOverlayBanks(uint32_t nbOverlayBanks) {
|
||||
// 2 if options.is32kMode, 1 otherwise
|
||||
uint32_t nbRom0Banks = sectionTypeInfo[SECTTYPE_ROM0].size / BANK_SIZE;
|
||||
// Discount ROM0 banks to avoid outputting too much
|
||||
uint32_t nbUncoveredBanks = nbOverlayBanks - nbRom0Banks > sections[SECTTYPE_ROMX].size()
|
||||
? nbOverlayBanks - nbRom0Banks
|
||||
: 0;
|
||||
uint32_t nbUncoveredBanks =
|
||||
nbOverlayBanks >= nbRom0Banks
|
||||
&& nbOverlayBanks - nbRom0Banks > sections[SECTTYPE_ROMX].size()
|
||||
? nbOverlayBanks - nbRom0Banks
|
||||
: 0;
|
||||
|
||||
if (nbUncoveredBanks > sections[SECTTYPE_ROMX].size()) {
|
||||
for (uint32_t i = sections[SECTTYPE_ROMX].size(); i < nbUncoveredBanks; ++i) {
|
||||
|
||||
@@ -0,0 +1,2 @@
|
||||
SECTION "test", ROM0[$42]
|
||||
Label:: dw Label
|
||||
@@ -0,0 +1,3 @@
|
||||
warning: Overlay file does not have a size multiple of 0x4000
|
||||
warning: Overlay is less than 0x8000 bytes large
|
||||
warning: Output is larger than overlay file, but no padding value was specified
|
||||
Binary file not shown.
File diff suppressed because one or more lines are too long
@@ -1 +1,2 @@
|
||||
warning: Overlay file does not have a size multiple of 0x4000
|
||||
warning: Overlay is less than 0x8000 bytes large
|
||||
|
||||
@@ -260,6 +260,16 @@ tryDiff "$test"/out.err "$outtemp"
|
||||
tryCmp "$test"/out.gb "$gbtemp"
|
||||
evaluateTest
|
||||
|
||||
test="overlay/smaller-32k"
|
||||
startTest
|
||||
"$RGBASM" -o "$otemp" "$test"/a.asm
|
||||
continueTest
|
||||
rgblinkQuiet -o "$gbtemp" -t -O "$test"/overlay.gb "$otemp" 2>"$outtemp"
|
||||
tryDiff "$test"/out.err "$outtemp"
|
||||
# This test does not trim its output with 'dd' because it needs to verify the correct output size
|
||||
tryCmp "$test"/out.gb "$gbtemp"
|
||||
evaluateTest
|
||||
|
||||
test="overlay/unfixed"
|
||||
startTest
|
||||
"$RGBASM" -o "$otemp" "$test"/a.asm
|
||||
|
||||
Reference in New Issue
Block a user