Everything
A.1.2.1 Changing the area to be allocated using the #pragma section directive

To change the allocated section, specify the attribute strings using #pragma section directive.

 

Example

#pragma section directive description

#pragma section gp_disp16 "mysdata"
int a = 1;              /*allocated to mysdata.sdata attribute section*/
int b;                  /*allocated to mysdata.sbss attribute section*/
#pragma section default

 

See "4.2.6.1 Allocation of function and data to section" for details about how to use the #pragma section directive.

 

When referencing a variable using the #pragma section directive from a function in another source file, it is necessary to declare the affected variable with the extern specifier and the same #pragma section directive in the file that performs reference.

Unlike when specifying a variable by means of a definition or declaration, it outputs the following error if the variable cannot be accessed with the specified section attribute.

E0562330 : Relocation size overflow : "file"-"section"-"offset"

 

Example 1.

File that defines a table

#pragma section zconst
const unsigned char table_data[9] = {1, 2, 3, 4, 5, 6, 7, 8, 9}; /*allocated to .zconst section*/
#pragma section default

 

Example 2.

File that references a table

#pragma section zconst
extern  const unsigned char  table_data[];      /*allocated to .zconst section*/
#pragma section default

 

Code such as the following can be used if portability of C source to the SH family of compilers is a concern.

Example

#pragma section directive description

#pragma section mydata
int a = 1;              /*allocated to mydata.data section*/
int b;                  /*allocated to mydata.bss section*/
#pragma section default