suppose I have variables:
int global a = 1;
int banana b = 2;
int mango c = 3;
I want GCC to generate them such that:
.global
a .long 1
.banana
b .long 2
.mango
c .long 3
What’s the easiest way to do that?
Updates:
Got:
__attribute__ ((section ("mmm"))) int a = 432;`
along with
target_asm_named_section()`
to generate:
.global
a:
.long 1
Which is great but there are two problems.
One is that unless the lists are ordered for different sections, you’ll get repeat sections.
so
__attribute__ ((section ("mmm"))) int a = 432;
__attribute__ ((section ("mmm"))) int b = 432;
__attribute__ ((section ("global"))) int c = 432;
is good, but
__attribute__ ((section ("mmm"))) int a = 432;
__attribute__ ((section ("global"))) int c = 432;
__attribute__ ((section ("mmm"))) int b = 432;
is bad, because .mmm will appear twice.
The second problem is that I’m already using attributes to do
`__attribute__((global))`
which, to the best of my attempts cannot be combined with the previous attribute.
Is there any easy way to resolve either of those two issues?
Solution:
First use:
#define MMR __attribute__((section ("section mmr")))Then, inside the function defining
navigate to the string via:
And viola, the section_name is the phrase you created inside section(“”). Then match it to what you want it to do.
I use flags for example:
The flag being set was the goal of the original _attribute_, and now that it can be done using the section attribute, both goals are achieved with the use of one attribute