This is the mail archive of the
newlib@sourceware.org
mailing list for the newlib project.
NewLib start up code
- From: Sergio <hardmaker at gmail dot com>
- To: "newlib at sourceware dot org" <newlib at sourceware dot org>
- Date: Sat, 15 Jan 2011 12:25:45 -0300
- Subject: NewLib start up code
Hi,
I'm new working with newlib. I can build a complete toolchain to work
with ARM architecture and Cortex M3. I write my own crt0 and syscalls.
All work ... but when I do a call to any library function does not
work. Searching in the net read about a _init and _fini functions to
initialize the library. Now, my crt0 file have a invocation to this
functions after and before of main, like:
...
// initialize the stack
// initialize _bss
_init();
main();
_fini();
...
When I this and link the application, recibe a error message from the
linker about override some segments. Searching about, find I must add
some declarations in then linker script to put the _init and _finit
code in the data segment. I use a linker script like this:
STARTUP(out/crt0.o)
ENTRY(main)
MEMORY
{
FLASH (rx) : ORIGIN = 0x00000800, LENGTH = 0x1F7FF
SRAM (rwx) : ORIGIN = 0x20000000, LENGTH = 0xFFFF
}
SECTIONS
{
.text :
{
_text = .;
KEEP(*(.isr_vector))
*(.text*)
*(.rodata*)
_etext = .;
PROVIDE (_init = .);
*crti.o(.init)
*(.init)
*crtn.o(.init)
PROVIDE (_fini = .);
*crti.o(.fini)
*(.fini)
*crtn.o(.fini)
} > FLASH
.data : AT(ADDR(.text) + SIZEOF(.text))
{
_data = .;
*(vtable)
*(.data*)
_edata = .;
} > SRAM
.bss :
{
__bss_start = .;
*(.bss*)
*(COMMON)
__bss_end = .;
. = ALIGN (8);
_end = .;
} > SRAM
}
PROVIDE( _HEAP_START = _end );
PROVIDE ( _HEAP_END = ALIGN(ORIGIN(SRAM) + LENGTH(SRAM) - 8 ,8) );
This is correct? The application it's build fine, but die when run and
do a function library call. I must add some extra code to initialize
the internals of newlib? I need add some segment to the linker script
to do space to library data?
If anyone can help, of course thank you very much
Sergio