Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test RGBLINK on SDCC object files #1479

Merged
merged 1 commit into from
Aug 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions test/link/sdcc/good/a.asm
Original file line number Diff line number Diff line change
@@ -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 changes: 11 additions & 0 deletions test/link/sdcc/good/b.c
Original file line number Diff line number Diff line change
@@ -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 changes: 24 additions & 0 deletions test/link/sdcc/good/b.rel
Original file line number Diff line number Diff line change
@@ -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 changes: 5 additions & 0 deletions test/link/sdcc/good/c.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
// sdcc -c -msm83 -o c.rel c.c

int function1(int de) {
return de | 0b10;
}
19 changes: 19 additions & 0 deletions test/link/sdcc/good/c.rel
Original file line number Diff line number Diff line change
@@ -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
Empty file added test/link/sdcc/good/out.err
Empty file.
Binary file added test/link/sdcc/good/ref.out.bin
Binary file not shown.
6 changes: 6 additions & 0 deletions test/link/sdcc/good/ref.out.sym
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
; File generated by rgblink
00:0000 start
01:4000 _function0
01:4005 _sm83
01:4007 _function1
00 .__.ABS.
21 changes: 21 additions & 0 deletions test/link/sdcc/good/script.link
Original file line number Diff line number Diff line change
@@ -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?
12 changes: 12 additions & 0 deletions test/link/sdcc/no-script/a.asm
Original file line number Diff line number Diff line change
@@ -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
5 changes: 5 additions & 0 deletions test/link/sdcc/no-script/b.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
// sdcc -c -msm83 -o b.rel b.c

int function(int de) {
return de * 2;
}
19 changes: 19 additions & 0 deletions test/link/sdcc/no-script/b.rel
Original file line number Diff line number Diff line change
@@ -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
8 changes: 8 additions & 0 deletions test/link/sdcc/no-script/out.err
Original file line number Diff line number Diff line change
@@ -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
18 changes: 18 additions & 0 deletions test/link/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,24 @@ tryDiff "$test"/out.err "$outtemp"
tryCmpRomSize "$gbtemp" 65536
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"
startTest
"$RGBASM" -o "$otemp" "$test"/a.asm
Expand Down