1
0
mirror of https://github.com/cc65/cc65.git synced 2024-12-26 08:32:00 +00:00

Force an import of the special symbol __STARTUP__ in the C compiler when

main() is encountered. Define this symbol in the startup code. This will
automatically force linking of the startup code which can then reside inside
the standard library as any other object file.


git-svn-id: svn://svn.cc65.org/cc65/trunk@3988 b7a2c559-68d2-44c3-8de9-860c34a00d81
This commit is contained in:
uz 2009-07-31 12:05:42 +00:00
parent 66391bfc25
commit 8216bf1d6a
18 changed files with 37 additions and 86 deletions

View File

@ -46,7 +46,6 @@ apple2lib:
$(MAKE) SYS=apple2 -C $$i || exit 1; \
$(AR) a apple2.lib $$i/*.o;\
done
mv apple2/crt0.o apple2.o
cp apple2/apple2-auxmem.emd a2.auxmem.emd
cp apple2/apple2-stdjoy.joy a2.stdjoy.joy
cp apple2/apple2-stdmou.mou a2.stdmou.mou
@ -62,7 +61,6 @@ apple2enhlib:
$(MAKE) SYS=apple2enh -C $$i || exit 1; \
$(AR) a apple2enh.lib $$i/*.o;\
done
mv apple2enh/crt0.o apple2enh.o
cp apple2enh/apple2-auxmem.emd a2e.auxmem.emd
cp apple2enh/apple2-stdjoy.joy a2e.stdjoy.joy
cp apple2enh/apple2-stdmou.mou a2e.stdmou.mou
@ -78,7 +76,6 @@ atarilib:
$(MAKE) SYS=atari -C $$i || exit 1; \
$(AR) a atari.lib $$i/*.o;\
done
mv atari/crt0.o atari.o
cp atari/atari-stdjoy.joy ataristd.joy
cp atari/atari-multijoy.joy atarimj8.joy
@ -90,7 +87,6 @@ atmoslib:
$(MAKE) SYS=atmos -C $$i || exit 1; \
$(AR) a atmos.lib $$i/*.o;\
done
mv atmos/crt0.o atmos.o
cp atmos/*.tgi .
#-----------------------------------------------------------------------------
@ -101,7 +97,6 @@ c16lib:
$(MAKE) SYS=c16 -C $$i || exit 1; \
$(AR) a c16.lib $$i/*.o;\
done
mv c16/crt0.o c16.o
cp c16/*.joy .
cp c16/*.emd .
@ -113,7 +108,6 @@ c64lib:
$(MAKE) SYS=c64 -C $$i || exit 1; \
$(AR) a c64.lib $$i/*.o;\
done
mv c64/crt0.o c64.o
cp c64/*.emd .
cp c64/*.joy .
cp c64/c64-1351.mou .
@ -130,7 +124,6 @@ c128lib:
$(MAKE) SYS=c128 -C $$i || exit 1; \
$(AR) a c128.lib $$i/*.o;\
done
mv c128/crt0.o c128.o
cp c128/*.emd .
cp c128/*.joy .
cp c128/c128-1351.mou .
@ -148,7 +141,6 @@ cbm510lib:
$(MAKE) SYS=cbm510 -C $$i || exit 1; \
$(AR) a cbm510.lib $$i/*.o;\
done
mv cbm510/crt0.o cbm510.o
cp cbm510/*.emd .
cp cbm510/cbm510-stdjoy.joy cbm510-std.joy
cp cbm510/cbm510-stdser.ser cbm510-std.ser
@ -161,7 +153,6 @@ cbm610lib:
$(MAKE) SYS=cbm610 -C $$i || exit 1; \
$(AR) a cbm610.lib $$i/*.o;\
done
mv cbm610/crt0.o cbm610.o
cp cbm610/*.emd .
cp cbm610/cbm610-stdser.ser cbm610-std.ser
@ -204,7 +195,6 @@ lynxlib:
$(MAKE) SYS=lynx -C $$i || exit 1; \
$(AR) a lynx.lib $$i/*.o;\
done
mv lynx/crt0.o lynx.o
cp lynx/*.joy .
cp lynx/*.tgi .
@ -216,7 +206,6 @@ neslib:
$(MAKE) SYS=nes -C $$i || exit 1; \
$(AR) a nes.lib $$i/*.o;\
done
mv nes/crt0.o nes.o
cp nes/*.joy .
#-----------------------------------------------------------------------------
@ -227,7 +216,6 @@ petlib:
$(MAKE) SYS=pet -C $$i || exit 1; \
$(AR) a pet.lib $$i/*.o;\
done
mv pet/crt0.o pet.o
cp pet/*.joy .
#-----------------------------------------------------------------------------
@ -238,7 +226,6 @@ plus4lib:
$(MAKE) SYS=plus4 -C $$i || exit 1; \
$(AR) a plus4.lib $$i/*.o;\
done
mv plus4/crt0.o plus4.o
cp plus4/*.joy .
cp plus4/*.ser .
@ -250,7 +237,6 @@ supervisionlib:
$(MAKE) SYS=supervision -C $$i || exit 1; \
$(AR) a supervision.lib $$i/*.o;\
done
mv supervision/crt0.o supervision.o
#-----------------------------------------------------------------------------
# Vic20
@ -260,7 +246,6 @@ vic20lib:
$(MAKE) SYS=vic20 -C $$i || exit 1; \
$(AR) a vic20.lib $$i/*.o;\
done
mv vic20/crt0.o vic20.o
cp vic20/*.joy .
#-----------------------------------------------------------------------------

View File

@ -1,10 +1,9 @@
;
; Startup code for cc65 (Apple2 version)
;
; This must be the *first* file on the linker command line
;
.export _exit
.export __STARTUP__ : absolute = 1 ; Mark as startup
.import zerobss
.import initlib, donelib
.import callmain, callirq
@ -40,13 +39,13 @@
; Switch in LC bank 2 for W/O
bit $C081
bit $C081
; Set source start address
lda #<(__ZPSAVE_RUN__ + __INIT_SIZE__)
ldy #>(__ZPSAVE_RUN__ + __INIT_SIZE__)
sta $9B
sty $9C
; Set source last address
lda #<(__ZPSAVE_RUN__ + __INIT_SIZE__ + __LC_LAST__ - __LC_START__)
ldy #>(__ZPSAVE_RUN__ + __INIT_SIZE__ + __LC_LAST__ - __LC_START__)
@ -68,7 +67,7 @@
ldy #>__ZPSAVE_RUN__
sta $9B
sty $9C
; Set source last address
lda #<(__ZPSAVE_RUN__ + __INIT_SIZE__)
ldy #>(__ZPSAVE_RUN__ + __INIT_SIZE__)
@ -92,7 +91,7 @@
_exit: ldx #<exit
lda #>exit
jsr reset ; Setup RESET vector
; Switch in ROM in case it wasn't already switched in by a RESET
bit $C082
@ -159,7 +158,7 @@ init: ldx #zpspace-1
ldx #<_exit
lda #>_exit
jsr reset ; Setup RESET vector
; Setup the stack
lda HIMEM
sta sp

View File

@ -5,11 +5,10 @@
; Mark Keates
; Freddy Offenga
; Christian Groessler
;
; This must be the *first* file on the linker command line
;
.export _exit
.export __STARTUP__ : absolute = 1 ; Mark as startup
.constructor initsp, 26
.import initlib, donelib, callmain

View File

@ -2,11 +2,10 @@
; Startup code for cc65 (Oric version)
;
; By Debrune Jérôme <jede@oric.org> and Ullrich von Bassewitz <uz@cc65.org>
;
; This must be the *first* file on the linker command line
;
.export _exit
.export __STARTUP__ : absolute = 1 ; Mark as startup
.import initlib, donelib
.import callmain, zerobss
.import __RAM_START__, __RAM_SIZE__, __BSS_LOAD__

View File

@ -1,10 +1,9 @@
;
; Startup code for cc65 (C128 version)
;
; This must be the *first* file on the linker command line
;
.export _exit
.export __STARTUP__ : absolute = 1 ; Mark as startup
.import callirq, initlib, donelib
.import zerobss
.import push0, callmain

View File

@ -1,13 +1,12 @@
;
; Startup code for cc65 (C16 version)
;
; This must be the *first* file on the linker command line
;
; Note: The C16 is actually the Plus/4 with just 16KB of memory. So many
; things are similar here, and we even use the plus4.inc include file.
;
.export _exit
.export __STARTUP__ : absolute = 1 ; Mark as startup
.import initlib, donelib, callirq
.import callmain, zerobss
.import MEMTOP, RESTOR, BSOUT, CLRCH

View File

@ -1,10 +1,9 @@
;
; Startup code for cc65 (C64 version)
;
; This must be the *first* file on the linker command line
;
.export _exit
.export __STARTUP__ : absolute = 1 ; Mark as startup
.import initlib, donelib, callirq
.import zerobss
.import callmain

View File

@ -1,10 +1,9 @@
;
; Startup code for cc65 (CBM 500 version)
;
; This must be the *first* file on the linker command line
;
.export _exit
.export __STARTUP__ : absolute = 1 ; Mark as startup
.import _clrscr, initlib, donelib, callirq_y
.import push0, callmain

View File

@ -1,10 +1,9 @@
;
; Startup code for cc65 (CBM 600/700 version)
;
; This must be the *first* file on the linker command line
;
.export _exit, BRKVec
.export __STARTUP__ : absolute = 1 ; Mark as startup
.import callirq_y, initlib, donelib
.import push0, callmain

View File

@ -13,12 +13,11 @@
; code structure. The C stack is located at the end of the RAM memory
; segment and grows downward. Bastian Schick's executable header is put
; on the front of the fully linked binary (see EXEHDR segment.)
;
; This must be the *first* file on the linker command line
;
.include "lynx.inc"
.export _exit
.export __STARTUP__ : absolute = 1 ; Mark as startup
.import initlib, donelib
.import zerobss

View File

@ -3,11 +3,10 @@
;
; by Groepaz/Hitmen <groepaz@gmx.net>
; based on code by Ullrich von Bassewitz <uz@cc65.org>
;
; This must be the *first* file on the linker command line
;
.export _exit
.export __STARTUP__ : absolute = 1 ; Mark as startup
.import initlib, donelib, callmain
.import push0, _main, zerobss, copydata
.import ppubuf_flush

View File

@ -1,10 +1,9 @@
;
; Startup code for cc65 (PET version)
;
; This must be the *first* file on the linker command line
;
.export _exit
.export __STARTUP__ : absolute = 1 ; Mark as startup
.import initlib, donelib, callirq
.import zerobss, push0
.import callmain

View File

@ -1,11 +1,10 @@
;
; Startup code for cc65 (Plus/4 version)
;
; This must be the *first* file on the linker command line
;
.export _exit
.export brk_jmp
.export __STARTUP__ : absolute = 1 ; Mark as startup
.import callirq_y, initlib, donelib
.import callmain, zerobss

View File

@ -1,10 +1,9 @@
;
; Startup code for cc65 (supervision version)
;
; This must be the *first* file on the linker command line
;
.export _exit
.export __STARTUP__ : absolute = 1 ; Mark as startup
.import _main
.import initlib, donelib, copydata

View File

@ -1,10 +1,9 @@
;
; Startup code for cc65 (Vic20 version)
;
; This must be the *first* file on the linker command line
;
.export _exit
.export __STARTUP__ : absolute = 1 ; Mark as startup
.import initlib, donelib, callirq
.import zerobss, push0
.import callmain

View File

@ -110,7 +110,6 @@ programs for the Apple ][ using the cc65 crosscompiler.
%files apple2
%attr(644,root,root) /usr/lib/cc65/lib/apple2.lib
%attr(644,root,root) /usr/lib/cc65/lib/apple2.o
%attr(644,root,root) /usr/lib/cc65/emd/a2.*.emd
%attr(644,root,root) /usr/lib/cc65/joy/a2.*.joy
%attr(644,root,root) /usr/lib/cc65/mou/a2.*.mou
@ -135,7 +134,6 @@ programs for the Apple //e using the cc65 crosscompiler.
%files apple2enh
%attr(644,root,root) /usr/lib/cc65/lib/apple2enh.lib
%attr(644,root,root) /usr/lib/cc65/lib/apple2enh.o
%attr(644,root,root) /usr/lib/cc65/emd/a2e.*.emd
%attr(644,root,root) /usr/lib/cc65/joy/a2e.*.joy
%attr(644,root,root) /usr/lib/cc65/mou/a2e.*.mou
@ -160,7 +158,6 @@ programs for the 8 bit Atari machines using the cc65 crosscompiler.
%files atari
%attr(644,root,root) /usr/lib/cc65/lib/atari.lib
%attr(644,root,root) /usr/lib/cc65/lib/atari.o
%attr(644,root,root) /usr/lib/cc65/joy/atari*.joy
@ -181,7 +178,6 @@ programs for the Oric Atmos using the cc65 crosscompiler.
%files atmos
%attr(644,root,root) /usr/lib/cc65/lib/atmos.lib
%attr(644,root,root) /usr/lib/cc65/lib/atmos.o
%attr(644,root,root) /usr/lib/cc65/tgi/atmos-*.tgi
@ -202,7 +198,6 @@ programs for the Commodore C128 using the cc65 crosscompiler.
%files c128
%attr(644,root,root) /usr/lib/cc65/lib/c128.lib
%attr(644,root,root) /usr/lib/cc65/lib/c128.o
%attr(644,root,root) /usr/lib/cc65/emd/c128-*.emd
%attr(644,root,root) /usr/lib/cc65/joy/c128-*.joy
%attr(644,root,root) /usr/lib/cc65/mou/c128-*.mou
@ -227,7 +222,6 @@ programs for the Commodore C16/116 using the cc65 crosscompiler.
%files c16
%attr(644,root,root) /usr/lib/cc65/lib/c16.lib
%attr(644,root,root) /usr/lib/cc65/lib/c16.o
%attr(644,root,root) /usr/lib/cc65/emd/c16-*.emd
%attr(644,root,root) /usr/lib/cc65/joy/c16-*.joy
@ -249,7 +243,6 @@ programs for the Commodore C64 using the cc65 crosscompiler.
%files c64
%attr(644,root,root) /usr/lib/cc65/lib/c64.lib
%attr(644,root,root) /usr/lib/cc65/lib/c64.o
%attr(644,root,root) /usr/lib/cc65/emd/dtv-*.emd
%attr(644,root,root) /usr/lib/cc65/emd/c64-*.emd
%attr(644,root,root) /usr/lib/cc65/joy/c64-*.joy
@ -276,7 +269,6 @@ crosscompiler.
%files cbm510
%attr(644,root,root) /usr/lib/cc65/lib/cbm510.lib
%attr(644,root,root) /usr/lib/cc65/lib/cbm510.o
%attr(644,root,root) /usr/lib/cc65/emd/cbm510-*.emd
%attr(644,root,root) /usr/lib/cc65/joy/cbm510-*.joy
%attr(644,root,root) /usr/lib/cc65/ser/cbm510-*.ser
@ -300,7 +292,6 @@ the cc65 crosscompiler.
%files cbm610
%attr(644,root,root) /usr/lib/cc65/lib/cbm610.lib
%attr(644,root,root) /usr/lib/cc65/lib/cbm610.o
%attr(644,root,root) /usr/lib/cc65/emd/cbm610-*.emd
%attr(644,root,root) /usr/lib/cc65/ser/cbm610-*.ser
@ -323,7 +314,6 @@ GEOS programs for the C64/C128 using the cc65 crosscompiler.
%files geos
%attr(755,root,root) /usr/bin/grc
%attr(644,root,root) /usr/lib/cc65/lib/geos.lib
%attr(644,root,root) /usr/lib/cc65/lib/geos.o
%attr(755,root,root) %dir /usr/lib/cc65/include/geos
%attr(644,root,root) /usr/lib/cc65/include/geos/*.h
%attr(644,root,root) /usr/lib/cc65/emd/geos-*.emd
@ -348,7 +338,6 @@ programs for the Lynx Game Console using the cc65 crosscompiler.
%files lynx
%attr(644,root,root) /usr/lib/cc65/lib/lynx.lib
%attr(644,root,root) /usr/lib/cc65/lib/lynx.o
%attr(644,root,root) /usr/lib/cc65/joy/lynx-*.joy
%attr(644,root,root) /usr/lib/cc65/tgi/lynx-*.tgi
@ -371,7 +360,6 @@ crosscompiler.
%files nes
%attr(644,root,root) /usr/lib/cc65/lib/nes.lib
%attr(644,root,root) /usr/lib/cc65/lib/nes.o
%attr(644,root,root) /usr/lib/cc65/joy/nes-*.joy
@ -393,7 +381,6 @@ crosscompiler.
%files pet
%attr(644,root,root) /usr/lib/cc65/lib/pet.lib
%attr(644,root,root) /usr/lib/cc65/lib/pet.o
%attr(644,root,root) /usr/lib/cc65/joy/pet-*.joy
@ -415,7 +402,6 @@ crosscompiler.
%files plus4
%attr(644,root,root) /usr/lib/cc65/lib/plus4.lib
%attr(644,root,root) /usr/lib/cc65/lib/plus4.o
%attr(644,root,root) /usr/lib/cc65/joy/plus4-*.joy
%attr(644,root,root) /usr/lib/cc65/ser/plus4-*.ser
@ -437,7 +423,6 @@ programs for the Supervision Game console using the cc65 crosscompiler.
%files supervision
%attr(644,root,root) /usr/lib/cc65/lib/supervision.lib
%attr(644,root,root) /usr/lib/cc65/lib/supervision.o
@ -457,7 +442,6 @@ programs for the Commodore VIC20 using the cc65 crosscompiler.
%files vic20
%attr(644,root,root) /usr/lib/cc65/lib/vic20.lib
%attr(644,root,root) /usr/lib/cc65/lib/vic20.o
%attr(644,root,root) /usr/lib/cc65/joy/vic20-*.joy

View File

@ -12,7 +12,6 @@ SYS = c64
# source tree, otherwise use the "official" directories.
ifeq "$(wildcard ../src)" ""
# No source tree
CRT0 = $(SYS).o
CLIB = $(SYS).lib
CL = cl65
CC = cc65
@ -21,7 +20,6 @@ LD = ld65
else
# Samples is part of a complete source tree
CRT0 = ../libsrc/$(SYS).o
CLIB = ../libsrc/$(SYS).lib
CL = ../src/cl65/cl65
CC = ../src/cc65/cc65
@ -68,63 +66,63 @@ EXELIST = ascii \
.PHONY: all
all: $(EXELIST)
ascii: $(CRT0) ascii.o $(CLIB)
ascii: ascii.o $(CLIB)
@$(LD) -t $(SYS) -m $(basename $@).map -o $@ $^
diodemo: $(CRT0) diodemo.o $(CLIB)
diodemo: diodemo.o $(CLIB)
@$(LD) -t $(SYS) -m $(basename $@).map -o $@ $^
fire: $(CRT0) fire.o $(CLIB)
fire: fire.o $(CLIB)
@$(LD) -t $(SYS) -m $(basename $@).map -o $@ $^
gunzip65: $(CRT0) gunzip65.o $(CLIB)
gunzip65: gunzip65.o $(CLIB)
@$(LD) -t $(SYS) -m $(basename $@).map -o $@ $^
hello: $(CRT0) hello.o $(CLIB)
hello: hello.o $(CLIB)
@$(LD) -t $(SYS) -m $(basename $@).map -o $@ $^
# The Apple machines need the start address adjusted for the mandelbrot demo
ifeq "$(SYS)" "apple2"
mandelbrot: $(CRT0) mandelbrot.o $(CLIB)
mandelbrot: mandelbrot.o $(CLIB)
@$(LD) -t $(SYS) -m $(basename $@).map --start-addr 0x4000 -o $@ $^
else
ifeq "$(SYS)" "apple2enh"
mandelbrot: $(CRT0) mandelbrot.o $(CLIB)
mandelbrot: mandelbrot.o $(CLIB)
@$(LD) -t $(SYS) -m $(basename $@).map --start-addr 0x4000 -o $@ $^
else
mandelbrot: $(CRT0) mandelbrot.o $(CLIB)
mandelbrot: mandelbrot.o $(CLIB)
@$(LD) -t $(SYS) -m $(basename $@).map -o $@ $^
endif
endif
# The Apple ][ needs the start address adjusted for the mousedemo
ifeq "$(SYS)" "apple2"
mousedemo: $(CRT0) mousedemo.o $(CLIB)
mousedemo: mousedemo.o $(CLIB)
@$(LD) -t $(SYS) -m $(basename $@).map --start-addr 0x4000 -o $@ $^
else
mousedemo: $(CRT0) mousedemo.o $(CLIB)
mousedemo: mousedemo.o $(CLIB)
@$(LD) -t $(SYS) -m $(basename $@).map -o $@ $^
endif
nachtm: $(CRT0) nachtm.o $(CLIB)
nachtm: nachtm.o $(CLIB)
@$(LD) -t $(SYS) -m $(basename $@).map -Ln $(basename $@).lbl -o $@ $^
plasma: $(CRT0) plasma.o $(CLIB)
plasma: plasma.o $(CLIB)
@$(LD) -t $(SYS) -m $(basename $@).map -o $@ $^
sieve: $(CRT0) sieve.o $(CLIB)
sieve: sieve.o $(CLIB)
@$(LD) -t $(SYS) -m $(basename $@).map -o $@ $^
# The Apple machines need the start address adjusted for the tgidemo
ifeq "$(SYS)" "apple2"
tgidemo: $(CRT0) tgidemo.o $(CLIB)
tgidemo: tgidemo.o $(CLIB)
@$(LD) -t $(SYS) -m $(basename $@).map --start-addr 0x4000 -o $@ $^
else
ifeq "$(SYS)" "apple2enh"
tgidemo: $(CRT0) tgidemo.o $(CLIB)
tgidemo: tgidemo.o $(CLIB)
@$(LD) -t $(SYS) -m $(basename $@).map --start-addr 0x4000 -o $@ $^
else
tgidemo: $(CRT0) tgidemo.o $(CLIB)
tgidemo: tgidemo.o $(CLIB)
@$(LD) -t $(SYS) -m $(basename $@).map -o $@ $^
endif
endif

View File

@ -386,11 +386,9 @@ void g_defimport (const char* Name, int ZP)
void g_importstartup (void)
/* Forced import of the startup segment */
/* Forced import of the startup module */
{
#if 0
AddTextLine ("\t.forceimport\t__STARTUP_RUN__");
#endif
AddTextLine ("\t.forceimport\t__STARTUP__");
}