Test RGBLINK on SDCC object files (#1479)

This commit is contained in:
Sylvie
2024-08-20 17:51:01 -04:00
committed by GitHub
parent 57c3d74b9e
commit 82e81ab1da
14 changed files with 166 additions and 0 deletions

18
test/link/sdcc/good/a.asm Normal file
View File

@@ -0,0 +1,18 @@
SECTION "entry", ROM0[$0100]
jp start
SECTION "header", ROM0[$0104]
ds $150 - $104, 0
SECTION "start", ROM0
start:
ld de, 0
call _function0 ; bc <- 1
ld b, b ; breakpoint
ld d, b :: ld e, c ; de <- bc
call _function1 ; bc <- 3
ld b, b ; breakpoint
stop

11
test/link/sdcc/good/b.c Normal file
View File

@@ -0,0 +1,11 @@
// sdcc -c -msm83 -o b.rel b.c
#ifdef __SDCC_sm83
const int sm83 = 1;
#else
const int sm83 = 0;
#endif
int function0(int de) {
return de | sm83;
}

24
test/link/sdcc/good/b.rel Normal file
View File

@@ -0,0 +1,24 @@
XL3
H 9 areas 3 global symbols
M b
O -msm83
S .__.ABS. Def000000
A _CODE size 7 flags 0 addr 0
S _sm83 Def000005
S _function0 Def000000
A _DATA size 0 flags 0 addr 0
A _INITIALIZED size 0 flags 0 addr 0
A _DABS size 0 flags 8 addr 0
A _HOME size 0 flags 0 addr 0
A _GSINIT size 0 flags 0 addr 0
A _GSFINAL size 0 flags 0 addr 0
A _INITIALIZER size 0 flags 0 addr 0
A _CABS size 0 flags 8 addr 0
T 00 00 00
R 00 00 00 00
T 00 00 00 4B 42 CB C1 C9
R 00 00 00 00
T 05 00 00
R 00 00 00 00
T 05 00 00 01 00
R 00 00 00 00

5
test/link/sdcc/good/c.c Normal file
View File

@@ -0,0 +1,5 @@
// sdcc -c -msm83 -o c.rel c.c
int function1(int de) {
return de | 0b10;
}

19
test/link/sdcc/good/c.rel Normal file
View File

@@ -0,0 +1,19 @@
XL3
H 9 areas 2 global symbols
M c
O -msm83
S .__.ABS. Def000000
A _CODE size 5 flags 0 addr 0
S _function1 Def000000
A _DATA size 0 flags 0 addr 0
A _INITIALIZED size 0 flags 0 addr 0
A _DABS size 0 flags 8 addr 0
A _HOME size 0 flags 0 addr 0
A _GSINIT size 0 flags 0 addr 0
A _GSFINAL size 0 flags 0 addr 0
A _INITIALIZER size 0 flags 0 addr 0
A _CABS size 0 flags 8 addr 0
T 00 00 00
R 00 00 00 00
T 00 00 00 4B 42 CB C9 C9
R 00 00 00 00

View File

Binary file not shown.

View File

@@ -0,0 +1,6 @@
; File generated by rgblink
00:0000 start
01:4000 _function0
01:4005 _sm83
01:4007 _function1
00 .__.ABS.

View File

@@ -0,0 +1,21 @@
ROM0
FLOATING
"_HOME" OPTIONAL
"_BASE" OPTIONAL
"_CODE_0" OPTIONAL
"_LIT_0" OPTIONAL
"_INITIALIZER" OPTIONAL ; Initializer of `_INITIALIZED`
"_GSINIT" OPTIONAL ; Reportedly internal to the crt0; TODO: investigate this
"_GSFINAL" OPTIONAL
ROMX FLOATING
FLOATING
"_CODE" OPTIONAL
"_LIT" OPTIONAL
WRAM0
FLOATING
"_DATA" OPTIONAL ; Uninitialized RAM
"_BSS" OPTIONAL ; Zero-initialized RAM
"_INITIALIZED" OPTIONAL ; Initialised by `_INITIALIZER`
"_DABS (ABS)" OPTIONAL ; TODO: what is this?

View File

@@ -0,0 +1,12 @@
SECTION "entry", ROM0[$0100]
jp start
SECTION "header", ROM0[$0104]
ds $150 - $104, 0
SECTION "start", ROM0
start:
ld de, 1234
call _function ; de <- 1234 * 2
ld b, b ; breakpoint
stop

View File

@@ -0,0 +1,5 @@
// sdcc -c -msm83 -o b.rel b.c
int function(int de) {
return de * 2;
}

View File

@@ -0,0 +1,19 @@
XL3
H 9 areas 2 global symbols
M b
O -msm83
S .__.ABS. Def000000
A _CODE size 6 flags 0 addr 0
S _function Def000000
A _DATA size 0 flags 0 addr 0
A _INITIALIZED size 0 flags 0 addr 0
A _DABS size 0 flags 8 addr 0
A _HOME size 0 flags 0 addr 0
A _GSINIT size 0 flags 0 addr 0
A _GSFINAL size 0 flags 0 addr 0
A _INITIALIZER size 0 flags 0 addr 0
A _CABS size 0 flags 8 addr 0
T 00 00 00
R 00 00 00 00
T 00 00 00 6B 62 29 4D 44 C9
R 00 00 00 00

View File

@@ -0,0 +1,8 @@
error: Section "_INITIALIZER" has not been assigned a type by a linker script
error: Section "_GSFINAL" has not been assigned a type by a linker script
error: Section "_GSINIT" has not been assigned a type by a linker script
error: Section "_HOME" has not been assigned a type by a linker script
error: Section "_INITIALIZED" has not been assigned a type by a linker script
error: Section "_DATA" has not been assigned a type by a linker script
error: Section "_CODE" has not been assigned a type by a linker script
Linking failed with 7 errors

View File

@@ -232,6 +232,24 @@ tryDiff "$test"/out.err "$outtemp"
tryCmpRomSize "$gbtemp" 65536 tryCmpRomSize "$gbtemp" 65536
evaluateTest evaluateTest
test="sdcc/good"
startTest
"$RGBASM" -o "$otemp" "$test"/a.asm
continueTest
rgblinkQuiet -o "$gbtemp" -n "$outtemp2" -l "$test"/script.link "$otemp" "$test"/b.rel "$test"/c.rel 2>"$outtemp"
tryDiff "$test"/out.err "$outtemp"
tryDiff "$test"/ref.out.sym "$outtemp2"
tryCmpRom "$test"/ref.out.bin
evaluateTest
test="sdcc/no-script"
startTest
"$RGBASM" -o "$otemp" "$test"/a.asm
continueTest
rgblinkQuiet "$otemp" "$test"/b.rel 2>"$outtemp"
tryDiff "$test"/out.err "$outtemp"
evaluateTest
test="section-fragment/good" test="section-fragment/good"
startTest startTest
"$RGBASM" -o "$otemp" "$test"/a.asm "$RGBASM" -o "$otemp" "$test"/a.asm