# Vault 7: Projects

This publication series is about specific projects related to the Vault 7 main publication.

### Protego

# MPLAB XC16 C-Compiler

- 1
- 2
…
- 78
- 79
- 80
- 81
- 82
…
- 365
- 366

MPLAB
®
XC16 C Compiler Users Guide
DS50002071C-page 80  2012-2013 Microchip Technology Inc.
5.4 RUNTIME FILES
The compiler uses the following files in addition to source, linker and header files.
5.4.1 Library Files
The compiler may include library files into the output per Figure 3-2.
By default, xc16-gcc will search known locations under the compiler installation direc-
tory for library files that are required during compilation.
5.4.1.1 STANDARD LIBRARIES
The C standard libraries contain a standardized collection of functions, such as string,
math and input/output routines. The range of these functions are described in the
16-Bit Language Tool Libraries (DS51456).
5.4.1.2 USER-DEFINED LIBRARIES
Users may create their own libraries. Libraries are useful for bundling and precompiling
selected functions so that application file management is easier and application com-
pilation times are shorter.
Libraries can be created manually using the compiler and the librarian. To create files
that may then be used as input to the 16-bit librarian (xc16-ar), use the -c compiler
option to stop compilation before the linker stage. For information on using the librarian,
see the MPLAB XC16 Assembler, Linker and Utilities Users Guide (DS52106).
Libraries should be called liblibrary.a and can be added to the compiler command
line by specifying its pathname (-Ldir) and -llibrary. For details on these options,
see Section 5.7.9 Options for Linking.
A simple example of adding the library libmyfns.a to the command-line is:
xc16-gcc -mcpu=30f2010 -lmyfns example.c
As with Standard C library functions, any functions contained in user-defined libraries
should have a declaration added to a header file. It is common practice to create one
or more header files that are packaged with the library file. These header files can then
be included into source code when required.
Library files specified on the command line are scanned first for unresolved symbols,
so these files may redefine anything that is defined in the C standard libraries.
5.4.2 Startup and Initialization
Two kinds of startup modules are available to initialize the C runtime environment:
 The primary startup module which is linked by default (or the -Wl, --data-init
option.)
 The alternate startup module which is linked when the -Wl, --no-data-init
option is specified (no data initialization.)
These modules are included in the libpic30-omf.a archive/library. Multiple versions
of these modules exist in order to support architectural differences between device
families. The compiler automatically uses the correct module.
For more information on the startup modules, see Section 15.3 Runtime Startup
and Initialization.

- 1
- 2
…
- 78
- 79
- 80
- 81
- 82
…
- 365
- 366