Cross gcc Mailing List Archive
[Prev][Next][Index][Thread]
Re: newlibs crt0.S
As an example how the initialisation of the data segment can be
done, I supply a ld-script and a short piece of code
from my crt0.S.
My target is a board with a 68341.
<start of linker-script>
MEMORY
{
rom : ORIGIN = 0x0, LENGTH = 256k
ram : ORIGIN = 0x40000, LENGTH = 256k
}
__stack = 0x40000 + 256k - 8;
SECTIONS
{
.text :
{
*(.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)
_initdata = .;
} > rom
.data :
AT ( ADDR(.text) + SIZEOF(.text))
{
_data = .;
*(.data)
_edata = .;
} > ram
.shbss ADDR(.text) + SIZEOF(.text) + SIZEOF(.data) :
{
*(.shbss)
} > rom
.bss SIZEOF(.data) + ADDR(.data) :
{
__bss_start = .;
*(.bss)
*(COMMON)
_end = ALIGN(0x8);
__end = ALIGN(0x8);
} > ram
.stab . (NOLOAD) :
{
[ .stab ]
}
.stabstr . (NOLOAD) :
{
[ .stabstr ]
}
}
< end of linker-script>
< start of code from crt0.S >
/*
* initialize data section
*/
data_init:
movel IMM(_initdata), a0
movel IMM(_data), a1
init_loop:
cmpl IMM(_edata), a1
jbge init_end
moveb (a0)+, (a1)+
jra init_loop
init_end:
< end of code from crt0.S >
Hope this helps,
Cord Elias
Home |
Subject Index |
Thread Index