10.4.2 Data Initialization Template
As noted in 10.4.1 Standard Data Section Names, the 32-bit Language Tools support bss-type sections (memory that is not
initialized) as well as data-type sections (memory that receives initial values). The
data-type sections receive initial values at start-up, and the bss-type sections are filled
with zeros. A generic data initialization template is used that supports any number of
arbitrary bss-type sections or data-type sections. The data initialization template is
created by the linker and is loaded into an output section named .dinit
in program memory. Start-up code in the run-time library interprets the
template and initializes data memory accordingly.
The data initialization template contains one record for each output section in data memory. The template is terminated by a null instruction word. The format of a data initialization record is:
/* data init record */
struct data_record {
char *dst; /* destination address */
unsigned int len; /* length in bytes */
unsigned int format:7; /* format code */
char dat[0]; /* variable length data */
};
The first element of the record is a pointer to the section in data memory. The second and third elements are the section length and format code, respectively. The last element is an optional array of data bytes. For bss-type sections, no data bytes are required.
The format code has two possible values.
Format Code | Description |
---|---|
0 |
Fill the output section with zeros |
1 |
Copy 4 bytes of data from each instruction word in the data array |