6.1.1
C/C++ Program Sections
The correspondence between memory areas and sections for C/C++ programs and the standard library is described in table 3.30.
Table 6.1 | Summary of Memory Area Types and Their Properties |
|
|
|
|
|
|
|
|
|
|
1
|
Program area
|
P*1*6
|
code
|
Relative
|
Yes
Not possible
|
1 byte*7
|
Stores machine code
|
2
|
Constant area
|
C*1*2*6*8
|
romdata
|
Relative
|
Yes
Not possible
|
4 bytes
|
Stores const type data
|
C_2*1*2*6*8
|
romdata
|
Relative
|
Yes
Not possible
|
2 bytes
|
C_1*1*2*6*8
|
romdata
|
Relative
|
Yes
Not possible
|
1 byte
|
3
|
Initialized data area
|
D*1*2*6*8
|
romdata
|
Relative
|
Yes
Possible
|
4 bytes
|
Stores data with initial values
|
D_2*1*2*6*8
|
romdata
|
Relative
|
Yes
Possible
|
2 bytes
|
D_1*1*2*6*8
|
romdata
|
Relative
|
Yes
Possible
|
1 byte
|
4
|
Uninitialized data area
|
B*1*2*6*8
|
data
|
Relative
|
No
Possible
|
4 bytes
|
Stores data without initial values
|
B_2*1*2*6*8
|
data
|
Relative
|
No
Possible
|
2 bytes
|
B_1*1*2*6*8
|
data
|
Relative
|
No
Possible
|
1 byte
|
5
|
switch statement branch table area
|
W*1*2
|
romdata
|
Relative
|
Yes
Not Possible
|
4 bytes
|
Stores branch tables for switch statements
|
W_2*1*2
|
romdata
|
Relative
|
Yes
Not Possible
|
2 bytes
|
W_1*1*2
|
romdata
|
Relative
|
Yes
Not Possible
|
1 byte
|
6
|
C++ initial processing/ postprocessing data area
|
C$INIT
|
romdata
|
Relative
|
Yes
Not possible
|
4 bytes
|
Stores addresses of constructors and destructors called for global class objects
|
7
|
C++ virtual function table area
|
C$VTBL
|
romdata
|
Relative
|
Yes
Not possible
|
4 bytes
|
Stores data for calling the virtual function when a virtual function exists in the class declaration
|
8
|
User stack area
|
SU
|
data
|
Relative
|
No
Possible
|
4 bytes
|
Area necessary for program execution
|
9
|
Interrupt stack area
|
SI
|
data
|
Relative
|
No
Possible
|
4 bytes
|
Area necessary for program execution
|
10
|
Heap area
|
|
|
Relative
|
No
Possible
|
|
Area used by library functions malloc, realloc, calloc, and new *9
|
11
|
Absolute address variable area
|
$ADDR_
<section>_
<address>
*3
|
data
|
Absolute
|
Yes/No
Possible/
Not possible*4
|
|
Stores variables specified by #pragma address
|
12
|
Variable vector area
|
C$VECT
C$VECT<vector table number>
|
romdata
|
Relative
|
No
Possible
|
4 bytes
|
Variable vector table
|
13
|
Literal area
|
L*5
|
romdata
|
Relative
|
Yes
Possible/
Not possible
|
4 bytes
|
Stores string literals and initializers used for dynamic initialization of aggregates
|
Notes 1. | Section names can be switched using the section option. |
Notes 2. | Specifying a section with a boundary alignment of 4 when switching the section names also changes the section name of sections with a boundary alignment of 1 or 2. |
Notes 3. | <section> is a C, D, or B section name, and <address> is an absolute address (hexadecimal). |
Notes 4. | The initial value and write operation depend on the attribute of <section>. |
Notes 5. | The section name can be changed by using the section option. In this case, the C section can be selected as the changed name. |
Notes 6. | The section name can be changed through #pragma section. |
Notes 7. | Specifying the instalign4 or instalign8 option, #pragma instalign4, or #pragma instalign8 changes the boundary alignment to 4 or 8. |
Notes 8. | If an endian not matching the endian option has been specified in #pragma endian, a dedicated section is created to store the relevant data. At the end of the section name, _B is added for #pragma endian big, and _L is added for #pragma endian little. |
Notes 9. | Using these functions requires the allocation of at least 16 bytes of memory as a heap area. |
Examples 1. | A program example is used to demonstrate the correspondence between a C program and the compiler-generated sections. |
C program
int a=1;
char b;
const short c=0;
void main(){
...
}
|
|
|
Program area (main(){...})
|
P
|
Constant area (c)
|
C_2
|
Initialized data area (a)
|
D
|
Uninitialized data area (b)
|
B_1
|
Examples 2. | A program example is used to demonstrate the correspondence between a C++ program and the compiler-generated sections. |
C++ program
class A{
int m;
A(int p);
~A();
};
A a(1);
char b;
extern const char c='a';
short d=1;
void f(){...}
|
|
|
Program area (f(){...})
|
P
|
Constant area (c)
|
C_1
|
Initialized data area (d)
|
D_2
|
Uninitialized data area (a)
Uninitialized data area (b)
|
B
B_1
|
Initial processing/
postprocessing data areas (&A::A, &A::~A)
|
C $INT
|