Skip to content
Myr

docs and diagram for exec_stack

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by David Tolnay · committed by David Tolnay · parent 6e27de4 · Browse files · 1 file+29 added−0 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+29 added−0 removed

  • other:+29 added−0 removed

1 file+29 added−0 removed

modified:exec_stack.h+29 added
4 unmodified lines
5#include <stdlib.h>6#include <string.h>7#include "jv_alloc.h"89/*10 * The stack is a directed forest of variably sized blocks. Each block has a11 * "next" block which is at a higher memory address, or 0 if the block has no12 * "next" block. More than one block may have no "next" block. A block may be13 * the "next" block of more than one other block. Pushed blocks are added at14 * the low-address end of the stack.15 *16 * Stack pointers are negative integers that are offsets relative to "mem_end",17 * the end of the allocated region. The stack "bound" is the stack pointer of18 * the last block that would be able to fit in the currently allocated region.19 * The stack "limit" is the stack pointer of the last block currently in the20 * stack. The stack pointer of the "next" block is stored directly below each21 * block.22 *23 * <- mem_end = 0x10024 * 0xF8 +------------+25 * 0xF0 | |26 * 0xE8 +------------+ <- stack_ptr1 = -0x1827 * 0xE0 next = 028 * 0xD8 +------------+29 * 0xD0 | |30 * 0xC8 | |31 * 0xC0 +------------+ <- stack_ptr2 = limit = -0x4032 * 0xB8 next = -0x1833 * 0xB034 * 0xA8 <- bound = -0x5835 * 0xA036 */3738struct determine_alignment {39 char x;40 union { int i; double d; uint64_t u64; size_t sz; void* ptr; } u;41};
71 unmodified lines