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
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;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With