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