cancel
Showing results for 
Search instead for 
Did you mean: 

Why linker section accepts load memory adress but we have to load manually

SeyyedMohammad
Senior III

We have to manually load data to virtual memory adres VMA from Load Memory Adress LMA. But linker also requires the LMA. Look:

.fastcode :
  {
	  . = ALIGN(4);
	  _sfastcode = .;
	  *(.fastcode)
	  . = ALIGN(4);
	  *(.fastcode*)
	  . = ALIGN(4);
	/*  *arm_cortexM7lfdp_math.a:arm_fir_f32.o(.text*)*/
	  *arm_cortexM7lfdp_math.a:arm_*.o(.text*)
	  . = ALIGN(4);
	  _efastcode = .;
  } >ITCMRAM AT> FLASH

There you can see FLASH shows the load adress but we must initiate data in the startup:

ldr r0, =_sfastcode
 ldr r1, =_efastcode
 ldr r2, =_sifastcode
 movs r3, #0
 b LoopCopyFastcodeInit
 
CopyFastcodeInit:
 ldr r4, [r2, r3]
 str r4, [r0, r3]
 adds r3, r3, #4
 
LoopCopyFastcodeInit:
 adds r4, r0, r3
 cmp r4, r1
 bcc CopyFastcodeInit

Then relly there is no action happen by feeding ITCMRAM to LMA?

1 ACCEPTED SOLUTION

Accepted Solutions
KnarfB
Principal III

The linker script requires the LMA such that a .bin file can be generated for example. Also in an .elf file must be enough information such that a loader can load that stuff into the flash for persistent storage.

In your above script, a line

_sifastcode = LOADADDR(.fastcode);

is not shown which will provide the .fastcode LMA in a symbol for your copy loop.

The linker itself will not generate code, just may provide symbols for your code.

See also https://sourceware.org/binutils/docs/ld/index.html

hth

KnarfB

View solution in original post

1 REPLY 1
KnarfB
Principal III

The linker script requires the LMA such that a .bin file can be generated for example. Also in an .elf file must be enough information such that a loader can load that stuff into the flash for persistent storage.

In your above script, a line

_sifastcode = LOADADDR(.fastcode);

is not shown which will provide the .fastcode LMA in a symbol for your copy loop.

The linker itself will not generate code, just may provide symbols for your code.

See also https://sourceware.org/binutils/docs/ld/index.html

hth

KnarfB