Calling the Linker Directly

Top  Previous  Next

Sometimes you may wish to call the linker directly, instead of using the 3L T or 3L TA commands. There are some required options that you must use every time you link Diamond tasks; the easiest way to get them is to use the standard Command.dat files as templates: see 3L Command. The following is a batch file that has the same effect as 3L T:

 

echo -ar -cr                                     > tmp.cmd  ¤1 ¤2

echo SECTIONS                                   >> tmp.cmd  ¤3

echo {                                          >> tmp.cmd

echo .bss:   { *(.bss)   }                      >> tmp.cmd

echo .cinit: { *(.cinit) }                      >> tmp.cmd

echo .text:  { *(.text)  }                      >> tmp.cmd

echo }                                          >> tmp.cmd

echo file1                                      >> tmp.cmd  ¤4

echo file2                                      >> tmp.cmd  ¤4

echo file3                                      >> tmp.cmd  ¤4

echo file4                                      >> tmp.cmd  ¤4

echo -l "<3L>Diamond\edition\Lyrtech\C6000\lib\rtl.lib"  >> tmp.cmd  ¤5

echo -l rts6200.lib                             >> tmp.cmd  ¤6

echo -o %1.tsk                                  >> tmp.cmd

lnk6x -qq tmp.cmd

erase tmp.cmd

 

¤1

The -ar option makes the linker generate a relocatable task image file. We need this, since the configurer will later decide the absolute locations where the sections of the task will be loaded. See section 7.4.1 of the TI linker documentation.

¤2

The -cr option instructs the linker to build a task that follows the conventions for a C6000 C program. It also requests that static variables should be initialized at run time; the Diamond environment requires this. See section 7.16 of the TI linker documentation.

¤3

SECTIONS is there to cope with a change introduced in recent TI code generation tools. Without this SECTIONS incantation, the linker no longer combines all the necessary subsections of .bss, .cinit, and .text into single areas, and the configurer subsequently reports errors.

¤4

The example assumes you are linking four files named file1.obj, file2.obj, file3.obj, and file4.obj, but you may link as many or as few object files as you wish. You should, of course, use the names of your own files.

¤5

The option -l "<3L>Diamond\edition\Lyrtech\C6000\lib\rtl.lib" specifies the full Diamond library as a library to be searched by the linker. You can replace rtl with sartl to build a stand-alone task. You need to replace <3L> with the path to the Diamond installation folder, usually C:\3L\ (note the final '\').

¤6

The option -l rts6200.lib specifies the TI library as a library to be searched by the linker for functions not defined in the Diamond library. It is important that you place this library after the Diamond library. You can also use device-specific libraries, such as rts64000.