This is the mail archive of the
mailing list for the binutils project.
Linking to rom code symbols
- From: Fabrice Gautier <fabrice at sdesigns dot com>
- To: binutils at sourceware dot org
- Date: Thu, 12 Nov 2009 17:27:56 -0800
- Subject: Linking to rom code symbols
I'm trying to find an efficient and convenient way to link a aplication
to rom code.
The rom code is compiled as a rom.elf file.
I stripped this file to keep only the needed symbol (using strip -K)
Then in my application, I use the following linker script:
.rom 0x80190000 :
_ftext = . ;
. = ALIGN(4);
etext = . ;
_fdata = . ;
. = ALIGN(4);
Linking with this works fine and give me an app.elf file.
I can then extra the .text and .data section in binary files and load
the app this way.
I have a couple of (minor) issues with this method though:
a) This requires me to carry around the rom.elf file. The actual code
itself should not be required to link, only the symbol tables i believe.
So I would like to find a way to generate a "symbol file" that I can
easily include in my linking.
I tried to use the "objcopy --extract-symbol" to create a rom.sym file,
which is still an elf file but that contains only the symbol tables.
But this did not work. For some reason, it gets the offset all wrong
when linking. ie, even though readelf or nm return the symbols in the
0x80190000 range when looking at the rom.sym file, after the linking
process, the rom symbols in the app.elf file are in the 0x320000 range.
I'm not sure if thats a bug of the particular toolchain i'm using or
because I'm not doing the right thing.
b) The second issue is that I need to specify the .rom address in my app
linker script, but that information should already be in the rom.elf file.
Is there an easy and clean way to extract this information to give it to
the linker script ?