Hello,
I have a scatter loading file that defines the stack as below:
ARM_LIB_STACK 0x00BFFFFFF0 EMPTY -0x20000 {}
In the compiled image, I can see these symbols (by running nm -g command):
00000000bffdfff0 A Image$$ARM_LIB_STACK$$ZI$$Base0000000000020000 A Image$$ARM_LIB_STACK$$ZI$$Length00000000bffffff0 A Image$$ARM_LIB_STACK$$ZI$$Limit
The common practice is to set SP to 0x00BFFFFFF0 in the system initialization code. But armlink_user_guide documents Image$$region_name$$ZI$$Limit as "Address of the byte beyond the end of the ZI output section in the execution region". It sounds like Image$$ARM_LIB_STACK$$ZI$$Limit should not be part of the stack. This is confusing. which address should be regarded as part of the stack, Image$$ARM_LIB_STACK$$ZI$$Base or Image$$ARM_LIB_STACK$$ZI$$Limit? Due to the stack alignment requirement, the SP can only be 0x00BFFFFFF0 in my case. Then Image$$ARM_LIB_STACK$$ZI$$Base is not correct. Obviously:
Image$$ARM_LIB_STACK$$ZI$$Limit - Image$$ARM_LIB_STACK$$ZI$$Base + 1 = 0x20000 + 1
if both of them are inclusive.
Thanks
-Oscar
Hi Oscar, can you point me to where this is stated in the documentation, it does not say 'beyond' in the latest documentation
https://developer.arm.com/docs/100070/latest/scatter-loading-features/the-scatter-loading-mechanism/placing-the-stack-and-heap-with-a-scatter-file
Stack limit is correct as 0xbfffff0. and should always be 64-bit aligned.
It is documented in https://developer.arm.com/docs/100070/latest/accessing-and-managing-symbols-with-armlink/region-related-symbols/image-execution-region-symbols. I think the document of Image$$region_name$$ZI$$Limit should be applicable to Image$$ARM_LIB_STACK$$ZI$$Lim
Oscar - reading this again, the last address of the region will be 0xbffffef, and so the definition as one byte 'beyond' is correct.
However I can see that this could be confusing, and so I will ask to get this improved.
Thanks, Ronan. I checked AAPCS64 again, yes, it is correct.