mirror of
https://github.com/gbdev/rgbds.git
synced 2026-09-18 11:47:06 +00:00
Fix underflow of ALIGN[16, offset] (#2090)
This commit is contained in:
+11
-2
@@ -717,8 +717,17 @@ void sect_AlignPC(uint8_t alignment, uint16_t offset) {
|
|||||||
} else if (alignment == 16) {
|
} else if (alignment == 16) {
|
||||||
// Treat an alignment large enough as fixing the address.
|
// Treat an alignment large enough as fixing the address.
|
||||||
// Note that this also ensures that a section's alignment never becomes 16 or greater.
|
// Note that this also ensures that a section's alignment never becomes 16 or greater.
|
||||||
sect->align = 0; // Reset the alignment, since we're fixing the address.
|
if (offset < curOffset) {
|
||||||
sect->org = offset - curOffset;
|
error(
|
||||||
|
"Section already contains %" PRIu32
|
||||||
|
" bytes, higher than this aligned address $%04" PRIx32,
|
||||||
|
curOffset,
|
||||||
|
offset
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
sect->align = 0; // Reset the alignment, since we're fixing the address.
|
||||||
|
sect->org = offset - curOffset;
|
||||||
|
}
|
||||||
} else if (alignment > sect->align) {
|
} else if (alignment > sect->align) {
|
||||||
sect->align = alignment;
|
sect->align = alignment;
|
||||||
// We need `(sect->alignOfs + curOffset) & alignMask == offset`
|
// We need `(sect->alignOfs + curOffset) & alignMask == offset`
|
||||||
|
|||||||
@@ -0,0 +1,3 @@
|
|||||||
|
SECTION "test", ROM0
|
||||||
|
db 1, 2, 3
|
||||||
|
align 16, 2
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
error: Section already contains 3 bytes, higher than this aligned address $0002
|
||||||
|
at align-beyond-size.asm(3)
|
||||||
|
Assembly aborted with 1 error
|
||||||
Reference in New Issue
Block a user