Fix SECTION UNION alignment depending on piece order

This commit is contained in:
Rangi
2026-01-06 17:53:47 -05:00
committed by Rangi
parent 92bfe5d930
commit a91d26192d
6 changed files with 36 additions and 0 deletions

View File

@@ -96,6 +96,7 @@ static void checkSectUnionCompat(Section &target, Section &other) {
if (checkAgainstFixedAlign(target, other, other.alignOfs)) { if (checkAgainstFixedAlign(target, other, other.alignOfs)) {
target.isAlignFixed = true; target.isAlignFixed = true;
target.alignMask = other.alignMask; target.alignMask = other.alignMask;
target.alignOfs = other.alignOfs;
} }
} }
} }

View File

@@ -0,0 +1,4 @@
SECTION "ROM", ROM0
LOAD UNION "U", WRAM0
ds 1
ENDL

View File

@@ -0,0 +1,17 @@
SECTION "R1", WRAM0
ds $77
SECTION "R2", WRAM0
ds $ef
SECTION UNION "U", WRAM0
ds $52e
SECTION UNION "U", WRAM0
wStart::
ds $89
assert @ & $FF == 0, "wContent must be 8-bit aligned"
align 8
wContent::
ds $111
wEnd::

Binary file not shown.

View File

@@ -0,0 +1,5 @@
WRAM0
align 8
"R1"
"U"
"R2"

View File

@@ -390,6 +390,15 @@ rgblinkQuiet "$otemp" "$gbtemp" 2>"$outtemp"
tryDiff "$test"/out.err "$outtemp" tryDiff "$test"/out.err "$outtemp"
evaluateTest evaluateTest
test="section-union/compat"
startTest
"$RGBASM" -o "$otemp" "$test"/a.asm
"$RGBASM" -o "$gbtemp2" "$test"/b.asm
continueTest
rgblinkQuiet -o "$gbtemp" -l "$test"/script.link "$otemp" "$gbtemp2"
tryCmpRom "$test"/ref.out.bin
evaluateTest
test="section-union/good" test="section-union/good"
startTest startTest
"$RGBASM" -o "$otemp" "$test"/a.asm "$RGBASM" -o "$otemp" "$test"/a.asm