The CC-RH controls allocation to memory or the access method by allocating functions or data to sections.
This section cannot be used by the PIC facility.
The .zdata, .zbss, .zdata23, and .zbss23 sections are used for access in a short instruction length. |
The sld or sst instruction which is even shorter can be used.
These sections can be used even by the PID facility.
The .edata, .ebss, .edata23, and .ebss23 sections are used for access in a short instruction length. |
These sections can be used even by the PID facility.
The .sdata, .sbss, .sdata23, and .sbss23 sections are used for access in a short instruction length. |
These sections can be used even by the PID facility.
The initial values of auto variables are in the .const section when the PIROD facility is not used and are in the .pcconst32 section when the PIROD facility is used. In either case, they cannot be changed. |
This section cannot be used by the PIROD facility.
These sections cannot be used by the PIROD facility.
The sections to which the CC-RH allocates functions or data are the four sections .text, .data, .bss, and .const, by default.
The longer the relative distance at access is, the access is in a long instruction length and the code size is increased.
The CC-RH can allocate functions and data to desired sections using the extended facilities. This makes it possible to generate code using the relocation attribute characteristics of each section.
Describe the #pragma section directive in the following format.
#pragma section data attribute-strings-for-data "user-defined-name" [V2.03.00 or later] or #pragma section data attribute-strings-for-data [V2.03.00 or later] |
#pragma section const attribute-strings-for-constant-data "user-defined-name" [V2.03.00 or later] or #pragma section const attribute-strings-for-constant-data [V2.03.00 or later] |
The allocation section of constant data is changed. The functions and constant data are not affected. |
When specifying the attribute strings for data, the allocation section of constant data is changed to the default section (.const). |
When specifying the attribute strings for constant data, the allocation section of data is changed to the default section (.data or .bss). |
The relocation attributes of functions, data and constant data are changed to their defaults, and the sections names are changed according to the user defined names. |
The allocation section of functions is changed to the default section (.text). The data and constant data are not affected. |
The allocation section of data is changed to the default section (.data or .bss). The functions and constant data are not affected. |
The allocation section of constant data is changed to the default section (.const). The functions and data are not affected. |
The allocation sections of functions, data and constant data are changed to the default sections (.text, .data, .bss, .const). |
Section relocation attributes are specified using "attribute strings", and section names are specified using "user-defined names". The usable attribute strings vary depending on the specified options.
The relationship between specifiable attribute strings, corresponding section relocation attributes, and options that can be specified as conditions is shown in Table 4.16, Table 4.17, and Table 4.18.
Attribute strings are case-sensitive.
The following characters are usable in user-defined names.
The allocation section of functions or data written after a #pragma section directive is determined in accordance with the following rules.
1. The relocation attribute is determined from the "attribute string".
(1) For data, *data* or *bss* is automatically selected depending on whether there is an initial value.
(2) A format with no attribute string has an effect on both functions and data, and the default relocation attribute of the compiler is used.
2. A string representing the relocation attribute is linked after the "user-defined name"Note.
(1) If the user-defined name starts with a number from 0 to 9, "_" is added to the beginning.
(2) If there is no user-defined name, the default section name is used without change.
This is to prevent sections with different section relocation attributes from having the same section name. |
3. When the format of #pragma section default or #pragma section is specified, it has an effect on both functions and data, and the default relocation attribute of the compiler and the default section name are used.
A #pragma section directive is valid from the position where it was written up to the position where the next #pragma section directive appears or up to the end of the source file.
The effect of a #pragma section directive differs between variables and functions.
If there are multiple declarations and definitions for a variable and a different #pragma section directive is specified for each, the #pragma section directive that appears first is valid.
int x = 1; /* Variable x is allocated to foo.data */ int y = 2; /* Variable y is allocated to bar.data */ #pragma section foo extern int x; #pragma section bar extern int x; extern int y; |
When the -pic option is not specified, #pragma section is valid only for function definitions.
When the -pic option is specified, similar as to variables, #pragma section is valid for both declarations and definitions.
[V2.02.00 or later] #pragma section can also be described within a function.
Therefore, #pragma section within a function is now valid, which was ignored and caused W0520609 to be output in V2.01.00 or earlier.
Due to this specification change, if there are multiple static variables within the function or multiple string literals, each value can be allocated to separate sections.