From 960f82126f4030a567effd06ed69bfe40797a8b4 Mon Sep 17 00:00:00 2001 From: ISSOtm Date: Wed, 16 Sep 2026 12:32:19 -0400 Subject: [PATCH] Fix to actually allow one-past-the-end zero-sized sections in linker scripts --- src/link/layout.cpp | 2 +- test/link/script-oob-org.out | 8 +------- 2 files changed, 2 insertions(+), 8 deletions(-) diff --git a/src/link/layout.cpp b/src/link/layout.cpp index 5d4db1b5..b5a79145 100644 --- a/src/link/layout.cpp +++ b/src/link/layout.cpp @@ -92,7 +92,7 @@ void layout_SetAddr(uint32_t addr) { if (uint16_t &pc = curAddr[activeType][activeBankIdx]; addr < pc) { scriptError("Cannot decrease the current address (from $%04x to $%04x)", pc, addr); - } else if (addr > typeInfo.endAddr()) { // Allow "one past the end" sections. + } else if (addr > typeInfo.endAddr() + 1u) { // Allow "one past the end" zero-sized sections. scriptError( "Cannot set the current address to $%04" PRIx32 ": %s ends at $%04" PRIx16, addr, diff --git a/test/link/script-oob-org.out b/test/link/script-oob-org.out index b92bbc97..b1350b97 100644 --- a/test/link/script-oob-org.out +++ b/test/link/script-oob-org.out @@ -1,19 +1,13 @@ -error: Cannot set the current address to $4000: ROM0 ends at $3fff - at script-oob-org.link(2) error: Cannot set the current address to $4001: ROM0 ends at $3fff at script-oob-org.link(3) error: Cannot decrease the current address (from $4000 to $3fff) at script-oob-org.link(6) -error: Cannot set the current address to $8000: ROMX ends at $7fff - at script-oob-org.link(7) error: Cannot set the current address to $8001: ROMX ends at $7fff at script-oob-org.link(8) error: Cannot decrease the current address (from $ff80 to $0000) at script-oob-org.link(11) error: Cannot decrease the current address (from $ff80 to $ff7f) at script-oob-org.link(12) -error: Cannot set the current address to $ffff: HRAM ends at $fffe - at script-oob-org.link(14) error: Cannot set the current address to $10000: HRAM ends at $fffe at script-oob-org.link(15) -Linking failed with 9 errors +Linking failed with 6 errors