4.3.2.1 Runtime Startup Code Generation

Rather than the traditional method of linking in generic, precompiled runtime startup routines, the MPLAB XC8 C Compiler determines what runtime startup code is required from the user’s program and then generates this code each time you build your project.

The default operation of the driver is to keep the startup module; however, you can ask that it be deleted by using the option -mno-keep-startup (see 4.6.1.13 Keep Startup Option). If you are using the MPLAB X IDE to build, the file will be deleted unless you indicate otherwise in the Project Properties dialog.

If the startup module is kept, it will be called startup.s and will be located in the current working directory. If you are using an IDE to perform the compilation, the destination directory will be dictated by the IDE. Assuming you have the default configuration selected, MPLAB X IDE stores this file in either the dist/default/production or dist/default/debug directories (based on whether you perform a production or debug build) in your project directory.

Generation of the runtime startup code is an automatic process that does not require any user interaction; however, some aspects of the runtime code can be controlled, if required, using the -Wl,--no-data-init option. 4.6.12 Mapped Linker Options describes the use of this option.

The runtime startup code is executed before main(). However, if you require any special initialization to be performed immediately after Reset, you should use the powerup feature described later in 5.10.3 The Powerup Routine.