5.15.6 Linker-Defined Symbols
The linker defines special symbols that can be used to determine where sections that were explicitly linked via an option where located in memory. These symbols can be used in C or assembly code, if required.
The link address of a section can be obtained from the value of a global
symbol with name __Lname
(two leading underscores) where
name
is the name of the section. For example,
__LbssBANK0
is the low bound of the bssBANK0
section.
The highest address of a section (i.e., the link address plus the size) is represented by
the symbol __Hname
. If the section has different load and link
addresses, the load start address is represented by the symbol
__Bname
; however these are rarely used with PIC devices.
If a section is implicitly linked via a linker class, that is, it is not
placed in memory without the explicit use of a -P
linker option (see 7.1.18 P: Position Psect), the special symbols
associated with it are not assigned an address and will have the value 0. Addresses are
only assigned to the symbols when the section is linked using a -P
linker
option. That option can simply place the section anywhere in a linker class, for example
-PmyConstData=CONST
.
GLOBAL __Lidata
extern char * _Lidata;
Note that there is
only one leading underscore in the C domain. As the C identifier represents an address, a
pointer is the typical type choice.