[cc65] Linker is not following configuration file

From: Payton Byrd <plbyrd1gmail.com>
Date: 2012-01-25 04:47:20
OK, here's the scenario.  I want to leave a hole from $1000 to $3000 for
loading in music files.  I've setup my linker config as such:

SYMBOLS {
    __LOADADDR__:    type = import;
    __EXEHDR__:      type = import;
    __STACKSIZE__:   type = weak,   value = $0800; # 2k stack
    __OVERLAYSIZE__: type = weak,   value = $4000;
    __SCIENCELOADADDR__: type = import;
    __COMBATLOADADDR__: type = import;
	__PLANETLOADADDR__: type = import;
	__SETUPLOADADDR__: type = import;
}
MEMORY {
    ZP:       file = "", define = yes, start = $0002, size = $001A;
    LOADADDR: file = %O,               start = $07FF, size = $0002;
    HEADER:   file = %O,               start = $0801, size = $000C;
    RAM1:      file = %O, define = yes, start = $080D, size = $07F3; #
- __STACKSIZE__ - __OVERLAYSIZE__;
	MUSIC:		file = %O, define = yes, start = $1000, size = $2000;
	RAM:		file = %O, define = yes, start = $3000, size = $6000;
    SCIENCELA:   file = "science.ovl",           start = $D000 -
__OVERLAYSIZE__, size = $0002;
    SCIENCE:     file = "science.ovl",           start = $D000 -
__OVERLAYSIZE__, size = __OVERLAYSIZE__;
    COMBATLA:   file = "combat.ovl",           start = $D000 -
__OVERLAYSIZE__, size = $0002;
    COMBAT:     file = "combat.ovl",           start = $D000 -
__OVERLAYSIZE__, size = __OVERLAYSIZE__;
    PLANETLA:   file = "planet.ovl",           start = $D000 -
__OVERLAYSIZE__, size = $0002;
    PLANET:     file = "planet.ovl",           start = $D000 -
__OVERLAYSIZE__, size = __OVERLAYSIZE__;
    SETUPLA:   file = "setup.ovl",           start = $D000 -
__OVERLAYSIZE__, size = $0002;
    SETUP:     file = "setup.ovl",           start = $D000 -
__OVERLAYSIZE__, size = __OVERLAYSIZE__;
}
SEGMENTS {
    LOADADDR: load = LOADADDR, type = ro;
    EXEHDR:   load = HEADER,   type = ro;
    STARTUP:  load = RAM1,      type = ro;
    LOWCODE:  load = RAM,      type = ro,                optional = yes;
    INIT:     load = RAM,      type = ro,  define = yes, optional = yes;
    CODE:     load = RAM,      type = ro;
    SCIENCELA: load = SCIENCELA, type = ro;
    SCIENCECODE: load = SCIENCE,     type = ro,  define = yes;
    COMBATLA: load = COMBATLA, type = ro;
    COMBATCODE: load = COMBAT,     type = ro,  define = yes;
    PLANETLA: load = PLANETLA, type = ro;
    PLANETCODE: load = PLANET,     type = ro,  define = yes;
    SETUPLA: load = SETUPLA, type = ro;
    SETUPCODE: load = SETUP,     type = ro,  define = yes;
    RODATA:   load = RAM,      type = ro;
    DATA:     load = RAM,      type = rw;
    ZPSAVE:   load = RAM,      type = bss;
    BSS:      load = RAM,      type = bss, define = yes;
    ZEROPAGE: load = ZP,       type = zp;
}

Looking at this configuration, the startup code should go to $080D and
everything else should start at $3000 for main code and $9000 for the
overlays.  The map file generated by the linker shows the following:

Segment list:
-------------
Name                   Start     End    Size  Align
----------------------------------------------------
ZEROPAGE              000002  00001B  00001A  00001

LOADADDR              0007FF  000800  000002  00001
EXEHDR                000801  00080C  00000C  00001
STARTUP               00080D  00088D  000081  00001
INIT                  003000  003087  000088  00001
CODE                  003088  004D23  001C9C  00001

RODATA                004D24  005260  00053D  00001
DATA                  005261  005661  000401  00001
ZPSAVE                005662  00567B  00001A  00001
BSS                   00567C  0058C5  00024A  00001
COMBATCODE            009000  009028  000029  00001

COMBATLA              009000  009001  000002  00001
PLANETCODE            009000  009028  000029  00001
PLANETLA              009000  009001  000002  00001
SCIENCECODE           009000  009051  000052  00001
SCIENCELA             009000  009001  000002  00001

SETUPCODE             009000  009777  000778  00001
SETUPLA               009000  009001  000002  00001

This looks like exactly what I am expecting to happen.

HOWEVER, this is not what gets output in the executable file.  As you can
see, the init code should end at $088D, but here's the disassembly:

(C:$1093) d 0880
.C:0880   9A         TXS
.C:0881   AE 43 58   LDX $5843
.C:0884   86 01      STX $01
.C:0886   60         RTS
.C:0887   D8         CLD
.C:0888   20 93 55   JSR $5593
.C:088b   4C D6 55   JMP $55D6
.C:088e   A0 08      LDY #$08
.C:0890   F0 07      BEQ $0899
.C:0892   A9 80      LDA #$80
.C:0894   A2 30      LDX #$30
.C:0896   4C B1 55   JMP $55B1
.C:0899   60         RTS
.C:089a   A5 BA      LDA $BA
.C:089c   D0 04      BNE $08A2
.C:089e   A9 08      LDA #$08
.C:08a0   85 BA      STA $BA
.C:08a2   8D 6E 58   STA $586E
.C:08a5   60         RTS
.C:08a6   A9 01      LDA #$01
.C:08a8   8D 5C 58   STA $585C

Notice that the last code in INIT is JMPing to $55d6.  Unfortunately,
there's no code there.

(C:$08ab) d 55d6
.C:55d6   FF FF FF   ISB $FFFF,X
.C:55d9   FF FF FF   ISB $FFFF,X
.C:55dc   FF FF FF   ISB $FFFF,X
.C:55df   FF FF FF   ISB $FFFF,X
.C:55e2   FF FF FF   ISB $FFFF,X
.C:55e5   FF FF FF   ISB $FFFF,X
.C:55e8   FF FF FF   ISB $FFFF,X
.C:55eb   FF FF FF   ISB $FFFF,X
.C:55ee   FF FF FF   ISB $FFFF,X
.C:55f1   FF FF FF   ISB $FFFF,X
.C:55f4   FF FF FF   ISB $FFFF,X
.C:55f7   FF FF FF   ISB $FFFF,X
.C:55fa   FF FF FF   ISB $FFFF,X
.C:55fd   FF FF FF   ISB $FFFF,X

I'm obviously not doing something right here, but I cannot figure it out.
 Please help.
-- 
Payton Byrd
<http://www.paytonbyrd.com>
<http://it.toolbox.com/blogs/paytonbyrd>

----------------------------------------------------------------------
To unsubscribe from the list send mail to majordomo@musoftware.de with
the string "unsubscribe cc65" in the body(!) of the mail.
Received on Wed Jan 25 04:47:59 2012

This archive was generated by hypermail 2.1.8 : 2012-01-25 04:48:03 CET