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

Name

Section

Format Type

Initial Value

Align-
ment Number

Description

Name

Attribute

Write Operation

Program area

P*1*6

code

Relative

Yes
Not possible

1 byte*7

Stores machine code

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

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

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

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

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

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

User stack area

SU

data

Relative

No
Possible

4 bytes

Area necessary for program execution

Interrupt stack area

SI

data

Relative

No
Possible

4 bytes

Area necessary for program execution

Heap area

Relative

No
Possible

Area used by library functions malloc, realloc, calloc, and new *9

Absolute address variable area

$ADDR_
<section>_
<address>
*3


data

Absolute

Yes/No
Possible/
Not possible*4

Stores variables specified by #pragma address

Variable vector area

C$VECT

romdata

Relative

No
Possible

4 bytes

Variable vector table

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.

Examples 2.

A program example is used to demonstrate the correspondence between a C++ program and the compiler-generated sections.