Add a few more linker script tests

This commit is contained in:
ISSOtm
2024-02-19 00:23:00 +01:00
parent 3860ab11c7
commit 18e83c17b4
16 changed files with 67 additions and 5 deletions

View File

@@ -422,7 +422,7 @@ static void alignTo(uint32_t alignment, uint32_t alignOfs) {
if (alignOfs >= alignSize) {
scriptError(context, "Cannot align: The alignment offset (%" PRIu32
") must be less than alignment size (%" PRIu32 ")\n",
") must be less than alignment size (%" PRIu32 ")",
alignOfs, alignSize);
return;
}
@@ -437,7 +437,7 @@ static void alignTo(uint32_t alignment, uint32_t alignOfs) {
auto &pc = curAddr[activeType][activeBankIdx];
if (alignment > 16) {
scriptError(context, "Cannot align: The alignment (%" PRIu32 ") must be less than 16\n",
scriptError(context, "Cannot align: The alignment (%" PRIu32 ") must be less than 16",
alignment);
return;
}
@@ -450,7 +450,7 @@ static void alignTo(uint32_t alignment, uint32_t alignOfs) {
if (alignOfs >= alignSize) {
scriptError(context, "Cannot align: The alignment offset (%" PRIu32
") must be less than alignment size (%" PRIu32 ")\n",
") must be less than alignment size (%" PRIu32 ")",
alignOfs, alignSize);
return;
}
@@ -546,9 +546,10 @@ static void placeSection(std::string const &name, bool isOptional) {
uint16_t curOfs = org - typeInfo.startAddr;
if (section->size > typeInfo.size - curOfs) {
scriptError(context, "The linker script assigns section \"%s\" to address $%04" PRIx16 ", but then it would overflow %s by %" PRIx16 " bytes",
uint16_t overflowSize = section->size - (typeInfo.size - curOfs);
scriptError(context, "The linker script assigns section \"%s\" to address $%04" PRIx16 ", but then it would overflow %s by %" PRIx16 " byte%s",
name.c_str(), org, typeInfo.name.c_str(),
(uint16_t)(section->size - (typeInfo.size - curOfs)));
overflowSize, overflowSize == 1 ? "" : "s");
// Fill as much as possible without going out of bounds.
org = typeInfo.startAddr + typeInfo.size;
} else {

View File

@@ -0,0 +1,2 @@
rom0
align 17, $1234

View File

@@ -0,0 +1,2 @@
error: script-align-17.link(2): Cannot align: The alignment (17) must be less than 16
Linking failed with 1 error

View File

@@ -0,0 +1,7 @@
rom0
ds $4000 ; OK
ds 1 ; Boom!
hram
ds $7F ; OK
ds $FFFF ; Boom!

View File

@@ -0,0 +1,3 @@
error: script-ds-overflow.link(3): Cannot increase the current address by 1 bytes: only 0 bytes to $4000
error: script-ds-overflow.link(7): Cannot increase the current address by 65535 bytes: only 0 bytes to $ffff
Linking failed with 2 errors

View File

@@ -0,0 +1,2 @@
rom0
align 1, 2

View File

@@ -0,0 +1,2 @@
error: script-excess-align-ofs.link(2): Cannot align: The alignment offset (2) must be less than alignment size (2)
Linking failed with 1 error

View File

@@ -0,0 +1,2 @@
rom0
ds $10000

View File

@@ -0,0 +1,2 @@
error: script-huge-ds.link(2): Cannot increase the current address by 65536 bytes: only 16384 bytes to $4000
Linking failed with 1 error

View File

@@ -0,0 +1,15 @@
rom0
org $4000 ; OK
org $4001 ; Nope
romx 1
org $3FFF ; Nope
org $8000 ; OK
org $8001 ; Nope
hram
org 0 ; Nope
org $FF7F ; Nope
org $FF80 ; OK
org $FFFF ; OK
org $10000 ; Nope

View File

@@ -0,0 +1,10 @@
error: script-oob-org.link(2): Cannot set the current address to $4000: ROM0 ends at $3fff
error: script-oob-org.link(3): Cannot set the current address to $4001: ROM0 ends at $3fff
error: script-oob-org.link(6): Cannot decrease the current address (from $4000 to $3fff)
error: script-oob-org.link(7): Cannot set the current address to $8000: ROMX ends at $7fff
error: script-oob-org.link(8): Cannot set the current address to $8001: ROMX ends at $7fff
error: script-oob-org.link(11): Cannot decrease the current address (from $ff80 to $0000)
error: script-oob-org.link(12): Cannot decrease the current address (from $ff80 to $ff7f)
error: script-oob-org.link(14): Cannot set the current address to $ffff: HRAM ends at $fffe
error: script-oob-org.link(15): Cannot set the current address to $10000: HRAM ends at $fffe
Linking failed with 9 errors

View File

@@ -0,0 +1,5 @@
romx 2
org $7000
"ROM2 1K" ; OK
"ROM2 1" ; Boom!

View File

@@ -0,0 +1,2 @@
error: script-overflowing-sect.link(5): The linker script assigns section "ROM2 1" to address $8000, but then it would overflow ROMX by 1 byte
Linking failed with 1 error

View File

@@ -0,0 +1 @@
"The section isn't even known"

View File

@@ -0,0 +1,2 @@
error: script-typeless-bank.link(1): No memory region has been specified to place section "The section isn't even known" in
Linking failed with 1 error

View File

@@ -3,3 +3,7 @@
SECTION "ROM0", ROM0
SECTION "ROM1", ROMX,BANK[1]
SECTION "ROM2 1K", ROMX,BANK[2]
ds $1000
SECTION "ROM2 1", ROMX,BANK[2]
ds 1