9.1 Overview of Linker Scripts

Linker scripts control all aspects of the link process, including:
  • allocation of data memory and program memory
  • mapping of sections from input files into the output file
  • construction of special data structures (such as interrupt vector tables)

Linker scripts are text files that contain a series of commands. Each command is either a keyword, possibly followed by arguments, or an assignment to a symbol. These commands are described in subsequent sections.

By default, the linker will use the linker script provided by the Device Family Pack (DPF) specified when linking the project. If no DFP is supplied, a default script from the family/lib/ldscripts will be used; however, these will not take into account device-specific features and are not recommended. If you require customization of the linker script, base your changes on the linker script supplied by the DFP.

The -mdfp option used indicates which DFP will be used with the project. The linker script provided by the DPF is appropriate for most applications. Only applications with specific memory-allocation needs will require an application-specific linker script. The linker script used by a project can be examined by invoking the linker with the --verbose option:
xc32-ld --verbose
Alternatively, the compiler will save a copy of the script if the -save-temps option has been specified.