mirror of
https://github.com/gbdev/rgbds.git
synced 2026-09-22 13:47:05 +00:00
Fix constrained empty sections escaping their regions (#2137)
This commit is contained in:
@@ -0,0 +1,2 @@
|
||||
SECTION "fixed", ROM0[$4321]
|
||||
assert @ == $4321
|
||||
+10
-2
@@ -338,8 +338,16 @@ static void placeSection(Section §ion) {
|
||||
}
|
||||
}
|
||||
|
||||
assignSection(section, location);
|
||||
return;
|
||||
// This check safely handles sections with impossible alignment and no fixed address.
|
||||
// The above `location.address = section.typeInfo().startAddr` would be valid on its own,
|
||||
// but `location.makeAddressAligned(...)` can increase `location.address` above the valid
|
||||
// range for its `section`, which would violate an assumption in `assignSection`.
|
||||
// Note that sections with fixed addresses are handled earlier by `sect_DoSanityChecks`,
|
||||
// but this check would safely handle them too if they ever reached it.
|
||||
if (location.address <= section.typeInfo().endAddr() + 1) {
|
||||
assignSection(section, location);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
FreeSpaceIter iter = tryPlacing(section, location);
|
||||
|
||||
@@ -0,0 +1,2 @@
|
||||
FATAL: Unable to place "aligned" (ROM0 section) with align mask $8000 and offset $6420
|
||||
Linking aborted with 1 error
|
||||
@@ -0,0 +1,2 @@
|
||||
SECTION "aligned", ROM0, ALIGN[15, $6420]
|
||||
assert @ == $6420
|
||||
@@ -0,0 +1,2 @@
|
||||
error: Section "z"'s fixed address $4321 is outside of range [$0000; $3fff]
|
||||
Linking failed with 1 error
|
||||
@@ -0,0 +1,2 @@
|
||||
SECTION "z", ROM0[$4321]
|
||||
assert @ == $4321
|
||||
Reference in New Issue
Block a user