简体   繁体   中英

Linker to link Functions found in different Code space but same Flash

I am using HCS08 micro-controller and Code Warrior as Development Environment. I have 2 separate programs residing on the ROM (Bootloader and Application code). I have some files/functions present in Bootlaoder Code and also required for my Application code but I do not want to duplicate these functions(are 3-4k bytes). So, is there any way possible to use functions which are not part of Application code but are present in ROM. Is this think possible? Can linker be told something?

In general, yes, but the way you'd do this through the linker is likely to be toolset specific. I've never used CodeWarrior for embedded development, but as an example using ARM's RVCT toolset, you could create a 'symdefs' file when you link the bootloader, and have the application code link against that file.

If you don't want to worry about toolset lock-in, then an option would be to use GNU's binutils to export a symbol table from your bootloader's executable (eg nm foo.exe > symtab.txt ), run a script over the symbol table to convert it into a .h file of the form:

#define symbol_name_ADDR 0x00001efc

and call externally-defined functions through a mechanism like:

((void (*)(int arg)) symbol_name_ADDR)(12);

which is pretty ugly, but should get the job done.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM