overwrite segment tests

asm/listing linker CFG support
asm and asm/listing test documentation
This commit is contained in:
bbbradsmith 2023-03-07 18:44:56 -05:00
parent 8b818aac67
commit 4732e937ad
10 changed files with 121 additions and 20 deletions

View File

@ -0,0 +1,20 @@
MEMORY
{
A: start = 0, size = 8, file = %O, fill = yes, fillval = $33;
B: start = 8, size = 8, file = %O, fill = yes, fillval = $44;
C: start = 0, size = 8, file = %O, fill = yes, fillval = $55;
D: start = 8, size = 8, file = %O, fill = no, fillval = $66;
}
SEGMENTS
{
A: load = A, type = ro;
B: load = B, type = ro;
C0: load = C, type = ro;
C1: load = C, type = ro, start = 5;
D: load = D, type = ro;
AO: load = A, type = overwrite, start = 4;
BO: load = B, type = overwrite, start = 8+5;
CO: load = C, type = overwrite, start = 2;
DO: load = D, type = overwrite, start = 8+4;
}

View File

@ -0,0 +1,29 @@
; verification of overwrite segment feature
; See: https://github.com/cc65/cc65/issues/1366
; A: full memory area which is overwritten to the end
.segment "A"
.byte 0,1,2,3,4,5,6,7
.segment "AO"
.byte $24,$25,$26,$27
; B: incomplete memory area overwritten in the fill area
.segment "B"
.byte 0,1,2
.segment "BO"
.byte $25,$26
; C: memory area with gap overwritten across the gap
.segment "C0"
.byte 0,1,2
.segment "C1"
.byte 5,6,7
.segment "CO"
.byte $22,$23,$24,$25
; D: incomplete memory area without fill,
; but overwrite extends past existing segments
.segment "D"
.byte 0,1,2
.segment "DO"
.byte $24,$25

View File

@ -0,0 +1,12 @@
MEMORY
{
A: start = 0, size = 8, file = %O, fill = yes, fillval = $33;
B: start = 8, size = 8, file = %O, fill = yes, fillval = $44;
}
SEGMENTS
{
A: load = A, type = ro;
B: load = B, type = ro;
AO: load = A, type = overwrite, start = 6;
BO: load = B, type = overwrite, start = 8+6;
}

View File

@ -0,0 +1,13 @@
; verification of overwrite segment overflow cases
; error: overflow past end of A memory area
.segment "A"
.byte 0,1,2,3
.segment "AO"
.byte $26,$27,$28
; error: overflow past end of B memory area
.segment "B"
.byte 0,1,2,3
.segment "BO"
.byte $26,$27,$28

View File

