Creating a Linker Command File
2 - 12 C2000 Microcontroller Workshop - Programming Development Environment
Creating a Linker Command File
Sections
Looking at a C program, you'll notice it contains both code and different kinds of data (global,
local, etc.). All code consists of different parts called sections. All default section names begin
with a dot and are typically lower case. The compiler has default section names for initialized
and uninitialized sections. For example, x and y are global variables, and they are placed in the
section .ebss. Whereas 2 and 7 are initialized values, and they are placed in the section called
.cinit. The local variables are in a section .stack, and the code is placed in a section called .txt.
Sections
All code consists of
different parts called
sections
All default section
names begin with “.”
The compiler has
default section names
for initialized and
uninitialized sections
int x = 2;
int y = 7;
void main(void)
{
long z;
z = x + y;
}
Global vars (.ebss)
Init values (.cinit)
Local vars (.stack) Code (.text)
In the TI code-generation tools (as with any toolset based on the COFF – Common Object File
Format), these various parts of a program are called Sections. Breaking the program code and
data into various sections provides flexibility since it allows you to place code sections in ROM
and variables in RAM. The preceding diagram illustrated four sections:
• Global Variables
• Initial Values for global variables
• Local Variables (i.e. the stack)
• Code (the actual instructions)