Skip to content

Commit

Permalink
Add several tests for linker script syntax
Browse files Browse the repository at this point in the history
Fixes a slice of #1276
  • Loading branch information
ISSOtm committed Feb 18, 2024
1 parent 0769694 commit b100c8e
Show file tree
Hide file tree
Showing 21 changed files with 67 additions and 0 deletions.
2 changes: 2 additions & 0 deletions test/link/script-different-bank.link
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
romx 2
"ROM1"
2 changes: 2 additions & 0 deletions test/link/script-different-bank.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
error: script-different-bank.link(2): The linker script places section "ROM1" in ROMX bank 2, but it was already defined in bank 1
Linking failed with 1 error
2 changes: 2 additions & 0 deletions test/link/script-different-type.link
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
sram 1
"ROM1"
2 changes: 2 additions & 0 deletions test/link/script-different-type.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
error: script-different-type.link(2): "ROM1" is specified to be a SRAM section, but it is already a ROMX section
Linking failed with 1 error
1 change: 1 addition & 0 deletions test/link/script-lone-dollar.link
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
vram $
2 changes: 2 additions & 0 deletions test/link/script-lone-dollar.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
error: script-lone-dollar.link(1): No hexadecimal digits found after '$'
Linking failed with 1 error
1 change: 1 addition & 0 deletions test/link/script-lone-percent.link
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
vram %
2 changes: 2 additions & 0 deletions test/link/script-lone-percent.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
error: script-lone-percent.link(1): No binary digits found after '%'
Linking failed with 1 error
8 changes: 8 additions & 0 deletions test/link/script-missing-bank-no.link
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
rom0
romx
vram
sram
wram0
wramx
oam
hram
5 changes: 5 additions & 0 deletions test/link/script-missing-bank-no.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
error: script-missing-bank-no.link(2): A bank number must be specified for ROMX
error: script-missing-bank-no.link(3): A bank number must be specified for VRAM
error: script-missing-bank-no.link(4): A bank number must be specified for SRAM
error: script-missing-bank-no.link(6): A bank number must be specified for WRAMX
Linking failed with 4 errors
5 changes: 5 additions & 0 deletions test/link/script-num-fmt.link
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
ROM0
org 42
org %101010
org $2A
org 41 ; Error!
2 changes: 2 additions & 0 deletions test/link/script-num-fmt.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
error: script-num-fmt.link(5): Cannot decrease the current address (from $002a to $0029)
Linking failed with 1 error
8 changes: 8 additions & 0 deletions test/link/script-oob-bank-num.link
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
rom0 1
romx 0
vram 2
wram0 1
wramx 0
wramx 8
oam 1
hram 1
9 changes: 9 additions & 0 deletions test/link/script-oob-bank-num.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
error: script-oob-bank-num.link(1): ROM0 bank 1 doesn't exist (the maximum is 0)
error: script-oob-bank-num.link(2): ROMX bank 0 doesn't exist (the minimum is 1)
error: script-oob-bank-num.link(3): VRAM bank 2 doesn't exist (the maximum is 1)
error: script-oob-bank-num.link(4): WRAM0 bank 1 doesn't exist (the maximum is 0)
error: script-oob-bank-num.link(5): WRAMX bank 0 doesn't exist (the minimum is 1)
error: script-oob-bank-num.link(6): WRAMX bank 8 doesn't exist (the maximum is 7)
error: script-oob-bank-num.link(7): OAM bank 1 doesn't exist (the maximum is 0)
error: script-oob-bank-num.link(8): HRAM bank 1 doesn't exist (the maximum is 0)
Linking failed with 8 errors
1 change: 1 addition & 0 deletions test/link/script-unk-keyword.link
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
bonjour
2 changes: 2 additions & 0 deletions test/link/script-unk-keyword.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
error: script-unk-keyword.link(1): Unknown keyword "bonjour"
Linking failed with 1 error
2 changes: 2 additions & 0 deletions test/link/script-unknown-section.link
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
rom0
"Wheeee"
2 changes: 2 additions & 0 deletions test/link/script-unknown-section.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
error: script-unknown-section.link(2): Unknown section "Wheeee"
Linking failed with 1 error
2 changes: 2 additions & 0 deletions test/link/script-unterminated-string.link
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
rom0
"ROM0
2 changes: 2 additions & 0 deletions test/link/script-unterminated-string.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
error: script-unterminated-string.link(2): Unterminated string
Linking failed with 1 error
5 changes: 5 additions & 0 deletions test/link/script.asm
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
; script*.link are tests for the linker script.
; So there isn't much to see here.

SECTION "ROM0", ROM0
SECTION "ROM1", ROMX,BANK[1]

0 comments on commit b100c8e

Please sign in to comment.