Linking

Top  Previous  Next

Once you have compiled the source files for a task into one or more object files, you must link them together along with any external functions they require, including functions like printf from the run-time library. The Texas Instruments linker does this, and the result is called a task image file.

 

Diamond’s task image files are relocatable, that is, the various code and data areas they contain have not yet been allocated to particular memory addresses in the target processor. This is done during the subsequent configuration step. For this reason you must not supply linker command files with the MEMORY and SECTIONS directives that would be necessary when using TI’s tools alone.

 

Here we discuss the most common linker operations; more about the linker can be found in the linker's documentation.

 

You can link together any number of object files to form a task image with a command of the following form:

 

3L T object-file object-file …

 

For example: » 3L T hello

 

3L T  is a command that invokes the linker in the most typical way. You provide a list of one or more object files and libraries to be linked together. Each object-file should be the name of an object file produced by the compiler or a library file. You do not need to supply the .obj extension; the linker assumes the extension .obj if you do not give one. In the example above, hello.obj is linked with the necessary modules from the library, and a task image file hello.tsk is created.

 

If you specify more than one object file, the 3L T command constructs the task image file name from the first parameter. For example, if there are two C source files, main.c and fns.c, the following commands compile them and link them together to produce main.tsk.

 

» 3L C main.c

» 3L C fns.c

» 3L T main fns

 

Dragons003The name of the first object file argument will be used to construct the name of the task image file by replacing any extension with .tsk.

 

You can use the linker option -o filename to specify a different task image name.