10.3.1 Processor and Startup Modules

The first several lines of a linker script define the processor and startup modules:

OUTPUT_ARCH("33EP32MC504")
CRT0_STARTUP(crt0_extendedep.o)
CRT1_STARTUP(crt1_extendedep.o)
#if __XC16_VERSION__ > 1027
/*
 * Define how to startup, by default we initialize
 * everything as normal; change to crt_start_mode to
 * preserve preserved data on a restart
 *
 * Or define your own __crt_start_mode fucntion
 */
CRT_STARTMODE(crt_start_mode_normal)
#endif

OPTIONAL(-lp33EP32MC504)
OPTIONAL(-lfx)

The OUTPUT_ARCH command specifies the target processor. The CRTn_STARTUP commands specify two C run-time startup modules to be loaded from archives. The linker will select one of these based on whether data initialization has been enabled.

The CRT_STARTMODE command specifies whether data sections marked "preserved" should be initialized upon startup. This command is bracketed by a preprocessor expression because some legacy linkers do not support this command.

The OPTIONAL commands specify device-specific libraries that should be opened if available. If the library file cannot be found, the link will continue without error unless there are unresolved references in the application.