Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Memory Layout

This page is intended to give a relatively high-level overview of the memory layout used by Ariel OS across processor architectures and MCU families. Minor variations across them are omitted for clarity. Additionally, no stability guarantees are currently provided regarding the memory layout.

Tip

If needed, the following command can be used to obtain the exact locations of sections:

readelf --sections <path-to-elf>
  • On architectures and MCUs that allow it1, Ariel OS places the ISR stack, .isr_stack, at the very beginning of the RAM. This provides a form of stack overflow protection, as write attempts would then collide with the boundary of the physical RAM and trigger a fault, instead of overwriting static data. See the flip-link crate for an explanation of the technique. The ISR stack is named .stack on Xtensa, and may not be placed at the beginning of the RAM nor before the .data section.
  • Async tasks are allocated statically, as individual statics, anywhere in the .bss section.
  • The thread stacks, if multithreading is enabled, are currently allocated as individual statics, anywhere in the .bss section.
  • If multithreading is enabled, and if the MCU has two symmetrical cores and multi-core is enabled, the ISR stack of the second core is allocated as a static, anywhere in the .bss section.
  • Depending on the architecture, the uninitialized section is either called .uninit or .noinit.
  • The heap, if enabled, may take up to the remaining space. heapsize_required ensures that there is enough space for the heap, at link time.
           .-------------. - beginning of RAM
           |      ⋮      |
           +-------------+ -
           |             |
         | |             | ^
Addresses| | .isr_stack  | | ≥ isr_stacksize_required + executor_stacksize_required
         v |             | v
           |             |
           +-------------+ -
           |             |
           |             |
           |             |    .- - .-------------.
           |             |    |    |      ⋮      |
           |    .data    |    |    +-------------+
           |             |    |    |    Async    |
           |             |    |    |    tasks    |
           |             |    |    |      ...    |
           |             |    |    +-------------+
           +-------------+ - -'    |      ⋮      |
           |             |         +-------------+
           |             |         |   [Thread   |
           |    .bss     |         |    stacks   |
           |             |         |      ...]   |
           |             |         +-------------+
           +-------------+ - -.    |      ⋮      |
           |             |    '- - '-------------'
           |   .uninit   |
           |     or      |
           |   .noinit   |
           |             |
           +-------------+ -
           |             |
           |             |
           '             ' ^
           |             | |
           '    [Heap]   ' | ≥ "heapsize_required"
           |             | |
           '             ' v
           |             |
           |             |
           '-------------' - end of RAM
Memory layout when using executor-interrupt
           .-------------. - beginning of RAM
           |      ⋮      |
           +-------------+ -
           |             |
         | |             | ^
Addresses| | .isr_stack  | | ≥ "isr_stacksize_required"
         v |             | v
           |             |
           +-------------+ -
           |             |
           |             |
           |             |    .- - .-------------.
           |             |    |    |      ⋮      |
           |             |    |    +-------------+
           |    .data    |    |    |    Async    |
           |             |    |    |    tasks    |
           |             |    |    |      ...    |
           |             |    |    +-------------+
           |             |    |    |      ⋮      |
           |             |    |    +-------------+ -
           +-------------+ - -'    |   Executor  | ^
           |             |         |    thread   | | ≥ "executor_stacksize_required"
           |             |         |    stack    | v
           |             |         +-------------+ -
           |    .bss     |         |      ⋮      |
           |             |         +-------------+
           |             |         |   [Thread   |
           |             |         |    stacks   |
           +-------------+ - -.    |      ...]   |
           |             |    |    +-------------+
           |             |    |    |      ⋮      |
           |   .uninit   |    '- - '-------------'
           |     or      |
           |   .noinit   |
           |             |
           |             |
           +-------------+ -
           |             |
           |             |
           '             ' ^
           |             | |
           '    [Heap]   ' | ≥ "heapsize_required"
           |             | |
           '             ' v
           |             |
           |             |
           '-------------' - end of RAM
Memory layout when using executor-thread