Re: How to link embedded code against existing routines in flash

emeb wrote:

I'm using arm-elf-gcc to write embedded code targeting the NXP
LPC2148. My application code will be loaded from an SD card into the
MCU flash and run by an existing bootloader described in more detail

This bootloader contains a number of utility / library routines that
I'd like to be able to use from my own application rather than
duplicating the same code in my binary file. Since I've compiled &
flashed the bootloader myself, I have access to all the linker output
from the build process, including the maps, lists and symbol tables
and I know what the function addresses are. What I need is a clean way
to let the compiler/linker know this when I prepare the application

This sounds to me kind of like linking against a shared library, but
since this is an embedded application I'm sure that the process is
very different. I've done a bit of checking around but haven't found
anything that looks similar enough to what I'm trying to do to be a
good starting point.

Any suggestions on where I should start with this?

Keep the final elf file of your bootloader and link your new application
code with the linker parameter --just-symbols=<your bootloader elf file>.
This will force the linker to link all references in your new application
to the bootloader in an absolute manner. So your application code can run
anywhere from RAM while it calls code from your bootloader (at a fixed
address) in flash.

Hope it helps.