23.3.4.25 Stack Location

A symbol is defined to represent the location of the Stack Pointer (_stack). As described previously, the heap and the stack are now allocated to the largest available gap of memory after other sections have been allocated.

For PIC32 devices with more than 64K of data memory, GP relative addressing mode should not be used. To avoid conflict of using GP-relative addressing to the linker generated symbols, allocate the symbols in section "_linkergenerated": extern unsigned int __attribute__((section("_linkergenerated"))) _splim;