@LiveForIt
Quote:
its not a string, so why do you want on less char?
I'm not allocating one byte less, I'm allocating sizeof(double)-1 bytes more than needed. This is to ensure that a double (8-byte) aligned address of the required size can always be found within the aligned buffer no matter what the alignment of the array itself is.
Quote:
GCC should automatilcy allign data, and you can use compiler options for it, "packed".
It should but it doesn't.
Using my own compiled test code as example:
While the .data section itself is 16-byte aligned to the start of the executable file:
Section Headers:
[Nr] Name Type Addr Off Size
[ 6] .ctors PROGBITS 01011094 001094 000008 00 WA 0 0 4
[ 7] .dtors PROGBITS 0101109c 00109c 000008 00 WA 0 0 4
[ 8] .data PROGBITS 010110b0 0010b0 000010 00 WA 0 0 16
it is preceeded in the segment by .ctors and .dtors sections which are only 4-byte aligned (see above):
Section to Segment mapping:
Segment Sections...
00 .text .rodata .__newlib_version
01 .ctors .dtors .data .sbss
The result is that when elf.library loads the entire segment 32-byte aligned the .data section gets loaded into it at offset 10b0-1094=1c which is only 4-byte aligned.