5.4.3 Start-Up and Initialization

The C/C++ runtime startup code is device specific. The xc32-gcc and xc32-g++ compilation drivers select the appropriate runtime startup code when linking, based on the -mprocessor option.

The source code for the startup modules, which initialize the runtime environment, is platform specific and can be found in files matching startup_device.c or startup_device.S within the directories pic32c/lib/proc/DEVICE/in your compiler's distribution directory. In general, the default device-specific startup code is written in C for microcontrollers (MCU) and assembly for microprocessors (MPU), since the microcprocessor initialization code requires some instructions that aren't normally available from standard C code.

Note: The device-specific runtime startup source code is also packaged in the Device Family Pack (DFP) relevant for your target device. However, some frameworks like MPLAB Harmony v3, provide their own application specific startup code rather than the default provided in a DFP.

Prebuilt startup object files are found in architecture specific directories under the lib/gcc/pic32c/<gcc-version>/ directory of your compiler distribution.

The object files for startup and runtime are named: crti.o, crtn.o, crtbegin.o and crtend.o. Other related libraries can be found there as well. Multilib versions of these modules exist in order to support architectural differences between device families.

For more information about what the code in these start-up modules actual does, see 18.2 Runtime Start-up Code.