# Vault 7: Projects

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

### Protego

# MPLAB XC16 C-Compiler

- 1
- 2
…
- 167
- 168
- 169
- 170
- 171
…
- 365
- 366

Memory Allocation and Access
 2012-2013 Microchip Technology Inc. DS50002071C-page 169
10.12.1 Near or Far Data
If variables are allocated in the near data space, the compiler is often able to generate
better (more compact) code than if the variables are not allocated in near data. If all
variables for an application can fit within the 8 KB of near data, then the compiler can
be requested to place them there by using the default -msmall-data command line
option when compiling each module. If the amount of data consumed by scalar types
(no arrays or structures) totals less than 8 KB, the default -msmall-scalar, com-
bined with -mlarge-data, may be used. This requests that the compiler arrange to
have just the scalars for an application allocated in the near data space.
If neither of these global options is suitable, then the following alternatives are
available.
1. It is possible to compile some modules of an application using the
-mlarge-data or -mlarge-scalar command line options. In this case, only
the variables used by those modules will be allocated in the far data section. If
this alternative is used, then care must be taken when using externally defined
variables. If a variable that is used by modules compiled using one of these
options is defined externally, then the module in which it is defined must also be
compiled using the same option, or the variable declaration and definition must
be tagged with the far attribute.
2. If the command line options -mlarge-data or -mlarge-scalar have been
used, then an individual variable may be excluded from the far data space by
tagging it with the near attribute.
3. Instead of using command-line options, which have module scope, individual
variables may be placed in the far data section by tagging them with the far
attribute.
The linker will produce an error message if all near variables for an application cannot
fit in the 8K near data space.

- 1
- 2
…
- 167
- 168
- 169
- 170
- 171
…
- 365
- 366