A.1.1 Changing Mapped Areas

The defaults for the mapped sections of variables are as follows:

-

Variables without initial values: Sections B, B_2, and B_1

-

Variables with initial values: Sections D, D_2, and D_1 (ROM) and sections R, R_2, and R_1 (RAM)

-

const variables: Sections C, C_2, and C_1

For changing the area (section) to map variables, specify the section type and section name through #pragma section.

#pragma section <section type> <section name>

Variable declaration/definition

#pragma section

When a section type is specified, only section names of the specified type can be changed.

Note that in the RX family C/C++ compiler, the section to map a variable depends on the alignment value of the variable.

Example

B: Variables without initial values and an alignment value of four bytes are mapped

B_2: Variables without initial values and an alignment value of two bytes are mapped

B_1: Variables without initial values and an alignment value of one byte are mapped

 

For variables with initial values, the initial value is mapped to ROM and the variable itself is mapped to RAM (both ROM and RAM areas are necessary). When the resetprg.c file of the startup routine is used, the INITSCT function copies the initial values in ROM to the variables in RAM.

The relationship between the section type and the created section is shown in the following.

Name

Section
Name

Attribute

Format Type

Initial Value and Write Operation

Alignment Value

Constant area

C*1*2

romdata

Relative

Has initial values and writing is not possible

4 bytes

C_2*1*2

romdata

Relative

Has initial values and writing is not possible

2 bytes

C_1*1*2

romdata

Relative

Has initial values and writing is not possible

1 byte

Initialized data area

D*1*2

romdata

Relative

Has initial values and writing is possible

4 bytes

D_2*1*2

romdata

Relative

Has initial values and writing is possible

2 bytes

D_1*1*2

romdata

Relative

Has initial values and writing is possible

1 byte

Uninitialized data area

B*1*2

data

Relative

Does not have initial values and writing is possible

4 bytes

B_2*1*2

data

Relative

Does not have initial values and writing is possible

2 bytes

B_1*1*2

data

Relative

Does not have initial values and writing is possible

1 byte

switch statement branch table area

W*1*2

romdata

Relative

Has initial values and writing is not possible

4 bytes

W_2*1*2

romdata

Relative

Has initial values and writing is not possible

2 bytes

W_1*1*2

romdata

Relative

Has initial values and writing is not possible

1 byte

C++ initial processing/
postprocessing
data area

C$INT

romdata

Relative

Has initial values and writing is not possible

4 bytes

C++ virtual function table area

C$VTBL

romdata

Relative

Has initial values and writing is not possible

4 bytes

Absolute address variable area

$ADDR_
<section>_
<address>*3

data

Absolute

Has or does not have initial values and writing is possible or not possible*4

Variable vector area

C$VECT

romdata

Relative

Does not have initial values and writing is possible

Example 1.

Section names can be switched by the section option or the #pragma section extension. However, partial data (e.g., string literal) is not affected by #pragma section. For details, see the detailed description of 4.2.3 #pragma Directive - #pragma section.

Example 2.

Specifying a section with an alignment value of 4 when switching the section names also changes the section name of sections with an alignment value of 1 or 2. When #pragma endian is used to specify an endian that differs from the setting by the endian option, a dedicated section is created and the relevant data stored. For this section, after the section name, _B is added for #pragma endian big and _L is added for #pragma endian little. However, partial data (e.g., string literal) is not affected by #pragma endian. For details, see the detailed description of 4.2.3 #pragma Directive - #pragma endian.

Example 3.

<section> is a C, D, or B section name, and <address> is an absolute address (hexadecimal).

Example 4.

The initial value and write operation depend on the attribute of <section>.