"Use __attribute__ ((aligned(...))) directive to specify to the compiler on what memory boundary to store data objects. This directive specifies which multiple of bytes to store an object.
The format of this directive is
__attribute__ ((aligned( x ))
where x is a decimal number of a power of 2 from 1 to 4096."
That is a quote from CW 10.4 Documentation for PPC Arch.
First of all the CW will complain only if x is greater than 8192. And seems that it works with 8192. So the documentation seems to be wrong on this.
Second why is there such a limit? Why not 16384 or 32768? And how can I trick it to align to a larger value?
Hi Bogdan,
I got feedback from compiler team.
In fat there is a problem with the documentation - this will be fixed in a next version.
Compiler is designed to allow up to 8192 (2^13) and throws error for anything more.
For higher alignment value, this can be done via the LCF.
I've created an example on my side.
to resume ...
For my example if I want to write:
int V1[4] __attribute__ ((aligned (16384)));
the compiler generates an error.
The V1[] is allocated in the .bss section.
To do that I can:
In the main.c
#pragma push //Save the original pragma context
#pragma section data_type ".__my_data" ".__my_data"
int V1[4];
#pragma pop
In the lcf file
.bss : {}
.__my_data ALIGN(0x4000) :{}
} > internal_ram_p0
Extract of map file:
.__my_data section layout
Starting Virtual File
address Size address offset
---------------------------------
00000000 000010 40004000 00004000 1 .__my_data main_c.obj
00000000 000010 40004000 00004000 8 V1 main_c.obj
Regards
Pascal
Hi Bogdan,
Sorry for the delay.
I've performed some tests on my side with MCU V10.4.
Extract of documentation:
The format of this directive is
__attribute__ ((aligned( x ))
where x is a decimal number of a power of 2 from 1 to 4096.
I can write __attribute__ ((aligned (4096))); and __attribute__ ((aligned (8192)));
according to the doc the value of x should be between 1 to 4096.
I will check with compiler team to have more info.
Keep you informed.
Pascal