@ -58,12 +58,20 @@ $(WORKDIR)/$1.bin: $1.s $(ISEQUAL)
ifeq ($(wildcard control/$1.err),)
$(CA65) -t none -o $$(@:.bin=.o) $$< > $$(@:.bin=.err) 2> $$(@:.bin=.err2)
ifeq ($(wildcard control/$1.no-ld65),)
ifeq ($(wildcard $1.cfg),)
$(LD65) -t none -o $$@ $$(@:.bin=.o) none.lib > $$(@:.bin=.ld65-err) 2> $$(@:.bin=.ld65-err2)
else
$(LD65) -C $$(<:.s=.cfg) -o $$@ $$(@:.bin=.o) none.lib > $$(@:.bin=.ld65-err) 2> $$(@:.bin=.ld65-err2)
endif
endif
else
$(CA65) -t none -o $$(@:.bin=.o) $$< > $$(@:.bin=.err) 2> $$(@:.bin=.err2) || $(TRUE)
ifeq ($(wildcard control/$1.no-ld65),)
ifeq ($(wildcard $1.cfg),)
$(LD65) -t none -o $$@ $$(@:.bin=.o) none.lib > $$(@:.bin=.ld65-err) 2> $$(@:.bin=.ld65-err2) || $(TRUE)
else
$(LD65) -C $$(<:.s=.cfg) -o $$@ $$(@:.bin=.o) none.lib > $$(@:.bin=.ld65-err) 2> $$(@:.bin=.ld65-err2) || $(TRUE)
endif
endif
endif
@ -117,12 +125,20 @@ endif
ifeq ($(wildcard control/$1.err),)
$(CA65) -t none -l $$(@:.bin=.list-lst) -o $$(@:.bin=.list-o) $$< > $$(@:.bin=.list-err) 2> $$(@:.bin=.list-err2)
ifeq ($(wildcard control/$1.no-ld65),)
ifeq ($(wildcard $1.cfg),)
$(LD65) -t none -o $$(@:.bin=.list-bin) $$(@:.bin=.list-o) none.lib > $$(@:.bin=.list-ld65-err) 2> $$(@:.bin=.list-ld65-err2)
else
$(LD65) -C $$(<:.s=.cfg) -o $$(@:.bin=.list-bin) $$(@:.bin=.list-o) none.lib > $$(@:.bin=.list-ld65-err) 2> $$(@:.bin=.list-ld65-err2)
endif
endif
else
$(CA65) -t none -l $$(@:.bin=.list-lst) -o $$(@:.bin=.list-o) $$< > $$(@:.bin=.list-err) 2> $$(@:.bin=.list-err2) || $(TRUE)
ifeq ($(wildcard control/$1.no-ld65),)
ifeq ($(wildcard $1.cfg),)
$(LD65) -t none -o $$(@:.bin=.list-bin) $$(@:.bin=.list-o) none.lib > $$(@:.bin=.list-ld65-err) 2> $$(@:.bin=.list-ld65-err2) || $(TRUE)
else
$(LD65) -C $$(<:.s=.cfg) -o $$(@:.bin=.list-bin) $$(@:.bin=.list-o) none.lib > $$(@:.bin=.list-ld65-err) 2> $$(@:.bin=.list-ld65-err2) || $(TRUE)
endif
endif
endif

View File

@ -4,6 +4,8 @@ Overall test:
These testcases can be used to test different aspects of the assembler.
The name of a test is everything in the form <test>.s.
If a custom linker configuration is needed, also include <test>.cfg.
The following reference files can be added:
- ref/<test>.bin-ref:

Binary file not shown.

View File

@ -0,0 +1,3 @@
ld65: Warning: 201-overwrite-overflow.cfg:3: Segment 'AO' overflows memory area 'A' by 1 byte
ld65: Warning: 201-overwrite-overflow.cfg:4: Segment 'BO' overflows memory area 'B' by 1 byte
ld65: Error: Cannot generate most of the files due to memory area overflows

View File

@ -1,32 +1,38 @@
Assembler Testcases
===================
Opcode Tests:
-------------
cpudetect
---------
these go into opcodes/. Refer to opcodes/readme.txt
Tests the --cpu command line option of ca65/ld65.
Refer to cpudetect/readme.txt
CPU Detect Tests
----------------
opcodes
-------
these go into cpudetect/. Refer to cpudetect/readme.txt
Test of assembler opcodes for each CPU.
Refer to opcodes/readme.txt
Overall tests:
--------------
These go into listing/. Refer to listing/readme.txt
val:
----
Works very much like the /val directory used to test the compiler - individual
tests are run in the simulator and should exit with an exit code of 0 when they
pass, or either -1 or a number indicating what part of the test failed on error.
err:
----
Works very much like the /err directory used to test the compiler - individual
tests are assembled and MUST NOT assemble without error.
Used to test assembler errors. These tests MUST NOT assemble without error.
listing:
--------
This is the most versatile assembler test form, allowing control customizations,
reference tests for binary output, stdout and error text ouput, error tests,
listings, custom linker configuration, etc. as needed.
Refer to listing/readme.txt
val:
----
Runtime assembly tests using sim65 that should exit with an exit code of 0 when
the pass, or either -1 or a number indicating what part of the test failed on
error.