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.
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.
| Section Name | Generated by | Final Location | Default linker-script MEMORY region |
|---|---|---|---|
.reset | Reset handler | Executable boot-code segment | kseg0_boot_mem |
.bev_excpt | BEV-Exception handler | Executable boot-code segment | kseg0_boot_mem |
.app_excpt | General-Exception handler | Executable boot-code segment | kseg0_boot_mem |
.vector_n | Interrupt Vector n | Executable boot-code segment | kseg0_boot_mem |
.startup | C startup code | Executable boot-code segment | kseg0_boot_mem |
.text | Compiler- or assembler-generated instructions | Executable code segment | kseg0_program_mem |
.rodata | Strings and C data declared const | Read-only data segment | kseg0_program_mem |
.sdata2 | Small initialized constant global and static data | Read-only data segment | kseg0_program_mem |
.sbss2 | Uninitialized constant global and static data (i.e., variables which will always be zero) | Read-only data segment | kseg0_program_mem |
.data | Variables >n
bytes (compiled -Gn) with an initial value. Values
copied from program memory to data memory at C
startup. | Initialized data segment | kseg1_data_mem &
kseg0_program_mem |
.sdata | Variables
<=n bytes (compiled -Gn) with an initial value. Used for
gp-relative addressing. | Small initialized data segment | kseg1_data_mem &
kseg0_program_mem |
.lit4
/ .lit8 | Constants (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 segment | kseg1_data_mem &
kseg0_program_mem |
.sbss | Uninitialized
variables <=n bytes (compiled -Gn). Used for
gp-relative addressing. | Small zero-filled segment | kseg1_data_mem |
.bss | Uninitialized larger variables | Zero-filled segment | kseg1_data_mem |
.heap | Heap used for dynamic memory | Reserved by linker script | kseg1_data_mem |
.stack | Minimum space reserved for stack | Reserved by linker script | kseg1_data_mem |
.ramfunc | RAM-functions, copied from program memory to data memory at C startup | Initialized data segment | kseg1_data_mem &
kseg0_program_mem |
.reginfo
| Debug information | Not in load image | n/a |
.line | DWARF debug information | Not in load image | n/a |
.comment | #ident /.ident
directive | Not in load image | n/a |
