I was wondering if anyone could point me to the documents that discuss stack and section alignment?
I have been looking through the linker script for the STM32F4xx series and notices that several output sections are 16-byte aligned (e.g. startup : ALIGN(16) SUBALIGN(16)) while others are 4-byte aligned (e.g. constructors : ALIGN(4) SUBALIGN(4)). The only reference I can find to section alignment is in the "ELF For Arm Architecture" (ARM IHI 0044E) and it states:
4.3.5 Section Alignment
There is no minimum alignment required for a section. However, sections containing thumb code must be at least
16-bit aligned and sections containing ARM code must be at least 32-bit aligned.
Platform standards may set a limit on the maximum alignment that they can guarantee (normally the page size).
So why the 16 byte (quad-word) alignment on certain sections? Why are the sections in .data and .bss 4-byte (word) aligned?
Finally can someone explain this:
5.2.1.2 Stack constraints at a public interface
The stack must also conform to the following constraint at a public interface:
SP mod 8 = 0. The stack must be double-word aligned.
What exactly is a "public interface" in this context? I have only heard that term in reference to object-oriented programming. Is this why the main_stack_base and main_thread_stack_base are 8-byte aligned?
I am just curious... I really am trying to get comfortable with the internals.
Thanks!
Sam