SPNU118Z September 1995 – March 2023 66AK2E05 , 66AK2H06 , 66AK2H12 , 66AK2H14 , AM1705 , AM1707 , AM1802 , AM1806 , AM1808 , AM1810 , AM5K2E04 , OMAP-L132 , OMAP-L137 , OMAP-L138 , SM470R1B1M-HT , TMS470R1A288 , TMS470R1A384 , TMS470R1A64 , TMS470R1B1M , TMS470R1B512 , TMS470R1B768
Six operators allow you to define symbols for load-time and run-time addresses and sizes:
LOAD_START(
sym)
START( sym) |
Defines sym with the load-time start address of related allocation unit |
LOAD_END(
sym)
END( sym) |
Defines sym with the load-time end address of related allocation unit |
LOAD_SIZE(
sym)
SIZE( sym) |
Defines sym with the load-time size of related allocation unit |
RUN_START( sym) | Defines sym with the run-time start address of related allocation unit |
RUN_END( sym) | Defines sym with the run-time end address of related allocation unit |
RUN_SIZE(sym) | Defines sym with the run-time size of related allocation unit |
LAST(sym) | Defines sym with the run-time address of the last allocated byte in the related memory range. |
These address and dimension operators can be associated with several different kinds of allocation units, including input items, output sections, GROUPs, and UNIONs. The following sections provide some examples of how the operators can be used in each case.
These symbols defined by the linker can be accessed at runtime using the _symval operator, which is essentially a cast operation. For example, suppose your linker command file contains the following:
.text: RUN_START(text_run_start), RUN_SIZE(text_run_size) { *(.text) }
Your C program can access these symbols as follows:
extern char text_run_start, text_run_size;
printf(".text load start is %lx\n", _symval(&text_run_start));
printf(".text load size is %lx\n", _symval(&text_run_size));
See Section 8.6 for more information about referring to linker symbols in C/C++ code.