This is the mail archive of the
newlib@sourceware.org
mailing list for the newlib project.
RE: linker script for V850?
- From: Robles Román, José Miguel <jmrroman at indra dot es>
- To: <newlib at sourceware dot org>
- Date: Wed, 3 May 2006 11:06:41 +0200
- Subject: RE: linker script for V850?
Hi,
I have solved a a similar problem as following:
Definition of memory map:
...
MEMORY
{
eprom (rx) : ORIGIN = 0x0, LENGTH = 1M
ram (rwx) : ORIGIN = 0x400000, LENGTH = 4M
}
The section .text of my executable is built from the .text
sections of the objects:
...
.text {
_start_text = .;
*(.text)
_stop_text = .;
} > eprom
Just after the .text section, I locate the ROM image of .data.
This ROM image must be copied by the code (it can be the startup
code or, as in my case, a C function executed at the very
beginning of the program).
_start_rom_data = _stop_text;
.data : AT (_start_rom_data) {
_start_data = .;
*(.data)
_end_data = .; } > ram
_stop_rom_data = _start_rom_data + _end_data - _start_data;
The C code that makes the copy is summarized here:
...
extern unsigned int _start_rom_data;
extern unsigned int _stop_rom_data;
...
for (src = (unsigned int)&_start_rom_data,
dst = (unsigned int)&_start_data;
src < (unsigned int)&_stop_rom_data;
src++, dst++)
{
*(unsigned char *)dst = *(unsigned char *)src;
}
I hope this helps.
Best Regards,
José Miguel