
Memory Model
6-7
Run-Time Environment
Dynamically allocated objects are not addressed directly (they are always
accessed with pointers) and the memory pool is in a separate section (.sys-
mem); therefore, the dynamic memory pool can have a size limited only by the
amount of available memory in your system. To conserve space in the .bss
section, you can allocate large arrays from the heap instead of defining them
as global or static. For example, instead of a definition such as:
struct big table[100];
use a pointer and call the malloc function:
struct big *table
table = (struct big *)malloc(100*sizeof(struct big));
6.1.5 Initialization of Variables
The C compiler produces code that is suitable for use as firmware in a
ROM-based system. In such a system, the initialization tables in the .cinit
section (used for initialization of globals and statics) are stored in ROM. At
system initialization time, the C boot routine copies data from these tables (in
ROM) to the initialized variables in .bss (RAM).
In situations where a program is loaded directly from an object file into memory
and run, you can avoid having the .cinit section occupy space in memory. A
loader can read the initialization tables directly from the object file instead of
from ROM and perform the initialization directly at load time (instead of at run
time). You can specify this to the linker by using the
−
cr linker option. For more
information on system initialization, see section 6.8,
System Initialization
, on
6.1.6 Allocating Memory for Static and Global Variables
A unique, contiguous space is allocated for each external or static variable that
is declared in a C program. The linker determines the address of the space.
The compiler ensures that space for these variables is allocated in multiples
of words so that each variable is aligned on a word boundary.
The C compiler expects global variables to be allocated into data memory by
reserving space for them in .bss. Variables declared in the same module are
allocated into a single, contiguous block of memory.
Содержание TMS320C2x
Страница 8: ...viii...
Страница 69: ...2 47 C Compiler Description...
Страница 159: ...6 36...
Страница 226: ...8 6...
Страница 250: ...Index Index 14 Z z shell option 2 2 2 4 2 14 overriding with c option 4 5 overriding with n option 2 13...