Linker script (.lcf): placing sections of object files from a library (Kinetis)

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Linker script (.lcf): placing sections of object files from a library (Kinetis)

Jump to solution
1,519 Views
konrada
Contributor IV

Hello all,

 

my application used to fit into the internal flash of my K70 board, but now it has grown so that I have to use external Flash and external RAM. As an intermediate step, I want to get the copying of code to work from internal Flash to external RAM.

 

I'm using CW 10.2 for MCU. I have identified the five compilation units which contribute the code which runs before external RAM is ready for copying, and I want to use the linker script to place them in a section which executes from ROM, and the remaining code in a section which executes from RAM. 

 

My lcf looks like the following (grossly simplified):

MEMORY{  rom (RX): ORIGIN = 0x00000420, LENGTH=0x000FFBE0  extram (RW): ORIGIN = 0x80000000, LENGTH=0x01000000}SECTIONS{  .early_code :  {    cw.obj(.text)    __arm_eabi_init.obj(.text)  } > rom  .main_application :  {    *(.text)  } >> rom}

 When the object files for .early_code reside in the application, this works fine. However, when I try to place the code from cw.obj (from my BSP library) or __arm_eabi_init.obj (from some CW library) that way, the compiler complains that it cannot find the files cw.obj and __arm_eabi_init.obj.

 

"Linker command file error at line xx File not found: cw.obj"

 

I've tried using the names "cw.o" (like in the linker map file) and "cw.c" (like in the online help), with no improvements. Is there special syntax for placing files from libraries?

Labels (1)
0 Kudos
1 Solution
456 Views
konrada
Contributor IV

Answering myself,

 

the linker has the OBJECT directive to place single objects (functions, variables):

.early_code :  {    OBJECT(_my_init_function, libBlaBlub.a)  } > rom

I can thus enumerate all the early-boot functions instead of their compilation units. Works for me. Instead of "bla.c", as the doc says, I use "bla.obj" or if it's in a library, "libWhateverLibrary.a".

 

View solution in original post

0 Kudos
1 Reply
457 Views
konrada
Contributor IV

Answering myself,

 

the linker has the OBJECT directive to place single objects (functions, variables):

.early_code :  {    OBJECT(_my_init_function, libBlaBlub.a)  } > rom

I can thus enumerate all the early-boot functions instead of their compilation units. Works for me. Instead of "bla.c", as the doc says, I use "bla.obj" or if it's in a library, "libWhateverLibrary.a".

 

0 Kudos