23.3 Default Linker Script
For PIC32MX Devices Only:
If no linker script or alternative Device Family Pack (DFP) is specified on the command line, the linker will use an internal version known as the built-in default linker script. The default linker script has section mapping that is appropriate for all PIC32 MCUs. It uses an INCLUDE
directive to include the device-specific memory regions.
The default linker script is appropriate for most PIC32 MCU applications. Only applications with specific memory-allocation needs will require an application-specific linker script. The default linker script can be examined by invoking the linker with the --verbose
option:
xc32-ld --verbose
In a normal tool-suite installation, a copy of the default linker script is located at \pic32mx\lib\ldscripts\elf32pic32mx.x
. Note that this file is only a copy of the default linker script. The script that the linker uses is internal to the linker.
The device-specific portion of the linker script is located in \pic32mx\pic32mx\lib\proc\32MXGENERIC\procdefs.ld
, where device is the device value specified to the -mprocessor
compilation-driver (xc32-gcc
) option.
If the -mdfp
option has been used, the linker script in the specified DFP will be used instead.
For PIC32MZ and Later Devices:
The linker script for PIC32MZ devices are contained within a single file (for example, pic32mx/lib/proc/32MZ2048ECH100/p32MZ2048ECH100.ld
). This eliminates the dependency on two files (elf32pic32mx.x
and procdefs.ld
) used by the older linker-script model. Like before, the xc32-gcc compilation driver will pass the device-specific linker script to the linker when building with -mprocessor
option. And additionally, the linker script in the specified DFP will be selected if the -mdfp
option has been used.
The default linker script contains the following categories of information:
- 23.3.1 Output Format and Entry Points
- 23.3.2 Default Values for Minimum Stack and Heap Sizes
- 23.3.3 Processor Definitions Include File for PIC32MX Family
- 23.3.4 Input/Output Section Map