mirror of
https://github.com/gbdev/rgbds.git
synced 2025-11-20 10:12:06 +00:00
Add a few more linker script tests
This commit is contained in:
@@ -422,7 +422,7 @@ static void alignTo(uint32_t alignment, uint32_t alignOfs) {
|
|||||||
|
|
||||||
if (alignOfs >= alignSize) {
|
if (alignOfs >= alignSize) {
|
||||||
scriptError(context, "Cannot align: The alignment offset (%" PRIu32
|
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);
|
alignOfs, alignSize);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -437,7 +437,7 @@ static void alignTo(uint32_t alignment, uint32_t alignOfs) {
|
|||||||
auto &pc = curAddr[activeType][activeBankIdx];
|
auto &pc = curAddr[activeType][activeBankIdx];
|
||||||
|
|
||||||
if (alignment > 16) {
|
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);
|
alignment);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -450,7 +450,7 @@ static void alignTo(uint32_t alignment, uint32_t alignOfs) {
|
|||||||
|
|
||||||
if (alignOfs >= alignSize) {
|
if (alignOfs >= alignSize) {
|
||||||
scriptError(context, "Cannot align: The alignment offset (%" PRIu32
|
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);
|
alignOfs, alignSize);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -546,9 +546,10 @@ static void placeSection(std::string const &name, bool isOptional) {
|
|||||||
|
|
||||||
uint16_t curOfs = org - typeInfo.startAddr;
|
uint16_t curOfs = org - typeInfo.startAddr;
|
||||||
if (section->size > typeInfo.size - curOfs) {
|
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(),
|
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.
|
// Fill as much as possible without going out of bounds.
|
||||||
org = typeInfo.startAddr + typeInfo.size;
|
org = typeInfo.startAddr + typeInfo.size;
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
2
test/link/script-align-17.link
Normal file
2
test/link/script-align-17.link
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
rom0
|
||||||
|
align 17, $1234
|
||||||
2
test/link/script-align-17.out
Normal file
2
test/link/script-align-17.out
Normal 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
|
||||||
7
test/link/script-ds-overflow.link
Normal file
7
test/link/script-ds-overflow.link
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
rom0
|
||||||
|
ds $4000 ; OK
|
||||||
|
ds 1 ; Boom!
|
||||||
|
|
||||||
|
hram
|
||||||
|
ds $7F ; OK
|
||||||
|
ds $FFFF ; Boom!
|
||||||
3
test/link/script-ds-overflow.out
Normal file
3
test/link/script-ds-overflow.out
Normal 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
|
||||||
2
test/link/script-excess-align-ofs.link
Normal file
2
test/link/script-excess-align-ofs.link
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
rom0
|
||||||
|
align 1, 2
|
||||||
2
test/link/script-excess-align-ofs.out
Normal file
2
test/link/script-excess-align-ofs.out
Normal 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
|
||||||
2
test/link/script-huge-ds.link
Normal file
2
test/link/script-huge-ds.link
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
rom0
|
||||||
|
ds $10000
|
||||||
2
test/link/script-huge-ds.out
Normal file
2
test/link/script-huge-ds.out
Normal 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
|
||||||
15
test/link/script-oob-org.link
Normal file
15
test/link/script-oob-org.link
Normal 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
|
||||||
10
test/link/script-oob-org.out
Normal file
10
test/link/script-oob-org.out
Normal 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
|
||||||
5
test/link/script-overflowing-sect.link
Normal file
5
test/link/script-overflowing-sect.link
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
|
||||||
|
romx 2
|
||||||
|
org $7000
|
||||||
|
"ROM2 1K" ; OK
|
||||||
|
"ROM2 1" ; Boom!
|
||||||
2
test/link/script-overflowing-sect.out
Normal file
2
test/link/script-overflowing-sect.out
Normal 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
|
||||||
1
test/link/script-typeless-bank.link
Normal file
1
test/link/script-typeless-bank.link
Normal file
@@ -0,0 +1 @@
|
|||||||
|
"The section isn't even known"
|
||||||
2
test/link/script-typeless-bank.out
Normal file
2
test/link/script-typeless-bank.out
Normal 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
|
||||||
@@ -3,3 +3,7 @@
|
|||||||
|
|
||||||
SECTION "ROM0", ROM0
|
SECTION "ROM0", ROM0
|
||||||
SECTION "ROM1", ROMX,BANK[1]
|
SECTION "ROM1", ROMX,BANK[1]
|
||||||
|
SECTION "ROM2 1K", ROMX,BANK[2]
|
||||||
|
ds $1000
|
||||||
|
SECTION "ROM2 1", ROMX,BANK[2]
|
||||||
|
ds 1
|
||||||
|
|||||||
Reference in New Issue
Block a user