SLAU646F September 2015 – June 2020
The GNU compiler, assembler, and linker in the MSP430 GCC toolchain support the target-specific options listed in Table 4-2, Table 4-3, and Table 4-4, in addition to the standard options. For the full list of options for the GNU compiler, refer to the GCC online documentation. For the full list of options for the GNU assembler (gas) and linker (ld), refer to the GNU binutils online documentation. The manifest distributed with the toolchain specifies the version numbers of each of the components.
Option | Description |
---|---|
-masm-hex | This option forces assembly output to always use hex constants. Normally such constants are signed decimals, but this option is available for test suite or aesthetic purposes. |
-mcode-region=
-mdata-region= |
These options
change the behavior of the compiler and linker. The names of function and data
sections are modified so that they will be placed in a specific way across the upper
and lower memory regions, according to the rules in the linker script. These options
have no effect unless -mlarge is also passed. Possible values are:
The default settings for these options are: -mdata-region=lower and -mcode-region=none. |
-mhwmult= | This option
describes the type of hardware multiply supported by the target. Accepted values:
If no -mmcu option is specified, then no hardware multiply support is assumed. 'auto' is the default setting. Hardware multiplies are normally performed by calling a library routine. This saves space in the generated code. When compiling at -O3 or higher, however, the hardware multiplier is invoked inline. This makes for larger but faster code. The hardware multiply routines disable interrupts while running and restore the previous interrupt state when they finish. This makes them safe to use inside interrupt handlers as well as in normal code. |
-mdisable-device-warnings | Disable warnings emitted when the devices.csv file cannot be found by the compiler. |
-minrt | This option is deprecated. The toolchain now dynamically decides which start up and initialization/termination functions are required. |
-mlarge | Use large-model addressing (20-bit pointers, 20-bit size_t). Small-model addressing is the default. |
-mmax-inline-shift=<0,64> | This option
takes an integer between 0 and 64 inclusive. The value sets the maximum number of
inline shift instructions to emit to perform a shift operation by a constant amount.
If this value will be exceeded, an MSPABI helper function is used instead. The
default value is 4. This option affects only cases where a shift by multiple positions cannot be completed with a single instruction (for example, all shifts by more than one position on the MSP430 ISA). Shifts of a 32-bit value are at least twice as costly, so the value passed for this option is divided by 2 and the resulting value is used instead. |
-mmcu= | This option
selects the MCU to target. This is used to create a C preprocessor symbol based upon
the MCU name, converted to upper case and prefixed and postfixed with '__'. This in
turn is used by the 'msp430.h' header file to select an MCU-specific supplementary
header file. The option also sets the ISA to use. If the MCU name is one that is known to only support the 430 ISA then that is selected, otherwise the 430X ISA is selected. A generic MCU name of 'msp430' can also be used to select the 430 ISA. Similarly, the generic 'msp430x' MCU name selects the 430X ISA. In addition, an MCU-specific linker script is added to the linker command line. The script's name is the name of the MCU with '.ld' appended. Thus specifying '-mmcu=xxx' on the gcc command line defines the C preprocessor symbol __XXX__ and causes the linker to search for a script called 'xxx.ld'. This option is also passed on to the assembler. Manually passing a linker script using the -T option prevents this linker script from being used automatically. To augment rather than displace this linker script, use the --script option to pass directly to the linker (-Wl,--script=). |
-mrelax | This option enables both assembler and linker relaxation, which are optimizations that modify the code that was emitted by the compiler. See the descriptions of the -mQ option for the assembler and --relax option for the linker for more information. By default, assembler relaxation is disabled, and linker relaxation is enabled. |
-msilicon-errata=NAME[,NAME...] | This option
implements fixes for named silicon errata. Multiple silicon errata can be specified
by multiple uses of the -msilicon-errata option or by including the errata names,
separated by commas, on an individual -msilicon-errata option. Errata names
currently recognized by the assembler are: cpu4 = PUSH #4 and PUSH #8 need longer encodings on the MSP430. This errata is enabled by default; it cannot be disabled. cpu8 = Do not set the SP to an odd value. cpu11 = Do not update the SR and the PC in the same instruction. cpu12 = Do not use the PC in a CMP or BIT instruction. cpu13 = Do not use an arithmetic instruction to modify the SR. cpu19 = Insert NOP after CPUOFF. |
-msim | This option links to the simulator runtime libraries and linker script. Overrides any scripts that would be selected by the '-mmcu=' option. |
-msmall | Use small-model addressing (16-bit pointers, 16-bit size_t). This is the default. |
-msilicon-errata-warn=NAME[,NAME...] | This option is similar to the -msilicon-errata option, except that instead of fixing the specified errata, a warning message is issued instead. This option can either be used with -msilicon-errata to generate messages whenever a problem is fixed, or used on its own to inspect code for potential problems. |
-mtiny-printf | This option links a reduced-size implementation of the printf() and puts() library functions. This reduced size implementation is not reentrant, so should be used with care in multi-threaded applications. Buffering of the string to be output has been removed from printf() and puts(), so user implementations of the system write() function must also implement buffering. The library implementation of write() that is included with MSP430 GCC does buffer the output string. |
-muse-lower-region-prefix | This option adds
the ".lower" prefix to function or data section names when -mdata-region=lower or -mcode-region=lower is passed. |
-mwarn-mcu -mno-warn-mcu |
This option enables or disables warnings about conflicts between the MCU name specified by the -mmcu option and the ISA set by the -mcpu option or the hardware multiply support set by the -mhwmult option. It also toggles warnings about unrecognized MCU names. This option is on by default. |
Most assembler and linker options specific to MSP430 are passed automatically by the GCC wrapper, depending on the options passed to GCC itself. Table 4-3 and Table 4-4 list options that control behavior specific to the assembler and linker.
When passing an option to the assembler via the GCC wrapper (msp430-elf-gcc), the option must be prefixed with “
-Wa,
”. For example, to pass -mU to the assembler, you would pass
-Wa,-mU
to msp430-elf-gcc.
The assembler emits warnings when instructions to enable or disable interrupts are used without surrounding NOP instructions. See Section 8.2 for details. This behavior can be modified using the options in Table 4-3.
Option | Description |
---|---|
-mn | Insert NOPs around interrupt enable/disable instructions. |
-mN | Do not insert NOPs around interrupt enable/disable instructions (default). |
-mQ | Enable assembler relaxation. The assembler tries to replace some instructions with alternate versions that have smaller code sizes. This is disabled by default. |
-mu | Warn or insert NOP instructions (default) around an instruction that may change the interrupt enable state if it is not known how the state will change. Whether a warning is emitted or a NOP is inserted is dependent on which of the -m{N,n,Y,y} options are set. |
-mU | Do not warn or insert NOP instructions around an instruction that may change the interrupt enable state if it is not known how the state will change. |
-my | Warn about missing NOPs around interrupt enable/disable instructions (default). |
-mY | Do not warn about missing NOPs around interrupt enable/disable instructions. |
When passing options to the linker via the GCC wrapper (msp430-elf-gcc), the option must be prefixed with “
-Wl,
”. For example, to pass --disable-sec-transformation to the linker, you would pass
-Wl,--disable-sec-transformation
to msp430-elf-gcc.
Option | Description |
---|---|
--disable-sec-transformation | Disable the transformation of section names in object files being
linked, based on the -mdata-region and -mcode-region options. For example, passing “-mdata-region=either -Wl,--disable-sec-transformation” to msp430-elf-gcc instructs the compiler to add the “.either” prefix to data section names being compiled, but the linker will not add the “.either” prefix to any section names in the object files it is passed. |
--relax --no-relax | Enable or disable relaxation. The linker tries to replace some instructions with alternate versions that have smaller code sizes. Relaxation may grow short branch instructions that do not reach their target. Linker relaxation is enabled by default and cannot be disabled when linking executable files. |
Option | Description |
---|---|
--symtab-meta | Print the symbol meta-information entries from the .symtab_meta section of the specified ELF object or executable file. |