10.6.1 Advantages of an Application-Defined Memory Region

Using an application-defined memory region in source code can provide a few advantages over adding a memory region to a custom linker script.

  • Portability: An application-defined memory region can help reduce the need for a custom linker script. This can be beneficial because you can use the device's default linker script and thereby avoid potential migration issues between XC32 versions, as well as between different PIC32 variants.
  • Best-Fit Allocation: Region-attributed variables and functions are handled by the linker's best-fit allocator, as described in the MPLAB XC32 Assembler, Linker, and Utilities User's Guide (DS50002186). Sections mapped to a new region in a custom linker script must be explicitly mapped using the SECTIONS command and are allocated sequentially.