Variable order and location within the section - oprimization level dependent
Dear all,
I have been observing the difference in the variable order within the section in dependency on whether an optimization level is switched on (no O or -O1).
Code snippet:
volatile U16 try0 __attribute__ ((section (".MEM_TRY"))) __attribute__ ((aligned (2)));
volatile U16 try1[3u] __attribute__ ((section (".MEM_TRY"))) __attribute__ ((aligned (2)));
volatile U16 try2 __attribute__ ((section (".MEM_TRY"))) __attribute__ ((aligned (2)));
No optimization -- MAP FILE:
.mem_try 0x62000000 0xa
*(.MEM_TRY)
.MEM_TRY 0x62000000 0xa build/try.o
Optimization -O1 turned on -- MAP FILE:
.mem_try 0x62000000 0xa
*(.MEM_TRY)
.MEM_TRY 0x62000000 0xa build/try.o
Used GCC version: 4.7 2013q2
Target: ARM Cortex R4F big-endian
Is this behaviour expected? May you clarify this? Is there any flag by which this behaviour can be suppressed?
Many thanks in advance,
Best regards, Jiri
PS:
Yes, there are ways how to avoid this issue (direct address pointer by macro, "encapsulation"of the variables into the struct). Anyway I would like to know whether the above described approach is possible...?
Question information
- Language:
- English Edit question
- Status:
- Answered
- Assignee:
- No assignee Edit question
- Last query:
- Last reply:
Can you help with this problem?
Provide an answer of your own, or ask JiriJ for more information if necessary.