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.

Assembly code can use these symbol by globally declaring them (noting the two leading underscore characters in the names), for example:
GLOBAL __Lidata
and C code could use them by declaring a symbol such as the following.
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.