Linker files and startup code
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Linker files and startup code
- To: coldfire-gnu-discuss@xxxxxxxxxxxxxxxx
- Subject: Linker files and startup code
- From: David Brown <david@xxxxxxxxxxxxxxx>
- Date: Wed, 01 Nov 2006 13:02:13 +0100
Hi,
I'm trying to establish exactly what happens in the startup C files and
loader scripts that come with the CodeSourcery gcc package. Normally,
I've used my own loader scripts and my own startup code, but for the
project I'm starting work on at the moment, I thought I'd look at the
scripts that came with the pre-packaged setup. I'm using a MCF5213
(256K flash, 32K Ram) here, on my own board and with no other software
but my own code. This post is a few comments on what I have seen so
far, which may be of interest to the CodeSourcery guys (many thanks for
your work, by the way!) or other users.
First off, it's a tough job finding the source code for the startup
files. I tracked down the appropriate crt0.S, though it would be *very*
useful to have had that in the binary build distributions as well as the
source distribution. But I can't trace the sources for crtbegin.o or
crtend.o anywhere. Since they are small, an objdump disassembly listing
is not bad, but I'd like to know where they came from...
The linker scripts and the crt0.S seem to be based entirely on the idea
that the code is running from ram. On many ColdFire's, that is the case
- you have a bootloader of some sort which copies the code from slow
flash into fast ram for execution. But on the more integrated devices
like the 5213, you need to run the code from flash. This means that the
loader scripts should support the separate memory areas, with code going
in flash, bss going in ram, and data going in flash but with logical
addresses in ram, and the crt0 startup should copy the initial values
into ram.
A minor point about the crt0.S code is that it clears the bss section
byte by byte. On the ColdFire, writing 32-bit words will clear the
section about four times as fast.
mvh.,
David