问题
The below link https://www.iar.com/support/tech-notes/linker/how-do-i-place-a-group-of-functions-or-variables-in-a-specific-section/ explains how a group of variables can be placed in a specific section, this is with IAR arm linker.
Pasting the example (for which i want a gcc equivalent) from the link here
/* Place following data in section MY_DATA */
#pragma default_variable_attributes = @ "MY_DATA"
int data1;
int data2;
/* Stop placing data in section MY_DATA */
#pragma default_variable_attributes =
In gcc do we have any such feature, which helps me to define in the source code how the variables can be place contiguously.
Regards
回答1:
With gcc you use the compiler's __attribute__
extension of the declarator syntax, e.g.
int my_global_1 __attribute__ ((section ("MyData"))) = 0;
int my_global_2 __attribute__ ((section ("MyData"))) = 0;
__attribute__ ((section ("MyFuncs"))) int foo(int i)
{
return i * i;
}
来源:https://stackoverflow.com/questions/34638115/how-do-i-place-a-group-of-variables-in-a-specific-section-in-gcc-is-there-anyth