mirror of
https://github.com/gbdev/rgbds.git
synced 2026-09-18 11:47:06 +00:00
Fix RGBLINK ignoring alignment constraints when placing empty sections
Fixes #2095
This commit is contained in:
+8
-2
@@ -256,12 +256,18 @@ static void placeSection(Section §ion) {
|
||||
|
||||
// Specially handle 0-byte SECTIONs, as they can't overlap anything
|
||||
if (section.size == 0) {
|
||||
// Unless the SECTION's address was fixed, the starting address
|
||||
// is fine for any alignment, as checked in sect_DoSanityChecks.
|
||||
// Unless the SECTION has a fixed address or non-zero alignment, the starting
|
||||
// address is fine for any alignment, as checked in `sect_DoSanityChecks`.
|
||||
MemoryLocation location = {
|
||||
.address = section.isAddressFixed ? section.org : typeInfo.startAddr,
|
||||
.bank = section.isBankFixed ? section.bank : typeInfo.firstBank,
|
||||
};
|
||||
if (section.isAlignFixed && !section.isAddressFixed) {
|
||||
if (uint16_t offset = (location.address - section.alignOfs) & section.alignMask;
|
||||
offset != 0) {
|
||||
location.address += section.alignMask + 1 - offset;
|
||||
}
|
||||
}
|
||||
assignSection(section, location);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
; Sections going into space already reserved.
|
||||
SECTION "address", ROM0[$0135]
|
||||
assert @ == $0135
|
||||
|
||||
SECTION "align16", ROM0, ALIGN[16,$0123] ; Should be equivalent to the above.
|
||||
assert @ == $0123
|
||||
|
||||
SECTION "align", ROM0, ALIGN[8,42]
|
||||
assert @ == 42 ; Assuming that it goes into the first suitable location.
|
||||
|
||||
|
||||
SECTION "om nom nom", ROM0[0]
|
||||
ds $200 ; Filling the first part of ROM0, so that the above don't land in a “free space” block but the next do.
|
||||
|
||||
|
||||
SECTION "free address", ROM0[$2468]
|
||||
assert @ == $2468
|
||||
|
||||
SECTION "free align16", ROM0, ALIGN[16,$2222] ; Should be equivalent to the above.
|
||||
assert @ == $2222
|
||||
|
||||
SECTION "free align", ROM0, ALIGN[13,$1234] ; Has more than one suitable location, so cannot be trivially solved.
|
||||
assert @ == $1234 ; Assuming that it goes into the first suitable location.
|
||||
Reference in New Issue
Block a user