9.3 Section Mapping

The linker script for PIC32MZ and later devices are contained within a single file (e.g. p32MZ2048ECH100.ld) located in the Device Family Pack (DFP) you have downloaded for your project. 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.

Note: The Compiler guide relevant for you target device examines the contents of the default linker script in detail. The discussion applies to both assembly-code and C-code projects.

The default linker script maps each standard input section to one or more specific MEMORY regions. In turn, each MEMORY region maps to an address segment on the PIC32 MCU (e.g. kseg0, kseg1). See the Section 3 of the PIC32MX Family Reference Manual (DS61115) for a full description of the user/kernel address segments.

The table below shows how the default linker script maps standard sections to MEMORY regions.

Table 9-1. PIC32 Reserved, Standard Section Names in Default Linker Script
Section NameGenerated byFinal LocationDefault linker-script MEMORY region
.resetReset handlerExecutable boot-code segmentkseg0_boot_mem
.bev_excptBEV-Exception handlerExecutable boot-code segmentkseg0_boot_mem
.app_excptGeneral-Exception handlerExecutable boot-code segmentkseg0_boot_mem
.vector_nInterrupt Vector nExecutable boot-code segmentkseg0_boot_mem
.startupC startup codeExecutable boot-code segmentkseg0_boot_mem
.textCompiler- or assembler-generated instructionsExecutable code segmentkseg0_program_mem
.rodataStrings and C data declared constRead-only data segmentkseg0_program_mem
.sdata2Small initialized constant global and static dataRead-only data segmentkseg0_program_mem
.sbss2Uninitialized constant global and static data (i.e., variables which will always be zero)Read-only data segmentkseg0_program_mem
.dataVariables >n bytes (compiled -Gn) with an initial value. Values copied from program memory to data memory at C startup.Initialized data segmentkseg1_data_mem & kseg0_program_mem
.sdataVariables <=n bytes (compiled -Gn) with an initial value. Used for gp-relative addressing.Small initialized data segmentkseg1_data_mem & kseg0_program_mem
.lit4 / .lit8Constants (usually floating point) which the assembler decides to store in memory rather than in the instruction stream. Used for gp-relative addressing.Small initialized data segmentkseg1_data_mem & kseg0_program_mem
.sbssUninitialized variables <=n bytes (compiled -Gn). Used for gp-relative addressing.Small zero-filled segmentkseg1_data_mem
.bssUninitialized larger variablesZero-filled segmentkseg1_data_mem
.heapHeap used for dynamic memoryReserved by linker scriptkseg1_data_mem
.stackMinimum space reserved for stackReserved by linker scriptkseg1_data_mem
.ramfuncRAM-functions, copied from program memory to data memory at C startupInitialized data segmentkseg1_data_mem & kseg0_program_mem
.reginfo

.stab*

.debug*

Debug informationNot in load imagen/a
.lineDWARF debug informationNot in load imagen/a
.comment#ident /.ident directiveNot in load imagen/a
Note: The table above contains sections that are no longer mapped in the linker script. Starting with XC32 v2.00, the best-fit allocator allocates them.