Keil Logo

__user_setup_stackheap()

4.54 __user_setup_stackheap()

__user_setup_stackheap() sets up and returns the locations of the initial stack and heap.

If you define this function, it is called by the C library during program start-up.
When __user_setup_stackheap() is called, sp has the same value it had on entry to the application. If this was set to a valid value before calling the C library initialization code, it can be left at this value. If sp is not valid, __user_setup_stackheap() must change this value before using any stack and before returning.
__user_setup_stackheap() returns the:
  • Heap base in r0 (if the program uses the heap).
  • Stack base in sp.
  • Heap limit in r2 (if the program uses the heap and uses two-region memory).
If this function is re-implemented, it must:
  • Not corrupt registers other than r0 to r3, ip and sp.
  • Maintain eight-byte alignment of the heap by ensuring that the heap base is a multiple of eight.
To create a version of __user_setup_stackheap() that inherits sp from the execution environment and does not have a heap, set r0 and r2 to zero and return.
There is no limit to the size of the stack. However, if the heap region grows into the stack, malloc() attempts to detect the overlapping memory and fails the new memory allocation request.

Note

Any re-implementation of __user_setup_stackheap() must be in assembler.
Non-ConfidentialPDF file icon PDF versionARM DUI0378H
Copyright © 2007, 2008, 2011, 2012, 2014-2016 ARM. All rights reserved. 
  Arm logo
Important information

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies.

Change Settings

Privacy Policy Update

Arm’s Privacy Policy has been updated. By continuing to use our site, you consent to Arm’s Privacy Policy. Please review our Privacy Policy to learn more about our collection, use and transfers
of your data.