shithub: rgbds

Download patch

ref: 190678107bc79a19ce787ce94233661ae1dc45ef
parent: 9f82fa4cf7df9e18d8b44bc91c525411a51f8e2e
author: ISSOtm <eldredhabert0@gmail.com>
date: Tue Apr 7 16:41:20 EDT 2020

Prevent RGBLINK from crashing when getting the bank of a constant

diff: cannot open b/test/link/bank-const//null: file does not exist: 'b/test/link/bank-const//null'
--- a/src/link/patch.c
+++ b/src/link/patch.c
@@ -260,6 +260,11 @@
 				      patch->fileName,
 				      fileSymbols[value]->name);
 				value = 1;
+			} else if (!symbol->section) {
+				error("%s: Requested BANK() of non-label symbol \"%s\"",
+				      patch->fileName,
+				      fileSymbols[value]->name);
+				value = 1;
 			} else {
 				value = symbol->section->bank;
 			}
--- /dev/null
+++ b/test/link/bank-const/a.asm
@@ -1,0 +1,2 @@
+CONSTANT equ 0
+EXPORT CONSTANT
--- /dev/null
+++ b/test/link/bank-const/b.asm
@@ -1,0 +1,2 @@
+SECTION "Test", ROM0[0]
+	db BANK(CONSTANT)
--- /dev/null
+++ b/test/link/bank-const/err.out
@@ -1,0 +1,2 @@
+error: bank-const/b.asm(2): Requested BANK() of non-label symbol "CONSTANT"
+Linking failed with 1 error
--- a/test/link/test.sh
+++ b/test/link/test.sh
@@ -80,6 +80,12 @@
 i="high-low.asm" tryCmp $gbtemp $gbtemp2
 rc=$(($? || $rc))
 
+$RGBASM -o $otemp bank-const/a.asm
+$RGBASM -o $gbtemp2 bank-const/b.asm
+$RGBLINK -o $gbtemp $gbtemp2 $otemp > $outtemp 2>&1
+i="bank-const.asm" tryDiff bank-const/err.out $outtemp
+rc=$(($? || $rc))
+
 $RGBASM -o $otemp section-union/good/a.asm
 $RGBASM -o $gbtemp2 section-union/good/b.asm
 $RGBLINK -o $gbtemp -l section-union/good/script.link $otemp $gbtemp2