14.01.2015 Views

RealView Compilation Tools Developer Guide - ARM Information ...

RealView Compilation Tools Developer Guide - ARM Information ...

RealView Compilation Tools Developer Guide - ARM Information ...

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Embedded Software Development<br />

2.4.6 Placing the stack and heap<br />

Scatter-loading provides a method for specifying the placement of code and statically<br />

allocated data in your image. The application stack and heap are set up during C library<br />

initialization. You can tailor stack and heap placement by re-implementing the<br />

__user_initial_stackheap() function. Alternatively you can use the specially named<br />

<strong>ARM</strong>_LIB_HEAP and <strong>ARM</strong>_LIB_STACK execution regions. See Specifying stack and heap using<br />

the scatter-loading description file on page 5-3 in the Linker and Utilities <strong>Guide</strong> for<br />

more information.<br />

2.4.7 Runtime memory models<br />

Two runtime memory models are provided. In both runtime memory models, the stack<br />

grows unchecked.<br />

Note<br />

Both these examples are suitable for the Integrator system.<br />

One-region model<br />

In the default, one-region model, the application stack and heap grow towards each<br />

other in the same region of memory. In this case, the heap is checked against the value<br />

of the stack pointer when new heap space is allocated, for example, when malloc() is<br />

called.<br />

Figure 2-9 on page 2-21 and Example 2-5 on page 2-21 show an example of<br />

__user_initial_stackheap() implementing a simple one-region model, where the stack<br />

grows downwards from address 0x40000, and the heap grows upwards from 0x20000.<br />

The routine loads the appropriate values into the registers r0 and r1, and then returns.<br />

Register r2 remains unchanged, because a heap limit is not used in a one-region model.<br />

Register r3 is not used.<br />

2-20 Copyright © 2002-2007 <strong>ARM</strong> Limited. All rights reserved. <strong>ARM</strong> DUI 0203H<br />

Non-Confidential

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!