SLAU132Y September 2004 – June 2021
This is the general syntax for linking C/C++ programs as a separate step:
cl430 --run_linker {--rom_model | --ram_model} filenames | |
[options] [--output_file=name.out] --library=library [lnk.cmd] |
cl430 --run_linker | The command that invokes the linker. |
--rom_model | --ram_model | Options that tell the linker to use special
conventions defined by the C/C++ environment. When you use
cl430
--run_linker without listing any C/C++
files to be compiled on the command line, you must
use --rom_model or --ram_model on the command
line or in the linker command file. The --rom_model option
uses automatic variable initialization at run time; the
--ram_model option uses variable initialization at load
time. See Section 5.4.7 for details about using the --rom_model and --ram_model
options. If you fail to specify the ROM or RAM model, you
will see a linker warning that says:
|
filenames | Names of object files, linker command files, or archive libraries. The default extensions for input files are .c.obj (for C source files) and .cpp.obj (for C++ source files). Any other extension must be explicitly specified. The linker can determine whether the input file is an object or ASCII file that contains linker commands. The default output filename is a.out, unless you use the --output_file option. |
options | Options affect how the linker handles your object files. Linker options can only appear after the --run_linker option on the command line, but otherwise may be in any order. (Options are discussed in detail in the MSP430 Assembly Language Tools User's Guide.) |
--output_file= name.out | Names the output file. |
--library= library | Identifies the appropriate archive library containing C/C++ run-time-support and floating-point math functions, or linker command files. If you are linking C/C++ code, you must use a run-time-support library. You can use the libraries included with the compiler, or you can create your own run-time-support library. If you have specified a run-time-support library in a linker command file, you do not need this parameter. The --library option's short form is -l. |
lnk.cmd | Contains options, filenames, directives, or commands for the linker. |
The default file extensions for object files created by the compiler have been changed. Object files generated from C source files have the .c.obj extension. Object files generated from C++ source files have the .cpp.obj extension.
When you specify a library as linker input, the linker includes and links only those library members that resolve undefined references. The linker uses a default allocation algorithm to allocate your program into memory. You can use the MEMORY and SECTIONS directives in the linker command file to customize the allocation process. For information, see the MSP430 Assembly Language Tools User's Guide.
You can link a C/C++ program consisting of object files prog1.c.obj, prog2.c.obj, and prog3.cpp.obj, with an executable object file filename of prog.out with the command:
cl430 --run_linker --rom_model prog1 prog2 prog3 --output_file=prog.out
--library=rts430.lib