SPRUI03E June 2015 – January 2023
Normally, any reference to a symbol refers to its run-time address. However, it may be necessary at run time to refer to a load-time address. Specifically, the code that copies a section from its load address to its run address must have access to the load address. The .label directive defines a special symbol that refers to the section's load address. Thus, whereas normal symbols are relocated with respect to the run address, .label symbols are relocated with respect to the load address. See Create a Load-Time Address Label for more information on the .label directive.
Moving a Function from Slow to Fast Memory at Run Time and Linker Command File for show the use of the .label directive to copy a section from its load address in SLOW_MEM to its run address in FAST_MEM. Figure 9-3 illustrates the run-time execution of Moving a Function from Slow to Fast Memory at Run Time.
If you use the table operator, the .label directive is not needed. See Section 9.9.4.1.
.sect ".fir"
.align 4
.label fir_src
fir
; insert code here
.label fir_end
.text
MVKL fir_src, A4
MVKH fir_src, A4
MVKL fir_end, A5
MVKH fir_end, A5
MVKL fir, A6
MVKH fir, A6
SUB A5, A4, A1
loop:
[!A1] B done
LDW *A4+ +, B3
NOP 4
; branch occurs
STW B3, *A6+ +
SUB A1, 4, A1
B loop
NOP 5
; branch occurs
done:
B fir
NOP 5
; call occurs
/* PARTIAL LINKER COMMAND FILE FOR FIR EXAMPLE */
MEMORY
{
FAST_MEM : origin = 0x00001000, length = 0x00001000
SLOW_MEM : origin = 0x10000000, length = 0x00001000
}
SECTIONS
{
.text: load = FAST_MEM
.fir: load = SLOW_MEM, run FAST_MEM
}
See Section 9.7.1 for information about referring to linker symbols in C/C++ code.