mirror of
https://github.com/gbdev/rgbds.git
synced 2026-10-03 10:45:37 +00:00
Fix large ds in linker script overflowing the PC
This commit is contained in:
1 parent
c0ff3d92ad
commit
19e60d9864
6 files changed
+24
-1
No files matched your search
+3
-1
@@ -204,7 +204,9 @@ void layout_Pad(uint32_t length) {
|
||||
uint16_t &pc = curAddr[activeType][activeBankIdx];
|
||||
|
||||
assume(pc >= typeInfo.startAddr);
|
||||
if (uint16_t offset = pc - typeInfo.startAddr; length + offset > typeInfo.size) {
|
||||
// `length + offset` can overflow `uint32_t`, so check just `length` first
|
||||
if (uint16_t offset = pc - typeInfo.startAddr;
|
||||
length > typeInfo.size || length + offset > typeInfo.size) {
|
||||
scriptError(
|
||||
"Cannot increase the current address by %u bytes: only %u bytes to $%04" PRIx16,
|
||||
length,
|
||||
|
||||
Reference in new issue
Block a user