SPRUI03E June 2015 – January 2023
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 |
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 9.7.1 for more information about referring to linker symbols in C/C++ code.