11.1 Memory Addresses and Relocatable Code
For most applications it is preferable to write fully relocatable source code, thus allowing the linker to determine the exact addresses in memory where functions and variables are placed. The final address of external symbols in memory can be determined from the link map output, as shown in this excerpt:
...
.text 0x9d0000f0 0x64
.text 0x9d0000f0 0x64 test.o
0x9d0000f0 myfunc
0x9d000110 main
.text._DefaultInterrupt 0x9d000154 0x48
.text._DefaultInterrupt 0x9d000154 0x48 c:/program files/
microchip/xc32/v1.20/bin/
../lib/gcc/pic32mx/4.5.2/
../../../../pic32mx/
lib\libpic32.a
defaultinterrupt.o)
0x9d000154 _DefaultInterrupt...
In some cases it is necessary for the programmer to specify the address where a certain variable or function should be located. Traditionally this is done by creating a user-defined section and writing a custom linker script. The 32-bit assembler and compiler provide a set of attributes that can be used to specify absolute addresses and memory spaces directly in source code. When these attributes are used, custom linker scripts are not required.