mirror of
https://github.com/fachat/xa65.git
synced 2024-12-29 07:29:50 +00:00
reloc fix
This commit is contained in:
parent
1976931f60
commit
08dc1fcb4e
@ -288,9 +288,13 @@ int main(int argc, char *argv[]) {
|
||||
file->ddiff = ((dbase + tdlen) - file->dbase);
|
||||
file->bdiff = ((bbase + tblen) - file->bbase);
|
||||
file->zdiff = ((zbase + tzlen) - file->zbase);
|
||||
/*printf("tbase=%04x, file->tbase=%04x, ttlen=%04x -> tdiff=%04x\n",
|
||||
tbase, file->tbase, ttlen, file->tdiff);*/
|
||||
|
||||
/*
|
||||
printf("tbase=%04x+len=%04x->%04x, file->tbase=%04x, f.tlen=%04x -> tdiff=%04x\n",
|
||||
tbase, ttlen, (tbase + ttlen), file->tbase, file->tlen, file->tdiff);
|
||||
printf("zbase=%04x+len=%04x->%04x, file->zbase=%04x, f.zlen=%04x -> zdiff=%04x\n",
|
||||
zbase, tzlen, (zbase + tzlen), file->zbase, file->zlen, file->zdiff);
|
||||
*/
|
||||
/* update globals (for result file) */
|
||||
ttlen += file->tlen;
|
||||
tdlen += file->dlen;
|
||||
@ -298,6 +302,38 @@ int main(int argc, char *argv[]) {
|
||||
tzlen += file->zlen;
|
||||
}
|
||||
|
||||
// validate various situations.
|
||||
{
|
||||
int er = 0;
|
||||
if (tbase + ttlen > 0x10000) {
|
||||
fprintf(stderr,
|
||||
"Overflow in text segment: end at %06x behind 64k limit\n",
|
||||
tbase + ttlen);
|
||||
er = 1;
|
||||
}
|
||||
if (dbase + tdlen > 0x10000) {
|
||||
fprintf(stderr,
|
||||
"Overflow in data segment: end at %06x behind 64k limit\n",
|
||||
dbase + tdlen);
|
||||
er = 1;
|
||||
}
|
||||
if (bbase + tblen > 0x10000) {
|
||||
fprintf(stderr,
|
||||
"Overflow in bss segment: end at %06x behind 64k limit\n",
|
||||
bbase + tblen);
|
||||
er = 1;
|
||||
}
|
||||
if (zbase + tzlen > 0x100) {
|
||||
fprintf(stderr,
|
||||
"Overflow in zero segment: end at %04x behind 256 byte limit\n",
|
||||
zbase + tzlen);
|
||||
er = 1;
|
||||
}
|
||||
if (er) {
|
||||
exit (1);
|
||||
}
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
// step 3 - merge globals from all files into single table
|
||||
//
|
||||
@ -710,7 +746,7 @@ file65 *load_file(char *fname) {
|
||||
file->bbase = file->buf[17]*256+file->buf[16];
|
||||
file->blen = file->buf[19]*256+file->buf[18];
|
||||
file->zbase = file->buf[21]*256+file->buf[20];
|
||||
file->zlen = file->buf[23]*256+file->buf[21];
|
||||
file->zlen = file->buf[23]*256+file->buf[22];
|
||||
|
||||
file->tpos = hlen;
|
||||
file->dpos = hlen + file->tlen;
|
||||
@ -1056,10 +1092,6 @@ printf("found undef'd label %s, resolved=%d, newidx=%d, (ri=%d, ro=%d)\n", u->na
|
||||
ri += 4;// account for position, segment byte, label number in reloc table
|
||||
}
|
||||
new = old + diff;
|
||||
if (((diff & 0xff) + (old & 0xff)) > 0xff) {
|
||||
fprintf(stderr,"Warning: overflow in byte relocation at %04x in file %s\n",
|
||||
pos, fp->fname);
|
||||
}
|
||||
buf[addr-base+pos] = new & 255;
|
||||
break;
|
||||
}
|
||||
|
13
xa/tests/ldoreloc/60.s
Normal file
13
xa/tests/ldoreloc/60.s
Normal file
@ -0,0 +1,13 @@
|
||||
|
||||
.zero
|
||||
ptr .word 0
|
||||
.text
|
||||
|
||||
foo =$1234
|
||||
|
||||
lda ptr2
|
||||
loop: jmp loop
|
||||
|
||||
.data
|
||||
bar .word bla
|
||||
|
15
xa/tests/ldoreloc/61.s
Normal file
15
xa/tests/ldoreloc/61.s
Normal file
@ -0,0 +1,15 @@
|
||||
jsr loop
|
||||
bla: lda ptr
|
||||
lda #ptr
|
||||
|
||||
.zero
|
||||
ptr2 .byt 0
|
||||
|
||||
.data
|
||||
|
||||
.word foo
|
||||
.word bar
|
||||
.byte <foo
|
||||
.byte >foo
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
|
||||
default: all
|
||||
all: t1 t2 t10 t11 t20 t21 t30 t31 t40 t41 t50 t51
|
||||
all: t1 t2 t10 t11 t20 t21 t30 t31 t40 t41 t50 t51 t60 t61 t62
|
||||
|
||||
%.o65: %.s
|
||||
../../xa -R -c -o $@ $<
|
||||
@ -47,6 +47,15 @@ linked50.o65: 50.o65 51.o65
|
||||
linked51.o65: 50.o65 51.o65
|
||||
../../ldo65 -o $@ 51.o65 50.o65
|
||||
|
||||
linked60.o65: 60.o65 61.o65
|
||||
../../ldo65 -o $@ 60.o65 61.o65
|
||||
|
||||
linked61.o65: 60.o65 61.o65
|
||||
../../ldo65 -o $@ 61.o65 60.o65
|
||||
|
||||
linked62.o65: 60.o65 61.o65
|
||||
../../ldo65 -bd 65529 -bt 65523 -bz 255 -o $@ 61.o65 60.o65 && exit 1 || exit 0
|
||||
|
||||
t1: linked.o65
|
||||
../../reloc65 -bt 32768 -xt -o $@ $<
|
||||
../hextool $@ > $@.hex
|
||||
@ -110,6 +119,18 @@ t51: linked51.o65
|
||||
../hextool $@ > $@.hex
|
||||
../hextool -cmp=$@ < t51.ok
|
||||
|
||||
clean:
|
||||
rm -f *.o65 *.hex t1 t2 t10 t11 t20 t21 t30 t31 t40 t41 t50 t51
|
||||
t60: linked60.o65
|
||||
../../reloc65 -bt 32768 -bd 40960 -o $@ $<
|
||||
../hextool $@ > $@.hex
|
||||
../hextool -cmp=$@ < t60.ok
|
||||
|
||||
t61: linked61.o65
|
||||
../../reloc65 -bt 32768 -bd 40960 -o $@ $<
|
||||
../hextool $@ > $@.hex
|
||||
../hextool -cmp=$@ < t61.ok
|
||||
|
||||
t62: linked62.o65
|
||||
|
||||
clean:
|
||||
rm -f *.o65 *.hex t1 t2 t10 t11 t20 t21 t30 t31 t40 t41 t50 t51 t60 t61
|
||||
|
||||
|
BIN
xa/tests/ldoreloc/t60.ok
Normal file
BIN
xa/tests/ldoreloc/t60.ok
Normal file
Binary file not shown.
BIN
xa/tests/ldoreloc/t61.ok
Normal file
BIN
xa/tests/ldoreloc/t61.ok
Normal file
Binary file not shown.
Loading…
Reference in New Issue
Block a user