Microchip Technology XC8 Standard Compiler (Workstation) SW006021-1 SW006021-1 User Manual

Product codes
SW006021-1
Page of 518
C Language Features
 2012 Microchip Technology Inc.
DS52053B-page 239
5.15.6
Linker-Defined Symbols
The linker defines some special symbols that can be used to determine where some 
psects where linked in memory. These symbols can be used in code, if required.
The link address of a psect can be obtained from the value of a global symbol with 
name __Lname (two leading underscores) where name is the name of the psect. For 
example, __LbssBANK0 is the low bound of the bssBANK0 psect.
The highest address of a psect (i.e., the link address plus the size) is represented by 
the symbol __Hname.
If the psect has different load and link addresses, the load start address is represented 
by the symbol __Bname.
Not all psects are assigned these symbols, in particular those that are not placed in 
memory by a -P linker option. SeSection 7.2.19 “-Pspec”. Psect names may 
change from one device to another.
Assembly code can use these symbol by globally declaring them, 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, see 
Section 5.12.3.1 “Equivalent Assembly Symbols”. As the symbol represents an 
address, a pointer is the typical type choice.