Specifies where to store a variable or function in a section that has been predefined or defined with the #pragma section directive.
__declspec(section <section_name>) declaration
__declspec(section <section_name>) definition
section_name
Specifies the name of an initialized data section.
For example, if you use __declspec (section ".bss") extern int my_var;, where .bss is an uninitialized section you will get a descriptive error. In this case, use __declspec (section ".data") extern int my_var; as .data is normally paired with .bss and .data is an initialized section. Assuming the variable you are attaching this __declspec to is an uninitialized object (which is the case with my_var), the object will go into .bss.
__declspec (section ".init") extern void cache_init1(void);
__declspec (section ".text") extern void cache_init2(void);
extern void cache_init3(void);
void cache_init1(){} // goes into .init if the prototype is visible for
this definition
__declspec (section ".init") void cache_init2(){} // ignores previous
section .text and goes into .init
__declspec (section ".init") void cache_init3(){} // by default the
declaration implies .text but the definition forces it to .init
The predefined sections set with an object type become the default section for that type. The compiler predefines the sections listed in the table below.
| Type | Name | Data mode | Code mode |
|---|---|---|---|
| code_type | ".text" | data_mode=far_abs | code_mode=pc_rel |
| data_type | ".data" | data_mode=far_abs | code_mode=pc_rel |
| const_type | ".rodata" | data_mode=far_abs | code_mode=pc_rel |
| sdata_type | ".sdata" | data_mode=sda_rel | code_mode=pc_rel |
| sconst_type | ".sdata2" ".sbss2" | data_mode=sda_rel | code_mode=pc_rel |
| ".PPC.EMB.sdata0" ".PPC.EMB.sbss0" | data_mode=sda_rel | code_mode=pc_rel |