This is the mail archive of the crossgcc@sourceware.org mailing list for the crossgcc project.

See the CrossGCC FAQ for lots more information.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Linker script for barebone M68k compile.


Hello!

Sorry if this has been asked before, but I didn't find it when using Google.
I'm trying to set up a m68k-elf toolchain to produce non-libc images. My goal 
is to have a GNU toolchain for really small systems which can produce binary 
images from C++ code which can be flashed to a target system. I would like to 
be able to generate images for the 68hc11 some day. (Another target, I know.)

I want to minimize bytecount so I don't want any extra libraries, just the 
bare mininum for setting up before calling main and destruction of 
static/global objects after exit of main. I do not need heap allocation and I 
might skip exceptions also.
 
I have a Makefile which produces a 'hello world', or 'blink the led' in my 
case. Here it is:
---------------------------------------------------------------------------------------------------------------
ATH=/usr/local/m68k
TARGET = m68k-elf
CC = g++
LD = ld

CFLAGS = -c -O3 -m68000 -fno-exceptions

TLD = $(PATH)/bin/$(TARGET)-$(LD)
TCC = $(PATH)/bin/$(TARGET)-$(CC)
TOBJCPY = $(PATH)/bin/$(TARGET)-objcopy
CRTP = $(PATH)/lib/gcc/m68k-elf/4.0.1
CRTNP =$(PATH)/m68k-elf/lib
all:
	$(TCC) $(CFLAGS) ambase.cc
	$(TLD) -T memory.x -L$(PATH)/lib/gcc/m68k-elf/4.0.1 -o a.out ambase.o 
-liberty
	$(TOBJCPY) --output-target=binary -j .text a.out a.bin 
	./mkamigarom
---------------------------------------------------------------------------------------------------------------
As you can see I use a separate link step with a memory.x linker script. This 
has been set up using trial and error and is probably riddled with bugs.

Are there any good location to find a good linker script? It should work with 
gcc-4.0.1, be able to produce a ROM image without using a fullblown libc 
installation and make sure all neccessary sections are handled.

Also, I have problem with atexit(). I'm currently supplying that as an empty 
function but is there some source I could use instead?

Any feedback is appreciated.

--- Mikael R

PS. For the curious, mkamigarom produce a binary image suitable for loading 
into the Universal Amiga Emulator uae as a kickstart file. An excellent tool 
if you do not have an evaluation board. .DS

------
Want more information?  See the CrossGCC FAQ, http://www.objsw.com/CrossGCC/
Want to unsubscribe? Send a note to crossgcc-unsubscribe@sources.redhat.com


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]