Cross gcc Mailing List Archive
[Prev][Next][Index][Thread]
Re: Newlib's crt0.S
Ng BengKiat wrote:
>
> I'm writing s/w for BCC 68332 board. So, there's no OS to initialise.
> During testing, my s/w will be downloaded into RAM. Finally, it will be
> ROMed.
Ok. You will need two seperate link maps for these cases, unless
you use a small bootstrap loader to copy the entire program from
ROM to RAM before starting it (not necessarily a bad idea).
> In all other cross compilers that I've used before, there is an
> option to compile for RAM or ROM. When compiled for ROM, the global
> variables initial values are created in a data space in ROM. Normally,
> this ROM's data is copied into the actual variable space in RAM in the
> C-startup code. Is this what is happening in gcc for embedded system?
> ( I didn't notice any ROM or RAM option in gcc). If so, how do I do
> the copying from ROM to RAM. I need to know the data segments name and size!
As above, you can either write a custom crt0.S that copies everything
from _start to _end into RAM and then jumps to it (note that your
copy code will have to be position-independant), or you can emit a
symbol using the load map that indicates the start of the data segment.
Here's one I use for a 68000 with ROM at 0 (yuck):
/* $Id: mb.ld,v 1.2 1996/11/02 12:48:23 miff Exp $ */
STARTUP(crt0-mb.o)
OUTPUT_ARCH(m68k)
SEARCH_DIR(.)
__DYNAMIC = 0;
/*
** Setup the memory map of the CS50 board for MicroBoot in ROM
**
** vec : 68000 vectors (ROM)
** rom : code (ROM)
** sys : shadow vectors etc. (RAM)
** ram : working memory (RAM)
*/
MEMORY
{
vec : ORIGIN = 0x0, LENGTH = 1K
rom : ORIGIN = 0x400, LENGTH = 63K
/* sys : ORIGIN = 0x100000, LENGTH = 1K ** don't put anything here
*/
ram : ORIGIN = 0x100400, LENGTH = 1K
}
__stack = 0x100800 - 8;
SECTIONS
{
/*
* vectors in the vector area
*/
vec : { *(.vectors) } >vec
/*
* code and data into rom
*/
.text :
{
CREATE_OBJECT_SYMBOLS
*(.text)
etext = .;
__CTOR_LIST__ = .;
LONG((__CTOR_END__ - __CTOR_LIST__) / 4 - 2)
*(.ctors)
LONG(0)
__CTOR_END__ = .;
__DTOR_LIST__ = .;
LONG((__DTOR_END__ - __DTOR_LIST__) / 4 - 2)
*(.dtors)
LONG(0)
__DTOR_END__ = .;
*(.lit)
*(.shdata)
} > rom
.shbss SIZEOF(.text) + ADDR(.text) : {
*(.shbss)
} > ram
.talias : { } > rom
.data : {
__data_start = ALIGN(0x8);
*(.data)
CONSTRUCTORS
_edata = .;
} > rom
/*
* bss into ram
*/
.bss :
{
__bss_start = ALIGN(0x8);
*(.bss)
*(COMMON)
end = ALIGN(0x8);
_end = ALIGN(0x8);
__end = ALIGN(0x8);
} >ram
.mstack : { } > ram
.rstack : { } > ram
.stab . (NOLOAD) :
{
[ .stab ]
} > ram
.stabstr . (NOLOAD) :
{
[ .stabstr ]
} > ram
}
> Thanks!
--
Mike Smith *BSD hack Unix hardware collector
The question "why are the fundamental laws of nature mathematical"
invites the trivial response "because we define as fundamental those
laws which are mathematical". Paul Davies, _The_Mind_of_God_
References:
Home |
Subject Index |
Thread Index