rgblink identifies patches' PC sections after reading all sections

Fixes #794
This commit is contained in:
Rangi
2021-03-18 13:21:24 -04:00
committed by Eldred Habert
parent 5fb7fcf461
commit 8d1b56bcf5
5 changed files with 54 additions and 28 deletions

View File

@@ -0,0 +1,12 @@
SECTION "main", ROM0
LOAD FRAGMENT "test", SRAM
ENDL
; The RPN patch for 'jr Label' in section "alt" refers to section "test",
; but the object file puts section "test" after section "alt".
; This case needs to be handled when identifying patches' PC sections.
SECTION "alt", ROM0
LOAD FRAGMENT "test", SRAM
jr Label
Label:
ENDL

View File

Binary file not shown.

View File

@@ -39,7 +39,7 @@ tryCmp () {
fi
}
rgblink() {
rgblinkQuiet () {
out="$(env $RGBLINK "$@")" || return $?
if [[ -n "$out" ]]; then
echo "$bold${red}Linking shouldn't produce anything on stdout!$rescolors$resbold"
@@ -55,13 +55,13 @@ for i in *.asm; do
ran_flag=
for flag in '-d' '-t' '-w'; do
if [ -f ${i%.asm}-no${flag}.out ]; then
rgblink -o $gbtemp $otemp > $outtemp 2>&1
rgblinkQuiet -o $gbtemp $otemp > $outtemp 2>&1
tryDiff ${i%.asm}-no${flag}.out $outtemp
rc=$(($? || $rc))
ran_flag=1
fi
if [ -f ${i%.asm}${flag}.out ]; then
rgblink ${flag} -o $gbtemp $otemp > $outtemp 2>&1
rgblinkQuiet ${flag} -o $gbtemp $otemp > $outtemp 2>&1
tryDiff ${i%.asm}${flag}.out $outtemp
rc=$(($? || $rc))
ran_flag=1
@@ -73,7 +73,7 @@ for i in *.asm; do
# Other tests have several linker scripts
find . -name "${i%.asm}*.link" | while read script; do
rgblink -l $script -o $gbtemp $otemp > $outtemp 2>&1
rgblinkQuiet -l $script -o $gbtemp $otemp > $outtemp 2>&1
tryDiff ${script%.link}.out $outtemp
rc=$(($? || $rc))
ran_flag=1
@@ -83,7 +83,7 @@ for i in *.asm; do
fi
# The rest of the tests just links a file, and maybe checks the binary
rgblink -o $gbtemp $otemp > $outtemp 2>&1
rgblinkQuiet -o $gbtemp $otemp > $outtemp 2>&1
if [ -f ${i%.asm}.out ]; then
tryDiff ${i%.asm}.out $outtemp
rc=$(($? || $rc))
@@ -103,7 +103,7 @@ i="bank-const.asm"
startTest
$RGBASM -o $otemp bank-const/a.asm
$RGBASM -o $gbtemp2 bank-const/b.asm
rgblink -o $gbtemp $gbtemp2 $otemp > $outtemp 2>&1
rgblinkQuiet -o $gbtemp $gbtemp2 $otemp > $outtemp 2>&1
tryDiff bank-const/out.err $outtemp
rc=$(($? || $rc))
@@ -111,7 +111,7 @@ for i in fragment-align/*; do
startTest
$RGBASM -o $otemp $i/a.asm
$RGBASM -o $gbtemp2 $i/b.asm
rgblink -o $gbtemp $otemp $gbtemp2 2>$outtemp
rgblinkQuiet -o $gbtemp $otemp $gbtemp2 2>$outtemp
tryDiff $i/out.err $outtemp
rc=$(($? || $rc))
if [[ -f $i/out.gb ]]; then
@@ -124,16 +124,16 @@ done
i="high-low.asm"
startTest
$RGBASM -o $otemp high-low/a.asm
rgblink -o $gbtemp $otemp
rgblinkQuiet -o $gbtemp $otemp
$RGBASM -o $otemp high-low/b.asm
rgblink -o $gbtemp2 $otemp
rgblinkQuiet -o $gbtemp2 $otemp
tryCmp $gbtemp $gbtemp2
rc=$(($? || $rc))
i="overlay.asm"
startTest
$RGBASM -o $otemp overlay/a.asm
rgblink -o $gbtemp -t -O overlay/overlay.gb $otemp > $outtemp 2>&1
rgblinkQuiet -o $gbtemp -t -O overlay/overlay.gb $otemp > $outtemp 2>&1
# This test does not trim its output with 'dd' because it needs to verify the correct output size
tryDiff overlay/out.err $outtemp
rc=$(($? || $rc))
@@ -144,7 +144,7 @@ i="section-union/good.asm"
startTest
$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
rgblinkQuiet -o $gbtemp -l section-union/good/script.link $otemp $gbtemp2
dd if=$gbtemp count=1 bs=$(printf %s $(wc -c < section-union/good/ref.out.bin)) > $otemp 2>/dev/null
tryCmp section-union/good/ref.out.bin $otemp
rc=$(($? || $rc))
@@ -153,7 +153,7 @@ i="section-union/fragments.asm"
startTest
$RGBASM -o $otemp section-union/fragments/a.asm
$RGBASM -o $gbtemp2 section-union/fragments/b.asm
rgblink -o $gbtemp $otemp $gbtemp2
rgblinkQuiet -o $gbtemp $otemp $gbtemp2
dd if=$gbtemp count=1 bs=$(printf %s $(wc -c < section-union/fragments/ref.out.bin)) > $otemp 2>/dev/null
tryCmp section-union/fragments/ref.out.bin $otemp
rc=$(($? || $rc))
@@ -162,7 +162,7 @@ for i in section-union/*.asm; do
startTest
$RGBASM -o $otemp $i
$RGBASM -o $gbtemp2 $i -DSECOND
if rgblink $otemp $gbtemp2 2>$outtemp; then
if rgblinkQuiet $otemp $gbtemp2 2>$outtemp; then
echo -e "${bold}${red}$i didn't fail to link!${rescolors}${resbold}"
rc=1
fi