From: Oliver Schmidt
Date: Sun, 13 Mar 2016 13:32:07 +0000 (+0100)
Subject: Cleaned up C64 linker configs.
X-Git-Tag: V2.16~169
X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=a3a22733f8f83f0cf8547a9d2cf34d8056b97c97;p=cc65
Cleaned up C64 linker configs.
The BSS segment and the ONCE segment share the same start address. So they need to be placed in two different memory areas.
So far BSS was placed in the MAIN memory area and ONCE was placed in an additional memory area. Both memory areas were written to the output file. They just "happened" to be loadable and runnable at a stretch.
Now ONCE is placed in the MAIN memory area and BSS is placed in an additional memory area. Only MAIN is written to the output file. It becomes more obvious that BSS is "just" defined to share memory with ONCE.
---
diff --git a/cfg/c64-asm.cfg b/cfg/c64-asm.cfg
index 224bd704a..25d12ee71 100644
--- a/cfg/c64-asm.cfg
+++ b/cfg/c64-asm.cfg
@@ -10,11 +10,11 @@ MEMORY {
MAIN: file = %O, start = %S, size = $D000 - %S;
}
SEGMENTS {
+ ZEROPAGE: load = ZP, type = zp, optional = yes;
LOADADDR: load = LOADADDR, type = ro;
EXEHDR: load = MAIN, type = ro, optional = yes;
CODE: load = MAIN, type = rw, optional = yes;
RODATA: load = MAIN, type = ro, optional = yes;
DATA: load = MAIN, type = rw, optional = yes;
BSS: load = MAIN, type = bss, optional = yes;
- ZEROPAGE: load = ZP, type = zp, optional = yes;
}
diff --git a/cfg/c64-overlay.cfg b/cfg/c64-overlay.cfg
index 872fdd775..e88bffe00 100644
--- a/cfg/c64-overlay.cfg
+++ b/cfg/c64-overlay.cfg
@@ -1,5 +1,5 @@
FEATURES {
- STARTADDRESS: default = $0801;
+ STARTADDRESS: default = $0801;
}
SYMBOLS {
__LOADADDR__: type = import;
@@ -14,8 +14,8 @@ MEMORY {
ZP: file = "", define = yes, start = $0002, size = $001A;
LOADADDR: file = %O, start = %S - 2, size = $0002;
HEADER: file = %O, define = yes, start = %S, size = $000D;
- MAIN: file = %O, define = yes, start = __HEADER_LAST__, size = __OVERLAYSTART__ - __STACKSIZE__ - __HEADER_LAST__;
- INIT: file = %O, start = __BSS_RUN__, size = __HIMEM__ - __BSS_RUN__;
+ MAIN: file = %O, define = yes, start = __HEADER_LAST__, size = __HIMEM__ - __HEADER_LAST__;
+ BSS: file = "", start = __ONCE_RUN__, size = __OVERLAYSTART__ - __STACKSIZE__ - __ONCE_RUN__;
OVL1ADDR: file = "%O.1", start = __OVERLAYSTART__ - 2, size = $0002;
OVL1: file = "%O.1", start = __OVERLAYSTART__, size = __OVERLAYSIZE__;
OVL2ADDR: file = "%O.2", start = __OVERLAYSTART__ - 2, size = $0002;
@@ -45,8 +45,8 @@ SEGMENTS {
RODATA: load = MAIN, type = ro;
DATA: load = MAIN, type = rw;
INIT: load = MAIN, type = rw;
- BSS: load = MAIN, type = bss, define = yes;
- ONCE: load = INIT, type = ro;
+ ONCE: load = MAIN, type = ro, define = yes;
+ BSS: load = BSS, type = bss, define = yes;
OVL1ADDR: load = OVL1ADDR, type = ro;
OVERLAY1: load = OVL1, type = ro, define = yes, optional = yes;
OVL2ADDR: load = OVL2ADDR, type = ro;
diff --git a/cfg/c64.cfg b/cfg/c64.cfg
index 3735a0a65..43ccce2ca 100644
--- a/cfg/c64.cfg
+++ b/cfg/c64.cfg
@@ -1,5 +1,5 @@
FEATURES {
- STARTADDRESS: default = $0801;
+ STARTADDRESS: default = $0801;
}
SYMBOLS {
__LOADADDR__: type = import;
@@ -8,11 +8,11 @@ SYMBOLS {
__HIMEM__: type = weak, value = $D000;
}
MEMORY {
- ZP: file = "", define = yes, start = $0002, size = $001A;
- LOADADDR: file = %O, start = %S - 2, size = $0002;
- HEADER: file = %O, define = yes, start = %S, size = $000D;
- MAIN: file = %O, define = yes, start = __HEADER_LAST__, size = __HIMEM__ - __STACKSIZE__ - __HEADER_LAST__;
- INIT: file = %O, start = __BSS_RUN__, size = __HIMEM__ - __BSS_RUN__;
+ ZP: file = "", define = yes, start = $0002, size = $001A;
+ LOADADDR: file = %O, start = %S - 2, size = $0002;
+ HEADER: file = %O, define = yes, start = %S, size = $000D;
+ MAIN: file = %O, define = yes, start = __HEADER_LAST__, size = __HIMEM__ - __HEADER_LAST__;
+ BSS: file = "", start = __ONCE_RUN__, size = __HIMEM__ - __STACKSIZE__ - __ONCE_RUN__;
}
SEGMENTS {
ZEROPAGE: load = ZP, type = zp;
@@ -24,8 +24,8 @@ SEGMENTS {
RODATA: load = MAIN, type = ro;
DATA: load = MAIN, type = rw;
INIT: load = MAIN, type = rw;
- BSS: load = MAIN, type = bss, define = yes;
- ONCE: load = INIT, type = ro, define = yes;
+ ONCE: load = MAIN, type = ro, define = yes;
+ BSS: load = BSS, type = bss, define = yes;
}
FEATURES {
CONDES: type = constructor,
diff --git a/libsrc/c64/crt0.s b/libsrc/c64/crt0.s
index c8a7386cb..7bd294ca7 100644
--- a/libsrc/c64/crt0.s
+++ b/libsrc/c64/crt0.s
@@ -93,8 +93,8 @@ L1: lda sp,x
; Set up the stack.
- lda #<(__MAIN_START__ + __MAIN_SIZE__ + __STACKSIZE__)
- ldx #>(__MAIN_START__ + __MAIN_SIZE__ + __STACKSIZE__)
+ lda #<(__MAIN_START__ + __MAIN_SIZE__)
+ ldx #>(__MAIN_START__ + __MAIN_SIZE__)
sta sp
stx sp+1 ; Set argument stack ptr