Forums

How can I load an executable into both Flash and RAM using GNU ld

Started by r_williams408 July 14, 2006
I am using the Keil IDE with the GNU compiler and linker.
My target is a LPC2124 running at 60Mhz.

I need to load part of my application into Flash and a couple of
library routines into RAM. So far I have been unable to link the
library so that it can be copied into RAM and executed. The linker
seems to always want to resolve all of the code links into Flash
address space.

I have tried explicitly assigning the .text segment of the library
into the RAM's VMA, but the linker map file indicates it did not load
any of the library there, instead it pulled the library in when it was
loading the Flash text segments.

Is the GNU linker able to load code into 2 different address spaces
within a single executable? If so how do I instruct ld to do this in
the linker script?

An Engineer's Guide to the LPC2100 Series

Hi,

> I am using the Keil IDE with the GNU compiler and linker.
> My target is a LPC2124 running at 60Mhz.
>
> I need to load part of my application into Flash and a couple of
> library routines into RAM. So far I have been unable to link the
> library so that it can be copied into RAM and executed. The linker
> seems to always want to resolve all of the code links into Flash
> address space.
>
> I have tried explicitly assigning the .text segment of the library
> into the RAM's VMA, but the linker map file indicates it did not load
> any of the library there, instead it pulled the library in when it was
> loading the Flash text segments.
>
> Is the GNU linker able to load code into 2 different address spaces
> within a single executable? If so how do I instruct ld to do this in
> the linker script?

You have a couple of options:

1 - In your source files, tag the functions to go into a different section:

void foobar1 (void) __attribute__ ((section ("foo")));
void foobar1 (void)
{
}

2 - Use linker rules to move .text sections for a whole section:

You existing linker file probably has something like this:

.text {
*(.init)
*(.text)

You can replace the * with the name of an object file:

.mysection {
file1.o(.text)
}

to place the .text from file1.o into some other section

--
Dave Hylands
Vancouver, BC, Canada
http://www.DaveHylands.com/